From: azv Date: Thu, 6 Apr 2017 11:26:38 +0000 (+0300) Subject: Issue #2106: Arc transformed in line problem X-Git-Tag: V_2.7.0~46 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=100a42cd50aa7fa072f55c6558d81ac8a0502477;p=modules%2Fshaper.git Issue #2106: Arc transformed in line problem --- diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index ca7579d86..e818241d0 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -37,7 +37,7 @@ #include #include // for sqrt on Linux -#include +#include const double tolerance = 1e-7; const double paramTolerance = 1.e-4; @@ -99,16 +99,21 @@ void SketchPlugin_Arc::execute() aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); std::shared_ptr aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z())); - GeomShapePtr anArcShape = boolean(REVERSED_ID())->value() ? - GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, anEnd, aStart, aNormal) - : GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStart, anEnd, aNormal); - if (myParamBefore == 0) { // parameter has not been calculate yet std::shared_ptr aCircleForArc( new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt())); aCircleForArc->parameter(anEndAttr->pnt(), paramTolerance, myParamBefore); } + GeomShapePtr anArcShape; + if (fabs(myParamBefore - 2.0 * PI) < paramTolerance) + anArcShape = GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aStart->distance(aCenter)); + else { + anArcShape = boolean(REVERSED_ID())->value() ? + GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, anEnd, aStart, aNormal) + : GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStart, anEnd, aNormal); + } + std::shared_ptr aResult = document()->createConstruction(data(), 1); aResult->setShape(anArcShape); aResult->setIsInHistory(false); @@ -245,6 +250,9 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) } data()->blockSendAttributeUpdated(aWasBlocked, false); } + if (fabs(aParameterNew) < paramTolerance || + fabs(aParameterNew - 2.0 * PI) < paramTolerance) + aParameterNew = 2.0 * PI; myParamBefore = aParameterNew; } }