-
- // if next vertex connected only to alone edge, this is a part of wire (not a closed loop),
- // we need to go back through the list of already checked edges to find a branching vertex
- if (!aMapVE.IsEmpty() && aMapVE.Contains(aNextVertex)
- && aMapVE.FindFromKey(aNextVertex).Size() == 1) {
- std::list<TopoDS_Vertex>::reverse_iterator aVRIter = aProcVertexes.rbegin();
- std::list<TopoDS_Edge>::reverse_iterator aERIter = aProcEdges.rbegin();
- if (aVRIter != aProcVertexes.rend())
- aVRIter++;
- if (aERIter != aProcEdges.rend())
- aERIter++;
-
- for (; aERIter != aProcEdges.rend(); aERIter++, aVRIter++)
- if (aMapVE.FindFromKey(*aVRIter).Size() > 2)
- break;
- if (aERIter != aProcEdges.rend()
- || (aVRIter != aProcVertexes.rend() && aMapVE.FindFromKey(*aVRIter).Size() == 1)) { // the branching vertex was found or current list of edges is a wire without branches
- std::list<TopoDS_Edge>::iterator aEIter;
- TopoDS_Edge aCurEdge;
- if (aERIter != aProcEdges.rend()) {
- aEIter = aERIter.base();
- aCurEdge = *aERIter;
- } else
- aEIter = aProcEdges.begin();
- std::list<TopoDS_Wire> aTail;
- createWireList(*aVRIter, aEIter, aProcEdges.end(), anEdgesInLoops, aTail);
- std::list<TopoDS_Wire>::const_iterator aTailIter = aTail.begin();
- for (; aTailIter != aTail.end(); aTailIter++)
- if (!aTailIter->IsNull()) {
- boost::shared_ptr<GeomAPI_Shape> aWire(new GeomAPI_Shape);
- aWire->setImpl(new TopoDS_Shape(*aTailIter));
- theResultWires.push_back(aWire);
- }
- std::list<TopoDS_Vertex>::iterator aVIter = aVRIter.base();
- std::list<TopoDS_Edge>::iterator aEItCopy = aEIter;
- removeWasteEdges(--aVIter, aEItCopy, aProcVertexes.end(), aProcEdges.end(), aMapVE);
-
- aProcEdges.erase(aEIter, aProcEdges.end());
- aVIter = aVRIter.base();
- aProcVertexes.erase(aVIter, aProcVertexes.end());
-
- if (!aProcVertexes.empty()) {
- aNextVertex = aProcVertexes.back();
- if (!aCurEdge.IsNull())
- aNextDir = getOuterEdgeDirection(aCurEdge, aNextVertex);
- }
- } else { // there is no branching vertex in the list of proceeded,
- // so we should revert the list and go the opposite way
- aProcVertexes.reverse();
- aProcEdges.reverse();
- aNextVertex = aProcVertexes.back();
- aNextDir =
- aProcEdges.empty() ? aDirY : getOuterEdgeDirection(aProcEdges.back(), aNextVertex);
- }
- }
-
- // When all edges of current component of connectivity are processed,
- // we should repeat procedure for finding initial vertex in the remaining
- if (!aMapVE.IsEmpty() && !aMapVE.Contains(aNextVertex)) {
- aProcVertexes.clear();
- aProcEdges.clear();
-
- aStartVertex = findStartVertex(aMapVE, aDirX, aDirY);
- aProcVertexes.push_back(aStartVertex);
- aNextVertex = aStartVertex;
- aNextDir = aDirY.Reversed();
- aCurNorm = aNorm.Reversed();
- }
-
- aCurVertex = aNextVertex;
- aCurDir = aNextDir;