X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_ShapeHierarchy.cpp;h=53522d415840a2c24139d8a14ef338e8cd15e3e2;hb=4bc963e2f9b2a904df0e1e17f7f98b70957630bc;hp=cac15eabe4d78435489629b17e9fae0374b55e51;hpb=f305d203baea0aeb8f88b0df6e5cc7fff81db5e9;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_ShapeHierarchy.cpp b/src/GeomAPI/GeomAPI_ShapeHierarchy.cpp index cac15eabe..53522d415 100644 --- a/src/GeomAPI/GeomAPI_ShapeHierarchy.cpp +++ b/src/GeomAPI/GeomAPI_ShapeHierarchy.cpp @@ -60,6 +60,19 @@ GeomShapePtr GeomAPI_ShapeHierarchy::parent(const GeomShapePtr& theShape, return aParent; } +GeomShapePtr GeomAPI_ShapeHierarchy::root(const GeomShapePtr& theShape, + bool theMarkProcessed) +{ + GeomShapePtr aParent = parent(theShape, theMarkProcessed); + GeomShapePtr aRoot = aParent; + while (aParent) { + aParent = parent(aRoot, theMarkProcessed); + if (aParent) + aRoot = aParent; + } + return aRoot; +} + void GeomAPI_ShapeHierarchy::markProcessed(const GeomShapePtr& theShape) { myProcessedObjects.insert(theShape); @@ -84,6 +97,17 @@ void GeomAPI_ShapeHierarchy::markModified(const GeomShapePtr& theSource, myModifiedObjects[theSource] = theModified; } +const ListOfShape& GeomAPI_ShapeHierarchy::objects(GeomShapePtr theParent) const +{ + MapShapeToIndex::const_iterator aFoundIndex = myParentIndices.find(theParent); + if (aFoundIndex == myParentIndices.end()) { + static const ListOfShape THE_DUMMY = ListOfShape(); + return THE_DUMMY; // no such shape + } + + return mySubshapes[aFoundIndex->second].second; +} + void GeomAPI_ShapeHierarchy::objectsByType( ListOfShape& theShapesByType, ListOfShape& theOtherShapes, @@ -146,17 +170,16 @@ void GeomAPI_ShapeHierarchy::topLevelObjects(ListOfShape& theDestination) const iterator anIt = aThis->begin(), aEnd = aThis->end(); for (; anIt != aEnd; ++anIt) { GeomShapePtr aShape = *anIt; - GeomShapePtr aParent = aThis->parent(aShape); - GeomShapePtr aRoot = aParent; - while (aParent) { - aParent = aThis->parent(aRoot); - if (aParent) - aRoot = aParent; - } - + GeomShapePtr aRoot = aThis->root(aShape); if (aRoot) { - // compose a compund with the modified shapes - aShape = collectSubs(aRoot, SetOfShape(), myModifiedObjects); + // check the current shape was modified + MapShapeToShape::const_iterator aFound = myModifiedObjects.find(aRoot); + if (aFound != myModifiedObjects.end()) + aShape = aFound->second; + else { + // compose a compund with the modified shapes + aShape = collectSubs(aRoot, SetOfShape(), myModifiedObjects); + } } else { // check the current shape was modified