4e57c75e |
1 | // Created by: Peter KURNEV |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
4e57c75e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
4e57c75e |
5 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
4e57c75e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
4e57c75e |
14 | |
42cf5bc1 |
15 | #include <BOPAlgo_WireEdgeSet.hxx> |
16 | #include <BOPAlgo_WireSplitter.hxx> |
319da2e4 |
17 | #include <BOPCol_IndexedDataMapOfShapeInteger.hxx> |
42cf5bc1 |
18 | #include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx> |
19 | #include <BOPCol_ListOfShape.hxx> |
20 | #include <BOPCol_MapOfShape.hxx> |
21 | #include <BOPCol_SequenceOfPnt2d.hxx> |
22 | #include <BOPCol_SequenceOfReal.hxx> |
23 | #include <BOPCol_SequenceOfShape.hxx> |
24 | #include <BOPTools_AlgoTools2D.hxx> |
25 | #include <BRep_Builder.hxx> |
26 | #include <BRep_Tool.hxx> |
27 | #include <BRepAdaptor_Surface.hxx> |
4e57c75e |
28 | #include <Geom2d_Curve.hxx> |
c5face6f |
29 | #include <Geom2d_Line.hxx> |
c5face6f |
30 | #include <Geom2dAdaptor_Curve.hxx> |
c5face6f |
31 | #include <Geom2dInt_GInter.hxx> |
42cf5bc1 |
32 | #include <Geom_Plane.hxx> |
33 | #include <Geom_RectangularTrimmedSurface.hxx> |
34 | #include <Geom_Surface.hxx> |
35 | #include <GeomAdaptor_Surface.hxx> |
36 | #include <gp_Dir2d.hxx> |
37 | #include <gp_Pnt2d.hxx> |
38 | #include <gp_Vec2d.hxx> |
c5face6f |
39 | #include <IntRes2d_Domain.hxx> |
40 | #include <IntRes2d_IntersectionPoint.hxx> |
42cf5bc1 |
41 | #include <Precision.hxx> |
42 | #include <TopExp.hxx> |
43 | #include <TopExp_Explorer.hxx> |
c5face6f |
44 | #include <TopLoc_Location.hxx> |
4e57c75e |
45 | #include <TopoDS_Edge.hxx> |
42cf5bc1 |
46 | #include <TopoDS_Face.hxx> |
47 | #include <TopoDS_Iterator.hxx> |
4e57c75e |
48 | #include <TopoDS_Vertex.hxx> |
49 | #include <TopoDS_Wire.hxx> |
c5face6f |
50 | #include <TopTools_ShapeMapHasher.hxx> |
3ba87fdb |
51 | #include <Geom2dLProp_CLProps2d.hxx> |
f56518cd |
52 | typedef NCollection_DataMap \ |
53 | <TopoDS_Shape, Standard_Boolean, TopTools_ShapeMapHasher> \ |
54 | BOPCol_DataMapOfShapeBoolean; |
55 | // |
56 | |
4e57c75e |
57 | static |
58 | Standard_Real Angle (const gp_Dir2d& aDir2D); |
59 | |
60 | static |
61 | Standard_Real Angle2D (const TopoDS_Vertex& aV, |
62 | const TopoDS_Edge& anEdge, |
63 | const TopoDS_Face& myFace, |
64 | const GeomAdaptor_Surface& aGAS, |
51db0179 |
65 | const Standard_Boolean aFlag, |
66 | const Handle(IntTools_Context)& theContext); |
4e57c75e |
67 | |
68 | static |
69 | void GetNextVertex(const TopoDS_Vertex& aV, |
70 | const TopoDS_Edge& aE, |
71 | TopoDS_Vertex& aV1); |
72 | |
73 | static |
74 | Standard_Real AngleIn(const TopoDS_Edge& aEIn, |
75 | const BOPAlgo_ListOfEdgeInfo& aLEInfo); |
76 | |
77 | static |
78 | Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo); |
79 | |
80 | static |
81 | gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE, |
82 | const TopoDS_Face& aF); |
83 | |
84 | static |
85 | gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1, |
86 | const TopoDS_Edge& aE1, |
87 | const TopoDS_Face& aF); |
88 | |
f56518cd |
89 | static |
4e57c75e |
90 | Standard_Real ClockWiseAngle(const Standard_Real aAngleIn, |
91 | const Standard_Real aAngleOut); |
92 | |
93 | static |
94 | void Path (const GeomAdaptor_Surface& aGAS, |
95 | const TopoDS_Face& myFace, |
96 | const TopoDS_Vertex& aVa, |
97 | const TopoDS_Edge& aEOuta, |
98 | BOPAlgo_EdgeInfo& anEdgeInfo, |
99 | BOPCol_SequenceOfShape& aLS, |
100 | BOPCol_SequenceOfShape& aVertVa, |
101 | BOPCol_SequenceOfPnt2d& aCoordVa, |
102 | BOPTools_ConnexityBlock& aCB, |
f56518cd |
103 | BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap, |
104 | BOPCol_DataMapOfShapeBoolean aVertMap); |
105 | |
4e57c75e |
106 | static |
107 | Standard_Real Angle (const gp_Dir2d& aDir2D); |
108 | |
109 | static |
110 | Standard_Real Tolerance2D (const TopoDS_Vertex& aV, |
111 | const GeomAdaptor_Surface& aGAS); |
112 | |
acccace3 |
113 | |
4e57c75e |
114 | |
115 | static |
116 | Standard_Real UTolerance2D (const TopoDS_Vertex& aV, |
117 | const GeomAdaptor_Surface& aGAS); |
118 | static |
119 | Standard_Real VTolerance2D (const TopoDS_Vertex& aV, |
120 | const GeomAdaptor_Surface& aGAS); |
121 | |
c5face6f |
122 | static |
123 | void RefineAngles(const TopoDS_Face& myFace, |
124 | const BOPCol_ListOfShape&, |
51db0179 |
125 | BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo&, |
126 | const Handle(IntTools_Context)&); |
c5face6f |
127 | |
128 | |
129 | static |
130 | void RefineAngles(const TopoDS_Vertex& , |
131 | const TopoDS_Face& , |
132 | const BOPCol_MapOfShape& , |
51db0179 |
133 | BOPAlgo_ListOfEdgeInfo&, |
134 | const Handle(IntTools_Context)&); |
c5face6f |
135 | |
136 | static |
137 | Standard_Boolean RefineAngle2D(const TopoDS_Vertex& , |
138 | const TopoDS_Edge& , |
139 | const TopoDS_Face& , |
140 | const Standard_Real , |
141 | const Standard_Real , |
51db0179 |
142 | Standard_Real& , |
143 | const Handle(IntTools_Context)& ); |
c5face6f |
144 | |
4e57c75e |
145 | //======================================================================= |
146 | //function : SplitBlock |
147 | //purpose : |
148 | //======================================================================= |
db8e4b9a |
149 | void BOPAlgo_WireSplitter::SplitBlock(const TopoDS_Face& myFace, |
51db0179 |
150 | BOPTools_ConnexityBlock& aCB, |
151 | const Handle(IntTools_Context)& theContext) |
4e57c75e |
152 | { |
f56518cd |
153 | Standard_Boolean bNothingToDo, bIsClosed, bIsIN; |
4e57c75e |
154 | Standard_Integer aIx, aNb, i, aCntIn, aCntOut; |
155 | Standard_Real aAngle; |
156 | TopAbs_Orientation aOr; |
157 | TopoDS_Iterator aItS; |
158 | TopoDS_Vertex aVV; |
f56518cd |
159 | TopoDS_Shape aV1; |
4e57c75e |
160 | BOPCol_ListIteratorOfListOfShape aIt; |
161 | BOPAlgo_ListIteratorOfListOfEdgeInfo aItLEI; |
162 | // |
db8e4b9a |
163 | BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo mySmartMap(100); |
f56518cd |
164 | BOPCol_DataMapOfShapeBoolean aVertMap; |
4e57c75e |
165 | // |
4e57c75e |
166 | const BOPCol_ListOfShape& myEdges=aCB.Shapes(); |
167 | // |
168 | // 1.Filling mySmartMap |
4e57c75e |
169 | aIt.Initialize(myEdges); |
170 | for(; aIt.More(); aIt.Next()) { |
171 | const TopoDS_Edge& aE=(*(TopoDS_Edge *)&aIt.Value()); |
172 | if (!BOPTools_AlgoTools2D::HasCurveOnSurface (aE, myFace)) { |
173 | continue; |
174 | } |
175 | // |
f56518cd |
176 | bIsClosed = BRep_Tool::Degenerated(aE) || |
177 | BRep_Tool::IsClosed(aE, myFace); |
178 | // |
4e57c75e |
179 | aItS.Initialize(aE); |
f56518cd |
180 | for(i = 0; aItS.More(); aItS.Next(), ++i) { |
181 | const TopoDS_Shape& aV = aItS.Value(); |
182 | aIx = mySmartMap.FindIndex(aV); |
4e57c75e |
183 | if (!aIx) { |
db8e4b9a |
184 | BOPAlgo_ListOfEdgeInfo aLEIx; |
f56518cd |
185 | aIx = mySmartMap.Add(aV, aLEIx); |
4e57c75e |
186 | } |
187 | // |
f56518cd |
188 | BOPAlgo_ListOfEdgeInfo& aLEI = mySmartMap(aIx); |
4e57c75e |
189 | BOPAlgo_EdgeInfo aEI; |
190 | // |
191 | aEI.SetEdge(aE); |
f56518cd |
192 | aOr = aV.Orientation(); |
193 | bIsIN = (aOr == TopAbs_REVERSED); |
194 | aEI.SetInFlag(bIsIN); |
195 | aLEI.Append(aEI); |
196 | // |
197 | if (!i) { |
198 | aV1 = aV; |
199 | } else { |
200 | bIsClosed = bIsClosed || aV1.IsSame(aV); |
4e57c75e |
201 | } |
f56518cd |
202 | // |
203 | if (aVertMap.IsBound(aV)) { |
204 | if (bIsClosed) { |
205 | aVertMap.ChangeFind(aV) = bIsClosed; |
206 | } |
207 | } else { |
208 | aVertMap.Bind(aV, bIsClosed); |
4e57c75e |
209 | } |
4e57c75e |
210 | } |
211 | } |
212 | // |
213 | aNb=mySmartMap.Extent(); |
214 | // |
215 | bNothingToDo=Standard_True; |
216 | for (i=1; i<=aNb; i++) { |
217 | aCntIn=0; |
218 | aCntOut=0; |
219 | const BOPAlgo_ListOfEdgeInfo& aLEInfo= mySmartMap(i); |
220 | BOPAlgo_ListIteratorOfListOfEdgeInfo anIt(aLEInfo); |
221 | for (; anIt.More(); anIt.Next()) { |
222 | const BOPAlgo_EdgeInfo& aEI=anIt.Value(); |
223 | if (aEI.IsIn()) { |
224 | aCntIn++; |
225 | } |
226 | else { |
227 | aCntOut++; |
228 | } |
229 | } |
230 | if (aCntIn!=1 || aCntOut!=1) { |
231 | bNothingToDo=Standard_False; |
232 | break; |
233 | } |
234 | } |
235 | // |
236 | // Each vertex has one edge In and one - Out. Good. But it is not enought |
237 | // to consider that nothing to do with this. We must check edges on TShape |
238 | // coinsidence. If there are such edges there is something to do with. |
239 | if (bNothingToDo) { |
240 | Standard_Integer aNbE, aNbMapEE; |
241 | Standard_Boolean bFlag; |
242 | // |
db8e4b9a |
243 | BOPCol_IndexedDataMapOfShapeListOfShape aMapEE(100); |
4e57c75e |
244 | aNbE=myEdges.Extent(); |
245 | // |
246 | aIt.Initialize(myEdges); |
247 | for (; aIt.More(); aIt.Next()) { |
248 | const TopoDS_Shape& aE = aIt.Value(); |
249 | if (!aMapEE.Contains(aE)) { |
db8e4b9a |
250 | BOPCol_ListOfShape aLEx; |
4e57c75e |
251 | aLEx.Append(aE); |
252 | aMapEE.Add(aE, aLEx); |
253 | } |
254 | else { |
255 | BOPCol_ListOfShape& aLEx=aMapEE.ChangeFromKey(aE); |
256 | aLEx.Append(aE); |
257 | } |
258 | } |
259 | // |
260 | bFlag=Standard_True; |
261 | aNbMapEE=aMapEE.Extent(); |
262 | for (i=1; i<=aNbMapEE; ++i) { |
263 | const BOPCol_ListOfShape& aLEx=aMapEE(i); |
264 | aNbE=aLEx.Extent(); |
265 | if (aNbE==1) {// usual case |
266 | continue; |
267 | } |
268 | else if (aNbE==2){ |
269 | const TopoDS_Shape& aE1=aLEx.First(); |
270 | const TopoDS_Shape& aE2=aLEx.Last(); |
271 | if (aE1.IsSame(aE2)) { |
272 | bFlag=Standard_False; |
273 | break; |
274 | } |
275 | } |
276 | else { |
277 | bFlag=Standard_False; |
278 | break; |
279 | } |
280 | } |
281 | bNothingToDo=bNothingToDo && bFlag; |
282 | } // if (bNothingToDo) { |
283 | if (bNothingToDo) { |
284 | TopoDS_Wire aW; |
285 | // |
286 | BOPCol_ListOfShape& aLECB=aCB.ChangeShapes(); |
287 | BOPAlgo_WireSplitter::MakeWire(aLECB, aW); |
288 | BOPCol_ListOfShape& aLoops=aCB.ChangeLoops(); |
289 | aLoops.Append(aW); |
290 | // |
4e57c75e |
291 | return; |
292 | } |
293 | // |
294 | // 3. Angles in mySmartMap |
51db0179 |
295 | const BRepAdaptor_Surface& aBAS = theContext->SurfaceAdaptor(myFace); |
4e57c75e |
296 | const GeomAdaptor_Surface& aGAS=aBAS.Surface(); |
297 | // |
298 | for (i=1; i<=aNb; i++) { |
f56518cd |
299 | const TopoDS_Vertex& aV = (*(TopoDS_Vertex *)(&mySmartMap.FindKey(i))); |
4e57c75e |
300 | const BOPAlgo_ListOfEdgeInfo& aLEI= mySmartMap(i); |
4e57c75e |
301 | aItLEI.Initialize(aLEI); |
302 | for (; aItLEI.More(); aItLEI.Next()) { |
303 | BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue(); |
304 | const TopoDS_Edge& aE=aEI.Edge(); |
305 | // |
f56518cd |
306 | aVV = aV; |
307 | bIsIN = aEI.IsIn(); |
308 | aOr = bIsIN ? TopAbs_REVERSED : TopAbs_FORWARD; |
309 | aVV.Orientation(aOr); |
51db0179 |
310 | aAngle = Angle2D(aVV, aE, myFace, aGAS, bIsIN, theContext); |
4e57c75e |
311 | aEI.SetAngle(aAngle); |
312 | } |
313 | }// for (i=1; i<=aNb; i++) { |
314 | // |
c5face6f |
315 | //Theme: The treatment p-curves convergent in node. |
316 | //The refining the angles of p-curves taking into account |
51db0179 |
317 | //bounding curves if exist. |
318 | RefineAngles(myFace, myEdges, mySmartMap, theContext); |
c5face6f |
319 | // |
4e57c75e |
320 | // 4. Do |
321 | // |
322 | Standard_Boolean bIsOut, bIsNotPassed; |
323 | BOPCol_SequenceOfShape aLS, aVertVa; |
324 | BOPCol_SequenceOfPnt2d aCoordVa; |
325 | // |
326 | for (i=1; i<=aNb; ++i) { |
327 | const TopoDS_Vertex& aVa=(*(TopoDS_Vertex *)(&mySmartMap.FindKey(i))); |
328 | const BOPAlgo_ListOfEdgeInfo& aLEI=mySmartMap(i); |
329 | aItLEI.Initialize(aLEI); |
330 | for (; aItLEI.More(); aItLEI.Next()) { |
331 | BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue(); |
332 | const TopoDS_Edge& aEOuta=aEI.Edge(); |
333 | // |
334 | bIsOut=!aEI.IsIn(); |
335 | bIsNotPassed=!aEI.Passed(); |
336 | if (bIsOut && bIsNotPassed) { |
337 | // |
338 | aLS.Clear(); |
339 | aVertVa.Clear(); |
340 | aCoordVa.Clear(); |
341 | // |
342 | Path(aGAS, myFace, aVa, aEOuta, aEI, aLS, |
f56518cd |
343 | aVertVa, aCoordVa, aCB, mySmartMap, aVertMap); |
4e57c75e |
344 | } |
345 | } |
346 | }// for (i=1; i<=aNb; ++i) { |
347 | } |
348 | //======================================================================= |
349 | // function: Path |
350 | // purpose: |
351 | //======================================================================= |
352 | void Path (const GeomAdaptor_Surface& aGAS, |
353 | const TopoDS_Face& myFace, |
b7357c8b |
354 | const TopoDS_Vertex& aVFirst, |
355 | const TopoDS_Edge& aEFirst, |
356 | BOPAlgo_EdgeInfo& aEIFirst, |
4e57c75e |
357 | BOPCol_SequenceOfShape& aLS, |
358 | BOPCol_SequenceOfShape& aVertVa, |
359 | BOPCol_SequenceOfPnt2d& aCoordVa, |
360 | BOPTools_ConnexityBlock& aCB, |
f56518cd |
361 | BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap, |
362 | BOPCol_DataMapOfShapeBoolean aVertMap) |
4e57c75e |
363 | |
364 | { |
365 | Standard_Integer i, j, aNb, aNbj; |
ecba6de3 |
366 | Standard_Real anAngleIn, anAngleOut, anAngle, aMinAngle; |
367 | Standard_Real aTol2D, aTol2D2, aD2, aTwoPI; |
4e57c75e |
368 | Standard_Boolean anIsSameV2d, anIsSameV, anIsFound, anIsOut, anIsNotPassed; |
f56518cd |
369 | Standard_Boolean bIsClosed; |
b7357c8b |
370 | TopoDS_Vertex aVa, aVb; |
371 | TopoDS_Edge aEOuta; |
4e57c75e |
372 | BOPAlgo_ListIteratorOfListOfEdgeInfo anIt; |
3ba87fdb |
373 | Standard_Real eps = Epsilon(1.); |
4e57c75e |
374 | // |
b7357c8b |
375 | aVa = aVFirst; |
376 | aEOuta = aEFirst; |
377 | BOPAlgo_EdgeInfo* anEdgeInfo = &aEIFirst; |
378 | // |
b20eeb13 |
379 | aTwoPI = M_PI + M_PI; |
4e57c75e |
380 | // |
381 | // append block |
382 | // |
b7357c8b |
383 | for (;;) { |
384 | // Do not escape through edge from which you enter |
385 | aNb=aLS.Length(); |
386 | if (aNb==1) { |
387 | const TopoDS_Shape& anEPrev=aLS(aNb); |
388 | if (anEPrev.IsSame(aEOuta)) { |
389 | return; |
390 | } |
4e57c75e |
391 | } |
4e57c75e |
392 | // |
b7357c8b |
393 | anEdgeInfo->SetPassed(Standard_True); |
394 | aLS.Append(aEOuta); |
395 | aVertVa.Append(aVa); |
396 | |
397 | TopoDS_Vertex pVa=aVa; |
398 | pVa.Orientation(TopAbs_FORWARD); |
399 | gp_Pnt2d aPa=Coord2d(pVa, aEOuta, myFace); |
400 | aCoordVa.Append(aPa); |
401 | |
402 | GetNextVertex (pVa, aEOuta, aVb); |
403 | |
404 | gp_Pnt2d aPb=Coord2d(aVb, aEOuta, myFace); |
405 | |
ecba6de3 |
406 | const BOPAlgo_ListOfEdgeInfo& aLEInfo=mySmartMap.FindFromKey(aVb); |
4e57c75e |
407 | // |
ecba6de3 |
408 | aTol2D = 2.*Tolerance2D(aVb, aGAS); |
409 | aTol2D2 = aTol2D * aTol2D; |
410 | // |
f56518cd |
411 | bIsClosed = aVertMap.Find(aVb); |
b7357c8b |
412 | // |
413 | aNb=aLS.Length(); |
414 | if (aNb>0) { |
415 | // |
416 | BOPCol_ListOfShape aBuf; |
417 | // |
418 | for (i=aNb; i>0; --i) { |
419 | const TopoDS_Shape& aVPrev=aVertVa(i); |
420 | const gp_Pnt2d& aPaPrev=aCoordVa(i); |
421 | const TopoDS_Shape& aEPrev=aLS(i); |
422 | |
423 | aBuf.Append(aEPrev); |
424 | |
ecba6de3 |
425 | anIsSameV = aVPrev.IsSame(aVb); |
426 | anIsSameV2d = anIsSameV; |
b7357c8b |
427 | if (anIsSameV) { |
ecba6de3 |
428 | if(bIsClosed) { |
429 | aD2 = aPaPrev.SquareDistance(aPb); |
430 | anIsSameV2d = aD2 < aTol2D2; |
431 | if (anIsSameV2d) { |
432 | Standard_Real udist = fabs(aPaPrev.X() - aPb.X()); |
433 | Standard_Real vdist = fabs(aPaPrev.Y() - aPb.Y()); |
434 | Standard_Real aTolU = 2.*UTolerance2D(aVb, aGAS); |
435 | Standard_Real aTolV = 2.*VTolerance2D(aVb, aGAS); |
436 | // |
437 | if((udist > aTolU) || (vdist > aTolV)) { |
438 | anIsSameV2d = Standard_False; |
439 | } |
b7357c8b |
440 | } |
441 | } |
442 | }//if (anIsSameV) { |
4e57c75e |
443 | // |
b7357c8b |
444 | if (anIsSameV && anIsSameV2d) { |
445 | Standard_Integer iPriz; |
446 | iPriz=1; |
447 | if (aBuf.Extent()==2) { |
448 | if(aBuf.First().IsSame(aBuf.Last())) { |
449 | iPriz=0; |
450 | } |
451 | } |
452 | if (iPriz) { |
453 | TopoDS_Wire aW; |
454 | BOPAlgo_WireSplitter::MakeWire(aBuf, aW); |
455 | aCB.ChangeLoops().Append(aW); |
456 | } |
4e57c75e |
457 | // |
b7357c8b |
458 | aNbj=i-1; |
459 | if (aNbj<1) { |
460 | // |
461 | aLS.Clear(); |
462 | aVertVa.Clear(); |
463 | aCoordVa.Clear(); |
464 | // |
465 | return; |
4e57c75e |
466 | } |
b7357c8b |
467 | // |
468 | BOPCol_SequenceOfShape aLSt, aVertVat; |
469 | BOPCol_SequenceOfPnt2d aCoordVat; |
470 | // |
471 | aVb=(*(TopoDS_Vertex *)(&aVertVa(i))); |
472 | // |
473 | for (j=1; j<=aNbj; ++j) { |
474 | aLSt.Append(aLS(j)); |
475 | aVertVat.Append(aVertVa(j)); |
476 | aCoordVat.Append(aCoordVa(j)); |
4e57c75e |
477 | } |
4e57c75e |
478 | // |
479 | aLS.Clear(); |
480 | aVertVa.Clear(); |
481 | aCoordVa.Clear(); |
b7357c8b |
482 | |
483 | aLS=aLSt; |
484 | aVertVa=aVertVat; |
485 | aCoordVa=aCoordVat; |
4e57c75e |
486 | // |
b7357c8b |
487 | break; |
4e57c75e |
488 | } |
4e57c75e |
489 | } |
490 | } |
b7357c8b |
491 | // |
b7357c8b |
492 | // aEOutb |
493 | BOPAlgo_EdgeInfo *pEdgeInfo=NULL; |
494 | // |
ecba6de3 |
495 | anAngleIn = AngleIn(aEOuta, aLEInfo); |
496 | aMinAngle = 100.; |
497 | anIsFound = Standard_False; |
b7357c8b |
498 | Standard_Integer aCurIndexE = 0; |
499 | anIt.Initialize(aLEInfo); |
500 | for (; anIt.More(); anIt.Next()) { |
501 | BOPAlgo_EdgeInfo& anEI=anIt.ChangeValue(); |
502 | const TopoDS_Edge& aE=anEI.Edge(); |
503 | anIsOut=!anEI.IsIn(); |
504 | anIsNotPassed=!anEI.Passed(); |
f56518cd |
505 | // |
b7357c8b |
506 | if (anIsOut && anIsNotPassed) { |
507 | aCurIndexE++; |
b20eeb13 |
508 | // |
b7357c8b |
509 | // Is there one way to go out of the vertex |
510 | // we have to use it only. |
511 | Standard_Integer iCnt; |
512 | iCnt=NbWaysOut (aLEInfo); |
b20eeb13 |
513 | // |
b7357c8b |
514 | if (!iCnt) { |
515 | // no way to go . (Error) |
516 | return; |
4e57c75e |
517 | } |
b20eeb13 |
518 | // |
b7357c8b |
519 | if (iCnt==1) { |
520 | // the one and only way to go out . |
521 | pEdgeInfo=&anEI; |
522 | anIsFound=Standard_True; |
523 | break; |
524 | } |
b20eeb13 |
525 | // |
b7357c8b |
526 | if (aE.IsSame(aEOuta)) { |
527 | anAngle = aTwoPI; |
528 | } else { |
ecba6de3 |
529 | //check 2d distance |
530 | if (bIsClosed) { |
531 | gp_Pnt2d aP2Dx; |
532 | // |
533 | aP2Dx = Coord2dVf(aE, myFace); |
534 | // |
535 | aD2 = aP2Dx.SquareDistance(aPb); |
536 | if (aD2 > aTol2D2){ |
537 | continue; |
538 | } |
b20eeb13 |
539 | } |
b7357c8b |
540 | // |
ecba6de3 |
541 | // Look for minimal angle and make the choice. |
b7357c8b |
542 | anAngleOut=anEI.Angle(); |
b7357c8b |
543 | anAngle=ClockWiseAngle(anAngleIn, anAngleOut); |
544 | } |
3ba87fdb |
545 | if (anAngle < aMinAngle - eps) { |
b7357c8b |
546 | aMinAngle=anAngle; |
547 | pEdgeInfo=&anEI; |
548 | anIsFound=Standard_True; |
b20eeb13 |
549 | } |
4e57c75e |
550 | } |
b7357c8b |
551 | } // for (; anIt.More(); anIt.Next()) |
552 | // |
553 | if (!anIsFound) { |
554 | // no way to go . (Error) |
555 | return; |
4e57c75e |
556 | } |
b7357c8b |
557 | // |
558 | aVa = aVb; |
559 | aEOuta = pEdgeInfo->Edge(); |
560 | anEdgeInfo = pEdgeInfo; |
4e57c75e |
561 | } |
4e57c75e |
562 | } |
563 | //======================================================================= |
564 | // function: ClockWiseAngle |
565 | // purpose: |
566 | //======================================================================= |
567 | Standard_Real ClockWiseAngle(const Standard_Real aAngleIn, |
568 | const Standard_Real aAngleOut) |
569 | { |
570 | Standard_Real aTwoPi=M_PI+M_PI; |
571 | Standard_Real dA, A1, A2, AIn, AOut ; |
572 | |
573 | AIn=aAngleIn; |
574 | AOut=aAngleOut; |
575 | if (AIn >= aTwoPi) { |
576 | AIn=AIn-aTwoPi; |
577 | } |
578 | |
579 | if (AOut >= aTwoPi) { |
580 | AOut=AOut-aTwoPi; |
581 | } |
582 | |
583 | A1=AIn+M_PI; |
584 | |
585 | if (A1 >= aTwoPi) { |
586 | A1=A1-aTwoPi; |
587 | } |
588 | |
589 | A2=AOut; |
590 | |
591 | dA=A1-A2; |
592 | if (dA <= 0.) { |
593 | dA=aTwoPi+dA; |
594 | } |
595 | //xx |
596 | //else if (dA <= 1.e-15) { |
597 | else if (dA <= 1.e-14) { |
598 | dA=aTwoPi; |
599 | } |
600 | return dA; |
601 | } |
602 | //======================================================================= |
603 | // function: Coord2d |
604 | // purpose: |
605 | //======================================================================= |
606 | gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1, |
607 | const TopoDS_Edge& aE1, |
608 | const TopoDS_Face& aF) |
609 | { |
610 | Standard_Real aT, aFirst, aLast; |
611 | Handle(Geom2d_Curve) aC2D; |
612 | gp_Pnt2d aP2D1; |
613 | // |
614 | aT=BRep_Tool::Parameter (aV1, aE1, aF); |
615 | aC2D=BRep_Tool::CurveOnSurface(aE1, aF, aFirst, aLast); |
616 | aC2D->D0 (aT, aP2D1); |
617 | // |
618 | return aP2D1; |
619 | } |
620 | //======================================================================= |
621 | // function: Coord2dVf |
622 | // purpose: |
623 | //======================================================================= |
624 | gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE, |
625 | const TopoDS_Face& aF) |
626 | { |
627 | Standard_Real aCoord=99.; |
628 | gp_Pnt2d aP2D1(aCoord, aCoord); |
629 | TopoDS_Iterator aIt; |
630 | // |
631 | aIt.Initialize(aE); |
632 | for (; aIt.More(); aIt.Next()) { |
633 | const TopoDS_Shape& aVx=aIt.Value(); |
634 | if (aVx.Orientation()==TopAbs_FORWARD) { |
635 | |
636 | const TopoDS_Vertex& aVxx=(*(TopoDS_Vertex *)(&aVx));// TopoDS::Vertex(aVx); |
637 | aP2D1=Coord2d(aVxx, aE, aF); |
638 | return aP2D1; |
639 | } |
640 | } |
641 | return aP2D1; |
642 | } |
643 | |
644 | //======================================================================= |
645 | // function: NbWaysOut |
646 | // purpose: |
647 | //======================================================================= |
648 | Standard_Integer NbWaysOut(const BOPAlgo_ListOfEdgeInfo& aLEInfo) |
649 | { |
650 | Standard_Boolean bIsOut, bIsNotPassed; |
651 | Standard_Integer iCnt=0; |
652 | BOPAlgo_ListIteratorOfListOfEdgeInfo anIt; |
653 | // |
654 | anIt.Initialize(aLEInfo); |
655 | for (; anIt.More(); anIt.Next()) { |
656 | const BOPAlgo_EdgeInfo& anEI=anIt.Value(); |
657 | // |
658 | bIsOut=!anEI.IsIn(); |
659 | bIsNotPassed=!anEI.Passed(); |
660 | if (bIsOut && bIsNotPassed) { |
661 | iCnt++; |
662 | } |
663 | } |
664 | return iCnt; |
665 | } |
666 | |
667 | //======================================================================= |
668 | // function: AngleIn |
669 | // purpose: |
670 | //======================================================================= |
671 | Standard_Real AngleIn(const TopoDS_Edge& aEIn, |
672 | const BOPAlgo_ListOfEdgeInfo& aLEInfo) |
673 | { |
674 | Standard_Real anAngleIn; |
675 | Standard_Boolean anIsIn; |
676 | BOPAlgo_ListIteratorOfListOfEdgeInfo anIt; |
677 | |
678 | anIt.Initialize(aLEInfo); |
679 | for (; anIt.More(); anIt.Next()) { |
680 | const BOPAlgo_EdgeInfo& anEdgeInfo=anIt.Value(); |
681 | const TopoDS_Edge& aE=anEdgeInfo.Edge(); |
682 | anIsIn=anEdgeInfo.IsIn(); |
683 | // |
684 | if (anIsIn && aE==aEIn) { |
685 | anAngleIn=anEdgeInfo.Angle(); |
686 | return anAngleIn; |
687 | } |
688 | } |
689 | anAngleIn=0.; |
690 | return anAngleIn; |
691 | } |
692 | //======================================================================= |
693 | // function: GetNextVertex |
694 | // purpose: |
695 | //======================================================================= |
696 | void GetNextVertex(const TopoDS_Vertex& aV, |
697 | const TopoDS_Edge& aE, |
698 | TopoDS_Vertex& aV1) |
699 | { |
700 | TopoDS_Iterator aIt; |
701 | // |
702 | aIt.Initialize(aE); |
703 | for (; aIt.More(); aIt.Next()) { |
704 | const TopoDS_Shape& aVx=aIt.Value(); |
705 | if (!aVx.IsEqual(aV)) { |
706 | aV1=(*(TopoDS_Vertex *)(&aVx)); |
707 | return ; |
708 | } |
709 | } |
710 | aV1=aV; |
711 | } |
712 | //======================================================================= |
713 | // function: Angle2D |
714 | // purpose: |
715 | //======================================================================= |
716 | Standard_Real Angle2D (const TopoDS_Vertex& aV, |
717 | const TopoDS_Edge& anEdge, |
718 | const TopoDS_Face& myFace, |
719 | const GeomAdaptor_Surface& aGAS, |
51db0179 |
720 | const Standard_Boolean bIsIN, |
721 | const Handle(IntTools_Context)& theContext) |
4e57c75e |
722 | { |
723 | Standard_Real aFirst, aLast, aToler, dt, aTV, aTV1, anAngle, aTX; |
724 | gp_Pnt2d aPV, aPV1; |
725 | gp_Vec2d aV2D; |
726 | Handle(Geom2d_Curve) aC2D; |
727 | // |
728 | aTV=BRep_Tool::Parameter (aV, anEdge, myFace); |
729 | if (Precision::IsInfinite(aTV)) { |
730 | return 0.; |
731 | } |
732 | // |
733 | BOPTools_AlgoTools2D::CurveOnSurface (anEdge, myFace, aC2D, |
51db0179 |
734 | aFirst, aLast, aToler, theContext); |
3ba87fdb |
735 | Standard_Real tol2d =2.*Tolerance2D(aV, aGAS); |
736 | // |
737 | GeomAbs_CurveType aType; |
738 | Geom2dAdaptor_Curve aGAC2D(aC2D); |
739 | // |
740 | dt = Max(aGAC2D.Resolution(tol2d), Precision::PConfusion()); |
4e57c75e |
741 | // |
3ba87fdb |
742 | aType=aGAC2D.GetType(); |
743 | if (aType != GeomAbs_Line ) |
744 | { |
745 | Geom2dLProp_CLProps2d LProp(aC2D, aTV, 2, Precision::PConfusion()); |
746 | if(LProp.IsTangentDefined()) |
747 | { |
748 | Standard_Real R = LProp.Curvature(); |
749 | if(R > Precision::PConfusion()) |
750 | { |
751 | R = 1./R; |
752 | Standard_Real cosphi = R / (R + tol2d); |
753 | dt = Max(dt, ACos(cosphi)); //to avoid small dt for big R. |
754 | } |
755 | } |
756 | } |
4e57c75e |
757 | //for case chl/927/r9 |
3ba87fdb |
758 | aTX=0.05*(aLast - aFirst);//aTX=0.25*(aLast - aFirst); |
4e57c75e |
759 | if (aTX < 5.e-5) { |
760 | aTX = 5.e-5; |
761 | } |
762 | if(dt > aTX) { |
763 | // to save direction of the curve as much as it possible |
764 | // in the case of big tolerances |
765 | dt = aTX; |
766 | } |
3ba87fdb |
767 | |
4e57c75e |
768 | if (fabs (aTV-aFirst) < fabs(aTV - aLast)) { |
769 | aTV1=aTV + dt; |
770 | } |
771 | else { |
772 | aTV1=aTV - dt; |
773 | } |
774 | // |
3ba87fdb |
775 | aGAC2D.D0 (aTV1, aPV1); |
776 | aGAC2D.D0 (aTV, aPV); |
777 | // |
778 | aV2D = bIsIN ? gp_Vec2d(aPV1, aPV) : gp_Vec2d(aPV, aPV1); |
4e57c75e |
779 | // |
780 | gp_Dir2d aDir2D(aV2D); |
781 | anAngle=Angle(aDir2D); |
782 | // |
783 | return anAngle; |
784 | } |
785 | //======================================================================= |
786 | // function: Angle |
787 | // purpose: |
788 | //======================================================================= |
789 | Standard_Real Angle (const gp_Dir2d& aDir2D) |
790 | { |
791 | gp_Dir2d aRefDir(1., 0.); |
792 | Standard_Real anAngle; |
793 | |
794 | anAngle = aRefDir.Angle(aDir2D); |
795 | if (anAngle < 0.) |
796 | anAngle += M_PI + M_PI; |
797 | return anAngle; |
798 | } |
799 | //======================================================================= |
800 | // function: Tolerance2D |
801 | // purpose: |
802 | //======================================================================= |
803 | Standard_Real Tolerance2D (const TopoDS_Vertex& aV, |
804 | const GeomAdaptor_Surface& aGAS) |
805 | { |
806 | Standard_Real aTol2D, anUr, aVr, aTolV3D; |
807 | GeomAbs_SurfaceType aType; |
808 | // |
809 | aType=aGAS.GetType(); |
810 | aTolV3D=BRep_Tool::Tolerance(aV); |
811 | |
812 | anUr=aGAS.UResolution(aTolV3D); |
813 | aVr =aGAS.VResolution(aTolV3D); |
814 | aTol2D=(aVr>anUr) ? aVr : anUr; |
815 | // |
816 | if (aTol2D < aTolV3D) { |
817 | aTol2D=aTolV3D; |
818 | } |
819 | if (aType==GeomAbs_BSplineSurface) { |
820 | aTol2D=1.1*aTol2D; |
821 | } |
822 | // |
823 | return aTol2D; |
824 | } |
acccace3 |
825 | |
4e57c75e |
826 | //======================================================================= |
827 | //function : UTolerance2D |
828 | //purpose : |
829 | //======================================================================= |
830 | Standard_Real UTolerance2D (const TopoDS_Vertex& aV, |
831 | const GeomAdaptor_Surface& aGAS) |
832 | { |
833 | const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV); |
834 | const Standard_Real anUr = aGAS.UResolution(aTolV3D); |
835 | // |
836 | return anUr; |
837 | } |
838 | |
839 | //======================================================================= |
840 | //function : VTolerance2D |
841 | //purpose : |
842 | //======================================================================= |
843 | Standard_Real VTolerance2D (const TopoDS_Vertex& aV, |
844 | const GeomAdaptor_Surface& aGAS) |
845 | { |
846 | const Standard_Real aTolV3D = BRep_Tool::Tolerance(aV); |
847 | const Standard_Real anVr = aGAS.VResolution(aTolV3D); |
848 | // |
849 | return anVr; |
850 | } |
851 | |
c5face6f |
852 | //======================================================================= |
853 | //function : RefineAngles |
854 | //purpose : |
855 | //======================================================================= |
856 | void RefineAngles(const TopoDS_Face& myFace, |
857 | const BOPCol_ListOfShape& myEdges, |
51db0179 |
858 | BOPAlgo_IndexedDataMapOfShapeListOfEdgeInfo& mySmartMap, |
859 | const Handle(IntTools_Context)& theContext) |
c5face6f |
860 | { |
861 | Standard_Integer aNb, i; |
319da2e4 |
862 | BOPCol_IndexedDataMapOfShapeInteger aMSI; |
c5face6f |
863 | BOPCol_MapOfShape aMBE; |
864 | BOPCol_ListIteratorOfListOfShape aIt; |
865 | // |
866 | // 1. Boundary Edges |
867 | aIt.Initialize(myEdges); |
868 | for(; aIt.More(); aIt.Next()) { |
869 | const TopoDS_Shape& aE=aIt.Value(); |
319da2e4 |
870 | if(aMSI.Contains(aE)) { |
871 | Standard_Integer& iCnt = aMSI.ChangeFromKey(aE); |
c5face6f |
872 | ++iCnt; |
873 | } |
874 | else { |
319da2e4 |
875 | Standard_Integer iCnt = 1; |
876 | aMSI.Add(aE, iCnt); |
c5face6f |
877 | } |
878 | } |
879 | // |
319da2e4 |
880 | aNb = aMSI.Extent(); |
881 | for (i = 1; i <= aNb; ++i) { |
882 | Standard_Integer iCnt = aMSI(i); |
883 | if (iCnt == 1) { |
884 | const TopoDS_Shape& aE = aMSI.FindKey(i); |
c5face6f |
885 | aMBE.Add(aE); |
886 | } |
c5face6f |
887 | } |
888 | // |
889 | aMSI.Clear(); |
890 | // |
319da2e4 |
891 | aNb = mySmartMap.Extent(); |
892 | for (i = 1; i <= aNb; ++i) { |
c5face6f |
893 | const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&mySmartMap.FindKey(i)); |
894 | BOPAlgo_ListOfEdgeInfo& aLEI=mySmartMap(i); |
895 | // |
51db0179 |
896 | RefineAngles(aV, myFace, aMBE, aLEI, theContext); |
c5face6f |
897 | } |
898 | } |
899 | //======================================================================= |
900 | typedef NCollection_DataMap \ |
901 | <TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> \ |
902 | BOPCol_DataMapOfShapeReal; |
903 | typedef BOPCol_DataMapOfShapeReal::Iterator \ |
904 | BOPCol_DataMapIteratorOfDataMapOfShapeReal; |
905 | // |
906 | //======================================================================= |
907 | //function : RefineAngles |
908 | //purpose : |
909 | //======================================================================= |
910 | void RefineAngles(const TopoDS_Vertex& aV, |
911 | const TopoDS_Face& myFace, |
912 | const BOPCol_MapOfShape& aMBE, |
51db0179 |
913 | BOPAlgo_ListOfEdgeInfo& aLEI, |
914 | const Handle(IntTools_Context)& theContext) |
c5face6f |
915 | { |
916 | Standard_Boolean bIsIn, bIsBoundary, bRefined; |
f56518cd |
917 | Standard_Integer iCntBnd, iCntInt; |
c5face6f |
918 | Standard_Real aA, aA1, aA2; |
919 | BOPCol_DataMapOfShapeReal aDMSR; |
920 | BOPAlgo_ListIteratorOfListOfEdgeInfo aItLEI; |
921 | // |
922 | aA1=0.; |
923 | aA2=0.; |
f56518cd |
924 | iCntBnd=0; |
925 | iCntInt=0; |
c5face6f |
926 | aItLEI.Initialize(aLEI); |
927 | for (; aItLEI.More(); aItLEI.Next()) { |
928 | BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue(); |
929 | const TopoDS_Edge& aE=aEI.Edge(); |
930 | bIsIn=aEI.IsIn(); |
931 | aA=aEI.Angle(); |
932 | // |
933 | if (aMBE.Contains(aE)) { |
f56518cd |
934 | ++iCntBnd; |
c5face6f |
935 | if (!bIsIn) { |
936 | aA1=aA; |
937 | } |
938 | else { |
939 | aA2=aA+M_PI; |
940 | } |
941 | } |
f56518cd |
942 | else { |
943 | ++iCntInt; |
944 | } |
c5face6f |
945 | } |
946 | // |
f56518cd |
947 | if (iCntBnd!=2) { |
c5face6f |
948 | return; |
949 | } |
950 | // |
951 | aItLEI.Initialize(aLEI); |
952 | for (; aItLEI.More(); aItLEI.Next()) { |
953 | BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue(); |
954 | const TopoDS_Edge& aE=aEI.Edge(); |
955 | // |
956 | bIsBoundary=aMBE.Contains(aE); |
957 | bIsIn=aEI.IsIn(); |
958 | if (bIsBoundary || bIsIn) { |
959 | continue; |
960 | } |
961 | // |
962 | aA=aEI.Angle(); |
f56518cd |
963 | if (aA>aA1 && aA<aA2) { |
c5face6f |
964 | continue; |
965 | } |
966 | // |
51db0179 |
967 | bRefined=RefineAngle2D(aV, aE, myFace, aA1, aA2, aA, theContext); |
c5face6f |
968 | if (bRefined) { |
969 | aDMSR.Bind(aE, aA); |
970 | } |
f56518cd |
971 | else if (iCntInt == 2) { |
972 | aA = (aA <= aA1) ? (aA1 + Precision::Angular()) : |
973 | (aA2 - Precision::Angular()); |
974 | aDMSR.Bind(aE, aA); |
975 | } |
c5face6f |
976 | } |
977 | |
978 | if (aDMSR.IsEmpty()) { |
979 | return; |
980 | } |
981 | // |
982 | // update Angles |
983 | aItLEI.Initialize(aLEI); |
984 | for (; aItLEI.More(); aItLEI.Next()) { |
985 | BOPAlgo_EdgeInfo& aEI=aItLEI.ChangeValue(); |
986 | const TopoDS_Edge& aE=aEI.Edge(); |
987 | // |
988 | bIsIn=aEI.IsIn(); |
989 | if (!aDMSR.IsBound(aE)) { |
990 | continue; |
991 | } |
992 | // |
993 | aA=aDMSR.Find(aE); |
994 | if (bIsIn) { |
995 | aA=aA+M_PI; |
996 | } |
997 | // |
998 | aEI.SetAngle(aA); |
999 | } |
1000 | } |
1001 | //======================================================================= |
1002 | //function : RefineAngle2D |
1003 | //purpose : |
1004 | //======================================================================= |
1005 | Standard_Boolean RefineAngle2D(const TopoDS_Vertex& aV, |
1006 | const TopoDS_Edge& aE, |
1007 | const TopoDS_Face& myFace, |
1008 | const Standard_Real aA1, |
1009 | const Standard_Real aA2, |
51db0179 |
1010 | Standard_Real& aA, |
1011 | const Handle(IntTools_Context)& theContext) |
c5face6f |
1012 | { |
1013 | Standard_Boolean bRet; |
f56518cd |
1014 | Standard_Integer i, j, aNbP; |
1015 | Standard_Real aTV, aTol, aT1, aT2, dT, aAngle, aT, aTOp; |
c5face6f |
1016 | Standard_Real aTolInt, aAi, aXi, aYi, aT1j, aT2j, aT1max, aT2max, aCf; |
1017 | gp_Pnt2d aPV, aP, aP1, aP2; |
1018 | Handle(Geom2d_Curve) aC2D; |
1019 | Handle(Geom2d_Line) aLi; |
1020 | Geom2dAdaptor_Curve aGAC1, aGAC2; |
1021 | Geom2dInt_GInter aGInter; |
1022 | IntRes2d_Domain aDomain1, aDomain2; |
1023 | // |
1024 | bRet=Standard_True; |
1025 | aCf=0.01; |
1026 | aTolInt=1.e-10; |
1027 | // |
51db0179 |
1028 | BOPTools_AlgoTools2D::CurveOnSurface(aE, myFace, aC2D, aT1, aT2, aTol, theContext); |
94f71cad |
1029 | aGAC1.Load(aC2D, aT1, aT2); |
c5face6f |
1030 | // |
1031 | aTV=BRep_Tool::Parameter (aV, aE, myFace); |
94f71cad |
1032 | aGAC1.D0(aTV, aPV); |
c5face6f |
1033 | // |
f56518cd |
1034 | aTOp = (fabs(aTV-aT1) < fabs(aTV-aT2)) ? aT2 : aT1; |
c5face6f |
1035 | // |
94f71cad |
1036 | aGAC1.D0(aT1, aP1); |
1037 | aGAC1.D0(aT2, aP2); |
c5face6f |
1038 | aDomain1.SetValues(aP1, aT1, aTolInt, aP2, aT2, aTolInt); |
1039 | // |
1040 | for (i=0; i<2; ++i) { |
1041 | aAi=(!i) ? aA1 : aA2; |
1042 | aXi=cos(aAi); |
1043 | aYi=sin(aAi); |
1044 | gp_Dir2d aDiri(aXi, aYi); |
1045 | aLi=new Geom2d_Line(aPV, aDiri); |
1046 | // |
1047 | aGAC2.Load(aLi); |
c5face6f |
1048 | // |
1049 | aGInter.Perform(aGAC1, aDomain1, aGAC2, aDomain2, aTolInt, aTolInt); |
1050 | if (!aGInter.IsDone()) { |
1051 | continue; |
1052 | } |
1053 | // |
1054 | aNbP=aGInter.NbPoints(); |
1055 | if (aNbP<2) { |
1056 | continue; |
1057 | } |
1058 | // |
1059 | aT1max=aTV; |
1060 | aT2max=-1.; |
1061 | for (j=1; j<=aNbP; ++j) { |
1062 | const IntRes2d_IntersectionPoint& aIPj=aGInter.Point(j); |
1063 | aT1j=aIPj.ParamOnFirst(); |
1064 | aT2j=aIPj.ParamOnSecond(); |
1065 | // |
1066 | if (aT2j > aT2max) { |
1067 | aT2max=aT2j; |
1068 | aT1max=aT1j; |
1069 | } |
1070 | } |
1071 | // |
f56518cd |
1072 | dT = aTOp - aT1max; |
5e18f917 |
1073 | if (Abs(dT) < aTolInt) { |
1074 | continue; |
1075 | } |
c5face6f |
1076 | // |
f56518cd |
1077 | aT=aT1max + aCf*dT; |
94f71cad |
1078 | aGAC1.D0(aT, aP); |
c5face6f |
1079 | gp_Vec2d aV2D(aPV, aP); |
1080 | gp_Dir2d aDir2D(aV2D); |
1081 | // |
1082 | aAngle=Angle(aDir2D); |
1083 | if (aAngle>aA1 && aAngle<aA2) { |
1084 | aA=aAngle; |
1085 | return bRet; |
1086 | } |
1087 | }// for (i=0; i<2; ++i) { |
1088 | return !bRet; |
1089 | } |