]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #2458 : Tangent symbol is wrongly placed
authormpv <mpv@opencascade.com>
Thu, 5 Apr 2018 13:48:29 +0000 (16:48 +0300)
committermpv <mpv@opencascade.com>
Thu, 5 Apr 2018 13:48:29 +0000 (16:48 +0300)
src/SketcherPrs/SketcherPrs_PositionMgr.cpp

index edf7140a829053237f374d8412aea5152a3ba335..49892641961967dae0d903f327d14dd20e6d9e15 100644 (file)
@@ -194,6 +194,20 @@ gp_Vec getVector(ObjectPtr theShape, GeomDirPtr theDir, gp_Pnt theP)
       double aParam = anExtr.LowerDistanceParameter();
       gp_Pnt aP;
       aCurv->D1(aParam, aP, aVec);
+      // 2458: check correct orientation of the vector
+      if (aVec.SquareMagnitude() > Precision::Confusion()) {
+        std::shared_ptr<GeomAPI_Edge> aCircEdge(new GeomAPI_Edge(aShape));
+        double aFirstParam, aLastParam;
+        aCircEdge->getRange(aFirstParam, aLastParam);
+        // if parameter is near the LastParam, make the vector go inside (reverse)
+        double aDelta = aLastParam - aParam;
+        while (aDelta < -Precision::Confusion())
+          aDelta += 2. * M_PI;
+        while (aDelta > 2. * M_PI - Precision::Confusion())
+          aDelta -= 2. * M_PI;
+        if (fabs(aDelta) < Precision::Confusion())
+          aVec.Reverse();
+      }
     } else {
       GeomPointPtr aPnt1 = aCurve->getPoint(aCurve->endParam());
       GeomPointPtr aPnt2 = aCurve->getPoint(aCurve->startParam());