Salome HOME
Change the paradigm of versioning of Boolean Operations on the Python API level.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_BooleanFill.cpp
index 94630430f3a50a4ad73daea8aabe68b0958d63ec..6db4eb4d9ef67ffa6928563f1f1d4f661dc0bc99 100644 (file)
 #include <algorithm>
 #include <map>
 
-static const int THE_SPLIT_VERSION_1 = 20190506;
-
 //=================================================================================================
 FeaturesPlugin_BooleanFill::FeaturesPlugin_BooleanFill()
   : FeaturesPlugin_Boolean(FeaturesPlugin_Boolean::BOOL_FILL)
 {
 }
 
-//==================================================================================================
+//=================================================================================================
 void FeaturesPlugin_BooleanFill::initAttributes()
 {
   FeaturesPlugin_Boolean::initAttributes();
-  initVersion(THE_SPLIT_VERSION_1);
+  initVersion(THE_VERSION_1, selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID()));
 }
 
 //=================================================================================================
@@ -89,7 +87,7 @@ void FeaturesPlugin_BooleanFill::execute()
   std::shared_ptr<GeomAlgoAPI_MakeShapeList> aMakeShapeList(new GeomAlgoAPI_MakeShapeList());
 
   GeomShapePtr aResultCompound;
-  if (aSplitVersion == THE_SPLIT_VERSION_1) {
+  if (aSplitVersion == THE_VERSION_1) {
     // merge hierarchies of compounds containing objects and tools
     aResultCompound =
         keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList);
@@ -120,33 +118,8 @@ void FeaturesPlugin_BooleanFill::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
   // result shape has been deleted, but in another it was modified or stayed.