Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_CompositeBoolean.cpp
index 6f0d65f4d923f4824950dd9986ed2e64ab49b191..6e3e8796b16493de7e94cbdb991ef587f26db77d 100644 (file)
@@ -29,7 +29,7 @@
 #include <GeomAlgoAPI_PaveFiller.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
-#include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_ShapeIterator.h>
 
 #include <map>
 
@@ -77,8 +77,6 @@ void FeaturesPlugin_CompositeBoolean::executeCompositeBoolean()
   for(; aBoolObjIt != aBooleanObjects.cend() && aBoolMSIt != aBooleanMakeShapes.cend();
       ++aBoolObjIt, ++aBoolMSIt) {
 
-    int aTag = 1;
-
     ResultBodyPtr aResultBody = myFeature->document()->createBody(myFeature->data(), aResultIndex);
 
     if((*aBoolObjIt)->isEqual((*aBoolMSIt)->shape())) {
@@ -86,26 +84,25 @@ void FeaturesPlugin_CompositeBoolean::executeCompositeBoolean()
     }
     else
     {
-      aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape(), aTag);
-
-      aTag += 5000;
+      aResultBody->storeModified(*aBoolObjIt, (*aBoolMSIt)->shape());
 
       // Store generation history.
       ListOfShape::const_iterator aGenBaseIt = aGenBaseShapes.cbegin();
       ListOfMakeShape::const_iterator aGenMSIt = aGenMakeShapes.cbegin();
       for(; aGenBaseIt != aGenBaseShapes.cend() && aGenMSIt != aGenMakeShapes.cend();
           ++aGenBaseIt, ++aGenMSIt) {
-        storeGenerationHistory(aResultBody, *aGenBaseIt, *aGenMSIt, aTag);
+        std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMSList(new GeomAlgoAPI_MakeShapeList());
+        aMSList->appendAlgo(*aGenMSIt);
+        aMSList->appendAlgo(*aBoolMSIt);
+        storeGenerationHistory(aResultBody, *aGenBaseIt, aMSList);
       }
 
-      int aModTag = aTag;
-      storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt, aModTag);
+      storeModificationHistory(aResultBody, *aBoolObjIt, aTools, *aBoolMSIt);
 
       ResultBaseAlgo aRBA;
       aRBA.resultBody = aResultBody;
       aRBA.baseShape = *aBoolObjIt;
       aRBA.makeShape = *aBoolMSIt;
-      aRBA.delTag = aModTag;
       aResultBaseAlgoList.push_back(aRBA);
       aResultShapesList.push_back((*aBoolMSIt)->shape());
     }
@@ -199,9 +196,11 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools,
 
         // Collecting solids from compsolids which will not be modified in boolean operation.
         ListOfShape aShapesToAdd;
-        for(GeomAPI_ShapeExplorer
-            anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
-          GeomShapePtr aSolidInCompSolid = anExp.current();
+        for (GeomAPI_ShapeIterator aCompSolidIt(aCompSolid);
+             aCompSolidIt.more();
+             aCompSolidIt.next())
+        {
+          GeomShapePtr aSolidInCompSolid = aCompSolidIt.current();
           ListOfShape::const_iterator aUsedShapesIt = aUsedShapes.cbegin();
           for(; aUsedShapesIt != aUsedShapes.cend(); ++aUsedShapesIt) {
             if(aSolidInCompSolid->isEqual(*aUsedShapesIt)) {
@@ -282,9 +281,11 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools,
         aSolidsToFuse.insert(aSolidsToFuse.end(), aUsedShapes.begin(), aUsedShapes.end());
 
         // Collect solids from compsolid which will not be modified in boolean operation.
-        for(GeomAPI_ShapeExplorer
-            anExp(aCompSolid, GeomAPI_Shape::SOLID); anExp.more(); anExp.next()) {
-          GeomShapePtr aSolidInCompSolid = anExp.current();
+        for (GeomAPI_ShapeIterator aCompSolidIt(aCompSolid);
+             aCompSolidIt.more();
+             aCompSolidIt.next())
+        {
+          GeomShapePtr aSolidInCompSolid = aCompSolidIt.current();
           ListOfShape::iterator anIt = aUsedShapes.begin();
           for(; anIt != aUsedShapes.end(); anIt++) {
             if(aSolidInCompSolid->isEqual(*anIt)) {
@@ -380,38 +381,16 @@ bool FeaturesPlugin_CompositeBoolean::makeBoolean(const ListOfShape& theTools,
 void FeaturesPlugin_CompositeBoolean::storeModificationHistory(ResultBodyPtr theResultBody,
                                 const GeomShapePtr theObject,
                                 const ListOfShape& theTools,
-                                const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
-                                int& theTag)
+                                const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)
 {
-  int aModTag = theTag;
-  int anEdgesAndFacesTag = ++aModTag;
-  int aDelTag = ++anEdgesAndFacesTag;
-  theTag = aDelTag;
-
-  const std::string aModName = "Modfied";
-
   ListOfShape aTools = theTools;
   aTools.push_back(theObject);
 
-  std::shared_ptr<GeomAPI_DataMapOfShapeShape> aMap = theMakeShape->mapOfSubShapes();
-
-  int aTag;
-  std::string aName;
   for(ListOfShape::const_iterator anIt = aTools.begin(); anIt != aTools.end(); anIt++) {
-    if((*anIt)->shapeType() == GeomAPI_Shape::EDGE) {
-      aTag = anEdgesAndFacesTag;
-      aName = aModName + "_Edge";
-    }
-    else if((*anIt)->shapeType() == GeomAPI_Shape::FACE) {
-      aTag = anEdgesAndFacesTag;
-      aName = aModName + "_Face";
-    } else {
-      aTag = aModTag;
-      aName = aModName;
-    }
-    theResultBody->loadAndOrientModifiedShapes(theMakeShape.get(), *anIt,
-      (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
-      GeomAPI_Shape::EDGE : GeomAPI_Shape::FACE, aTag, aName, *aMap.get(), false, false, true);
+    theResultBody->loadModifiedShapes(theMakeShape, *anIt,
+                                      (*anIt)->shapeType() == GeomAPI_Shape::EDGE ?
+                                                              GeomAPI_Shape::EDGE :
+                                                              GeomAPI_Shape::FACE);
   }
 }
 
@@ -426,18 +405,16 @@ void FeaturesPlugin_CompositeBoolean::storeDeletedShapes(
     ++anIt)
   {
     ResultBaseAlgo& aRCA = *anIt;
-    aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+    aRCA.resultBody->loadDeletedShapes(aRCA.makeShape,
       aRCA.baseShape,
       GeomAPI_Shape::FACE,
-      aRCA.delTag,
       theResultShapesCompound);
 
     for (ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++)
     {
-      aRCA.resultBody->loadDeletedShapes(aRCA.makeShape.get(),
+      aRCA.resultBody->loadDeletedShapes(aRCA.makeShape,
         *anIter,
         GeomAPI_Shape::FACE,
-        aRCA.delTag,
         theResultShapesCompound);
     }
   }