X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomValidators%2FGeomValidators_ShapeType.cpp;fp=src%2FGeomValidators%2FGeomValidators_ShapeType.cpp;h=afb7dd0c93eb2c6a5bb6eefa2965bd750a5b698b;hb=3f28b864e07f77b37a46a67dbf3ee4639eee4e08;hp=3ee016de3709faea44c4184fa406ce640c623983;hpb=8d94dd9ddc9af69edf23dbe9996cee6ed54db5c1;p=modules%2Fshaper.git diff --git a/src/GeomValidators/GeomValidators_ShapeType.cpp b/src/GeomValidators/GeomValidators_ShapeType.cpp index 3ee016de3..afb7dd0c9 100755 --- a/src/GeomValidators/GeomValidators_ShapeType.cpp +++ b/src/GeomValidators/GeomValidators_ShapeType.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -130,8 +131,12 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute GeomShapePtr aShape = anAttr->value(); if (aShape.get()) aValid = isValidShape(aShape, theShapeType, theError); - else - aValid = isValidObject(anAttr->context(), theShapeType, theError); + else { + if (anAttr->context().get()) + aValid = isValidObject(anAttr->context(), theShapeType, theError); + else + aValid = isValidObject(anAttr->contextFeature(), theShapeType, theError); + } } else if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) { AttributeRefAttrPtr anAttr = std::dynamic_pointer_cast(theAttribute); @@ -178,6 +183,8 @@ bool GeomValidators_ShapeType::isValidAttribute(const AttributePtr& theAttribute theError = "The attribute with the %1 type is not processed"; theError.arg(anAttributeType); } + if (aValid) + theError = ""; return aValid; } @@ -194,20 +201,29 @@ bool GeomValidators_ShapeType::isValidObject(const ObjectPtr& theObject, } else { ResultPtr aResult = std::dynamic_pointer_cast(theObject); - if( theShapeType==Plane ) - { - ResultConstructionPtr aResultConstruction = - std::dynamic_pointer_cast(theObject); - FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); - const std::string& aKind = aFeature->getKind(); - return aResult.get() != NULL && aKind == "Plane"; - } - if (!aResult.get()) { - aValid = false; - theError = "The result is empty"; - } - else { - aValid = isValidShape(aResult->shape(), theShapeType, theError); + if (aResult.get()) { + if (theShapeType == Plane) + { + ResultConstructionPtr aResultConstruction = + std::dynamic_pointer_cast(theObject); + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + const std::string& aKind = aFeature->getKind(); + return aResult.get() != NULL && aKind == "Plane"; + } + if (!aResult.get()) { + aValid = false; + theError = "The result is empty"; + } else { + aValid = isValidShape(aResult->shape(), theShapeType, theError); + } + } else { + FeaturePtr aFeature = std::dynamic_pointer_cast(theObject); + if (aFeature.get() && (theShapeType == CompSolid)) + return aValid; + else { + aValid = false; + theError = "The feature has to produce a compsolid"; + } } } return aValid;