X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_ShapeTools.cpp;h=a47c77c7f28d1fa298a72a1613b71a5eabdd06ff;hb=5fb6a80c4e86e21b1181b4e6ee940d946b5c52e4;hp=ac3bee2557ca5faee1c330a6731ebeef1bbbe7b7;hpb=d10ed925d0a56a99162702dea8a00190248eef7c;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index ac3bee255..a47c77c7f 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -426,7 +427,7 @@ std::shared_ptr GeomAlgoAPI_ShapeTools::groupSharedTopology( } // Iterate over the map and group shapes. - NCollection_Vector aGroups; // groups of shapes connected by vertices + NCollection_Vector aGroups; // groups of shapes connected by vertices while (!allVertices.IsEmpty()) { // Get first group of shapes in map, and then unbind it. const TopoDS_Shape& aKey = allVertices.First(); @@ -467,12 +468,12 @@ std::shared_ptr GeomAlgoAPI_ShapeTools::groupSharedTopology( } } // Sort shapes from the most complicated to the simplest ones - TopTools_ListOfShape aSortedGroup; + TopTools_MapOfShape aSortedGroup; for (int aST = TopAbs_COMPOUND; aST <= TopAbs_SHAPE; ++aST) { TopTools_ListOfShape::Iterator anIt(aConnectedShapes); while (anIt.More()) { if (anIt.Value().ShapeType() == aST) { - aSortedGroup.Append(anIt.Value()); + aSortedGroup.Add(anIt.Value()); aConnectedShapes.Remove(anIt); } else { @@ -487,14 +488,21 @@ std::shared_ptr GeomAlgoAPI_ShapeTools::groupSharedTopology( BRep_Builder aBuilder; aBuilder.MakeCompound(aCompound); ListOfShape aCompSolids, aFreeSolids; - for(NCollection_Vector>::Iterator - anIt(aGroups); anIt.More(); anIt.Next()) { - NCollection_List aGroup = anIt.Value(); + for (NCollection_Vector::Iterator anIt(aGroups); anIt.More(); anIt.Next()) { + const TopTools_MapOfShape& aGroup = anIt.ChangeValue(); GeomShapePtr aGeomShape(new GeomAPI_Shape()); if(aGroup.Size() == 1) { - aGeomShape->setImpl(new TopoDS_Shape(aGroup.First())); + TopTools_MapOfShape::Iterator aOneShapeIter(aGroup); + aGeomShape->setImpl(new TopoDS_Shape(aOneShapeIter.Value())); } else { - aGeomShape->setImpl(new TopoDS_Shape(makeCompound(aGroup))); + // make sub-shapes in the group have order same as in original shape + TopTools_ListOfShape anOrderedGoup; + NCollection_List::Iterator anUngrouped(anUngroupedShapes); + for (; anUngrouped.More(); anUngrouped.Next()) { + if (aGroup.Contains(anUngrouped.Value())) + anOrderedGoup.Append(anUngrouped.Value()); + } + aGeomShape->setImpl(new TopoDS_Shape(makeCompound(anOrderedGoup))); aGeomShape = GeomAlgoAPI_ShapeTools::combineShapes(aGeomShape, GeomAPI_Shape::COMPSOLID, aCompSolids, @@ -1057,3 +1065,25 @@ std::shared_ptr GeomAlgoAPI_ShapeTools::wireToEdge( } return anEdge; } + +ListOfShape GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(const GeomShapePtr& theShape) +{ + ListOfShape aSubShapes; + + if (!theShape->isCompound() && !theShape->isCompSolid() && + !theShape->isShell() && !theShape->isWire()) { + return aSubShapes; + } + + for (GeomAPI_ShapeIterator anIt(theShape); anIt.more(); anIt.next()) { + GeomShapePtr aSubShape = anIt.current(); + if (aSubShape->isVertex() || aSubShape->isEdge() || + aSubShape->isFace() || aSubShape->isSolid()) { + aSubShapes.push_back(aSubShape); + } else { + aSubShapes.splice(aSubShapes.end(), getLowLevelSubShapes(aSubShape)); + } + } + + return aSubShapes; +} \ No newline at end of file