From 845084998a745e85392b5ab943f895c5896eb0ed Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 14 Jun 2022 08:05:17 +0300 Subject: [PATCH] Implement SketchAPI_Constraint::value() method to get the value of constraint. --- src/SketchAPI/SketchAPI_Constraint.cpp | 9 +++++++++ src/SketchAPI/SketchAPI_Constraint.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/SketchAPI/SketchAPI_Constraint.cpp b/src/SketchAPI/SketchAPI_Constraint.cpp index 97e01c332..724308c52 100644 --- a/src/SketchAPI/SketchAPI_Constraint.cpp +++ b/src/SketchAPI/SketchAPI_Constraint.cpp @@ -42,6 +42,8 @@ #include +#include + SketchAPI_Constraint::SketchAPI_Constraint( const std::shared_ptr & 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::quiet_NaN(); +} + static const std::string& constraintTypeToSetter(const std::string& theType) { if (theType == SketchPlugin_ConstraintCoincidence::ID()) { diff --git a/src/SketchAPI/SketchAPI_Constraint.h b/src/SketchAPI/SketchAPI_Constraint.h index 19b2d50ea..82d3962bd 100644 --- a/src/SketchAPI/SketchAPI_Constraint.h +++ b/src/SketchAPI/SketchAPI_Constraint.h @@ -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; -- 2.39.2