0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IntTools / IntTools_EdgeEdge.lxx
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 #include <Precision.hxx>
16 #include <BRep_Tool.hxx>
17
18 //=======================================================================
19 //function : IntTools_EdgeEdge
20 //purpose  : 
21 //=======================================================================
22 inline IntTools_EdgeEdge::IntTools_EdgeEdge()
23
24   myTol1(0.),
25   myTol2(0.),
26   myTol(0.),
27   myFuzzyValue(Precision::Confusion()),
28   myRes1(0.),
29   myRes2(0.),
30   myResCoeff1(0.),
31   myResCoeff2(0.),
32   myPTol1(0.),
33   myPTol2(0.),
34   myRange1(0., 0.),
35   myRange2(0., 0.),
36   mySwap(Standard_False),
37   myErrorStatus(0),
38   myQuickCoincidenceCheck(Standard_False)
39 {
40 }
41 //=======================================================================
42 //function : IntTools_EdgeEdge
43 //purpose  : 
44 //=======================================================================
45 inline IntTools_EdgeEdge::IntTools_EdgeEdge(const TopoDS_Edge&  theEdge1,
46                                             const TopoDS_Edge&  theEdge2)
47
48   myEdge1(theEdge1), 
49   myEdge2(theEdge2),
50   myTol1(0.),
51   myTol2(0.),
52   myTol(0.),
53   myFuzzyValue(Precision::Confusion()),
54   myRes1(0.),
55   myRes2(0.),
56   myResCoeff1(0.),
57   myResCoeff2(0.),
58   myPTol1(0.),
59   myPTol2(0.),
60   myRange1(0., 0.),
61   myRange2(0., 0.),
62   mySwap(Standard_False),
63   myErrorStatus(0),
64   myQuickCoincidenceCheck(Standard_False)
65 {
66 }
67 //=======================================================================
68 //function : IntTools_EdgeEdge
69 //purpose  : 
70 //=======================================================================
71 inline IntTools_EdgeEdge::IntTools_EdgeEdge(const TopoDS_Edge&  theEdge1,
72                                             const Standard_Real aT11,
73                                             const Standard_Real aT12,
74                                             const TopoDS_Edge&  theEdge2,
75                                             const Standard_Real aT21,
76                                             const Standard_Real aT22)
77
78   myEdge1(theEdge1), 
79   myEdge2(theEdge2),
80   myTol1(0.),
81   myTol2(0.),
82   myTol(0.),
83   myFuzzyValue(Precision::Confusion()),
84   myRes1(0.),
85   myRes2(0.),
86   myResCoeff1(0.),
87   myResCoeff2(0.),
88   myPTol1(0.),
89   myPTol2(0.),
90   myRange1(aT11, aT12),
91   myRange2(aT21, aT22),
92   mySwap(Standard_False),
93   myErrorStatus(0),
94   myQuickCoincidenceCheck(Standard_False)
95 {
96 }
97 //=======================================================================
98 //function : IntTools_EdgeEdge
99 //purpose  : 
100 //=======================================================================
101 inline IntTools_EdgeEdge::~IntTools_EdgeEdge()
102 {
103 }
104 //=======================================================================
105 //function : SetEdge1
106 //purpose  : 
107 //=======================================================================
108 inline void IntTools_EdgeEdge::SetEdge1(const TopoDS_Edge& theEdge)
109 {
110   myEdge1 = theEdge;
111 }
112 //=======================================================================
113 //function : SetRange1
114 //purpose  : 
115 //=======================================================================
116 inline void IntTools_EdgeEdge::SetRange1(const IntTools_Range& theRange)
117 {
118   myRange1 = theRange;
119 }
120 //=======================================================================
121 //function : SetRange1
122 //purpose  : 
123 //=======================================================================
124 inline void IntTools_EdgeEdge::SetRange1(const Standard_Real aT1,
125                                          const Standard_Real aT2)
126 {
127   myRange1.SetFirst(aT1);
128   myRange1.SetLast(aT2);
129 }
130 //=======================================================================
131 //function : SetEdge1
132 //purpose  : 
133 //=======================================================================
134 inline void IntTools_EdgeEdge::SetEdge1(const TopoDS_Edge&  theEdge,
135                                         const Standard_Real aT1,
136                                         const Standard_Real aT2)
137 {
138   SetEdge1(theEdge);
139   SetRange1(aT1, aT2);
140 }
141 //=======================================================================
142 //function : SetEdge2
143 //purpose  : 
144 //=======================================================================
145 inline void IntTools_EdgeEdge::SetEdge2(const TopoDS_Edge& theEdge)
146 {
147   myEdge2 = theEdge;
148 }
149 //=======================================================================
150 //function : SetRange1
151 //purpose  : 
152 //=======================================================================
153 inline void IntTools_EdgeEdge::SetRange2(const IntTools_Range& theRange)
154 {
155   myRange2 = theRange;
156 }
157 //=======================================================================
158 //function : SetRange1
159 //purpose  : 
160 //=======================================================================
161 inline void IntTools_EdgeEdge::SetRange2(const Standard_Real aT1,
162                                          const Standard_Real aT2)
163 {
164   myRange2.SetFirst(aT1);
165   myRange2.SetLast(aT2);
166 }
167 //=======================================================================
168 //function : SetEdge1
169 //purpose  : 
170 //=======================================================================
171 inline void IntTools_EdgeEdge::SetEdge2(const TopoDS_Edge&  theEdge,
172                                         const Standard_Real aT1,
173                                         const Standard_Real aT2)
174 {
175   SetEdge2(theEdge);
176   SetRange2(aT1, aT2);
177 }
178 //=======================================================================
179 //function : SetFuzzyValue
180 //purpose  : 
181 //=======================================================================
182 inline void IntTools_EdgeEdge::SetFuzzyValue(const Standard_Real theFuzz)
183 {
184   myFuzzyValue = Max(theFuzz, Precision::Confusion());
185 }
186 //=======================================================================
187 //function : FuzzyValue
188 //purpose  : 
189 //=======================================================================
190 inline Standard_Real IntTools_EdgeEdge::FuzzyValue() const
191 {
192   return myFuzzyValue;
193 }
194
195 //=======================================================================
196 //function : CommonParts
197 //purpose  : 
198 //=======================================================================
199 inline const IntTools_SequenceOfCommonPrts& IntTools_EdgeEdge::CommonParts() const
200 {
201   return myCommonParts;
202 }
203 //=======================================================================
204 //function : IsDone
205 //purpose  : 
206 //=======================================================================
207 inline Standard_Boolean IntTools_EdgeEdge::IsDone() const
208 {
209   return (myErrorStatus == 0);
210 }
211 //=======================================================================
212 //function : CheckData
213 //purpose  : 
214 //=======================================================================
215 inline void IntTools_EdgeEdge::CheckData()
216 {
217   if (myEdge1.IsNull() || myEdge2.IsNull()) {
218     myErrorStatus = 1;
219     return;
220   }
221   //
222   if (BRep_Tool::Degenerated(myEdge1) || BRep_Tool::Degenerated(myEdge2)) {
223     myErrorStatus = 2;
224     return;
225   }
226   //
227   if (!BRep_Tool::IsGeometric(myEdge1) || !BRep_Tool::IsGeometric(myEdge2)) { 
228     myErrorStatus = 3;
229     return;
230   }
231 }
232