Salome HOME
Switch to SSL mode for tests : Get rid off all SALOME_TEST_DRIVER reference
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Union.cpp
index 5663d69188ca8d3ee1d7991ba93cff9154e7c355..ad7a638de10fa2e6effa1ff9bb2e8f63a78fbc58 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
@@ -42,20 +42,20 @@ FeaturesPlugin_Union::FeaturesPlugin_Union()
 void FeaturesPlugin_Union::initAttributes()
 {
   data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
-  initVersion(THE_VERSION_1, selectionList(BASE_OBJECTS_ID()));
+  initVersion(BOP_VERSION_9_4(), selectionList(BASE_OBJECTS_ID()));
 }
 
 //=================================================================================================
 void FeaturesPlugin_Union::execute()
 {
-  ObjectHierarchy anObjects;
+  GeomAPI_ShapeHierarchy anObjects;
   ListOfShape anEmptyList;
 
   // Getting objects.
   if (!processAttribute(BASE_OBJECTS_ID(), anObjects, anEmptyList))
     return;
 
-  if(anObjects.Objects().size() < 2) {
+  if(anObjects.objects().size() < 2) {
     setError("Error: Not enough objects for operation. Should be at least 2.");
     return;
   }
@@ -65,20 +65,19 @@ void FeaturesPlugin_Union::execute()
   std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
   ListOfShape aResultShapesList;
 
-  int aUnionVersion = version();
   GeomShapePtr aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(ListOfShape());
 
   // Fuse objects.
   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, false);
+    GeomShapePtr aParent = anObjects.parent(anObject, false);
 
     if (aParent && aParent->shapeType() <= GeomAPI_Shape::COMPSOLID) {
       // get parent once again to mark it and the subs as processed
-      aParent = anObjects.Parent(anObject);
+      aParent = anObjects.parent(anObject);
       // compsolid handling
       isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_FUSE,
                               anObjects, aParent, anEmptyList, anEmptyList,
@@ -102,7 +101,7 @@ void FeaturesPlugin_Union::execute()
 
   GeomShapePtr aShape;
   GeomAPI_ShapeIterator aCIt(aResultCompound);
-  if (aUnionVersion < THE_VERSION_1) {
+  if (data()->version().empty()) {
     // if the compound consists of a single sub-shape, take it,
     // otherwise, take the full compound
     aShape = aCIt.current();
@@ -112,7 +111,8 @@ void FeaturesPlugin_Union::execute()
   }
   else {
     // merge hierarchies of compounds containing objects and tools
-    aShape = keepUnusedSubsOfCompound(aCIt.current(), anObjects, ObjectHierarchy(), aMakeShapeList);
+    aShape = keepUnusedSubsOfCompound(aCIt.current(), anObjects, GeomAPI_ShapeHierarchy(),
+                                      aMakeShapeList);
     for (aCIt.next(); aCIt.more(); aCIt.next()) {
       std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
       aBuilder->add(aShape, aCIt.current());
@@ -122,7 +122,7 @@ void FeaturesPlugin_Union::execute()
 
   // Store result and naming.
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
-  ListOfShape anObjectsList = anObjects.Objects();
+  ListOfShape anObjectsList = anObjects.objects();
   aResultBody->storeModified(anObjectsList.front(), aShape);
 
   for(ListOfShape::const_iterator anIter = anObjectsList.begin();