Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:10

0001 // Created on: 1999-03-03
0002 // Created by: Fabrice SERVANT
0003 // Copyright (c) 1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _IntPolyh_Intersection_HeaderFile
0018 #define _IntPolyh_Intersection_HeaderFile
0019 
0020 #include <Adaptor3d_Surface.hxx>
0021 #include <IntPolyh_ArrayOfPointNormal.hxx>
0022 #include <IntPolyh_ArrayOfSectionLines.hxx>
0023 #include <IntPolyh_ArrayOfTangentZones.hxx>
0024 #include <IntPolyh_ListOfCouples.hxx>
0025 #include <IntPolyh_PMaillageAffinage.hxx>
0026 #include <TColStd_Array1OfReal.hxx>
0027 
0028 //! API algorithm for intersection of two surfaces by intersection
0029 //! of their triangulations.
0030 //!
0031 //! Algorithm provides possibility to intersect surfaces as without
0032 //! the precomputed sampling as with it.
0033 //!
0034 //! If the numbers of sampling points are not given, it will build the
0035 //! net of 10x10 sampling points for each surface.
0036 //!
0037 //! The intersection is done inside constructors.
0038 //! Before obtaining the results of intersection it is necessary to check
0039 //! if intersection has been performed correctly. It can be done by calling
0040 //! the *IsDone()* method.
0041 //!
0042 //! The results of intersection are the intersection lines and points.
0043 class IntPolyh_Intersection
0044 {
0045 public:
0046 
0047   DEFINE_STANDARD_ALLOC
0048 
0049 public: //! @name Constructors
0050 
0051   //! Constructor for intersection of two surfaces with default parameters.
0052   //! Performs intersection.
0053   Standard_EXPORT IntPolyh_Intersection(const Handle(Adaptor3d_Surface)& theS1,
0054                                         const Handle(Adaptor3d_Surface)& theS2);
0055 
0056   //! Constructor for intersection of two surfaces with the given
0057   //! size of the sampling nets:
0058   //! - <theNbSU1> x <theNbSV1> - for the first surface <theS1>;
0059   //! - <theNbSU2> x <theNbSV2> - for the second surface <theS2>.
0060   //! Performs intersection.
0061   Standard_EXPORT IntPolyh_Intersection(const Handle(Adaptor3d_Surface)& theS1,
0062                                         const Standard_Integer            theNbSU1,
0063                                         const Standard_Integer            theNbSV1,
0064                                         const Handle(Adaptor3d_Surface)& theS2,
0065                                         const Standard_Integer            theNbSU2,
0066                                         const Standard_Integer            theNbSV2);
0067 
0068   //! Constructor for intersection of two surfaces with the precomputed sampling.
0069   //! Performs intersection.
0070   Standard_EXPORT IntPolyh_Intersection(const Handle(Adaptor3d_Surface)& theS1,
0071                                         const TColStd_Array1OfReal&       theUPars1,
0072                                         const TColStd_Array1OfReal&       theVPars1,
0073                                         const Handle(Adaptor3d_Surface)& theS2,
0074                                         const TColStd_Array1OfReal&       theUPars2,
0075                                         const TColStd_Array1OfReal&       theVPars2);
0076 
0077 
0078 public: //! @name Getting the results
0079 
0080   //! Returns state of the operation
0081   Standard_Boolean IsDone() const
0082   {
0083     return myIsDone;
0084   }
0085 
0086   //! Returns state of the operation
0087   Standard_Boolean IsParallel() const
0088   {
0089     return myIsParallel;
0090   }
0091 
0092   //! Returns the number of section lines
0093   Standard_Integer NbSectionLines() const
0094   {
0095     return mySectionLines.NbItems();
0096   }
0097 
0098   //! Returns the number of points in the given line
0099   Standard_Integer NbPointsInLine(const Standard_Integer IndexLine) const
0100   {
0101     return mySectionLines[IndexLine-1].NbStartPoints();
0102   }
0103 
0104   // Returns number of tangent zones
0105   Standard_Integer NbTangentZones() const
0106   {
0107     return myTangentZones.NbItems();
0108   }
0109 
0110   //! Returns number of points in tangent zone
0111   Standard_Integer NbPointsInTangentZone(const Standard_Integer) const
0112   {
0113     return 1;
0114   }
0115 
0116   //! Gets the parameters of the point in section line
0117   Standard_EXPORT void GetLinePoint(const Standard_Integer IndexLine,
0118                                     const Standard_Integer IndexPoint,
0119                                     Standard_Real& x, Standard_Real& y, Standard_Real& z,
0120                                     Standard_Real& u1, Standard_Real& v1,
0121                                     Standard_Real& u2, Standard_Real& v2,
0122                                     Standard_Real& incidence) const;
0123 
0124   //! Gets the parameters of the point in tangent zone
0125   Standard_EXPORT void GetTangentZonePoint(const Standard_Integer IndexLine,
0126                                            const Standard_Integer IndexPoint,
0127                                            Standard_Real& x, Standard_Real& y, Standard_Real& z,
0128                                            Standard_Real& u1, Standard_Real& v1,
0129                                            Standard_Real& u2, Standard_Real& v2) const;
0130 
0131 
0132 private: //! @name Performing the intersection
0133 
0134   //! Compute the intersection by first making the sampling of the surfaces.
0135   Standard_EXPORT void Perform();
0136 
0137   //! Compute the intersection on the precomputed sampling.
0138   Standard_EXPORT void Perform(const TColStd_Array1OfReal& theUPars1,
0139                                const TColStd_Array1OfReal& theVPars1,
0140                                const TColStd_Array1OfReal& theUPars2,
0141                                const TColStd_Array1OfReal& theVPars2);
0142 
0143   //! Performs the default (standard) intersection of the triangles
0144   Standard_EXPORT Standard_Boolean PerformStd(const TColStd_Array1OfReal& theUPars1,
0145                                               const TColStd_Array1OfReal& theVPars1,
0146                                               const TColStd_Array1OfReal& theUPars2,
0147                                               const TColStd_Array1OfReal& theVPars2,
0148                                               const Standard_Real         theDeflTol1,
0149                                               const Standard_Real         theDeflTol2,
0150                                               IntPolyh_PMaillageAffinage& theMaillageS,
0151                                               Standard_Integer&           theNbCouples);
0152 
0153   //! Performs the advanced intersection of the triangles - four intersection with
0154   //! different shifts of the sampling points.
0155   Standard_EXPORT Standard_Boolean PerformAdv(const TColStd_Array1OfReal& theUPars1,
0156                                               const TColStd_Array1OfReal& theVPars1,
0157                                               const TColStd_Array1OfReal& theUPars2,
0158                                               const TColStd_Array1OfReal& theVPars2,
0159                                               const Standard_Real         theDeflTol1,
0160                                               const Standard_Real         theDeflTol2,
0161                                               IntPolyh_PMaillageAffinage& theMaillageFF,
0162                                               IntPolyh_PMaillageAffinage& theMaillageFR,
0163                                               IntPolyh_PMaillageAffinage& theMaillageRF,
0164                                               IntPolyh_PMaillageAffinage& theMaillageRR,
0165                                               Standard_Integer&           theNbCouples);
0166 
0167   //! Performs the advanced intersection of the triangles.
0168   Standard_EXPORT Standard_Boolean PerformMaillage(const TColStd_Array1OfReal& theUPars1,
0169                                                    const TColStd_Array1OfReal& theVPars1,
0170                                                    const TColStd_Array1OfReal& theUPars2,
0171                                                    const TColStd_Array1OfReal& theVPars2,
0172                                                    const Standard_Real         theDeflTol1,
0173                                                    const Standard_Real         theDeflTol2,
0174                                                    IntPolyh_PMaillageAffinage& theMaillage);
0175 
0176   //! Performs the advanced intersection of the triangles.
0177   Standard_EXPORT Standard_Boolean PerformMaillage(const TColStd_Array1OfReal& theUPars1,
0178                                                    const TColStd_Array1OfReal& theVPars1,
0179                                                    const TColStd_Array1OfReal& theUPars2,
0180                                                    const TColStd_Array1OfReal& theVPars2,
0181                                                    const Standard_Real         theDeflTol1,
0182                                                    const Standard_Real         theDeflTol2,
0183                                                    const IntPolyh_ArrayOfPointNormal& thePoints1,
0184                                                    const IntPolyh_ArrayOfPointNormal& thePoints2,
0185                                                    const Standard_Boolean      theIsFirstFwd,
0186                                                    const Standard_Boolean      theIsSecondFwd,
0187                                                    IntPolyh_PMaillageAffinage& theMaillage);
0188 
0189   //! Clears the arrays from the duplicate couples, keeping only one instance of it.
0190   Standard_EXPORT void MergeCouples(IntPolyh_ListOfCouples& theArrayFF,
0191                                     IntPolyh_ListOfCouples& theArrayFR,
0192                                     IntPolyh_ListOfCouples& theArrayRF,
0193                                     IntPolyh_ListOfCouples& theArrayRR) const;
0194 
0195   Standard_Boolean AnalyzeIntersection(IntPolyh_PMaillageAffinage& theMaillage);
0196   Standard_Boolean IsAdvRequired(IntPolyh_PMaillageAffinage& theMaillage);
0197 
0198 
0199 private: //! @name Fields
0200 
0201   // Inputs
0202   Handle(Adaptor3d_Surface) mySurf1;          //!< First surface
0203   Handle(Adaptor3d_Surface) mySurf2;          //!< Second surface
0204   Standard_Integer myNbSU1;                    //!< Number of samples in U direction for first surface
0205   Standard_Integer myNbSV1;                    //!< Number of samples in V direction for first surface
0206   Standard_Integer myNbSU2;                    //!< Number of samples in U direction for second surface
0207   Standard_Integer myNbSV2;                    //!< Number of samples in V direction for second surface
0208   // Results
0209   Standard_Boolean myIsDone;                   //!< State of the operation
0210   IntPolyh_ArrayOfSectionLines mySectionLines; //!< Section lines
0211   IntPolyh_ArrayOfTangentZones myTangentZones; //!< Tangent zones
0212   Standard_Boolean myIsParallel;
0213 };
0214 
0215 #endif // _IntPolyh_Intersection_HeaderFile