X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Validators.cpp;fp=src%2FFeaturesPlugin%2FFeaturesPlugin_Validators.cpp;h=0d8da03a687404cb8058b3819ffeabdbe9f6edcc;hb=9afe243148ea67f2eccbd0afa419541424de451e;hp=71030a080b8f0e46b81a467ce35938b9c8f943f2;hpb=a930200bbf92c778fc684a3db477064f85f9cafe;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp index 71030a080..0d8da03a6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Validators.cpp @@ -2149,3 +2149,55 @@ bool FeaturesPlugin_ValidatorSewingSelection::isValid(const AttributePtr& theAtt return true; } + +//================================================================================================== +bool FeaturesPlugin_ValidatorGlueFacesSelection::isValid(const AttributePtr& theAttribute, + const std::list& theArguments, + Events_InfoMessage& theError) const +{ + AttributeSelectionListPtr anAttrSelectionList = + std::dynamic_pointer_cast(theAttribute); + if (!anAttrSelectionList.get()) { + theError = "Error: This validator can only work with selection list attributes."; + return false; + } + + // Check selected entities are of valid types + for (int anIndex = 0; anIndex < anAttrSelectionList->size(); ++anIndex) { + AttributeSelectionPtr anAttrSelection = anAttrSelectionList->value(anIndex); + if (!anAttrSelection.get()) { + theError = "Error: Empty attribute selection."; + return false; + } + ResultPtr aContext = anAttrSelection->context(); + if (!aContext.get()) { + theError = "Error: Empty selection context."; + return false; + } + if (aContext->groupName() != ModelAPI_ResultBody::group()) { + theError = "Error: Not a result body."; + return false; + } + + GeomShapePtr aContextShape = aContext->shape(); + if (!aContextShape.get()) { + theError = "Error: Empty shape."; + return false; + } + + GeomAPI_Shape::ShapeType aShapeType = aContextShape->shapeType(); + std::set anAllowedTypes; + anAllowedTypes.insert(GeomAPI_Shape::FACE); + anAllowedTypes.insert(GeomAPI_Shape::SHELL); + anAllowedTypes.insert(GeomAPI_Shape::SOLID); + anAllowedTypes.insert(GeomAPI_Shape::COMPSOLID); + anAllowedTypes.insert(GeomAPI_Shape::COMPOUND); + if (anAllowedTypes.find(aShapeType) == anAllowedTypes.end()) { + theError = "Error: Selected shape has the wrong type."; + return false; + } + + } + + return true; +}