]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make results stable: new objects are created for new features or serious changes...
authormpv <mikhail.ponikarov@opencascade.com>
Tue, 15 Jul 2014 14:54:43 +0000 (18:54 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Tue, 15 Jul 2014 14:54:43 +0000 (18:54 +0400)
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/Model/Model_Document.cpp

index 1838d32d9ca42c1d37710e445d4eabdf2cf18956..5a879d49d7df64f9aaace7e1251898cdd8e9c7c7 100644 (file)
@@ -27,7 +27,9 @@ void ConstructionPlugin_Point::initAttributes()
 void ConstructionPlugin_Point::execute() 
 {
   boost::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(
-    data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(), data()->real(POINT_ATTR_Z)->value()));
+    data()->real(POINT_ATTR_X)->value(), 
+    data()->real(POINT_ATTR_Y)->value(), 
+    data()->real(POINT_ATTR_Z)->value()));
 
   boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
   aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt));
index 210195844c039a2d894c5817cc4700bac4d14f5a..bd5abc228582a93fb4fc6d6cd82a54b9ed37e5ad 100644 (file)
@@ -750,24 +750,48 @@ void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData
 boost::shared_ptr<ModelAPI_ResultConstruction> Model_Document::createConstruction(
   const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
 {
-  boost::shared_ptr<ModelAPI_ResultConstruction> aResult(new Model_ResultConstruction());
-  storeResult(theFeatureData, aResult);
+  ObjectPtr anOldObject = object(boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
+    label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1));
+  boost::shared_ptr<ModelAPI_ResultConstruction> aResult;
+  if (anOldObject) {
+    aResult = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anOldObject);
+  }
+  if (!aResult) {
+    aResult = boost::shared_ptr<ModelAPI_ResultConstruction>(new Model_ResultConstruction);
+    storeResult(theFeatureData, aResult);
+  }
   return aResult;
 }
 
 boost::shared_ptr<ModelAPI_ResultBody> Model_Document::createBody(
   const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
 {
-  boost::shared_ptr<ModelAPI_ResultBody> aResult(new Model_ResultBody());
-  storeResult(theFeatureData, aResult);
+  ObjectPtr anOldObject = object(boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
+    label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1));
+  boost::shared_ptr<ModelAPI_ResultBody> aResult;
+  if (anOldObject) {
+    aResult = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(anOldObject);
+  }
+  if (!aResult) {
+    aResult = boost::shared_ptr<ModelAPI_ResultBody>(new Model_ResultBody);
+    storeResult(theFeatureData, aResult);
+  }
   return aResult;
 }
 
 boost::shared_ptr<ModelAPI_ResultPart> Model_Document::createPart(
   const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
 {
-  boost::shared_ptr<ModelAPI_ResultPart> aResult(new Model_ResultPart());
-  storeResult(theFeatureData, aResult);
+  ObjectPtr anOldObject = object(boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
+    label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1));
+  boost::shared_ptr<ModelAPI_ResultPart> aResult;
+  if (anOldObject) {
+    aResult = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(anOldObject);
+  }
+  if (!aResult) {
+    aResult = boost::shared_ptr<ModelAPI_ResultPart>(new Model_ResultPart);
+    storeResult(theFeatureData, aResult);
+  }
   return aResult;
 }