Salome HOME
Part debug
[modules/shaper.git] / src / PartSetPlugin / PartSetPlugin_Part.cpp
index 0fd91d96958458e2a292ef214608d854586eb12f..362841fb7fa28d31b0b03b481f716c6a042b1d1b 100644 (file)
@@ -7,6 +7,7 @@
 #include "ModelAPI_Document.h"
 #include "ModelAPI_Data.h"
 #include "ModelAPI_AttributeDocRef.h"
+#include <ModelAPI_ResultPart.h>
 
 using namespace std;
 
@@ -23,8 +24,14 @@ void PartSetPlugin_Part::execute()
 {
   boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(PART_ATTR_DOC_REF);
   if (!aDocRef->value()) { // create a document if not yet created
-    boost::shared_ptr<ModelAPI_Document> aPartSetDoc = ModelAPI_PluginManager::get()->rootDocument();
-    aDocRef->setValue(aPartSetDoc->subDocument(data()->getName()));
+    boost::shared_ptr<ModelAPI_Document> aPartSetDoc = 
+      ModelAPI_PluginManager::get()->rootDocument();
+    aDocRef->setValue(aPartSetDoc->subDocument(data()->name()));
+  }
+  // create a result only once
+  if (results().empty()) {
+    boost::shared_ptr<ModelAPI_ResultPart> aResult = document()->createPart(data());
+    setResult(aResult);
   }
 }