From 7be9fb87d5945e2d9b22af8421e63ec5b404bad1 Mon Sep 17 00:00:00 2001 From: azv Date: Thu, 21 Mar 2019 16:00:23 +0300 Subject: [PATCH] Fix incorrect treating a constraint Angle type while dumping (issue #2893) --- src/SketchAPI/SketchAPI_ConstraintAngle.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/SketchAPI/SketchAPI_ConstraintAngle.cpp b/src/SketchAPI/SketchAPI_ConstraintAngle.cpp index fa12b8592..50bbbb946 100644 --- a/src/SketchAPI/SketchAPI_ConstraintAngle.cpp +++ b/src/SketchAPI/SketchAPI_ConstraintAngle.cpp @@ -91,15 +91,18 @@ static std::string angleTypeToString(FeaturePtr theFeature) AttributeDoublePtr aValueAttr = theFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()); + double aDirectDiff = fabs(aValueAttr->value() - anAngleDirect); + double aComplementaryDiff = fabs(aValueAttr->value() - anAngleComplmentary); + double aBackwardDiff = fabs(aValueAttr->value() - anAngleBackward); + + // find the minimal difference std::string aType; - if (fabs(aValueAttr->value() - anAngleDirect) < TOLERANCE) { - // Nothing to do. - // This case is empty and going the first to check the direct angle before the others. + if (aDirectDiff > TOLERANCE) { + if (aComplementaryDiff < aDirectDiff && aComplementaryDiff < aBackwardDiff) + aType = "Complementary"; + else if (aBackwardDiff < aDirectDiff && aBackwardDiff < aComplementaryDiff) + aType = "Backward"; } - else if (fabs(aValueAttr->value() - anAngleComplmentary) < TOLERANCE) - aType = "Complementary"; - else if (fabs(aValueAttr->value() - anAngleBackward) < TOLERANCE) - aType = "Backward"; return aType; } -- 2.39.2