Salome HOME
Change the paradigm of versioning of Boolean Operations on the Python API level.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_BooleanCommon.cpp
index 9dd105a9d5e42a6c606b99d2db199194572f910e..1afe60e8bf1c214270da3ba81fc7f26905463ca3 100644 (file)
@@ -38,8 +38,6 @@
 #include <GeomAlgoAPI_CompoundBuilder.h>
 #include <GeomAlgoAPI_Tools.h>
 
-static const int THE_COMMON_VERSION_1 = 20190506;
-
 //==================================================================================================
 FeaturesPlugin_BooleanCommon::FeaturesPlugin_BooleanCommon()
 : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_COMMON)
@@ -54,7 +52,7 @@ void FeaturesPlugin_BooleanCommon::initAttributes()
   data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
 
-  initVersion(THE_COMMON_VERSION_1);
+  initVersion(THE_VERSION_1, selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID()));
 }
 
 //==================================================================================================
@@ -117,7 +115,7 @@ void FeaturesPlugin_BooleanCommon::execute()
       aMakeShapeList->appendAlgo(aCommonAlgo);
     }
 
-    if (aCommonVersion == THE_COMMON_VERSION_1) {
+    if (aCommonVersion == THE_VERSION_1) {
       // merge hierarchies of compounds containing objects and tools
       // and append the result of the FUSE operation
       aShape = keepUnusedSubsOfCompound(aShape, anObjects, aTools, aMakeShapeList);
@@ -149,7 +147,7 @@ void FeaturesPlugin_BooleanCommon::execute()
       aResultShapesList.push_back(aShape);
     }
   } else {
-    if (aCommonVersion == THE_COMMON_VERSION_1) {
+    if (aCommonVersion == THE_VERSION_1) {
       // merge hierarchies of compounds containing objects and tools
       aResultCompound =
           keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList);
@@ -188,33 +186,8 @@ void FeaturesPlugin_BooleanCommon::execute()
       }
     }
 
-    GeomAPI_ShapeIterator aShapeIt(aResultCompound);
-    if (aShapeIt.more()) {
-      std::shared_ptr<ModelAPI_ResultBody> aResultBody =
-          document()->createBody(data(), aResultIndex);
-
-      ListOfShape anObjectList = anObjects.Objects();
-      ListOfShape aToolsList = aTools.Objects();
-      FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
-                                               anObjectList,
-                                               aToolsList,
-                                               aMakeShapeList,
-                                               aResultCompound);
-      setResult(aResultBody, aResultIndex++);
-
-      // merge algorithms
-      FeaturesPlugin_Tools::ResultBaseAlgo aRBA;
-      aRBA.resultBody = aResultBody;
-      aRBA.baseShape = anObjectList.front();
-      for (std::vector<FeaturesPlugin_Tools::ResultBaseAlgo>::iterator
-           aRBAIt = aResultBaseAlgoList.begin();
-           aRBAIt != aResultBaseAlgoList.end(); ++aRBAIt) {
-        aMakeShapeList->appendAlgo(aRBAIt->makeShape);
-      }
-      aRBA.makeShape = aMakeShapeList;
-      aResultBaseAlgoList.clear();
-      aResultBaseAlgoList.push_back(aRBA);
-    }
+    storeResult(anObjects.Objects(), aTools.Objects(), aResultCompound, aResultIndex,
+                aMakeShapeList, aResultBaseAlgoList);
   }
 
   // Store deleted shapes after all results has been proceeded. This is to avoid issue when in one