X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomValidators%2FGeomValidators_Face.cpp;h=51a5012cdab7ac5cc292a9478893ac9a9b9f3cb0;hb=3205d0f18200948632155bbe7b640bc1e482243d;hp=90eb2aac390c138374290897de01f6339b949315;hpb=4ca3fd41634c37f840d0cbb3f896fa97c2d3c457;p=modules%2Fshaper.git diff --git a/src/GeomValidators/GeomValidators_Face.cpp b/src/GeomValidators/GeomValidators_Face.cpp index 90eb2aac3..51a5012cd 100644 --- a/src/GeomValidators/GeomValidators_Face.cpp +++ b/src/GeomValidators/GeomValidators_Face.cpp @@ -34,18 +34,20 @@ bool GeomValidators_Face::isValid(const AttributePtr& theAttribute, const std::list& theArguments, std::string& theError) const { - bool aValid = false; - - GeomAbs_SurfaceType aFaceType = GeomAbs_Plane; - if (theArguments.size() == 1) { - std::string anArgument = theArguments.front(); - aFaceType = faceType(anArgument); + std::string anAttributeType = theAttribute->attributeType(); + if (anAttributeType != ModelAPI_AttributeSelection::typeId()) { + theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed"; + return false; } + bool aValid = true; ObjectPtr anObject = GeomValidators_Tools::getObject(theAttribute); - if (anObject.get() != NULL) { - AttributeSelectionPtr aSelectionAttr = std::dynamic_pointer_cast - (theAttribute); + if (!anObject.get()) { + aValid = true; // an empty face selected is valid. + } + else { + AttributeSelectionPtr aSelectionAttr = + std::dynamic_pointer_cast(theAttribute); std::shared_ptr aGeomShape = aSelectionAttr->value(); if (!aGeomShape.get()) { // if the shape is empty, apply the validator to the shape of result @@ -54,23 +56,42 @@ bool GeomValidators_Face::isValid(const AttributePtr& theAttribute, // it is necessary to check whether the shape is face in order to set in selection a value // with any type and check the type in this validator // It is realized to select any object in OB and filter it in this validator (sketch plane) - if (aGeomShape->isFace()) { + if (!aGeomShape->isFace()) { + aValid = false; + theError = "The shape is not a face."; + } + else { std::shared_ptr aGeomFace(new GeomAPI_Face(aGeomShape)); - if (aGeomFace.get() != NULL) { - switch(aFaceType) { - case GeomAbs_Plane: - aValid = aGeomFace->isPlanar(); - break; - case GeomAbs_Cylinder: - aValid = aGeomFace->isCylindrical(); - break; - default: - break; + if (!aGeomFace.get()) { + aValid = false; + theError = "The shape is not a face."; + } + else { + GeomAbs_SurfaceType aFaceType = GeomAbs_Plane; + if (theArguments.size() == 1) + aFaceType = faceType(theArguments.front()); + + switch (aFaceType) { + case GeomAbs_Plane: { + aValid = aGeomFace->isPlanar(); + if (!aValid) + theError = "The shape is not a plane."; + } + break; + case GeomAbs_Cylinder:{ + aValid = aGeomFace->isCylindrical(); + if (!aValid) + theError = "The shape is not a cylinder."; + } + break; + default: { + aValid = false; + theError = "The shape is not an available face."; + break; + } } } } } - else - aValid = true; // an empty face selected is valid. return aValid; }