Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-30 09:14:08

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   DEFINE_STANDARD_ALLOC
0047 
0048 public: //! @name Constructors
0049   //! Constructor for intersection of two surfaces with default parameters.
0050   //! Performs intersection.
0051   Standard_EXPORT IntPolyh_Intersection(const Handle(Adaptor3d_Surface)& theS1,
0052                                         const Handle(Adaptor3d_Surface)& theS2);
0053 
0054   //! Constructor for intersection of two surfaces with the given
0055   //! size of the sampling nets:
0056   //! - <theNbSU1> x <theNbSV1> - for the first surface <theS1>;
0057   //! - <theNbSU2> x <theNbSV2> - for the second surface <theS2>.
0058   //! Performs intersection.
0059   Standard_EXPORT IntPolyh_Intersection(const Handle(Adaptor3d_Surface)& theS1,
0060                                         const Standard_Integer           theNbSU1,
0061                                         const Standard_Integer           theNbSV1,
0062                                         const Handle(Adaptor3d_Surface)& theS2,
0063                                         const Standard_Integer           theNbSU2,
0064                                         const Standard_Integer           theNbSV2);
0065 
0066   //! Constructor for intersection of two surfaces with the precomputed sampling.
0067   //! Performs intersection.
0068   Standard_EXPORT IntPolyh_Intersection(const Handle(Adaptor3d_Surface)& theS1,
0069                                         const TColStd_Array1OfReal&      theUPars1,
0070                                         const TColStd_Array1OfReal&      theVPars1,
0071                                         const Handle(Adaptor3d_Surface)& theS2,
0072                                         const TColStd_Array1OfReal&      theUPars2,
0073                                         const TColStd_Array1OfReal&      theVPars2);
0074 
0075 public: //! @name Getting the results
0076   //! Returns state of the operation
0077   Standard_Boolean IsDone() const { return myIsDone; }
0078 
0079   //! Returns state of the operation
0080   Standard_Boolean IsParallel() const { return myIsParallel; }
0081 
0082   //! Returns the number of section lines
0083   Standard_Integer NbSectionLines() const { return mySectionLines.NbItems(); }
0084 
0085   //! Returns the number of points in the given line
0086   Standard_Integer NbPointsInLine(const Standard_Integer IndexLine) const
0087   {
0088     return mySectionLines[IndexLine - 1].NbStartPoints();
0089   }
0090 
0091   // Returns number of tangent zones
0092   Standard_Integer NbTangentZones() const { return myTangentZones.NbItems(); }
0093 
0094   //! Returns number of points in tangent zone
0095   Standard_Integer NbPointsInTangentZone(const Standard_Integer) const { return 1; }
0096 
0097   //! Gets the parameters of the point in section line
0098   Standard_EXPORT void GetLinePoint(const Standard_Integer IndexLine,
0099                                     const Standard_Integer IndexPoint,
0100                                     Standard_Real&         x,
0101                                     Standard_Real&         y,
0102                                     Standard_Real&         z,
0103                                     Standard_Real&         u1,
0104                                     Standard_Real&         v1,
0105                                     Standard_Real&         u2,
0106                                     Standard_Real&         v2,
0107                                     Standard_Real&         incidence) const;
0108 
0109   //! Gets the parameters of the point in tangent zone
0110   Standard_EXPORT void GetTangentZonePoint(const Standard_Integer IndexLine,
0111                                            const Standard_Integer IndexPoint,
0112                                            Standard_Real&         x,
0113                                            Standard_Real&         y,
0114                                            Standard_Real&         z,
0115                                            Standard_Real&         u1,
0116                                            Standard_Real&         v1,
0117                                            Standard_Real&         u2,
0118                                            Standard_Real&         v2) const;
0119 
0120 private: //! @name Performing the intersection
0121   //! Compute the intersection by first making the sampling of the surfaces.
0122   Standard_EXPORT void Perform();
0123 
0124   //! Compute the intersection on the precomputed sampling.
0125   Standard_EXPORT void Perform(const TColStd_Array1OfReal& theUPars1,
0126                                const TColStd_Array1OfReal& theVPars1,
0127                                const TColStd_Array1OfReal& theUPars2,
0128                                const TColStd_Array1OfReal& theVPars2);
0129 
0130   //! Performs the default (standard) intersection of the triangles
0131   Standard_EXPORT Standard_Boolean PerformStd(const TColStd_Array1OfReal& theUPars1,
0132                                               const TColStd_Array1OfReal& theVPars1,
0133                                               const TColStd_Array1OfReal& theUPars2,
0134                                               const TColStd_Array1OfReal& theVPars2,
0135                                               const Standard_Real         theDeflTol1,
0136                                               const Standard_Real         theDeflTol2,
0137                                               IntPolyh_PMaillageAffinage& theMaillageS,
0138                                               Standard_Integer&           theNbCouples);
0139 
0140   //! Performs the advanced intersection of the triangles - four intersection with
0141   //! different shifts of the sampling points.
0142   Standard_EXPORT Standard_Boolean PerformAdv(const TColStd_Array1OfReal& theUPars1,
0143                                               const TColStd_Array1OfReal& theVPars1,
0144                                               const TColStd_Array1OfReal& theUPars2,
0145                                               const TColStd_Array1OfReal& theVPars2,
0146                                               const Standard_Real         theDeflTol1,
0147                                               const Standard_Real         theDeflTol2,
0148                                               IntPolyh_PMaillageAffinage& theMaillageFF,
0149                                               IntPolyh_PMaillageAffinage& theMaillageFR,
0150                                               IntPolyh_PMaillageAffinage& theMaillageRF,
0151                                               IntPolyh_PMaillageAffinage& theMaillageRR,
0152                                               Standard_Integer&           theNbCouples);
0153 
0154   //! Performs the advanced intersection of the triangles.
0155   Standard_EXPORT Standard_Boolean PerformMaillage(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& theMaillage);
0162 
0163   //! Performs the advanced intersection of the triangles.
0164   Standard_EXPORT Standard_Boolean PerformMaillage(const TColStd_Array1OfReal&        theUPars1,
0165                                                    const TColStd_Array1OfReal&        theVPars1,
0166                                                    const TColStd_Array1OfReal&        theUPars2,
0167                                                    const TColStd_Array1OfReal&        theVPars2,
0168                                                    const Standard_Real                theDeflTol1,
0169                                                    const Standard_Real                theDeflTol2,
0170                                                    const IntPolyh_ArrayOfPointNormal& thePoints1,
0171                                                    const IntPolyh_ArrayOfPointNormal& thePoints2,
0172                                                    const Standard_Boolean             theIsFirstFwd,
0173                                                    const Standard_Boolean      theIsSecondFwd,
0174                                                    IntPolyh_PMaillageAffinage& theMaillage);
0175 
0176   //! Clears the arrays from the duplicate couples, keeping only one instance of it.
0177   Standard_EXPORT void MergeCouples(IntPolyh_ListOfCouples& theArrayFF,
0178                                     IntPolyh_ListOfCouples& theArrayFR,
0179                                     IntPolyh_ListOfCouples& theArrayRF,
0180                                     IntPolyh_ListOfCouples& theArrayRR) const;
0181 
0182   Standard_Boolean AnalyzeIntersection(IntPolyh_PMaillageAffinage& theMaillage);
0183   Standard_Boolean IsAdvRequired(IntPolyh_PMaillageAffinage& theMaillage);
0184 
0185 private: //! @name Fields
0186   // Inputs
0187   Handle(Adaptor3d_Surface) mySurf1;           //!< First surface
0188   Handle(Adaptor3d_Surface) mySurf2;           //!< Second surface
0189                                                // clang-format off
0190   Standard_Integer myNbSU1;                    //!< Number of samples in U direction for first surface
0191   Standard_Integer myNbSV1;                    //!< Number of samples in V direction for first surface
0192   Standard_Integer myNbSU2;                    //!< Number of samples in U direction for second surface
0193   Standard_Integer myNbSV2;                    //!< Number of samples in V direction for second surface
0194   // Results
0195                                                // clang-format on
0196   Standard_Boolean             myIsDone;       //!< State of the operation
0197   IntPolyh_ArrayOfSectionLines mySectionLines; //!< Section lines
0198   IntPolyh_ArrayOfTangentZones myTangentZones; //!< Tangent zones
0199   Standard_Boolean             myIsParallel;
0200 };
0201 
0202 #endif // _IntPolyh_Intersection_HeaderFile