X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_BooleanFill.cpp;h=cb039b01a6b243854b251749cfb638b5764c7ca6;hb=a13f87935d2a6f52f942790b6abc874f1016c9fc;hp=1088fd82005dc401997373589f68f069a37cb825;hpb=abe69bb38b6f2dee52946e626ba70b04d7c11a56;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp index 1088fd820..cb039b01a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BooleanFill.cpp @@ -46,26 +46,33 @@ FeaturesPlugin_BooleanFill::FeaturesPlugin_BooleanFill() { } +//================================================================================================= +void FeaturesPlugin_BooleanFill::initAttributes() +{ + FeaturesPlugin_Boolean::initAttributes(); + initVersion(BOP_VERSION_9_4(), selectionList(OBJECT_LIST_ID()), selectionList(TOOL_LIST_ID())); +} + //================================================================================================= void FeaturesPlugin_BooleanFill::execute() { std::string anError; - ObjectHierarchy anObjects, aTools; - ListOfShape aPlanes, anEdgesAndFaces; + GeomAPI_ShapeHierarchy anObjects, aTools; + ListOfShape aPlanes; // Getting objects. - if (!processAttribute(OBJECT_LIST_ID(), anObjects, aPlanes, anEdgesAndFaces)) + if (!processAttribute(OBJECT_LIST_ID(), anObjects, aPlanes)) return; // Planes are not supported as objects of FILL operation aPlanes.clear(); // Getting tools. - if (!processAttribute(TOOL_LIST_ID(), aTools, aPlanes, anEdgesAndFaces)) + if (!processAttribute(TOOL_LIST_ID(), aTools, aPlanes)) return; int aResultIndex = 0; - if (anObjects.IsEmpty() || (aTools.IsEmpty() && aPlanes.empty())) { + if (anObjects.empty() || (aTools.empty() && aPlanes.empty())) { std::string aFeatureError = "Error: Not enough objects for boolean operation."; setError(aFeatureError); return; @@ -74,35 +81,50 @@ void FeaturesPlugin_BooleanFill::execute() std::vector aResultBaseAlgoList; ListOfShape aResultShapesList; + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList()); + + GeomShapePtr aResultCompound; + if (data()->version() == BOP_VERSION_9_4()) { + // merge hierarchies of compounds containing objects and tools + aResultCompound = + keepUnusedSubsOfCompound(GeomShapePtr(), anObjects, aTools, aMakeShapeList); + } + // For solids cut each object with all tools. 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_PARTITION, - anObjects, aParent, aTools.Objects(), aPlanes, - aResultIndex, aResultBaseAlgoList, aResultShapesList); + anObjects, aParent, aTools.objects(), aPlanes, + aResultIndex, aResultBaseAlgoList, aResultShapesList, + aResultCompound); } else { // process object as is isOk = processObject(GeomAlgoAPI_Tools::BOOL_PARTITION, - anObject, aTools.Objects(), aPlanes, - aResultIndex, aResultBaseAlgoList, aResultShapesList); + anObject, aTools.objects(), aPlanes, + aResultIndex, aResultBaseAlgoList, aResultShapesList, + aResultCompound); } } + 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. - GeomShapePtr aResultShapesCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList); + if (!aResultCompound) + aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(aResultShapesList); FeaturesPlugin_Tools::loadDeletedShapes(aResultBaseAlgoList, - aTools.Objects(), - aResultShapesCompound); + aTools.objects(), + aResultCompound); // remove the rest results if there were produced in the previous pass removeResults(aResultIndex);