From: azv Date: Fri, 31 Mar 2017 14:25:14 +0000 (+0300) Subject: Issue #2039: Wrong fillet orientation on a segment/arc intersection X-Git-Tag: V_2.7.0~111 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=61f1e2eb9bd37376d587b5cb2aa317586e89a261;p=modules%2Fshaper.git Issue #2039: Wrong fillet orientation on a segment/arc intersection Improve calculation of the center of fillet arc --- diff --git a/src/SketchPlugin/SketchPlugin_Fillet.cpp b/src/SketchPlugin/SketchPlugin_Fillet.cpp index 7039a37ad..6456d7b8c 100644 --- a/src/SketchPlugin/SketchPlugin_Fillet.cpp +++ b/src/SketchPlugin/SketchPlugin_Fillet.cpp @@ -40,6 +40,7 @@ const double tolerance = 1.e-7; const double paramTolerance = 1.e-4; +const double PI = 3.141592653589793238463; /// \brief Attract specified point on theNewArc to the attribute of theFeature static void recalculateAttributes(FeaturePtr theNewArc, const std::string& theNewArcAttribute, @@ -555,7 +556,9 @@ void calculateFilletCenter(FeaturePtr theFeatureA, FeaturePtr theFeatureB, new GeomAPI_Dir2d(aStart[1-aLineInd]->decreased(aCenter[1-aLineInd]))); std::shared_ptr aEndArcDir = std::shared_ptr( new GeomAPI_Dir2d(aEnd[1-aLineInd]->decreased(aCenter[1-aLineInd]))); - double anArcAngle = aEndArcDir->angle(aStartArcDir); + double anArcAngle = aStartArcDir->angle(aEndArcDir); + if (anArcAngle < 0.0) + anArcAngle += 2.0 * PI; // get possible centers and filter them std::list< std::shared_ptr > aSuspectCenters; @@ -578,9 +581,10 @@ void calculateFilletCenter(FeaturePtr theFeatureA, FeaturePtr theFeatureB, aWeight -= 1; std::shared_ptr aCurDir = std::shared_ptr( new GeomAPI_Dir2d((*anIt)->decreased(aCenter[1-aLineInd]))); - double aCurAngle = aCurDir->angle(aStartArcDir); - if (anArcAngle < 0.0) aCurAngle *= -1.0; - if (aCurAngle < 0.0 || aCurAngle > fabs(anArcAngle)) + double aCurAngle = aStartArcDir->angle(aCurDir); + if (aCurAngle < 0.0) + aCurAngle += 2.0 * PI; + if (aCurAngle < 0.0 || aCurAngle > anArcAngle) continue; if (aWeight > aBestWeight) aBestWeight = aWeight; @@ -611,7 +615,9 @@ void calculateFilletCenter(FeaturePtr theFeatureA, FeaturePtr theFeatureB, new GeomAPI_Dir2d(aStart[i]->decreased(aCenter[i]))); std::shared_ptr aEndArcDir = std::shared_ptr( new GeomAPI_Dir2d(aEnd[i]->decreased(aCenter[i]))); - anArcAngle[i] = aEndArcDir->angle(aStartArcDir[i]); + anArcAngle[i] = aStartArcDir[i]->angle(aEndArcDir); + if (anArcAngle[i] < 0.0) + anArcAngle[i] += 2.0 * PI; } // get and filter possible centers @@ -624,16 +630,18 @@ void calculateFilletCenter(FeaturePtr theFeatureA, FeaturePtr theFeatureB, for (; anIt != aSuspectCenters.end(); anIt++) { std::shared_ptr aCurDir = std::shared_ptr( new GeomAPI_Dir2d((*anIt)->decreased(aCenter[0]))); - double aCurAngle = aCurDir->angle(aStartArcDir[0]); - if (anArcAngle[0] < 0.0) aCurAngle *= -1.0; - if (aCurAngle < 0.0 || aCurAngle > fabs(anArcAngle[0])) + double aCurAngle = aStartArcDir[0]->angle(aCurDir); + if (aCurAngle < 0.0) + aCurAngle += 2.0 * PI; + if (aCurAngle < 0.0 || aCurAngle > anArcAngle[0]) continue; // incorrect position theTangentA = aCenter[0]->added(aCurDir->xy()->multiplied(anArcRadius[0])); aCurDir = std::shared_ptr(new GeomAPI_Dir2d((*anIt)->decreased(aCenter[1]))); - aCurAngle = aCurDir->angle(aStartArcDir[1]); - if (anArcAngle[1] < 0.0) aCurAngle *= -1.0; - if (aCurAngle < 0.0 || aCurAngle > fabs(anArcAngle[1])) + aCurAngle = aStartArcDir[1]->angle(aCurDir); + if (aCurAngle < 0.0) + aCurAngle += 2.0 * PI; + if (aCurAngle < 0.0 || aCurAngle > anArcAngle[1]) continue; // incorrect position theTangentB = aCenter[1]->added(aCurDir->xy()->multiplied(anArcRadius[1])); @@ -667,7 +675,7 @@ void getPointOnEdge(const FeaturePtr theFeature, theFeature->attribute(SketchPlugin_Arc::START_ID()))->pnt(); std::shared_ptr aPntEnd = std::dynamic_pointer_cast( theFeature->attribute(SketchPlugin_Arc::END_ID()))->pnt(); - if(theFeature->attribute(SketchPlugin_Arc::REVERSED_ID())) { + if(theFeature->boolean(SketchPlugin_Arc::REVERSED_ID())->value()) { aPntTemp = aPntStart; aPntStart = aPntEnd; aPntEnd = aPntTemp;