Salome HOME
Revert "First phase of SketchSolver refactoring"
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintAngle.cpp
index 895f99e62c224cf713eab09e6b4b6c7f73732835..10dbae16549bc0ab16c9024acee89c9c0b085199 100644 (file)
@@ -47,8 +47,11 @@ void SketchSolver_ConstraintAngle::adjustConstraint()
     return;
   double aDist[2][2];
   for (int i = 0; i < 2; i++) {
-    for (int j = 0; j < 2; j++)
+    for (int j = 0; j < 2; j++) {
       aDist[i][j] = anIntersection->distance(aPoints[i][j]);
+      if (fabs(aDist[i][j]) <= tolerance)
+        aDist[i][j] = 0.0;
+    }
     if (aDist[i][0] > tolerance && aDist[i][1] > tolerance &&
         aDist[i][0] + aDist[i][1] < aPoints[i][0]->distance(aPoints[i][1]) + 2.0 * tolerance) {
       // the intersection point is an inner point of the line,
@@ -66,8 +69,10 @@ void SketchSolver_ConstraintAngle::adjustConstraint()
       aDir[i] = std::shared_ptr<GeomAPI_Dir2d>(new GeomAPI_Dir2d(
           aPoints[i][0]->xy()->decreased(anIntersection->xy())));
       // main direction is opposite => change signs
-      aDist[i][0] *= -1.0;
-      aDist[i][1] *= -1.0;
+      if (aDist[i][0] < 0.0) {
+        aDist[i][0] *= -1.0;
+        aDist[i][1] *= -1.0;
+      }
     }
 
   aConstraint.other = false;