X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Partition.cpp;h=e1a257aefa37a8e17ae123e1620feb388c33dd10;hb=71e54dccdd7194a911151c626896ec7dc2942241;hp=23346e9192c6462763f58337e997deb8287d7b57;hpb=70a2f35b8d8ce4b0619d22d4b1bf356408da79fb;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp index 23346e919..e1a257aef 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Partition.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2020 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 @@ -48,8 +48,6 @@ #include #include -static const int THE_PARTITION_VERSION_1 = 20190506; - //================================================================================================= FeaturesPlugin_Partition::FeaturesPlugin_Partition() @@ -60,29 +58,29 @@ FeaturesPlugin_Partition::FeaturesPlugin_Partition() void FeaturesPlugin_Partition::initAttributes() { data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId()); - initVersion(THE_PARTITION_VERSION_1, selectionList(BASE_OBJECTS_ID())); + initVersion(BOP_VERSION_9_4(), selectionList(BASE_OBJECTS_ID())); } //================================================================================================= void FeaturesPlugin_Partition::execute() { - ObjectHierarchy anObjects; + GeomAPI_ShapeHierarchy anObjects; ListOfShape aPlanes; // Getting objects. processAttribute(BASE_OBJECTS_ID(), anObjects, aPlanes); - if(anObjects.IsEmpty()) { + if(anObjects.empty()) { static const std::string aFeatureError = "Error: No objects for partition."; setError(aFeatureError); return; } - ListOfShape aBaseObjects = anObjects.Objects(); + ListOfShape aBaseObjects = anObjects.objects(); aBaseObjects.insert(aBaseObjects.end(), aPlanes.begin(), aPlanes.end()); // resize planes to the bounding box of operated shapes std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); - resizePlanes(anObjects.Objects(), aPlanes, aMakeShapeList); + resizePlanes(anObjects.objects(), aPlanes, aMakeShapeList); // cut unused solids of composolids from the objects of partition ListOfShape aTargetObjects, anUnusedSubs; @@ -126,9 +124,8 @@ void FeaturesPlugin_Partition::execute() int aResultIndex = 0; - int aPartitionVersion = version(); - if (aPartitionVersion < THE_PARTITION_VERSION_1) { - // default behaviours of Partition + if (data()->version().empty()) { + // default behaviors of Partition if(aResultShape->shapeType() == GeomAPI_Shape::COMPOUND) { for(GeomAPI_ShapeIterator anIt(aResultShape); anIt.more(); anIt.next()) { storeResult(aBaseObjects, aPlanes, anIt.current(), aMakeShapeList, aResultIndex); @@ -150,9 +147,15 @@ void FeaturesPlugin_Partition::execute() } GeomShapePtr aResultCompound = - keepUnusedSubsOfCompound(aFirstShape, anObjects, ObjectHierarchy(), aMakeShapeList); + keepUnusedSubsOfCompound(aFirstShape, anObjects, GeomAPI_ShapeHierarchy(), aMakeShapeList); if (anIt.more()) { + if (aResultCompound->shapeType() != GeomAPI_Shape::COMPOUND) { + // put the shape into compound + ListOfShape aShapes; + aShapes.push_back(aResultCompound); + aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); + } std::shared_ptr aBuilder(new GeomAlgoAPI_ShapeBuilder); for (; anIt.more(); anIt.next()) aBuilder->add(aResultCompound, anIt.current()); @@ -231,7 +234,7 @@ static bool cutSubs(ListOfShape& theSubsToCut, } bool FeaturesPlugin_Partition::cutSubs( - FeaturesPlugin_Partition::ObjectHierarchy& theHierarchy, + GeomAPI_ShapeHierarchy& theHierarchy, ListOfShape& theUsed, ListOfShape& theNotUsed, std::shared_ptr& theMakeShapeList, @@ -240,14 +243,14 @@ bool FeaturesPlugin_Partition::cutSubs( theUsed.clear(); theNotUsed.clear(); - ObjectHierarchy::Iterator anIt = theHierarchy.Begin(); + GeomAPI_ShapeHierarchy::iterator anIt = theHierarchy.begin(); // compose a set of tools for the CUT operation: // find the list of unused subs of the first argument or use itself ListOfShape aToolsForUsed, aToolsForUnused; - GeomShapePtr aFirstArgument = theHierarchy.Parent(*anIt, false); + GeomShapePtr aFirstArgument = theHierarchy.parent(*anIt, false); if (aFirstArgument && aFirstArgument->shapeType() == GeomAPI_Shape::COMPSOLID) { - theHierarchy.SplitCompound(aFirstArgument, theUsed, aToolsForUsed); + theHierarchy.splitCompound(aFirstArgument, theUsed, aToolsForUsed); theNotUsed = aToolsForUsed; } else { @@ -258,13 +261,13 @@ bool FeaturesPlugin_Partition::cutSubs( // cut subs bool isOk = true; - for (++anIt; anIt != theHierarchy.End() && isOk; ++anIt) { + for (++anIt; anIt != theHierarchy.end() && isOk; ++anIt) { ListOfShape aUsed, aNotUsed; - GeomShapePtr aParent = theHierarchy.Parent(*anIt, false); + GeomShapePtr aParent = theHierarchy.parent(*anIt, false); if (aParent && aParent->shapeType() == GeomAPI_Shape::COMPSOLID) { - aParent = theHierarchy.Parent(*anIt); // get parent once again to mark its subs as processed - theHierarchy.SplitCompound(aParent, aUsed, aNotUsed); + aParent = theHierarchy.parent(*anIt); // get parent once again to mark its subs as processed + theHierarchy.splitCompound(aParent, aUsed, aNotUsed); } else aUsed.push_back(*anIt);