Salome HOME
Issue #1915: boolean failed
[modules/shaper.git] / src / BuildPlugin / BuildPlugin_Edge.cpp
index df60a8715655e72dbc2d27724f62285fff212a63..b78100d15a5f886cdf6f8febff64706ac0661d16 100644 (file)
@@ -9,6 +9,8 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_ResultBody.h>
 
+#include <GeomAlgoAPI_Copy.h>
+
 //=================================================================================================
 BuildPlugin_Edge::BuildPlugin_Edge()
 {
@@ -59,9 +61,36 @@ void BuildPlugin_Edge::execute()
       return;
     }
 
+    // Copy shape.
+    GeomAlgoAPI_Copy aCopyAlgo(aShape);
+
+    // Check that algo is done.
+    if(!aCopyAlgo.isDone()) {
+      setError("Error: " + getKind() + " algorithm failed.");
+      return;
+    }
+
+    // Check if shape is not null.
+    if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) {
+      setError("Error: Resulting shape is null.");
+      return;
+    }
+
+    // Check that resulting shape is valid.
+    if(!aCopyAlgo.isValid()) {
+      setError("Error: Resulting shape is not valid.");
+      return;
+    }
+
     // Store result.
     ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-    aResultBody->store(aShape);
+    aResultBody->storeModified(aShape, aCopyAlgo.shape());
+    std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = aCopyAlgo.mapOfSubShapes();
+    int aModVertexTag = 1;
+    std::string aModVertexName = "Modified_Vertex";
+    aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aShape, GeomAPI_Shape::VERTEX,
+                                             aModVertexTag, aModVertexName, *aSubShapes.get());
+
     setResult(aResultBody, aResultIndex);
     ++aResultIndex;
   }