Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-28 09:17: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 <NCollection_List.hxx>
0025 #include <IntPolyh_Couple.hxx>
0026 #include <IntPolyh_PMaillageAffinage.hxx>
0027 #include <NCollection_Array1.hxx>
0028 
0029 //! API algorithm for intersection of two surfaces by intersection
0030 //! of their triangulations.
0031 //!
0032 //! Algorithm provides possibility to intersect surfaces as without
0033 //! the precomputed sampling as with it.
0034 //!
0035 //! If the numbers of sampling points are not given, it will build the
0036 //! net of 10x10 sampling points for each surface.
0037 //!
0038 //! The intersection is done inside constructors.
0039 //! Before obtaining the results of intersection it is necessary to check
0040 //! if intersection has been performed correctly. It can be done by calling
0041 //! the *IsDone()* method.
0042 //!
0043 //! The results of intersection are the intersection lines and points.
0044 class IntPolyh_Intersection
0045 {
0046 public:
0047   DEFINE_STANDARD_ALLOC
0048 
0049 public: //! @name Constructors
0050   //! Constructor for intersection of two surfaces with default parameters.
0051   //! Performs intersection.
0052   Standard_EXPORT IntPolyh_Intersection(const occ::handle<Adaptor3d_Surface>& theS1,
0053                                         const occ::handle<Adaptor3d_Surface>& theS2);
0054 
0055   //! Constructor for intersection of two surfaces with the given
0056   //! size of the sampling nets:
0057   //! - <theNbSU1> x <theNbSV1> - for the first surface <theS1>;
0058   //! - <theNbSU2> x <theNbSV2> - for the second surface <theS2>.
0059   //! Performs intersection.
0060   Standard_EXPORT IntPolyh_Intersection(const occ::handle<Adaptor3d_Surface>& theS1,
0061                                         const int                             theNbSU1,
0062                                         const int                             theNbSV1,
0063                                         const occ::handle<Adaptor3d_Surface>& theS2,
0064                                         const int                             theNbSU2,
0065                                         const int                             theNbSV2);
0066 
0067   //! Constructor for intersection of two surfaces with the precomputed sampling.
0068   //! Performs intersection.
0069   Standard_EXPORT IntPolyh_Intersection(const occ::handle<Adaptor3d_Surface>& theS1,
0070                                         const NCollection_Array1<double>&     theUPars1,
0071                                         const NCollection_Array1<double>&     theVPars1,
0072                                         const occ::handle<Adaptor3d_Surface>& theS2,
0073                                         const NCollection_Array1<double>&     theUPars2,
0074                                         const NCollection_Array1<double>&     theVPars2);
0075 
0076 public: //! @name Getting the results
0077   //! Returns state of the operation
0078   bool IsDone() const { return myIsDone; }
0079 
0080   //! Returns state of the operation
0081   bool IsParallel() const { return myIsParallel; }
0082 
0083   //! Returns the number of section lines
0084   int NbSectionLines() const { return mySectionLines.NbItems(); }
0085 
0086   //! Returns the number of points in the given line
0087   int NbPointsInLine(const int IndexLine) const
0088   {
0089     return mySectionLines[IndexLine - 1].NbStartPoints();
0090   }
0091 
0092   // Returns number of tangent zones
0093   int NbTangentZones() const { return myTangentZones.NbItems(); }
0094 
0095   //! Returns number of points in tangent zone
0096   int NbPointsInTangentZone(const int) const { return 1; }
0097 
0098   //! Gets the parameters of the point in section line
0099   Standard_EXPORT void GetLinePoint(const int IndexLine,
0100                                     const int IndexPoint,
0101                                     double&   x,
0102                                     double&   y,
0103                                     double&   z,
0104                                     double&   u1,
0105                                     double&   v1,
0106                                     double&   u2,
0107                                     double&   v2,
0108                                     double&   incidence) const;
0109 
0110   //! Gets the parameters of the point in tangent zone
0111   Standard_EXPORT void GetTangentZonePoint(const int IndexLine,
0112                                            const int IndexPoint,
0113                                            double&   x,
0114                                            double&   y,
0115                                            double&   z,
0116                                            double&   u1,
0117                                            double&   v1,
0118                                            double&   u2,
0119                                            double&   v2) const;
0120 
0121 private: //! @name Performing the intersection
0122   //! Compute the intersection by first making the sampling of the surfaces.
0123   Standard_EXPORT void Perform();
0124 
0125   //! Compute the intersection on the precomputed sampling.
0126   Standard_EXPORT void Perform(const NCollection_Array1<double>& theUPars1,
0127                                const NCollection_Array1<double>& theVPars1,
0128                                const NCollection_Array1<double>& theUPars2,
0129                                const NCollection_Array1<double>& theVPars2);
0130 
0131   //! Performs the default (standard) intersection of the triangles
0132   Standard_EXPORT bool PerformStd(const NCollection_Array1<double>& theUPars1,
0133                                   const NCollection_Array1<double>& theVPars1,
0134                                   const NCollection_Array1<double>& theUPars2,
0135                                   const NCollection_Array1<double>& theVPars2,
0136                                   const double                      theDeflTol1,
0137                                   const double                      theDeflTol2,
0138                                   IntPolyh_PMaillageAffinage&       theMaillageS,
0139                                   int&                              theNbCouples);
0140 
0141   //! Performs the advanced intersection of the triangles - four intersection with
0142   //! different shifts of the sampling points.
0143   Standard_EXPORT bool PerformAdv(const NCollection_Array1<double>& theUPars1,
0144                                   const NCollection_Array1<double>& theVPars1,
0145                                   const NCollection_Array1<double>& theUPars2,
0146                                   const NCollection_Array1<double>& theVPars2,
0147                                   const double                      theDeflTol1,
0148                                   const double                      theDeflTol2,
0149                                   IntPolyh_PMaillageAffinage&       theMaillageFF,
0150                                   IntPolyh_PMaillageAffinage&       theMaillageFR,
0151                                   IntPolyh_PMaillageAffinage&       theMaillageRF,
0152                                   IntPolyh_PMaillageAffinage&       theMaillageRR,
0153                                   int&                              theNbCouples);
0154 
0155   //! Performs the advanced intersection of the triangles.
0156   Standard_EXPORT bool PerformMaillage(const NCollection_Array1<double>& theUPars1,
0157                                        const NCollection_Array1<double>& theVPars1,
0158                                        const NCollection_Array1<double>& theUPars2,
0159                                        const NCollection_Array1<double>& theVPars2,
0160                                        const double                      theDeflTol1,
0161                                        const double                      theDeflTol2,
0162                                        IntPolyh_PMaillageAffinage&       theMaillage);
0163 
0164   //! Performs the advanced intersection of the triangles.
0165   Standard_EXPORT bool PerformMaillage(const NCollection_Array1<double>&  theUPars1,
0166                                        const NCollection_Array1<double>&  theVPars1,
0167                                        const NCollection_Array1<double>&  theUPars2,
0168                                        const NCollection_Array1<double>&  theVPars2,
0169                                        const double                       theDeflTol1,
0170                                        const double                       theDeflTol2,
0171                                        const IntPolyh_ArrayOfPointNormal& thePoints1,
0172                                        const IntPolyh_ArrayOfPointNormal& thePoints2,
0173                                        const bool                         theIsFirstFwd,
0174                                        const bool                         theIsSecondFwd,
0175                                        IntPolyh_PMaillageAffinage&        theMaillage);
0176 
0177   //! Clears the arrays from the duplicate couples, keeping only one instance of it.
0178   Standard_EXPORT void MergeCouples(NCollection_List<IntPolyh_Couple>& theArrayFF,
0179                                     NCollection_List<IntPolyh_Couple>& theArrayFR,
0180                                     NCollection_List<IntPolyh_Couple>& theArrayRF,
0181                                     NCollection_List<IntPolyh_Couple>& theArrayRR) const;
0182 
0183   bool AnalyzeIntersection(IntPolyh_PMaillageAffinage& theMaillage);
0184   bool IsAdvRequired(IntPolyh_PMaillageAffinage& theMaillage);
0185 
0186 private: //! @name Fields
0187   // Inputs
0188   occ::handle<Adaptor3d_Surface> mySurf1;      //!< First surface
0189   occ::handle<Adaptor3d_Surface> mySurf2;      //!< Second surface
0190                                                // clang-format off
0191   int myNbSU1;                    //!< Number of samples in U direction for first surface
0192   int myNbSV1;                    //!< Number of samples in V direction for first surface
0193   int myNbSU2;                    //!< Number of samples in U direction for second surface
0194   int myNbSV2;                    //!< Number of samples in V direction for second surface
0195   // Results
0196                                                // clang-format on
0197   bool                         myIsDone;       //!< State of the operation
0198   IntPolyh_ArrayOfSectionLines mySectionLines; //!< Section lines
0199   IntPolyh_ArrayOfTangentZones myTangentZones; //!< Tangent zones
0200   bool                         myIsParallel;
0201 };
0202 
0203 #endif // _IntPolyh_Intersection_HeaderFile