]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Calculate points coordinates according their relation to the Angle center while chang...
authorazv <azv@opencascade.com>
Wed, 16 Sep 2015 07:37:12 +0000 (10:37 +0300)
committerazv <azv@opencascade.com>
Wed, 16 Sep 2015 07:38:03 +0000 (10:38 +0300)
src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp
src/SketchSolver/SketchSolver_ConstraintAngle.cpp

index 7874be39513f2c17c99082de801dbabbed27d366..c73ae7d175e339714dcab36fb25f1eeefc3deb8c 100644 (file)
@@ -160,24 +160,14 @@ double SketchPlugin_ConstraintAngle::calculateAngle()
   };
 
   // Directions of lines
-  if (aDist[0][1] < tolerance)
+  if (aDist[0][0] > aDist[0][1])
     aEndA = aStartA;
-  if (aDist[1][1] < tolerance)
+  if (aDist[1][0] > aDist[1][1])
     aEndB = aStartB;
   std::shared_ptr<GeomAPI_Dir2d> aDirA(new GeomAPI_Dir2d(aEndA->xy()->decreased(anInter->xy())));
   std::shared_ptr<GeomAPI_Dir2d> aDirB(new GeomAPI_Dir2d(aEndB->xy()->decreased(anInter->xy())));
 
   anAngle = fabs(aDirA->angle(aDirB)) * 180.0 / PI;
-
-  // If the lines intersected inside one of them, the angle selected is less than 90 degrees
-  if ((aDist[0][0] >= tolerance && aDist[0][1] >= tolerance &&
-      aDist[0][0] + aDist[0][1] < aStartA->distance(aEndA) + 2.0 * tolerance) ||
-      (aDist[1][0] >= tolerance && aDist[1][1] >= tolerance &&
-      aDist[1][0] + aDist[1][1] < aStartB->distance(aEndB) + 2.0 * tolerance)) {
-    if (anAngle > 90.0)
-      anAngle = 180.0 - anAngle;
-  }
-
   return anAngle;
 }
 
index d255da0e34fbc92d449238ac7cfbdaae1b4d1c45..895f99e62c224cf713eab09e6b4b6c7f73732835 100644 (file)
@@ -46,17 +46,29 @@ void SketchSolver_ConstraintAngle::adjustConstraint()
   if (!anIntersection)
     return;
   double aDist[2][2];
-  for (int i = 0; i < 2; i++)
+  for (int i = 0; i < 2; i++) {
     for (int j = 0; j < 2; j++)
       aDist[i][j] = anIntersection->distance(aPoints[i][j]);
+    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,
+      // we change the sign of distance till start point to calculate correct coordinates
+      // after rotation
+      aDist[i][0] *= -1.0;
+    }
+  }
   std::shared_ptr<GeomAPI_Dir2d> aDir[2];
   for (int i = 0; i < 2; i++)
-    if (aDist[i][1] > aDist[i][0])
+    if (aDist[i][1] > fabs(aDist[i][0]))
       aDir[i] = std::shared_ptr<GeomAPI_Dir2d>(new GeomAPI_Dir2d(
           aPoints[i][1]->xy()->decreased(anIntersection->xy())));
-    else
+    else {
       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;
+    }
 
   aConstraint.other = false;
   for (int i = 0; i < 2; i++)