X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Union.cpp;h=ad7a638de10fa2e6effa1ff9bb2e8f63a78fbc58;hb=b392d5b4fb3f49a8258ec024cdf1729f80f5629a;hp=c2385e93808972f81e654a1885d3c26f9292190f;hpb=5a10b65659c971be26bd7343c50a2488e48f49e3;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp index c2385e938..ad7a638de 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Union.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Union.cpp @@ -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 @@ -33,8 +33,6 @@ #include #include -static const int THE_UNION_VERSION_1 = 20190506; - //================================================================================================= FeaturesPlugin_Union::FeaturesPlugin_Union() { @@ -44,20 +42,20 @@ FeaturesPlugin_Union::FeaturesPlugin_Union() void FeaturesPlugin_Union::initAttributes() { data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId()); - initVersion(THE_UNION_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; } @@ -67,20 +65,19 @@ void FeaturesPlugin_Union::execute() std::vector 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, @@ -104,7 +101,7 @@ void FeaturesPlugin_Union::execute() GeomShapePtr aShape; GeomAPI_ShapeIterator aCIt(aResultCompound); - if (aUnionVersion < THE_UNION_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(); @@ -114,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 aBuilder(new GeomAlgoAPI_ShapeBuilder); aBuilder->add(aShape, aCIt.current()); @@ -124,10 +122,11 @@ void FeaturesPlugin_Union::execute() // Store result and naming. std::shared_ptr aResultBody = document()->createBody(data()); - ListOfShape anObjectsList = anObjects.Objects(); + ListOfShape anObjectsList = anObjects.objects(); aResultBody->storeModified(anObjectsList.front(), aShape); - for(ListOfShape::const_iterator anIter = anObjectsList.begin(); anIter != anObjectsList.end(); ++anIter) { + for(ListOfShape::const_iterator anIter = anObjectsList.begin(); + anIter != anObjectsList.end(); ++anIter) { aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::EDGE); aResultBody->loadModifiedShapes(aMakeShapeList, *anIter, GeomAPI_Shape::FACE); //aResultBody->loadDeletedShapes(&aMakeShapeList, *anIter, GeomAPI_Shape::FACE, aDeletedTag);