From: dbv Date: Thu, 30 Mar 2017 15:34:44 +0000 (+0300) Subject: Issue #1830: Fuse do a bad result X-Git-Tag: V_2.7.0~123 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a1a04fc1a20fe5b7adf9fddb2d400b711e441e7b;p=modules%2Fshaper.git Issue #1830: Fuse do a bad result Updated Boolean validator. Now it does not allow to select only sub-shapes of the same shape. --- diff --git a/src/GeomValidators/GeomValidators_BooleanArguments.cpp b/src/GeomValidators/GeomValidators_BooleanArguments.cpp index c22b7abd3..54cb1069e 100644 --- a/src/GeomValidators/GeomValidators_BooleanArguments.cpp +++ b/src/GeomValidators/GeomValidators_BooleanArguments.cpp @@ -10,6 +10,8 @@ #include #include +#include +#include //================================================================================================= bool GeomValidators_BooleanArguments::isValid(const std::shared_ptr& theFeature, @@ -26,15 +28,47 @@ bool GeomValidators_BooleanArguments::isValid(const std::shared_ptr::const_iterator anIt = theArguments.begin(), aLast = theArguments.end(); - std::shared_ptr anAttrSelList = theFeature->selectionList(*anIt); + bool isAllInSameCompSolid = true; + ResultCompSolidPtr aCompSolid; + + AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(*anIt); if(anAttrSelList) { anObjectsNb = anAttrSelList->size(); + for(int anIndex = 0; anIndex < anObjectsNb; ++anIndex) { + AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); + ResultPtr aContext = anAttr->context(); + ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext); + if(aResCompSolidPtr.get()) { + if(aCompSolid.get()) { + isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; + } else { + aCompSolid = aResCompSolidPtr; + } + } else { + isAllInSameCompSolid = false; + } + } } anIt++; + anAttrSelList = theFeature->selectionList(*anIt); if(anAttrSelList) { aToolsNb = anAttrSelList->size(); + for(int anIndex = 0; anIndex < aToolsNb; ++anIndex) { + AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); + ResultPtr aContext = anAttr->context(); + ResultCompSolidPtr aResCompSolidPtr = ModelAPI_Tools::compSolidOwner(aContext); + if(aResCompSolidPtr.get()) { + if(aCompSolid.get()) { + isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; + } else { + aCompSolid = aResCompSolidPtr; + } + } else { + isAllInSameCompSolid = false; + } + } } anIt++; @@ -43,14 +77,31 @@ bool GeomValidators_BooleanArguments::isValid(const std::shared_ptrvalue(); } - if(anOperationType == 1 && (anObjectsNb + aToolsNb > 1)) { - return true; - } else if (anOperationType != 1 && anObjectsNb > 0 && aToolsNb > 0) { - return true; + if(anOperationType == 1) { + // Fuse operation + if(anObjectsNb + aToolsNb < 2) { + theError = "Not enough arguments for Fuse operation."; + return false; + } else if(isAllInSameCompSolid) { + theError = "Operations only between sub-shapes of the same shape not allowed."; + return false; + } + } else { + if(anObjectsNb < 1) { + theError = "Objects not selected."; + return false; + } + if(aToolsNb < 1) { + theError = "Tools not selected."; + return false; + } + if(isAllInSameCompSolid) { + theError = "Operations only between sub-shapes of the same shape not allowed."; + return false; + } } - theError = "Not enough arguments"; - return false; + return true; } //=================================================================================================