From d01eb92de9e1b41819554431dff92b712803a67c Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 22 Mar 2019 12:53:47 +0300 Subject: [PATCH] Fix incorrect treating a constraint Angle type while dumping (issue #2893) --- src/SketchAPI/SketchAPI_ConstraintAngle.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/SketchAPI/SketchAPI_ConstraintAngle.cpp b/src/SketchAPI/SketchAPI_ConstraintAngle.cpp index 50bbbb946..9d7bf8c46 100644 --- a/src/SketchAPI/SketchAPI_ConstraintAngle.cpp +++ b/src/SketchAPI/SketchAPI_ConstraintAngle.cpp @@ -28,6 +28,8 @@ #include #include +#include + #include SketchAPI_ConstraintAngle::SketchAPI_ConstraintAngle( @@ -90,14 +92,26 @@ static std::string angleTypeToString(FeaturePtr theFeature) calculatePossibleValuesOfAngle(theFeature, anAngleDirect, anAngleComplmentary, anAngleBackward); 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); + AttributeIntegerPtr aTypeAttr = theFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()); + bool isDirect = aTypeAttr->value() == SketcherPrs_Tools::ANGLE_DIRECT; + bool isComplementary = aTypeAttr->value() == SketcherPrs_Tools::ANGLE_COMPLEMENTARY; + bool isBackward = aTypeAttr->value() == SketcherPrs_Tools::ANGLE_BACKWARD; + // find the minimal difference std::string aType; - if (aDirectDiff > TOLERANCE) { + if (isDirect && aDirectDiff < TOLERANCE) { + // Nothing to do. + // This case is empty and going the first to check the direct angle before the others. + } + else if (isComplementary && aComplementaryDiff < TOLERANCE) + aType = "Complementary"; + else if (isBackward && aBackwardDiff < TOLERANCE) + aType = "Backward"; + else { if (aComplementaryDiff < aDirectDiff && aComplementaryDiff < aBackwardDiff) aType = "Complementary"; else if (aBackwardDiff < aDirectDiff && aBackwardDiff < aComplementaryDiff) -- 2.30.2