Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Fillet.cpp
index 0df54c18949b68ce1e28861c372e3c8cd290f4c4..b4ce7d588badd97d7926ae166f79477979a264f5 100644 (file)
@@ -25,7 +25,6 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_Validator.h>
@@ -113,8 +112,16 @@ void FeaturesPlugin_Fillet::execute()
       return;
 
     ResultPtr aContext = anObjectAttr->context();
-    ResultCompSolidPtr aCtxOwner = ModelAPI_Tools::compSolidOwner(aContext);
-    GeomShapePtr aParent = aCtxOwner ? aCtxOwner->shape() : aContext->shape();
+    GeomShapePtr aParent;
+    if (aContext.get()) {
+      ResultBodyPtr aCtxOwner = ModelAPI_Tools::bodyOwner(aContext);
+      aParent = aCtxOwner ? aCtxOwner->shape() : aContext->shape();
+    } else { // get it from a feature
+      FeaturePtr aFeature = anObjectAttr->contextFeature();
+      if (aFeature.get()) {
+        aParent = aFeature->firstResult()->shape();
+      }
+    }
     if (!aParent)
       return;
 
@@ -158,7 +165,7 @@ void FeaturesPlugin_Fillet::execute()
     std::shared_ptr<ModelAPI_ResultBody> aResultBody =
         document()->createBody(data(), aResultIndex);
 
-    loadNamingDS(aResultBody, aSolid, aFilletEdgesAndVertices, aResult, aFilletBuilder);
+    loadNamingDS(aResultBody, aSolid, aResult, aFilletBuilder);
     setResult(aResultBody, aResultIndex);
     aResultIndex++;
   }
@@ -189,7 +196,6 @@ bool FeaturesPlugin_Fillet::isFailed(
 void FeaturesPlugin_Fillet::loadNamingDS(
     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
     const std::shared_ptr<GeomAPI_Shape> theBaseShape,
-    const ListOfShape& theFilletShapes,
     const std::shared_ptr<GeomAPI_Shape> theResultShape,
     const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape)
 {
@@ -199,33 +205,24 @@ void FeaturesPlugin_Fillet::loadNamingDS(
     return;
   }
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMapOfShapes = theMakeShape->mapOfSubShapes();
-
-  const int aDeletedTag = 1;
-  const int aModifyTag = 2;
-  const int aGeneratedTag = 3;
-  /// sub solids will be placed at labels 4, 5, etc. if result is compound of solids
-  const int aSubsolidsTag = 4;
-
-  theResultBody->storeModified(theBaseShape, theResultShape, aSubsolidsTag);
-  theResultBody->storeGenerated(theBaseShape, theResultShape);
+  theResultBody->storeModified(theBaseShape, theResultShape);
 
-  const std::string aModFaceName = "Modified_Face";
   const std::string aFilletFaceName = "Fillet_Face";
 
   // Store modified faces
-  theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), theBaseShape,
-      GeomAPI_Shape::FACE, aModifyTag, aModFaceName, *aMapOfShapes);
+  theResultBody->loadModifiedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
 
   // Store new faces generated from edges and vertices
-  theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape,
-      GeomAPI_Shape::EDGE, aGeneratedTag, aFilletFaceName, *aMapOfShapes);
-  theResultBody->loadAndOrientGeneratedShapes(theMakeShape.get(), theBaseShape,
-      GeomAPI_Shape::VERTEX, aGeneratedTag, aFilletFaceName, *aMapOfShapes);
+  theResultBody->loadGeneratedShapes(theMakeShape,
+                                     theBaseShape,
+                                     GeomAPI_Shape::EDGE,
+                                     aFilletFaceName);
+  theResultBody->loadGeneratedShapes(theMakeShape,
+                                     theBaseShape,
+                                     GeomAPI_Shape::VERTEX,
+                                     aFilletFaceName);
 
   // Deleted shapes
-  theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape,
-                                   GeomAPI_Shape::EDGE, aDeletedTag);
-  theResultBody->loadDeletedShapes(theMakeShape.get(), theBaseShape,
-                                   GeomAPI_Shape::FACE, aDeletedTag);
+  theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::EDGE);
+  theResultBody->loadDeletedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::FACE);
 }