]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1916: Fatal error when create sketch on body Remove subshapes
authordbv <dbv@opencascade.com>
Mon, 5 Dec 2016 15:43:20 +0000 (18:43 +0300)
committerdbv <dbv@opencascade.com>
Mon, 5 Dec 2016 15:43:20 +0000 (18:43 +0300)
Fixed

src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp

index 222880d87f033a6d2267318408b3209537f2810e..7279cf44644e6d2c92b26521e99ae1614367a9b9 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <GeomAPI_ShapeIterator.h>
 
+#include <GeomAlgoAPI_Copy.h>
 #include <GeomAlgoAPI_ShapeBuilder.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
@@ -93,22 +94,40 @@ void FeaturesPlugin_RemoveSubShapes::execute()
     return;
   }
 
-  // Copy base shape.
+  // Get base shape.
   GeomShapePtr aBaseShape = aShapeAttrSelection->value();
-  if(!aBaseShape.get()) {
-    return;
-  }
-  GeomShapePtr aResultShape = aBaseShape->emptyCopied();
 
-  // Copy sub-shapes from list to new shape.
-  for(int anIndex = 0; anIndex < aSubShapesAttrList->size(); ++anIndex) {
-    AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(anIndex);
-    GeomShapePtr aShapeToAdd = anAttrSelectionInList->value();
-    GeomAlgoAPI_ShapeBuilder::add(aResultShape, aShapeToAdd);
+  GeomShapePtr aResultShape;
+  int aSubsNb = aSubShapesAttrList->size();
+  if(aSubsNb > 1) {
+    if(!aBaseShape.get()) {
+      return;
+    }
+    GeomShapePtr aResultShape = aBaseShape->emptyCopied();
+
+    // Copy sub-shapes from list to new shape.
+    for(int anIndex = 0; anIndex < aSubsNb; ++anIndex) {
+      AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(anIndex);
+      GeomShapePtr aShapeToAdd = anAttrSelectionInList->value();
+      GeomAlgoAPI_ShapeBuilder::add(aResultShape, aShapeToAdd);
+    }
+  } else if(aSubsNb == 1) {
+    AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(0);
+    aResultShape = anAttrSelectionInList->value();
   }
 
+  GeomAlgoAPI_Copy aCopy(aResultShape);
+  aResultShape = aCopy.shape();
+
   // Store result.
   ResultBodyPtr aResultBody = document()->createBody(data());
-  aResultBody->storeModified(aBaseShape, aResultShape);
+  aResultBody->storeModified(aBaseShape, aResultShape, 1);
+  aResultBody->loadAndOrientModifiedShapes(&aCopy,
+                                           aBaseShape,
+                                           GeomAPI_Shape::FACE,
+                                           10000,
+                                           "Modified_Face",
+                                           *aCopy.mapOfSubShapes().get(),
+                                           true);
   setResult(aResultBody);
 }