From: azv Date: Fri, 22 Mar 2019 09:53:47 +0000 (+0300) Subject: Fix incorrect treating a constraint Angle type while dumping (issue #2893) X-Git-Tag: V9_3_0b2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d01eb92de9e1b41819554431dff92b712803a67c;p=modules%2Fshaper.git Fix incorrect treating a constraint Angle type while dumping (issue #2893) --- 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)