1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSetPlugin_Remove.cxx
4 // Created: 20 May 2014
5 // Author: Mikhail PONIKAROV
7 #include "PartSetPlugin_Remove.h"
8 #include "PartSetPlugin_Part.h"
9 #include <ModelAPI_Document.h>
10 #include <ModelAPI_Data.h>
11 #include <ModelAPI_AttributeDocRef.h>
12 #include <ModelAPI_ResultPart.h>
13 #include <ModelAPI_Session.h>
14 #include <ModelAPI_Feature.h>
15 #include <ModelAPI_Tools.h>
17 void PartSetPlugin_Remove::execute()
19 std::shared_ptr<ModelAPI_Session> aPManager = ModelAPI_Session::get();
20 std::shared_ptr<ModelAPI_Document> aRoot = aPManager->moduleDocument();
21 DocumentPtr aThisDoc = document();
22 ResultPtr aPart = ModelAPI_Tools::findPartResult(aRoot, aThisDoc);
24 FeaturePtr aFeature = aRoot->feature(aPart);
27 aPart->data()->document(ModelAPI_ResultPart::DOC_REF())->value()->close();
28 std::set<std::shared_ptr<ModelAPI_Feature> > aRefFeatures;
29 aRoot->refsToFeature(aFeature, aRefFeatures);
30 if (aRefFeatures.empty())
31 aRoot->removeFeature(aFeature);