1 // Created by: Eugeny MALTCHIKOV
2 // Copyright (c) 2013-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #ifndef _IntTools_EdgeEdge_HeaderFile
16 #define _IntTools_EdgeEdge_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
22 #include <TopoDS_Edge.hxx>
23 #include <BRepAdaptor_Curve.hxx>
24 #include <Standard_Real.hxx>
25 #include <IntTools_Range.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Integer.hxx>
28 #include <IntTools_SequenceOfCommonPrts.hxx>
29 #include <IntTools_SequenceOfRanges.hxx>
30 #include <TopAbs_ShapeEnum.hxx>
35 class BRepAdaptor_Curve;
39 //! The class provides Edge/Edge intersection algorithm
40 //! based on the intersection between edges bounding boxes.
41 class IntTools_EdgeEdge
55 IntTools_EdgeEdge(const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2);
59 IntTools_EdgeEdge(const TopoDS_Edge& theEdge1, const Standard_Real aT11, const Standard_Real aT12, const TopoDS_Edge& theEdge2, const Standard_Real aT21, const Standard_Real aT22);
62 //! Sets the first edge
63 void SetEdge1 (const TopoDS_Edge& theEdge);
66 //! Sets the first edge and its range
67 void SetEdge1 (const TopoDS_Edge& theEdge, const Standard_Real aT1, const Standard_Real aT2);
70 //! Sets the range for the first edge
71 void SetRange1 (const IntTools_Range& theRange1);
74 //! Sets the range for the first edge
75 void SetRange1 (const Standard_Real aT1, const Standard_Real aT2);
78 //! Sets the second edge
79 void SetEdge2 (const TopoDS_Edge& theEdge);
82 //! Sets the first edge and its range
83 void SetEdge2 (const TopoDS_Edge& theEdge, const Standard_Real aT1, const Standard_Real aT2);
86 //! Sets the range for the second edge
87 void SetRange2 (const IntTools_Range& theRange);
90 //! Sets the range for the second edge
91 void SetRange2 (const Standard_Real aT1, const Standard_Real aT2);
94 //! Performs the intersection between edges
95 Standard_EXPORT void Perform();
98 //! Returns TRUE if common part(s) is(are) found
99 Standard_Boolean IsDone() const;
102 //! Returns common parts
103 const IntTools_SequenceOfCommonPrts& CommonParts() const;
116 //! Prepares the data
117 Standard_EXPORT void Prepare();
120 //! Computes Line/Line intersection.
121 Standard_EXPORT void ComputeLineLine();
124 //! Intermediate function
125 Standard_EXPORT void FindSolutions (IntTools_SequenceOfRanges& theRanges1, IntTools_SequenceOfRanges& theRanges2, Standard_Boolean& bSplit2);
128 //! Looking for the exact intersection ranges
129 Standard_EXPORT void FindSolutions (const IntTools_Range& theR1, const IntTools_Range& theR2, const Bnd_Box& theBox2, IntTools_SequenceOfRanges& theRanges1, IntTools_SequenceOfRanges& theRanges2);
132 //! Merges found solutions
133 Standard_EXPORT void MergeSolutions (const IntTools_SequenceOfRanges& theRanges1, const IntTools_SequenceOfRanges& theRanges2, const Standard_Boolean bSplit2);
136 //! Looking for the range of the edge whick is in the box
137 Standard_EXPORT static Standard_Boolean FindParameters (const BRepAdaptor_Curve& theBAC, const Standard_Real aT1, const Standard_Real aT2, const Standard_Real theRes, const Standard_Real thePTol, const Standard_Real theResCoeff, const Bnd_Box& theCBox, Standard_Real& aTB1, Standard_Real& aTB2);
140 //! Checks if edges coincide on the ranges
141 Standard_EXPORT Standard_Integer CheckCoincidence (const Standard_Real aT11, const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22, const Standard_Real theCriteria, const Standard_Real theCurveRes1);
144 //! Adds common part of the given type to myCommonParts
145 Standard_EXPORT void AddSolution (const Standard_Real aT11, const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22, const TopAbs_ShapeEnum theType);
148 //! Looking for the minimal distance between edges on the ranges
149 Standard_EXPORT void FindBestSolution (const Standard_Real aT11, const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22, Standard_Real& aT1, Standard_Real& aT2);
152 //! Checks is there an intersection between edges on the given ranges
153 //! (for nearly conicident edges)
154 Standard_EXPORT Standard_Boolean IsIntersection (const Standard_Real aT11, const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22);
159 Handle(Geom_Curve) myGeom1;
160 Handle(Geom_Curve) myGeom2;
161 BRepAdaptor_Curve myCurve1;
162 BRepAdaptor_Curve myCurve2;
163 Standard_Real myTol1;
164 Standard_Real myTol2;
166 Standard_Real myRes1;
167 Standard_Real myRes2;
168 Standard_Real myResCoeff1;
169 Standard_Real myResCoeff2;
170 Standard_Real myPTol1;
171 Standard_Real myPTol2;
172 IntTools_Range myRange1;
173 IntTools_Range myRange2;
174 Standard_Boolean mySwap;
175 Standard_Integer myErrorStatus;
176 IntTools_SequenceOfCommonPrts myCommonParts;
188 #include <IntTools_EdgeEdge.lxx>
194 #endif // _IntTools_EdgeEdge_HeaderFile