X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Remove.cpp;h=d74666a65b208b0ee6bee701ff630f5e2942fd6d;hb=1b6e16d96b4f83c138791e0e86842d1507bcef1f;hp=56881ca51238c578361d7126271ac2b3127684bb;hpb=89aeee12f9f793e37165457ae46edbbf6aec1a26;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Remove.cpp b/src/PartSetPlugin/PartSetPlugin_Remove.cpp index 56881ca51..d74666a65 100644 --- a/src/PartSetPlugin/PartSetPlugin_Remove.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Remove.cpp @@ -12,25 +12,23 @@ #include #include #include +#include void PartSetPlugin_Remove::execute() { std::shared_ptr aPManager = ModelAPI_Session::get(); std::shared_ptr aRoot = aPManager->moduleDocument(); - std::shared_ptr a; - for (int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) { - ResultPartPtr aPart = std::dynamic_pointer_cast( - aRoot->object(ModelAPI_ResultPart::group(), a)); - if (aPart && aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value() == document()) { - FeaturePtr aFeature = aRoot->feature(aPart); - if (aFeature) { - // do remove - aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()->close(); - std::set > aRefFeatures; - aRoot->refsToFeature(aFeature, aRefFeatures); - if (aRefFeatures.empty()) - aRoot->removeFeature(aFeature); - } + DocumentPtr aThisDoc = document(); + ResultPtr aPart = ModelAPI_Tools::findPartResult(aRoot, aThisDoc); + if (aPart.get()) { + FeaturePtr aFeature = aRoot->feature(aPart); + if (aFeature) { + // do remove + aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()->close(); + std::set > aRefFeatures; + aRoot->refsToFeature(aFeature, aRefFeatures); + if (aRefFeatures.empty()) + aRoot->removeFeature(aFeature); } } }