]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp
Salome HOME
Issue #1922: After partition, some edges are not displayed below the connected shape...
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_ShapeTools.cpp
index 12e6c3c3bd190d62d18983b61ce0d6ace75bf355..14b2fbc41c43dc17a6498515e2b400977a3bb43d 100644 (file)
@@ -301,7 +301,7 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::groupSharedTopology(
   }
 
   TopoDS_Shape anInShape = aResult->impl<TopoDS_Shape>();
-  NCollection_List<TopoDS_Shape> anUngroupedShapes;
+  NCollection_List<TopoDS_Shape> anUngroupedShapes, aStillUngroupedShapes;
   addSimpleShapeToList(anInShape, anUngroupedShapes);
 
   NCollection_Vector<NCollection_List<TopoDS_Shape>> aGroups;
@@ -311,32 +311,40 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::groupSharedTopology(
     anUngroupedShapes.RemoveFirst();
     for(NCollection_List<TopoDS_Shape>::Iterator aGroupIt(aGroupedShapes);
         aGroupIt.More(); aGroupIt.Next()) {
-      const TopoDS_Shape& aGroupShape = aGroupIt.Value();
-      for(NCollection_List<TopoDS_Shape>::Iterator anUngroupedIt(anUngroupedShapes);
-          anUngroupedIt.More(); anUngroupedIt.Next()) {
-        const TopoDS_Shape& anUngroupedShape = anUngroupedIt.Value();
-        bool isFound = false;
-        for(TopExp_Explorer aGroupShapeExp(aGroupShape, TopAbs_VERTEX);
-            aGroupShapeExp.More(); aGroupShapeExp.Next()) {
-          const TopoDS_Shape& aVertex1 = aGroupShapeExp.Current();
-          for(TopExp_Explorer anUngroupedShapeExp(anUngroupedShape, TopAbs_VERTEX);
-              anUngroupedShapeExp.More(); anUngroupedShapeExp.Next()) {
-            const TopoDS_Shape& aVertex2 = anUngroupedShapeExp.Current();
+      const TopoDS_Shape& aGroupedShape = aGroupIt.Value();
+      for(TopExp_Explorer aGroupShapeExp(aGroupedShape, TopAbs_VERTEX);
+          aGroupShapeExp.More();
+          aGroupShapeExp.Next()) {
+        // Find all shapes which have same vertex.
+        aStillUngroupedShapes.Clear();
+        const TopoDS_Shape& aVertex1 = aGroupShapeExp.Current();
+        for(NCollection_List<TopoDS_Shape>::Iterator anUngroupedIt(anUngroupedShapes);
+            anUngroupedIt.More();
+            anUngroupedIt.Next()) {
+          const TopoDS_Shape& anUngroupedShape = anUngroupedIt.Value();
+          bool isAdded = false;
+          for(TopExp_Explorer anUgroupedShapeExp(anUngroupedShape, TopAbs_VERTEX);
+              anUgroupedShapeExp.More();
+              anUgroupedShapeExp.Next()) {
+            const TopoDS_Shape& aVertex2 = anUgroupedShapeExp.Current();
             if(aVertex1.IsSame(aVertex2)) {
               aGroupedShapes.Append(anUngroupedShape);
-              anUngroupedShapes.Remove(anUngroupedIt);
-              isFound = true;
+              isAdded = true;
               break;
             }
           }
-          if(isFound) {
-            break;
+          if(!isAdded) {
+            aStillUngroupedShapes.Append(anUngroupedShape);
           }
         }
-        if(!anUngroupedIt.More()) {
+        anUngroupedShapes = aStillUngroupedShapes;
+        if(anUngroupedShapes.IsEmpty()) {
           break;
         }
       }
+      if(anUngroupedShapes.IsEmpty()) {
+        break;
+      }
     }
     aGroups.Append(aGroupedShapes);
   }