]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/GeomValidators/GeomValidators_Positive.cpp
Salome HOME
Delete key regression corrections: in previous implementation sketch entities did...
[modules/shaper.git] / src / GeomValidators / GeomValidators_Positive.cpp
index 344cfe08d76369b799e9f6e59cef947ae670e341..b127ffe033a688edf64981f0c222287d5ea8cb71 100644 (file)
@@ -10,6 +10,8 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
+#include <cmath>
+
 /// Global instance for validators factory
 GeomValidators_Positive MY_POSITIVE_INSTANCE;
 
@@ -25,6 +27,17 @@ bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute,
                                       const std::list<std::string>& theArguments,
                                       std::string& theError) const
 {
+  double aMinValue = 1.e-5;
+  if(theArguments.size() == 1) {
+    std::list<std::string>::const_iterator anIt = theArguments.begin();
+    char *aErr;
+    double aValue = strtod((*anIt).c_str(), &aErr);
+    if(*aErr == 0) {
+      // very probably ok
+      aMinValue = aValue;
+    }
+  }
+
   if (theAttribute->attributeType() == ModelAPI_AttributeDouble::typeId()) {
     AttributeDoublePtr aDouble =
         std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
@@ -32,7 +45,7 @@ bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute,
       theError = "Double is not initialized.";
       return false;
     }
-    if (aDouble->value() <= 1.e-5) {
+    if (aDouble->value() <= aMinValue) {
       theError = "Double is not positive.";
       return false;
     }
@@ -45,7 +58,7 @@ bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute,
       theError = "Integer is not initialized.";
       return false;
     }
-    if (aInteger->value() <= 0) {
+    if (aInteger->value() <= floor(aMinValue)) {
       theError = "Integer is not positive.";
       return false;
     }