]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Implement SketchAPI_Constraint::value() method to get the value of constraint.
authorazv <azv@opencascade.com>
Tue, 14 Jun 2022 05:05:17 +0000 (08:05 +0300)
committerazv <azv@opencascade.com>
Tue, 14 Jun 2022 05:05:17 +0000 (08:05 +0300)
src/SketchAPI/SketchAPI_Constraint.cpp
src/SketchAPI/SketchAPI_Constraint.h

index 97e01c3328409ae88f64dfae671ed83de76dca7f..724308c5243645562dd64b8d860127ccdec2287b 100644 (file)
@@ -42,6 +42,8 @@
 
 #include <SketcherPrs_Tools.h>
 
+#include <limits>
+
 SketchAPI_Constraint::SketchAPI_Constraint(
     const std::shared_ptr<ModelAPI_Feature> & theFeature)
 : ModelHighAPI_Interface(theFeature)
@@ -89,6 +91,13 @@ void SketchAPI_Constraint::setValue(const ModelHighAPI_Double& theValue)
   fillAttribute(theValue, feature()->real(SketchPlugin_Constraint::VALUE()));
 }
 
+double SketchAPI_Constraint::value() const
+{
+  AttributeDoublePtr aValueAttr = feature()->real(SketchPlugin_Constraint::VALUE());
+  return aValueAttr->isInitialized() ? aValueAttr->value()
+                                     : std::numeric_limits<double>::quiet_NaN();
+}
+
 static const std::string& constraintTypeToSetter(const std::string& theType)
 {
   if (theType == SketchPlugin_ConstraintCoincidence::ID()) {
index 19b2d50ea495318f0549c6e1a56310182f9f020c..82d3962bd8244f9d8cb85cec3957a054184414ef 100644 (file)
@@ -62,6 +62,8 @@ public:
 
   SKETCHAPI_EXPORT void setValue(const ModelHighAPI_Double& theValue);
 
+  SKETCHAPI_EXPORT double value() const;
+
   /// Dump wrapped feature
   SKETCHAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;