From 1f8fc2a2d77852365ea5fa5b4af6cc7d9541ed43 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 5 Apr 2018 16:48:29 +0300 Subject: [PATCH] Fix for the issue #2458 : Tangent symbol is wrongly placed --- src/SketcherPrs/SketcherPrs_PositionMgr.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp index edf7140a8..498926419 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp @@ -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 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()); -- 2.39.2