]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/FeaturesPlugin/FeaturesPlugin_RemoveSubShapes.cpp
Salome HOME
Issue #2192 : change the naming principles of compsolid in case of Partition to make...
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_RemoveSubShapes.cpp
index 51d64cba431065a2446b5c271d56cd71e788e6a5..dbf4fc1ed059b17d9d6b768ebb3cfb0040376267 100644 (file)
 #include <ModelAPI_Validator.h>
 
 #include <GeomAPI_ShapeIterator.h>
+#include <GeomAPI_ShapeExplorer.h>
 
 #include <GeomAlgoAPI_Copy.h>
 #include <GeomAlgoAPI_ShapeBuilder.h>
 #include <GeomAlgoAPI_ShapeTools.h>
+#include <GeomAlgoAPI_MakeShapeCustom.h>
+
 
 //==================================================================================================
 FeaturesPlugin_RemoveSubShapes::FeaturesPlugin_RemoveSubShapes()
@@ -130,16 +133,38 @@ void FeaturesPlugin_RemoveSubShapes::execute()
     aResultShape = anAttrSelectionInList->value();
   }
 
+  // find all removed shapes
+  GeomAlgoAPI_MakeShapeCustom aDeletedSubs;
+  for(GeomAPI_ShapeIterator anIt(aBaseShape); anIt.more(); anIt.next()) {
+    if (!anIt.current().get() || anIt.current()->isNull())
+      continue;
+    int anIndex;
+    for(anIndex = 0; anIndex < aSubsNb; ++anIndex) {
+      AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(anIndex);
+      GeomShapePtr aLeftShape = anAttrSelectionInList->value();
+      if (anIt.current()->isEqual(aLeftShape)) {
+        break; // found in a left-list
+      }
+    }
+    if (anIndex == aSubsNb) { // not found in left
+      GeomAPI_ShapeExplorer aFaces(anIt.current(), GeomAPI_Shape::FACE);
+      for(; aFaces.more(); aFaces.next())
+        aDeletedSubs.addDeleted(aFaces.current());
+    }
+  }
+
+
   GeomAlgoAPI_Copy aCopy(aResultShape);
   aResultShape = aCopy.shape();
 
   // Store result.
   ResultBodyPtr aResultBody = document()->createBody(data());
   aResultBody->storeModified(aBaseShape, aResultShape, 1);
+  aResultBody->loadDeletedShapes(&aDeletedSubs, aBaseShape, GeomAPI_Shape::FACE, 1);
   aResultBody->loadAndOrientModifiedShapes(&aCopy,
                                            aBaseShape,
                                            GeomAPI_Shape::FACE,
-                                           10000,
+                                           2,
                                            "Modified_Face",
                                            *aCopy.mapOfSubShapes().get(),
                                            true);