Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-04 09:15:08

0001 // Created by: Eugeny MALTCHIKOV
0002 // Copyright (c) 2013-2014 OPEN CASCADE SAS
0003 //
0004 // This file is part of Open CASCADE Technology software library.
0005 //
0006 // This library is free software; you can redistribute it and/or modify it under
0007 // the terms of the GNU Lesser General Public License version 2.1 as published
0008 // by the Free Software Foundation, with special exception defined in the file
0009 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0010 // distribution for complete text of the license and disclaimer of any warranty.
0011 //
0012 // Alternatively, this file may be used under the terms of Open CASCADE
0013 // commercial license or contractual agreement.
0014 
0015 #ifndef _IntTools_EdgeEdge_HeaderFile
0016 #define _IntTools_EdgeEdge_HeaderFile
0017 
0018 #include <Standard.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 #include <Standard_Handle.hxx>
0021 
0022 #include <BRepAdaptor_Curve.hxx>
0023 #include <Standard_Integer.hxx>
0024 #include <IntTools_CommonPrt.hxx>
0025 #include <NCollection_Sequence.hxx>
0026 #include <IntTools_Range.hxx>
0027 #include <TopAbs_ShapeEnum.hxx>
0028 class Geom_Curve;
0029 class Bnd_Box;
0030 
0031 //! The class provides Edge/Edge intersection algorithm
0032 //! based on the intersection between edges bounding boxes.
0033 class IntTools_EdgeEdge
0034 {
0035 public:
0036   DEFINE_STANDARD_ALLOC
0037 
0038   //! Empty constructor
0039   IntTools_EdgeEdge();
0040 
0041   //! Destructor
0042   ~IntTools_EdgeEdge();
0043 
0044   //! Constructor
0045   IntTools_EdgeEdge(const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2);
0046 
0047   //! Constructor
0048   IntTools_EdgeEdge(const TopoDS_Edge& theEdge1,
0049                     const double       aT11,
0050                     const double       aT12,
0051                     const TopoDS_Edge& theEdge2,
0052                     const double       aT21,
0053                     const double       aT22);
0054 
0055   //! Sets the first edge
0056   void SetEdge1(const TopoDS_Edge& theEdge);
0057 
0058   //! Sets the first edge and its range
0059   void SetEdge1(const TopoDS_Edge& theEdge, const double aT1, const double aT2);
0060 
0061   //! Sets the range for the first edge
0062   void SetRange1(const IntTools_Range& theRange1);
0063 
0064   //! Sets the range for the first edge
0065   void SetRange1(const double aT1, const double aT2);
0066 
0067   //! Sets the second edge
0068   void SetEdge2(const TopoDS_Edge& theEdge);
0069 
0070   //! Sets the first edge and its range
0071   void SetEdge2(const TopoDS_Edge& theEdge, const double aT1, const double aT2);
0072 
0073   //! Sets the range for the second edge
0074   void SetRange2(const IntTools_Range& theRange);
0075 
0076   //! Sets the range for the second edge
0077   void SetRange2(const double aT1, const double aT2);
0078 
0079   //! Sets the Fuzzy value
0080   void SetFuzzyValue(const double theFuzz);
0081 
0082   //! Performs the intersection between edges
0083   Standard_EXPORT void Perform();
0084 
0085   //! Returns TRUE if common part(s) is(are) found
0086   bool IsDone() const;
0087 
0088   //! Returns Fuzzy value
0089   double FuzzyValue() const;
0090 
0091   //! Returns common parts
0092   const NCollection_Sequence<IntTools_CommonPrt>& CommonParts() const;
0093 
0094   //! Sets the flag myQuickCoincidenceCheck
0095   void UseQuickCoincidenceCheck(const bool bFlag) { myQuickCoincidenceCheck = bFlag; }
0096 
0097   //! Returns the flag myQuickCoincidenceCheck
0098   bool IsCoincidenceCheckedQuickly() { return myQuickCoincidenceCheck; }
0099 
0100 protected:
0101   //! Checks the data
0102   void CheckData();
0103 
0104   //! Prepares the data
0105   Standard_EXPORT void Prepare();
0106 
0107   //! Computes Line/Line intersection.
0108   Standard_EXPORT void ComputeLineLine();
0109 
0110   //! Intermediate function
0111   Standard_EXPORT void FindSolutions(NCollection_Sequence<IntTools_Range>& theRanges1,
0112                                      NCollection_Sequence<IntTools_Range>& theRanges2,
0113                                      bool&                                 bSplit2);
0114 
0115   //! Looking for the exact intersection ranges
0116   Standard_EXPORT void FindSolutions(const IntTools_Range&                 theR1,
0117                                      const Bnd_Box&                        theBox1,
0118                                      const IntTools_Range&                 theR2,
0119                                      const Bnd_Box&                        theBox2,
0120                                      NCollection_Sequence<IntTools_Range>& theRanges1,
0121                                      NCollection_Sequence<IntTools_Range>& theRanges2);
0122 
0123   //! Merges found solutions
0124   Standard_EXPORT void MergeSolutions(const NCollection_Sequence<IntTools_Range>& theRanges1,
0125                                       const NCollection_Sequence<IntTools_Range>& theRanges2,
0126                                       const bool                                  bSplit2);
0127 
0128   //! Looking for the range of the edge which is in the box
0129   Standard_EXPORT static bool FindParameters(const BRepAdaptor_Curve& theBAC,
0130                                              const double             aT1,
0131                                              const double             aT2,
0132                                              const double             theTol,
0133                                              const double             theRes,
0134                                              const double             thePTol,
0135                                              const double             theResCoeff,
0136                                              const Bnd_Box&           theCBox,
0137                                              double&                  aTB1,
0138                                              double&                  aTB2);
0139 
0140   //! Checks if edges coincide on the ranges
0141   Standard_EXPORT int CheckCoincidence(const double aT11,
0142                                        const double aT12,
0143                                        const double aT21,
0144                                        const double aT22,
0145                                        const double theCriteria,
0146                                        const double theCurveRes1);
0147 
0148   //! Adds common part of the given type to myCommonParts
0149   Standard_EXPORT void AddSolution(const double           aT11,
0150                                    const double           aT12,
0151                                    const double           aT21,
0152                                    const double           aT22,
0153                                    const TopAbs_ShapeEnum theType);
0154 
0155   //! Looking for the minimal distance between edges on the ranges
0156   Standard_EXPORT void FindBestSolution(const double aT11,
0157                                         const double aT12,
0158                                         const double aT21,
0159                                         const double aT22,
0160                                         double&      aT1,
0161                                         double&      aT2);
0162 
0163   //! Checks is there an intersection between edges on the given ranges
0164   //! (for nearly conicident edges)
0165   Standard_EXPORT bool IsIntersection(const double aT11,
0166                                       const double aT12,
0167                                       const double aT21,
0168                                       const double aT22);
0169 
0170   //! Checks if the edges are coincident really.
0171   Standard_EXPORT bool IsCoincident();
0172 
0173   TopoDS_Edge                              myEdge1;
0174   TopoDS_Edge                              myEdge2;
0175   occ::handle<Geom_Curve>                  myGeom1;
0176   occ::handle<Geom_Curve>                  myGeom2;
0177   BRepAdaptor_Curve                        myCurve1;
0178   BRepAdaptor_Curve                        myCurve2;
0179   double                                   myTol1;
0180   double                                   myTol2;
0181   double                                   myTol;
0182   double                                   myFuzzyValue;
0183   double                                   myRes1;
0184   double                                   myRes2;
0185   double                                   myResCoeff1;
0186   double                                   myResCoeff2;
0187   double                                   myPTol1;
0188   double                                   myPTol2;
0189   IntTools_Range                           myRange1;
0190   IntTools_Range                           myRange2;
0191   bool                                     mySwap;
0192   int                                      myErrorStatus;
0193   NCollection_Sequence<IntTools_CommonPrt> myCommonParts;
0194 
0195   //! Allows avoiding use Edge-Edge intersection
0196   //! algorithm (i.e. speeding up the Boolean algorithm)
0197   //! if the edges are coincided really.
0198   //! If it is not evidently set of this flag should
0199   //! be avoided (otherwise, the performance of
0200   //! Boolean algorithm will be slower).
0201   bool myQuickCoincidenceCheck;
0202 };
0203 
0204 #include <IntTools_EdgeEdge.lxx>
0205 
0206 #endif // _IntTools_EdgeEdge_HeaderFile