From 2ee2d3156506b38ddd90cc6675b3cde43c405440 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 14 Dec 2017 12:54:33 +0300 Subject: [PATCH] Apply names for top level shapes only when process naming of generated shapes --- src/Model/Model_BodyBuilder.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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++) { -- 2.39.2