1 // File: GeomAlgoAPI_SketchBuilder.cpp
2 // Created: 02 Jun 2014
3 // Author: Artem ZHIDKOV
5 #include <GeomAlgoAPI_SketchBuilder.h>
12 #include <BOPAlgo_Builder.hxx>
13 #include <BOPAlgo_Operation.hxx>
14 #include <BOPAlgo_PaveFiller.hxx>
15 #include <BOPTools.hxx>
16 #include <BRep_Builder.hxx>
17 #include <BRep_Curve3D.hxx>
18 #include <BRep_TEdge.hxx>
19 #include <BRep_TVertex.hxx>
20 #include <BRepAlgoAPI_Cut.hxx>
21 #include <BRepBuilderAPI_MakeFace.hxx>
22 #include <BRepClass_FaceClassifier.hxx>
23 #include <Geom_Curve.hxx>
24 #include <Geom_Plane.hxx>
26 #include <TopExp_Explorer.hxx>
27 #include <TopoDS_Edge.hxx>
28 #include <TopoDS_Face.hxx>
29 #include <TopoDS_Vertex.hxx>
30 #include <TopoDS_Wire.hxx>
32 #include <Precision.hxx>
33 const double tolerance = Precision::Confusion();
34 // This value helps to find direction on the boundaries of curve.
35 // It is not significant for lines, but is used for circles to avoid
36 // wrong directions of movement (when two edges are tangent on the certain vertex)
37 const double shift = acos(1.0 - 2.0 * tolerance);
39 /// \brief Search first vertex - the vertex with lowest x coordinate, which is used in 2 edges at least
40 static const TopoDS_Shape& findStartVertex(
41 const BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE,
42 const gp_Dir& theDirX, const gp_Dir& theDirY);
44 /// \brief Search the vertex on the sketch candidate to be the next one in the loop
45 static void findNextVertex(
46 const TopoDS_Shape& theStartVertex,
47 const BOPCol_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap,
48 const gp_Dir& theStartDir,
49 const gp_Dir& theNormal,
50 TopoDS_Shape& theNextVertex,
51 TopoDS_Shape& theNextEdge,
54 /// \brief Create planar face using the edges surrounding it
55 static void createFace(const TopoDS_Shape& theStartVertex,
56 const std::list<TopoDS_Shape>::iterator& theStartEdge,
57 const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
58 const gp_Pln& thePlane,
59 TopoDS_Face& theResFace);
61 /// \bief Create planar wire
62 static void createWireList(const TopoDS_Shape& theStartVertex,
63 const std::list<TopoDS_Shape>::iterator& theStartEdge,
64 const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
65 const std::set<Handle(TopoDS_TShape)>& theEdgesInLoops,
66 std::list<TopoDS_Wire>& theResWires);
68 /// \brief Calculate outer tengency on the edge in specified vertex
69 static gp_Dir getOuterEdgeDirection(const TopoDS_Shape& theEdge,
70 const TopoDS_Shape& theVertex);
72 /// \brief Unnecessary edges will be removed from the map.
73 /// Positions of iterator will be updated
74 static void removeWasteEdges(
75 std::list<TopoDS_Shape>::iterator& theStartVertex,
76 std::list<TopoDS_Shape>::iterator& theStartEdge,
77 const std::list<TopoDS_Shape>::iterator& theEndOfVertexes,
78 const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
79 BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE);
84 void GeomAlgoAPI_SketchBuilder::createFaces(
85 const boost::shared_ptr<GeomAPI_Pnt>& theOrigin,
86 const boost::shared_ptr<GeomAPI_Dir>& theDirX,
87 const boost::shared_ptr<GeomAPI_Dir>& theDirY,
88 const boost::shared_ptr<GeomAPI_Dir>& theNorm,
89 const std::list< boost::shared_ptr<GeomAPI_Shape> >& theFeatures,
90 std::list< boost::shared_ptr<GeomAPI_Shape> >& theResultFaces,
91 std::list< boost::shared_ptr<GeomAPI_Shape> >& theResultWires)
93 if (theFeatures.empty())
96 // Create the list of edges with shared vertexes
97 BOPAlgo_Builder aBuilder;
98 BOPAlgo_PaveFiller aPF;
99 TopoDS_Shape aFeaturesCompound;
101 if (theFeatures.size() == 1)
102 { // If there is only one feature, BOPAlgo_Builder will decline to work. Need to process it anyway
103 aFeaturesCompound = theFeatures.front()->impl<TopoDS_Shape>();
107 std::list< boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = theFeatures.begin();
108 for (; anIt != theFeatures.end(); anIt++)
110 boost::shared_ptr<GeomAPI_Shape> aPreview(*anIt);
111 aBuilder.AddArgument(aPreview->impl<TopoDS_Edge>());
113 aPF.SetArguments(aBuilder.Arguments());
115 int aErr = aPF.ErrorStatus();
117 aBuilder.PerformWithFiller(aPF);
118 aErr = aBuilder.ErrorStatus();
120 aFeaturesCompound = aBuilder.Shape();
123 BOPCol_IndexedDataMapOfShapeListOfShape aMapVE; // map between vertexes and edges
124 BOPTools::MapShapesAndAncestors(aFeaturesCompound, TopAbs_VERTEX, TopAbs_EDGE, aMapVE);
126 gp_Dir aDirX = theDirX->impl<gp_Dir>();
127 gp_Dir aDirY = theDirY->impl<gp_Dir>();
128 gp_Dir aNorm = theNorm->impl<gp_Dir>();
130 gp_Pln aPlane(theOrigin->impl<gp_Pnt>(), aNorm);
132 // Set of edges used in loops
133 std::set<Handle(TopoDS_TShape)> anEdgesInLoops;
134 // Lists for processed vertexes and edges
135 std::list<TopoDS_Shape> aProcVertexes;
136 std::list<TopoDS_Shape> aProcEdges;
138 // Search the start vertex
139 TopoDS_Shape aStartVertex = findStartVertex(aMapVE, aDirX, aDirY);
140 aProcVertexes.push_back(aStartVertex);
142 TopoDS_Shape aCurVertex = aStartVertex;
143 gp_Dir aCurDir = aDirY.Reversed();
144 gp_Dir aCurNorm = aNorm.Reversed();
146 // Go through the edges and find loops
147 TopoDS_Shape aNextVertex;
148 TopoDS_Shape aBindingEdge;
150 while (aMapVE.Extent() > 0)
152 findNextVertex(aCurVertex, aMapVE, aCurDir, aCurNorm, aNextVertex, aBindingEdge, aNextDir);
155 // Try to find next vertex in the list of already processed
156 std::list<TopoDS_Shape>::iterator aVertIter = aProcVertexes.begin();
157 std::list<TopoDS_Shape>::iterator anEdgeIter = aProcEdges.begin();
158 for ( ; aVertIter != aProcVertexes.end(); aVertIter++)
160 if (aVertIter->TShape() == aNextVertex.TShape())
162 if (anEdgeIter != aProcEdges.end())
166 aProcVertexes.push_back(aNextVertex);
167 aProcEdges.push_back(aBindingEdge);
169 // The loop was found
170 if (aVertIter != aProcVertexes.end())
172 // If the binding edge is a full circle, then the list may be empty before addition. Need to update edge iterator
173 if (aProcEdges.size() == 1)
174 anEdgeIter = aProcEdges.begin();
176 if (aVertIter != aProcVertexes.begin())
178 // Check the orientation of the loop
179 gp_Dir aCN = getOuterEdgeDirection(*anEdgeIter, *aVertIter);
180 gp_Dir aCP = getOuterEdgeDirection(aProcEdges.back(), *aVertIter);
183 if (aCN.DotCross(aCP, aNorm) < -tolerance)
185 // The found loop has wrong orientation and may contain sub-loops.
186 // Need to check it onle again with another initial direction.
187 aCurVertex = *aVertIter;
189 aProcVertexes.pop_back();
190 aProcEdges.pop_back();
191 } while (aCurVertex != aProcVertexes.back());
192 aCurDir = getOuterEdgeDirection(aProcEdges.back(), aCurVertex);
193 aCurNorm = aNorm.Reversed();
198 // When the orientation is correct or the edges looped through
199 // the first element, create new face and remove unnecessary edges.
201 createFace(*aVertIter, anEdgeIter, aProcEdges.end(), aPlane, aPatch);
202 if (!aPatch.IsNull())
204 boost::shared_ptr<GeomAPI_Shape> aFace(new GeomAPI_Shape);
205 aFace->setImpl(new TopoDS_Shape(aPatch));
206 theResultFaces.push_back(aFace);
208 // push the edges used in the loop to the map
209 std::list<TopoDS_Shape>::iterator anIter;
210 for (anIter = anEdgeIter; anIter != aProcEdges.end(); anIter++)
211 anEdgesInLoops.insert(anIter->TShape());
212 // remove unnecessary edges
213 std::list<TopoDS_Shape>::iterator aCopyVLoop = aVertIter;
214 std::list<TopoDS_Shape>::iterator aCopyELoop = anEdgeIter;
215 removeWasteEdges(aVertIter, anEdgeIter, aProcVertexes.end(), aProcEdges.end(), aMapVE);
217 // revert the list of remaining edges
218 std::list<TopoDS_Shape> aRemainVertexes;
219 for ( ; aVertIter != aProcVertexes.end(); aVertIter++)
220 aRemainVertexes.push_front(*aVertIter);
221 std::list<TopoDS_Shape> aRemainEdges;
222 for ( ; anEdgeIter != aProcEdges.end(); anEdgeIter++)
223 aRemainEdges.push_front(*anEdgeIter);
224 // remove edges and vertexes used in the loop and add remaining ones
225 aProcVertexes.erase(aCopyVLoop, aProcVertexes.end());
226 aProcVertexes.insert(aProcVertexes.end(), aRemainVertexes.begin(), aRemainVertexes.end());
227 aProcEdges.erase(aCopyELoop, aProcEdges.end());
228 aProcEdges.insert(aProcEdges.end(), aRemainEdges.begin(), aRemainEdges.end());
230 // Recalculate current vertex and current direction
231 if (!aProcVertexes.empty())
233 aNextVertex = aProcVertexes.back();
234 if (!aProcEdges.empty())
235 aNextDir = getOuterEdgeDirection(aProcEdges.back(), aNextVertex);
236 else aNextDir = aDirY;
240 // if next vertex connected only to alone edge, this is a part of wire (not a closed loop),
241 // we need to go back through the list of already checked edges to find a branching vertex
242 if (!aMapVE.IsEmpty() && aMapVE.Contains(aNextVertex) &&
243 aMapVE.FindFromKey(aNextVertex).Size() == 1)
245 std::list<TopoDS_Shape>::reverse_iterator aVRIter = aProcVertexes.rbegin();
246 std::list<TopoDS_Shape>::reverse_iterator aERIter = aProcEdges.rbegin();
247 for (++aERIter, ++aVRIter; aERIter != aProcEdges.rend(); aERIter++, aVRIter++)
248 if (aMapVE.FindFromKey(*aVRIter).Size() > 2)
250 if (aERIter != aProcEdges.rend() || aMapVE.FindFromKey(*aVRIter).Size() == 1)
251 { // the branching vertex was found or current list of edges is a wire without branches
252 std::list<TopoDS_Shape>::iterator aEIter;
253 TopoDS_Shape aCurEdge;
254 if (aERIter != aProcEdges.rend())
256 aEIter = aERIter.base();
260 aEIter = aProcEdges.begin();
261 std::list<TopoDS_Wire> aTail;
262 createWireList(*aVRIter, aEIter, aProcEdges.end(), anEdgesInLoops, aTail);
263 std::list<TopoDS_Wire>::const_iterator aTailIter = aTail.begin();
264 for ( ; aTailIter != aTail.end(); aTailIter++)
265 if (!aTailIter->IsNull())
267 boost::shared_ptr<GeomAPI_Shape> aWire(new GeomAPI_Shape);
268 aWire->setImpl(new TopoDS_Shape(*aTailIter));
269 theResultWires.push_back(aWire);
271 std::list<TopoDS_Shape>::iterator aVIter = aVRIter.base();
272 std::list<TopoDS_Shape>::iterator aEItCopy = aEIter;
273 removeWasteEdges(--aVIter, aEItCopy, aProcVertexes.end(), aProcEdges.end(), aMapVE);
275 aProcEdges.erase(aEIter, aProcEdges.end());
276 aVIter = aVRIter.base();
277 aProcVertexes.erase(aVIter, aProcVertexes.end());
279 if (!aProcVertexes.empty())
281 aNextVertex = aProcVertexes.back();
282 if (!aCurEdge.IsNull())
283 aNextDir = getOuterEdgeDirection(aCurEdge, aNextVertex);
287 { // there is no branching vertex in the list of proceeded,
288 // so we should revert the list and go the opposite way
289 aProcVertexes.reverse();
290 aProcEdges.reverse();
291 aNextVertex = aProcVertexes.back();
292 aNextDir = getOuterEdgeDirection(aProcEdges.back(), aNextVertex);
296 // When all edges of current component of connectivity are processed,
297 // we should repeat procedure for finding initial vertex in the remaining
298 if (!aMapVE.IsEmpty() && !aMapVE.Contains(aNextVertex))
300 aProcVertexes.clear();
303 TopoDS_Shape aStartEdge;
304 aStartVertex = findStartVertex(aMapVE, aDirX, aDirY);
305 aProcVertexes.push_back(aStartVertex);
306 aNextVertex = aStartVertex;
307 aNextDir = aDirY.Reversed();
308 aCurNorm = aNorm.Reversed();
311 aCurVertex = aNextVertex;
315 if (theResultFaces.size() > 1)
316 fixIntersections(theResultFaces);
319 void GeomAlgoAPI_SketchBuilder::fixIntersections(
320 std::list< boost::shared_ptr<GeomAPI_Shape> >& theFaces)
322 BRepClass_FaceClassifier aClassifier;
324 std::list< boost::shared_ptr<GeomAPI_Shape> >::iterator anIter1 = theFaces.begin();
325 std::list< boost::shared_ptr<GeomAPI_Shape> >::iterator anIter2;
326 for ( ; anIter1 != theFaces.end(); anIter1++)
329 for (++anIter2; anIter2 != theFaces.end(); anIter2++)
331 const TopoDS_Face& aF1 = (*anIter1)->impl<TopoDS_Face>();
332 TopExp_Explorer aVert2((*anIter2)->impl<TopoDS_Shape>(), TopAbs_VERTEX);
333 for ( ; aVert2.More(); aVert2.Next())
335 Handle(BRep_TVertex) aV = Handle(BRep_TVertex)::DownCast(aVert2.Current().TShape());
336 aClassifier.Perform(aF1, aV->Pnt(), tolerance);
337 if (aClassifier.State() != TopAbs_IN)
341 { // second shape is not inside first, change the shapes order and repeat comparision
342 const TopoDS_Face& aF2 = (*anIter2)->impl<TopoDS_Face>();
343 TopExp_Explorer aVert1((*anIter1)->impl<TopoDS_Shape>(), TopAbs_VERTEX);
344 for ( ; aVert1.More(); aVert1.Next())
346 Handle(BRep_TVertex) aV = Handle(BRep_TVertex)::DownCast(aVert1.Current().TShape());
347 aClassifier.Perform(aF2, aV->Pnt(), tolerance);
348 if (aClassifier.State() != TopAbs_IN)
352 { // first shape should be cut from the second
353 BRepAlgoAPI_Cut aCut((*anIter2)->impl<TopoDS_Shape>(),
354 (*anIter1)->impl<TopoDS_Shape>());
355 (*anIter2)->setImpl(new TopoDS_Shape(aCut.Shape()));
359 { // second shape should be cut from the first
360 BRepAlgoAPI_Cut aCut((*anIter1)->impl<TopoDS_Shape>(),
361 (*anIter2)->impl<TopoDS_Shape>());
362 (*anIter1)->setImpl(new TopoDS_Shape(aCut.Shape()));
369 // =================== Auxiliary functions ====================================
370 const TopoDS_Shape& findStartVertex(
371 const BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE,
372 const gp_Dir& theDirX, const gp_Dir& theDirY)
374 int aStartVertexInd = 1;
375 double aMaxX = -DBL_MAX;
376 double aMaxY = -DBL_MAX;
377 int aNbVert = theMapVE.Extent();
378 for (int i = 1; i <= aNbVert; i++)
380 const TopoDS_Vertex& aV = (const TopoDS_Vertex&)theMapVE.FindKey(i);
381 const Handle(BRep_TVertex)& aVert = (const Handle(BRep_TVertex)&)aV.TShape();
382 const gp_Pnt& aVertPnt = aVert->Pnt();
384 double aX = aVertPnt.XYZ().Dot(theDirX.XYZ());
385 double aY = aVertPnt.XYZ().Dot(theDirY.XYZ());
386 if ((aX > aMaxX || (fabs(aX - aMaxX) < tolerance && aY > aMaxY)) &&
387 theMapVE.FindFromIndex(i).Extent() > 1)
394 return theMapVE.FindKey(aStartVertexInd);
398 const TopoDS_Shape& theStartVertex,
399 const BOPCol_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap,
400 const gp_Dir& theStartDir,
401 const gp_Dir& theNormal,
402 TopoDS_Shape& theNextVertex,
403 TopoDS_Shape& theNextEdge,
406 const BOPCol_ListOfShape& anEdgesList = theVertexEdgeMap.FindFromKey(theStartVertex);
407 BOPCol_ListOfShape::Iterator aEdIter(anEdgesList);
408 double aBestEdgeProj = DBL_MAX;
409 for ( ; aEdIter.More(); aEdIter.Next())
411 gp_Dir aTang = getOuterEdgeDirection(aEdIter.Value(), theStartVertex);
414 // The projection is normalized in segment (-1, 1),
415 // where (-1, 0] corresponds to the angles (pi/2, 0] between theStartDir and aTang
416 // and [0, 1) corresponds to the angles [0, -pi/2)
417 double aProj = (aTang.Dot(theStartDir) - 1.0) * 0.5;
418 if (fabs(fabs(aProj) - 1) < tolerance)
420 if (theStartDir.DotCross(aTang, theNormal) < tolerance)
423 if (aProj < aBestEdgeProj)
425 aBestEdgeProj = aProj;
426 theNextEdge = aEdIter.Value();
427 TopExp_Explorer aVertExp(theNextEdge, TopAbs_VERTEX);
428 for ( ; aVertExp.More(); aVertExp.Next())
429 if (aVertExp.Current().TShape() != theStartVertex.TShape())
431 theNextVertex = aVertExp.Current();
432 theNextDir = getOuterEdgeDirection(aEdIter.Value(), theNextVertex);
435 if (!aVertExp.More())
436 { // This edge is a full circle
437 TopoDS_Vertex aV1, aV2;
438 TopExp::Vertices(*(const TopoDS_Edge*)(&theNextEdge), aV1, aV2);
439 if (aV1.Orientation() == theStartVertex.Orientation())
443 theNextDir = getOuterEdgeDirection(aEdIter.Value(), theNextVertex);
449 static void addEdgeToWire(const TopoDS_Edge& theEdge,
450 const BRep_Builder& theBuilder,
451 TopoDS_Shape& theSpliceVertex,
452 TopoDS_Wire& theWire)
454 TopoDS_Edge anEdge = theEdge;
455 bool isCurVertChanged = false;
456 TopoDS_Shape aCurVertChanged;
458 TopExp_Explorer aVertExp(theEdge, TopAbs_VERTEX);
459 for ( ; aVertExp.More(); aVertExp.Next())
461 const TopoDS_Shape& aVertex = aVertExp.Current();
462 if (aVertex.TShape() == theSpliceVertex.TShape() &&
463 aVertex.Orientation() != theEdge.Orientation())
464 { // Current vertex is the last for the edge, so its orientation is wrong, need to revert the edge
468 if (aVertex.TShape() != theSpliceVertex.TShape())
470 aCurVertChanged = aVertex;
471 isCurVertChanged = true;
474 theSpliceVertex = isCurVertChanged ? aCurVertChanged : aVertExp.Current();
476 theBuilder.Add(theWire, anEdge);
479 void createFace(const TopoDS_Shape& theStartVertex,
480 const std::list<TopoDS_Shape>::iterator& theStartEdge,
481 const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
482 const gp_Pln& thePlane,
483 TopoDS_Face& theResFace)
485 TopoDS_Wire aResWire;
486 BRep_Builder aBuilder;
487 aBuilder.MakeWire(aResWire);
489 TopoDS_Shape aCurVertex = theStartVertex;
490 std::list<TopoDS_Shape>::const_iterator anEdgeIter = theStartEdge;
491 for ( ; anEdgeIter != theEndOfEdges; anEdgeIter++)
493 TopoDS_Edge anEdge = *((TopoDS_Edge*)(&(*anEdgeIter)));
494 addEdgeToWire(anEdge, aBuilder, aCurVertex, aResWire);
497 BRepBuilderAPI_MakeFace aFaceBuilder(thePlane, aResWire);
498 if (aFaceBuilder.Error() == BRepBuilderAPI_FaceDone)
499 theResFace = aFaceBuilder.Face();
502 void createWireList(const TopoDS_Shape& theStartVertex,
503 const std::list<TopoDS_Shape>::iterator& theStartEdge,
504 const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
505 const std::set<Handle(TopoDS_TShape)>& theEdgesInLoops,
506 std::list<TopoDS_Wire>& theResWires)
508 BRep_Builder aBuilder;
509 bool needNewWire = true;
510 TopoDS_Shape aCurVertex = theStartVertex;
512 std::list<TopoDS_Shape>::iterator anIter = theStartEdge;
513 while (anIter != theEndOfEdges)
515 while (anIter != theEndOfEdges && needNewWire &&
516 theEdgesInLoops.count(anIter->TShape()) != 0)
518 TopExp_Explorer aVertExp(*anIter, TopAbs_VERTEX);
519 for ( ; aVertExp.More(); aVertExp.Next())
520 if (aVertExp.Current().TShape() != aCurVertex.TShape())
522 aCurVertex = aVertExp.Current();
527 if (anIter == theEndOfEdges)
531 { // The new wire should be created
533 aBuilder.MakeWire(aWire);
534 theResWires.push_back(aWire);
537 else if (theEdgesInLoops.count(anIter->TShape()) != 0)
538 { // There was found the edge already used in loop.
539 // Current wire should be released and new one should started
544 TopoDS_Edge anEdge = *((TopoDS_Edge*)(&(*anIter)));
545 addEdgeToWire(anEdge, aBuilder, aCurVertex, theResWires.back());
551 gp_Dir getOuterEdgeDirection(const TopoDS_Shape& theEdge,
552 const TopoDS_Shape& theVertex)
554 const Handle(BRep_TVertex)& aVertex = (const Handle(BRep_TVertex)&)theVertex.TShape();
555 gp_Pnt aVertexPnt = aVertex->Pnt();
557 const Handle(BRep_TEdge)& anEdge = (const Handle(BRep_TEdge)&)theEdge.TShape();
559 // Convert the edge to the curve to calculate the tangency.
560 // There should be only one curve in the edge.
561 Handle(BRep_Curve3D) aEdCurve =
562 Handle(BRep_Curve3D)::DownCast(anEdge->Curves().First());
563 double aFirst, aLast;
564 aEdCurve->Range(aFirst, aLast);
565 Handle(Geom_Curve) aCurve = aEdCurve->Curve3D();
569 aCurve->D1(aFirst + shift, aPnt, aTang);
570 aCurve->D0(aFirst, aPnt);
571 if (aVertexPnt.IsEqual(aPnt, tolerance))
572 return gp_Dir(aTang.Reversed());
574 aCurve->D1(aLast - shift, aPnt, aTang);
575 return gp_Dir(aTang);
578 void removeWasteEdges(
579 std::list<TopoDS_Shape>::iterator& theStartVertex,
580 std::list<TopoDS_Shape>::iterator& theStartEdge,
581 const std::list<TopoDS_Shape>::iterator& theEndOfVertexes,
582 const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
583 BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE)
585 bool isVertStep = true;
586 while (theStartVertex != theEndOfVertexes && theStartEdge != theEndOfEdges)
588 BOPCol_ListOfShape& aBunch = theMapVE.ChangeFromKey(*theStartVertex);
589 BOPCol_ListOfShape::Iterator anApprEdge(aBunch);
590 for ( ; anApprEdge.More(); anApprEdge.Next())
591 if (anApprEdge.Value() == *theStartEdge)
593 if (anApprEdge.More())
594 aBunch.Remove(anApprEdge);
601 // check current vertex to be a branching point
602 // if so, it will be a new starting point to find a loop
603 if (aBunch.Size() > 1)
606 isVertStep = !isVertStep;
609 // The map of vertex-edges may be changed
610 BOPCol_IndexedDataMapOfShapeListOfShape aMapVECopy;
611 BOPCol_IndexedDataMapOfShapeListOfShape::Iterator aMapIter(theMapVE);
612 for (int ind = 1; aMapIter.More(); aMapIter.Next(), ind++)
613 if (!aMapIter.Value().IsEmpty())
614 aMapVECopy.Add(theMapVE.FindKey(ind), aMapIter.Value());
616 theMapVE.Exchange(aMapVECopy);