Salome HOME
Updated copyright comment
[modules/shaper.git] / src / BuildPlugin / BuildPlugin_Wire.cpp
index f3d48bd8b4daeaf12131ee702fa40b4256bf9a92..bd7dffe82dd96e5fe88b451fc095160c94a31c0d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2024  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -320,11 +320,16 @@ bool buildSketchWires(FeaturePtr theSketchFeature, GeomShapePtr theSketchShape,
     const ListOfShape& aFaces = aSketchBuilder->faces();
     for (ListOfShape::const_iterator anIt = aFaces.begin(); anIt != aFaces.end(); ++anIt) {
       for (GeomAPI_ShapeExplorer aWExp(*anIt, GeomAPI_Shape::WIRE); aWExp.more(); aWExp.next()) {
+        // skip the wire if at least one its edge was already processed
         GeomAPI_ShapeExplorer aEExp(aWExp.current(), GeomAPI_Shape::EDGE);
-        if (aProcessedEdges.find(aEExp.current()) != aProcessedEdges.end())
-          continue; // wire is already processed
+        for (; aEExp.more(); aEExp.next()) {
+          if (aProcessedEdges.find(aEExp.current()) != aProcessedEdges.end())
+            break; // wire is already processed
+        }
+        if (aEExp.more())
+          continue;
         // mark edges as processed
-        for (; aEExp.more(); aEExp.next())
+        for (aEExp.init(aWExp.current(), GeomAPI_Shape::EDGE); aEExp.more(); aEExp.next())
           aProcessedEdges.insert(aEExp.current());
         // store the wire
         theWires.push_back(aWExp.current());
@@ -391,7 +396,9 @@ bool buildSketchWires(FeaturePtr theSketchFeature, GeomShapePtr theSketchShape,
       else {
         // both vertices are found
         aFoundStart->second->push_back(anEdge);
-        if (aFoundStart->second != aFoundEnd->second) {
+        if (aFoundStart->second == aFoundEnd->second)
+          aMapVW.erase(aFoundStart);
+        else {
           // different wires => merge segments
           aFoundStart->second->insert(aFoundStart->second->end(),
               aFoundEnd->second->begin(), aFoundEnd->second->end());
@@ -402,9 +409,9 @@ bool buildSketchWires(FeaturePtr theSketchFeature, GeomShapePtr theSketchShape,
               break;
             }
           aNewWires.erase(aFoundEnd->second);
+          aMapVW.erase(aFoundStart);
+          aMapVW.erase(aFoundEnd);
         }
-        aMapVW.erase(aFoundStart);
-        aMapVW.erase(aFoundEnd);
         continue;
       }
     }