X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Validators.cpp;h=4f9b5f1f1d4379f0a86584382ff0bebc5db5dfad;hb=16ec818602a442cd163cde1a136fd7b4091075b8;hp=ccb43b40643951035c1df9b12e70711e5bcb9576;hpb=e91e5875dfa825c2a382737b2fd2e7e4cb4e2acd;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index ccb43b406..4f9b5f1f1 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -411,7 +411,7 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute if (aContext.get()) aConstruction = std::dynamic_pointer_cast(aContext); if(aConstruction.get()) { - // Construciotn selected. Check that is is not infinite. + // Construction selected. Check that it is not infinite. if(aConstruction->isInfinite()) { theError = "Error: Infinite constructions is not allowed as base."; return false; @@ -430,7 +430,6 @@ bool FeaturesPlugin_ValidatorBaseForGeneration::isValidAttribute(const Attribute return true; } } - return false; } @@ -555,7 +554,8 @@ bool FeaturesPlugin_ValidatorExtrusionDir::isValid( } } - if(!aDirShape.get()) { + if(!aDirShape.get() || aDirShape->isNull() || + aDirShape->shapeType() != GeomAPI_Shape::EDGE) { // Check that dir can be empty. if(!isShapesCanBeEmpty(aCheckAttribute, theError)) { theError = "Error: Base objects list contains vertex or edge, so attribute \"%1\" " @@ -1168,75 +1168,44 @@ bool FeaturesPlugin_ValidatorBooleanArguments::isValid( return false; } - int anObjectsNb = 0, aToolsNb = 0; - //int anOperationType = 0; + int anObjectsToolsNb[2] = { 0, 0 }; std::list::const_iterator anIt = theArguments.begin(), aLast = theArguments.end(); bool isAllInSameCompSolid = true; ResultBodyPtr 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(); - ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); - if (aResCompSolidPtr.get()) - { - if (aCompSolid.get()) - { - isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; - } - else - { - aCompSolid = aResCompSolidPtr; - } - } - else - { - isAllInSameCompSolid = false; - break; - } - } - } - anIt++; - - - anAttrSelList = theFeature->selectionList(*anIt); - if (anAttrSelList) - { - aToolsNb = anAttrSelList->size(); - if (isAllInSameCompSolid) + for (int* anArgNbIt = anObjectsToolsNb; anIt != aLast; ++anIt, ++anArgNbIt) { + AttributeSelectionListPtr anAttrSelList = theFeature->selectionList(*anIt); + if (anAttrSelList) { - for (int anIndex = 0; anIndex < aToolsNb; ++anIndex) - { - AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); - ResultPtr aContext = anAttr->context(); - ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); - if (aResCompSolidPtr.get()) + *anArgNbIt = anAttrSelList->size(); + if (isAllInSameCompSolid) { + for (int anIndex = 0; anIndex < *anArgNbIt; ++anIndex) { - if (aCompSolid.get()) + AttributeSelectionPtr anAttr = anAttrSelList->value(anIndex); + ResultPtr aContext = anAttr->context(); + ResultBodyPtr aResCompSolidPtr = ModelAPI_Tools::bodyOwner(aContext); + if (aResCompSolidPtr.get()) { - isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; + if (aCompSolid.get()) + { + isAllInSameCompSolid = aCompSolid == aResCompSolidPtr; + } + else + { + aCompSolid = aResCompSolidPtr; + } } else { - aCompSolid = aResCompSolidPtr; + isAllInSameCompSolid = false; + break; } } - else - { - isAllInSameCompSolid = false; - break; - } } } } - anIt++; std::shared_ptr aFeature = std::dynamic_pointer_cast(theFeature); @@ -1245,7 +1214,7 @@ bool FeaturesPlugin_ValidatorBooleanArguments::isValid( if (anOperationType == FeaturesPlugin_Boolean::BOOL_FUSE) { // Fuse operation - if (anObjectsNb + aToolsNb < 2) + if (anObjectsToolsNb[0] + anObjectsToolsNb[1] < 2) { theError = "Not enough arguments for Fuse operation."; return false; @@ -1258,12 +1227,12 @@ bool FeaturesPlugin_ValidatorBooleanArguments::isValid( } else { - if (anObjectsNb < 1) + if (anObjectsToolsNb[0] < 1) // check number of objects { theError = "Objects not selected."; return false; } - if (aToolsNb < 1) + if (anObjectsToolsNb[1] < 1) // check number of tools { theError = "Tools not selected."; return false;