]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Apply names for top level shapes only when process naming of generated shapes Dev_UnitTestsForFill
authorazv <azv@opencascade.com>
Thu, 14 Dec 2017 09:54:33 +0000 (12:54 +0300)
committerazv <azv@opencascade.com>
Thu, 14 Dec 2017 09:54:33 +0000 (12:54 +0300)
src/Model/Model_BodyBuilder.cpp

index 14001921701af889675476cb6fa5d7484bc0964a..623ed23edd1b63dba50b24df9d64a17ecc13fcfa 100755 (executable)
@@ -460,6 +460,27 @@ void Model_BodyBuilder::loadAndOrientModifiedShapes (
   }
 }
 
+// Keep only the shapes with minimal shape type
+static void keepTopLevelShapes(ListOfShape& theShapes)
+{
+  GeomAPI_Shape::ShapeType aKeepShapeType = GeomAPI_Shape::SHAPE;
+  ListOfShape::iterator anIt = theShapes.begin();
+  while (anIt != theShapes.end()) {
+    GeomAPI_Shape::ShapeType aType = (*anIt)->shapeType();
+    if (aType < aKeepShapeType) {
+      // found a shape with lesser shape type => remove all previous shapes
+      aKeepShapeType = aType;
+      theShapes.erase(theShapes.begin(), anIt);
+      ++anIt;
+    } else if (aType > aKeepShapeType) {
+      // shapes with greater shape type should be removed from the list
+      ListOfShape::iterator aRemoveIt = anIt++;
+      theShapes.erase(aRemoveIt);
+    } else
+      ++anIt;
+  }
+}
+
 void Model_BodyBuilder::loadAndOrientGeneratedShapes (
   GeomAlgoAPI_MakeShape* theMS,
   std::shared_ptr<GeomAPI_Shape>  theShapeIn,
@@ -481,6 +502,7 @@ void Model_BodyBuilder::loadAndOrientGeneratedShapes (
     std::shared_ptr<GeomAPI_Shape> aRShape(new GeomAPI_Shape());
     aRShape->setImpl((new TopoDS_Shape(aRoot)));
     theMS->generated(aRShape, aList);
+    keepTopLevelShapes(aList);
     std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator
       anIt = aList.begin(), aLast = aList.end();
     for (; anIt != aLast; anIt++) {