Salome HOME
Copyright update 2021
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_BooleanCommon.cpp
index 1afe60e8bf1c214270da3ba81fc7f26905463ca3..085107edb431bd23ece7571978a4b23b0d632188 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -52,14 +52,14 @@ void FeaturesPlugin_BooleanCommon::initAttributes()
   data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(TOOL_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
 
-  initVersion(THE_VERSION_1, selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID()));
+  initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID()));
 }
 
 //==================================================================================================
 void FeaturesPlugin_BooleanCommon::execute()
 {
   ListOfShape aPlanes;
-  ObjectHierarchy anObjects, aTools;
+  GeomAPI_ShapeHierarchy anObjects, aTools;
 
   bool isSimpleMode = false;
 
@@ -80,14 +80,14 @@ void FeaturesPlugin_BooleanCommon::execute()
       !processAttribute(TOOL_LIST_ID(), aTools, aPlanes))
     return;
 
-  if (anObjects.IsEmpty() || (!isSimpleMode && aTools.IsEmpty() && aPlanes.empty())) {
+  if (anObjects.empty() || (!isSimpleMode && aTools.empty() && aPlanes.empty())) {
     std::string aFeatureError = "Error: Not enough objects for boolean operation.";
     setError(aFeatureError);
     return;
   }
 
   // version of COMMON feature
-  int aCommonVersion = version();
+  const std::string aCommonVersion = data()->version();
 
   int aResultIndex = 0;
   GeomShapePtr aResultCompound;
@@ -98,9 +98,9 @@ void FeaturesPlugin_BooleanCommon::execute()
   ListOfShape aResultShapesList;
 
   if (isSimpleMode) {
-    ObjectHierarchy::Iterator anObjectsIt = anObjects.Begin();
+    GeomAPI_ShapeHierarchy::iterator anObjectsIt = anObjects.begin();
     GeomShapePtr aShape = *anObjectsIt;
-    for (++anObjectsIt; anObjectsIt != anObjects.End(); ++anObjectsIt) {
+    for (++anObjectsIt; anObjectsIt != anObjects.end(); ++anObjectsIt) {
       std::shared_ptr<GeomAlgoAPI_Boolean> aCommonAlgo(
         new GeomAlgoAPI_Boolean(aShape,
                                 *anObjectsIt,
@@ -115,7 +115,7 @@ void FeaturesPlugin_BooleanCommon::execute()
       aMakeShapeList->appendAlgo(aCommonAlgo);
     }
 
-    if (aCommonVersion == THE_VERSION_1) {
+    if (aCommonVersion == BOP_VERSION_9_4()) {
       // merge hierarchies of compounds containing objects and tools
       // and append the result of the FUSE operation
       aShape = keepUnusedSubsOfCompound(aShape, anObjects, aTools, aMakeShapeList);
@@ -126,7 +126,7 @@ void FeaturesPlugin_BooleanCommon::execute()
       std::shared_ptr<ModelAPI_ResultBody> aResultBody =
         document()->createBody(data(), aResultIndex);
 
-      ListOfShape anObjectList = anObjects.Objects();
+      ListOfShape anObjectList = anObjects.objects();
       ListOfShape aToolsList;
       FeaturesPlugin_Tools::loadModifiedShapes(aResultBody,
                                                anObjectList,
@@ -147,46 +147,46 @@ void FeaturesPlugin_BooleanCommon::execute()
       aResultShapesList.push_back(aShape);
     }
   } else {
-    if (aCommonVersion == THE_VERSION_1) {
+    if (aCommonVersion == BOP_VERSION_9_4()) {
       // merge hierarchies of compounds containing objects and tools
       aResultCompound =
           keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList);
     }
 
     bool isOk = true;
-    for (ObjectHierarchy::Iterator anObjectsIt = anObjects.Begin();
-         anObjectsIt != anObjects.End() && isOk;
+    for (GeomAPI_ShapeHierarchy::iterator anObjectsIt = anObjects.begin();
+         anObjectsIt != anObjects.end() && isOk;
          ++anObjectsIt)
     {
       GeomShapePtr anObject = *anObjectsIt;
-      GeomShapePtr aParent = anObjects.Parent(anObject);
+      GeomShapePtr aParent = anObjects.parent(anObject);
 
       if (aParent) {
         GeomAPI_Shape::ShapeType aShapeType = aParent->shapeType();
         if (aShapeType == GeomAPI_Shape::COMPOUND) {
           // Compound handling
           isOk = processCompound(GeomAlgoAPI_Tools::BOOL_COMMON,
-                                 anObjects, aParent, aTools.Objects(),
+                                 anObjects, aParent, aTools.objects(),
                                  aResultIndex, aResultBaseAlgoList, aResultShapesList,
                                  aResultCompound);
         }
         else if (aShapeType == GeomAPI_Shape::COMPSOLID) {
           // Compsolid handling
           isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_COMMON,
-                                  anObjects, aParent, aTools.Objects(), ListOfShape(),
+                                  anObjects, aParent, aTools.objects(), ListOfShape(),
                                   aResultIndex, aResultBaseAlgoList, aResultShapesList,
                                   aResultCompound);
         }
       } else {
         // process object as is
         isOk = processObject(GeomAlgoAPI_Tools::BOOL_COMMON,
-                             anObject, aTools.Objects(), aPlanes,
+                             anObject, aTools.objects(), aPlanes,
                              aResultIndex, aResultBaseAlgoList, aResultShapesList,
                              aResultCompound);
       }
     }
 
-    storeResult(anObjects.Objects(), aTools.Objects(), aResultCompound, aResultIndex,
+    storeResult(anObjects.objects(), aTools.objects(), aResultCompound, aResultIndex,
                 aMakeShapeList, aResultBaseAlgoList);
   }
 
@@ -195,7 +195,7 @@ void FeaturesPlugin_BooleanCommon::execute()
   if (!aResultCompound)
     aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList);
   FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList,
-                                          aTools.Objects(),
+                                          aTools.objects(),
                                           aResultCompound);
 
   // remove the rest results if there were produced in the previous pass