]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix incorrect treating a constraint Angle type while dumping (issue #2893)
authorazv <azv@opencascade.com>
Thu, 21 Mar 2019 13:00:23 +0000 (16:00 +0300)
committerazv <azv@opencascade.com>
Thu, 21 Mar 2019 13:00:49 +0000 (16:00 +0300)
src/SketchAPI/SketchAPI_ConstraintAngle.cpp

index fa12b859241ab15978504fc442c66ff53cf46cca..50bbbb946ef93b285bea8e85887568b142c9b971 100644 (file)
@@ -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;
 }