Salome HOME
Get rid of compilation warnings. Part II. MSVC warnings.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_CompositeSketch.cpp
index 6fda4295be7328cdbf861991a92b7b153553b043..56f5861753a606f4fa7da04369ad4c0f5b452e0c 100644 (file)
@@ -67,7 +67,7 @@ std::shared_ptr<ModelAPI_Feature> FeaturesPlugin_CompositeSketch::addFeature(std
 }
 
 //=================================================================================================
-int FeaturesPlugin_CompositeSketch::numberOfSubs(bool forTree) const
+int FeaturesPlugin_CompositeSketch::numberOfSubs(bool /*forTree*/) const
 {
   ObjectPtr aObj = data()->reference(SKETCH_ID())->value();
   return aObj.get() ? 1 : 0;
@@ -75,7 +75,7 @@ int FeaturesPlugin_CompositeSketch::numberOfSubs(bool forTree) const
 
 //=================================================================================================
 std::shared_ptr<ModelAPI_Feature> FeaturesPlugin_CompositeSketch::subFeature(const int theIndex,
-                                                                             bool forTree)
+                                                                             bool /*forTree*/)
 {
   FeaturePtr aSubFeature;
   if(theIndex == 0) {
@@ -177,13 +177,10 @@ void FeaturesPlugin_CompositeSketch::storeGenerationHistory(ResultBodyPtr theRes
     case GeomAPI_Shape::COMPOUND: {
       aShapeTypeToExplode = GeomAPI_Shape::COMPOUND;
     }
+    default: // [to avoid compilation warnings]
+      break;
   }
 
-  int aLateralIndex = 1;
-  int aBaseEdgeIndex = 1;
-  int aVertexIndex = 1;
-  int aBaseVertexIndex = 1;
-
   if(aShapeTypeToExplode == GeomAPI_Shape::VERTEX ||
       aShapeTypeToExplode == GeomAPI_Shape::COMPOUND) {
     theResultBody->loadGeneratedShapes(theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX);
@@ -252,6 +249,8 @@ void FeaturesPlugin_CompositeSketch::storeShapes(
       aShapeTypeToExplore = GeomAPI_Shape::COMPOUND;
       break;
     }
+    default: // [to avoid compilation warnings]
+      break;
   }
 
   // Store shapes.
@@ -282,9 +281,30 @@ void storeSubShape(
   for(GeomAPI_ShapeExplorer anExp(theShape, theType); anExp.more(); anExp.next()) {
     GeomShapePtr aSubShape = anExp.current();
     if (!theResultBody->generated(aSubShape, theName)) {
-      // store from/to shapes as primitives and then store modification of them by the boolean
-      theResultBody->generated(aSubShape, theName, false);
-      theResultBody->loadModifiedShapes(theMakeShape, aSubShape, theType);
+      int aNbSubs = theResultBody->numberOfSubs();
+      if (aNbSubs > 0) {
+        // check the modified shape is in the result body, don't store it if not
+        ListOfShape aNewShapes;
+        theMakeShape->modified(aSubShape, aNewShapes);
+        for (int i = 0; i < aNbSubs; ++i) {
+          ResultBodyPtr aSubRes = theResultBody->subResult(i);
+          GeomShapePtr aShape = aSubRes->shape();
+          ListOfShape::iterator aNewIt = aNewShapes.begin();
+          for (; aNewIt != aNewShapes.end(); ++aNewIt)
+            if (aShape->isSubShape(*aNewIt, false))
+              break;
+          if (aNewIt != aNewShapes.end()) {
+            // store from/to shapes as primitives and then store modification of them by the boolean
+            aSubRes->generated(aSubShape, theName, false);
+            aSubRes->loadModifiedShapes(theMakeShape, aSubShape, theType);
+          }
+        }
+      }
+      else {
+        // store from/to shapes as primitives and then store modification of them by the boolean
+        theResultBody->generated(aSubShape, theName, false);
+        theResultBody->loadModifiedShapes(theMakeShape, aSubShape, theType);
+      }
     }
   }
 }