From: azv Date: Thu, 14 Dec 2017 09:54:33 +0000 (+0300) Subject: Apply names for top level shapes only when process naming of generated shapes X-Git-Tag: V_2.10.0RC~35^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2ee2d3156506b38ddd90cc6675b3cde43c405440;p=modules%2Fshaper.git Apply names for top level shapes only when process naming of generated shapes --- diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index 140019217..623ed23ed 100755 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -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 theShapeIn, @@ -481,6 +502,7 @@ void Model_BodyBuilder::loadAndOrientGeneratedShapes ( std::shared_ptr aRShape(new GeomAPI_Shape()); aRShape->setImpl((new TopoDS_Shape(aRoot))); theMS->generated(aRShape, aList); + keepTopLevelShapes(aList); std::list >::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) {