const std::list<std::string>& theArguments,
std::string& theError) const
{
- if (!theAttribute->isInitialized())
+ if (!theAttribute->isInitialized()) {
+ theError = "Is not initialized.";
return false;
+ }
const AttributeStringPtr aStrAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeString>(theAttribute);
- if (!aStrAttr)
+ if (!aStrAttr) {
+ theError = "Is not a string attribute.";
return false;
+ }
std::string aFileName = aStrAttr->value();
- if (aFileName.empty())
+ if (aFileName.empty()) {
+ theError = "File name is empty.";
return false;
+ }
std::list<std::string> aFormats;
ExchangePlugin_FormatValidator::parseFormats(theArguments, aFormats);
}
}
}
+ theError = "File name does not end with any available format.";
return false;
}
std::string& theError) const
{
if(theArguments.size() != 3) {
+ theError = "Wrong number of arguments (expected 3).";
return false;
}
bool aValid = false;
AttributeSelectionPtr aSelectionAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
(theAttribute);
- if (aSelectionAttr.get() == NULL)
+ if (aSelectionAttr.get() == NULL) {
+ theError = "Is not a selection attribute.";
return aValid;
+ }
ResultPtr aResult = aSelectionAttr->context();
GeomShapePtr aShape = aSelectionAttr->value();
}
else {
// an empty shape is used in attribute selection if the shape of the result is equal to
- // the selected shape, so according to the upper condifition, the result is true
+ // the selected shape, so according to the upper condition, the result is true
aValid = true;
}
}
ResultConstructionPtr aConstr =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
if (aConstr != NULL) {
- // it provides selection only on compositie features, construction without composite
+ // it provides selection only on composite features, construction without composite
// feature is not selectable
FeaturePtr aFeature = ModelAPI_Feature::feature(aConstr);
CompositeFeaturePtr aComposite =
std::list<AttributePtr>::const_iterator aNextIt = anAttributeIt; ++aNextIt;
while (aNextIt != anAttributes.end()) {
// if equal attribute is found then all attributes are not different
- if (std::find_if(aNextIt, anAttributes.end(), IsEqual(*anAttributeIt)) != anAttributes.end())
+ std::list<AttributePtr>::const_iterator aFindIt =
+ std::find_if(aNextIt, anAttributes.end(), IsEqual(*anAttributeIt));
+ if (aFindIt != anAttributes.end()) {
+ theError = "Attributes " + anAttributeIt->id() + " and " + aFindIt->id() + " are equal." ;
return false;
+ }
++anAttributeIt;
++aNextIt;
}
ObjectPtr anObject = GeomValidators_Tools::getObject(theAttribute);
if (anObject.get() != NULL) {
- AttributeSelectionPtr aSelectionAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
- (theAttribute);
+ AttributeSelectionPtr aSelectionAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ if (aSelectionAttr.get() == NULL) {
+ theError = "Is not a selection attribute.";
+ return aValid;
+ }
+
std::shared_ptr<GeomAPI_Shape> aGeomShape = aSelectionAttr->value();
if (!aGeomShape.get()) {
// if the shape is empty, apply the validator to the shape of result
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:
+ theError = "The shape is not an available face."
break;
}
}
- }
+ } else
+ theError = "The shape is not a face."
}
else
aValid = true; // an empty face selected is valid.
const std::list<std::string>& theArguments,
std::string& theError) const
{
- AttributeDoublePtr aDouble =
- std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
- if (aDouble.get())
- return aDouble->isInitialized() && aDouble->value() > 1.e-5;
- AttributeIntegerPtr aInteger =
- std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(theAttribute);
- return aInteger->isInitialized() && aInteger->value() > 0;
+ if (theAttribute->attributeType() == ModelAPI_AttributeDouble::typeId()) {
+ AttributeDoublePtr aDouble =
+ std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
+ if (!aDouble->isInitialized()) {
+ theError = "Double is not initialized.";
+ return false;
+ }
+ if (aDouble->value() <= 1.e-5) {
+ theError = "Double is not positive.";
+ return false;
+ }
+ }
+
+ if (theAttribute->attributeType() == ModelAPI_AttributeInteger::typeId()) {
+ AttributeIntegerPtr aInteger =
+ std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(theAttribute);
+ if (!aInteger->isInitialized()) {
+ theError = "Integer is not initialized.";
+ return false;
+ }
+ if (aInteger->value() <= 0) {
+ theError = "Integer is not positive.";
+ return false;
+ }
+ }
+
+ return true;
}
std::string& theError) const
{
if(theArguments.size() != 8) {
+ theError = "Wrong number of arguments (expected 8).";
return false;
}
if(aSelectedMethod == aCreationMethod) {
if(aToSize == -aFromSize) {
+ theError = "ToSize = -FromSize.";
return false;
} else {
return true;
if(((!aFromShape && !aToShape) || ((aFromShape && aToShape) && aFromShape->isEqual(aToShape)))
&& (aFromSize == -aToSize)) {
+ theError = "FromSize = -ToSize and bounding planes are equal.";
return false;
}
bool isParameterExternal = isExternalAttribute(aFeature->attribute(aFrontArgument));
// it is not possible that both features, attribute and attribute in parameter, are external
- if (isAttributeExternal && isParameterExternal)
+ if (isAttributeExternal && isParameterExternal) {
+ theError = "Both features, attribute and attribute in parameter, are external.";
return false;
+ }
return true;
}