0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IntTools / IntTools_EdgeEdge.hxx
CommitLineData
42cf5bc1 1// Created by: Eugeny MALTCHIKOV
2// Copyright (c) 2013-2014 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
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.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
15#ifndef _IntTools_EdgeEdge_HeaderFile
16#define _IntTools_EdgeEdge_HeaderFile
17
18#include <Standard.hxx>
19#include <Standard_DefineAlloc.hxx>
20#include <Standard_Handle.hxx>
21
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>
31class Geom_Curve;
32class TopoDS_Edge;
33class IntTools_Range;
34class Bnd_Box;
35class BRepAdaptor_Curve;
36
37
38
39//! The class provides Edge/Edge intersection algorithm
40//! based on the intersection between edges bounding boxes.
41class IntTools_EdgeEdge
42{
43public:
44
45 DEFINE_STANDARD_ALLOC
46
47
48
49 //! Empty contructor
3510db62 50 IntTools_EdgeEdge();
51
52 //! Destructor
53 ~IntTools_EdgeEdge();
42cf5bc1 54
55 //! Contructor
3510db62 56 IntTools_EdgeEdge(const TopoDS_Edge& theEdge1, const TopoDS_Edge& theEdge2);
42cf5bc1 57
58
59 //! Contructor
3510db62 60 IntTools_EdgeEdge(const TopoDS_Edge& theEdge1, const Standard_Real aT11,
61 const Standard_Real aT12, const TopoDS_Edge& theEdge2,
62 const Standard_Real aT21, const Standard_Real aT22);
42cf5bc1 63
64
65 //! Sets the first edge
3510db62 66 void SetEdge1(const TopoDS_Edge& theEdge);
42cf5bc1 67
68
69 //! Sets the first edge and its range
3510db62 70 void SetEdge1(const TopoDS_Edge& theEdge, const Standard_Real aT1, const Standard_Real aT2);
42cf5bc1 71
72
73 //! Sets the range for the first edge
3510db62 74 void SetRange1(const IntTools_Range& theRange1);
42cf5bc1 75
76
77 //! Sets the range for the first edge
3510db62 78 void SetRange1(const Standard_Real aT1, const Standard_Real aT2);
42cf5bc1 79
80
81 //! Sets the second edge
3510db62 82 void SetEdge2(const TopoDS_Edge& theEdge);
42cf5bc1 83
84
85 //! Sets the first edge and its range
3510db62 86 void SetEdge2(const TopoDS_Edge& theEdge, const Standard_Real aT1, const Standard_Real aT2);
42cf5bc1 87
88
89 //! Sets the range for the second edge
3510db62 90 void SetRange2(const IntTools_Range& theRange);
42cf5bc1 91
92
93 //! Sets the range for the second edge
3510db62 94 void SetRange2(const Standard_Real aT1, const Standard_Real aT2);
42cf5bc1 95
96
0d0481c7 97 //! Sets the Fuzzy value
98 void SetFuzzyValue (const Standard_Real theFuzz);
99
100
42cf5bc1 101 //! Performs the intersection between edges
102 Standard_EXPORT void Perform();
103
104
105 //! Returns TRUE if common part(s) is(are) found
3510db62 106 Standard_Boolean IsDone() const;
42cf5bc1 107
108
0d0481c7 109 //! Returns Fuzzy value
110 Standard_Real FuzzyValue() const;
111
112
42cf5bc1 113 //! Returns common parts
3510db62 114 const IntTools_SequenceOfCommonPrts& CommonParts() const;
42cf5bc1 115
116
6dc83e21 117 //! Sets the flag myQuickCoincidenceCheck
118 void UseQuickCoincidenceCheck (const Standard_Boolean bFlag) {
119 myQuickCoincidenceCheck=bFlag;
120 }
42cf5bc1 121
6dc83e21 122 //! Returns the flag myQuickCoincidenceCheck
123 Standard_Boolean IsCoincidenceCheckedQuickly () {
124 return myQuickCoincidenceCheck;
125 }
42cf5bc1 126
127protected:
128
129
130
131 //! Checks the data
3510db62 132 void CheckData();
42cf5bc1 133
134
135 //! Prepares the data
136 Standard_EXPORT void Prepare();
137
138
139 //! Computes Line/Line intersection.
140 Standard_EXPORT void ComputeLineLine();
141
142
143 //! Intermediate function
3510db62 144 Standard_EXPORT void FindSolutions (IntTools_SequenceOfRanges& theRanges1,
145 IntTools_SequenceOfRanges& theRanges2, Standard_Boolean& bSplit2);
42cf5bc1 146
147
148 //! Looking for the exact intersection ranges
88c3accd 149 Standard_EXPORT void FindSolutions (
150 const IntTools_Range& theR1, const Bnd_Box& theBox1,
3510db62 151 const IntTools_Range& theR2, const Bnd_Box& theBox2,
152 IntTools_SequenceOfRanges& theRanges1, IntTools_SequenceOfRanges& theRanges2);
42cf5bc1 153
154
155 //! Merges found solutions
3510db62 156 Standard_EXPORT void MergeSolutions (const IntTools_SequenceOfRanges& theRanges1,
157 const IntTools_SequenceOfRanges& theRanges2, const Standard_Boolean bSplit2);
42cf5bc1 158
159
28c08a7d 160 //! Looking for the range of the edge which is in the box
3510db62 161 Standard_EXPORT static Standard_Boolean FindParameters(const BRepAdaptor_Curve& theBAC,
162 const Standard_Real aT1, const Standard_Real aT2, const Standard_Real theTol,
163 const Standard_Real theRes, const Standard_Real thePTol,
164 const Standard_Real theResCoeff, const Bnd_Box& theCBox,
165 Standard_Real& aTB1, Standard_Real& aTB2);
42cf5bc1 166
167
168 //! Checks if edges coincide on the ranges
3510db62 169 Standard_EXPORT Standard_Integer CheckCoincidence (const Standard_Real aT11,
170 const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22,
171 const Standard_Real theCriteria, const Standard_Real theCurveRes1);
42cf5bc1 172
173
174 //! Adds common part of the given type to myCommonParts
3510db62 175 Standard_EXPORT void AddSolution (const Standard_Real aT11, const Standard_Real aT12,
176 const Standard_Real aT21, const Standard_Real aT22, const TopAbs_ShapeEnum theType);
42cf5bc1 177
178
179 //! Looking for the minimal distance between edges on the ranges
3510db62 180 Standard_EXPORT void FindBestSolution (const Standard_Real aT11, const Standard_Real aT12,
181 const Standard_Real aT21, const Standard_Real aT22,
182 Standard_Real& aT1, Standard_Real& aT2);
42cf5bc1 183
184
185 //! Checks is there an intersection between edges on the given ranges
186 //! (for nearly conicident edges)
3510db62 187 Standard_EXPORT Standard_Boolean IsIntersection (const Standard_Real aT11,
188 const Standard_Real aT12, const Standard_Real aT21, const Standard_Real aT22);
42cf5bc1 189
6dc83e21 190 //! Checks if the edges are coincident really.
191 Standard_EXPORT Standard_Boolean IsCoincident();
42cf5bc1 192
193 TopoDS_Edge myEdge1;
194 TopoDS_Edge myEdge2;
195 Handle(Geom_Curve) myGeom1;
196 Handle(Geom_Curve) myGeom2;
197 BRepAdaptor_Curve myCurve1;
198 BRepAdaptor_Curve myCurve2;
199 Standard_Real myTol1;
200 Standard_Real myTol2;
201 Standard_Real myTol;
0d0481c7 202 Standard_Real myFuzzyValue;
42cf5bc1 203 Standard_Real myRes1;
204 Standard_Real myRes2;
205 Standard_Real myResCoeff1;
206 Standard_Real myResCoeff2;
207 Standard_Real myPTol1;
208 Standard_Real myPTol2;
209 IntTools_Range myRange1;
210 IntTools_Range myRange2;
211 Standard_Boolean mySwap;
212 Standard_Integer myErrorStatus;
213 IntTools_SequenceOfCommonPrts myCommonParts;
214
6dc83e21 215 //! Allows avoiding use Edge-Edge intersection
216 //! algorithm (i.e. speeding up the Boolean algorithm)
217 //! if the edges are coincided really.
218 //! If it is not evidently set of this flag should
219 //! be avoided (otherwise, the performance of
220 //! Boolean algorithm will be slower).
221 Standard_Boolean myQuickCoincidenceCheck;
222
42cf5bc1 223private:
224
42cf5bc1 225};
226
42cf5bc1 227#include <IntTools_EdgeEdge.lxx>
228
42cf5bc1 229#endif // _IntTools_EdgeEdge_HeaderFile