From: azv Date: Fri, 31 Jan 2020 14:40:17 +0000 (+0300) Subject: Avoid error messages while constructing ellipse/elliptic arc when major axis is degen... X-Git-Tag: V9_5_0a1~41 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2231d4ba3833486bfb36c85220e0b2ab9c3f8849;p=modules%2Fshaper.git Avoid error messages while constructing ellipse/elliptic arc when major axis is degenerated. --- diff --git a/src/SketchPlugin/SketchPlugin_MacroEllipse.cpp b/src/SketchPlugin/SketchPlugin_MacroEllipse.cpp index 2cf1cbc7f..630b735ce 100644 --- a/src/SketchPlugin/SketchPlugin_MacroEllipse.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroEllipse.cpp @@ -44,6 +44,7 @@ #include #include +static const double TOLERANCE = 1.e-7; SketchPlugin_MacroEllipse::SketchPlugin_MacroEllipse() : SketchPlugin_SketchEntity(), @@ -169,6 +170,9 @@ void SketchPlugin_MacroEllipse::attributeChanged(const std::string& theID) anEllipsePoints[0]->setY(0.5 * (anEllipsePoints[0]->y() + anEllipsePoints[1]->y())); } + if (anEllipsePoints[0]->distance(anEllipsePoints[1]) < TOLERANCE) + return; // ellipse is not valid + std::shared_ptr anEllipse; if (aNbInitialized == 2) { GeomDir2dPtr aXDir(new GeomAPI_Dir2d(anEllipsePoints[1]->x() - anEllipsePoints[0]->x(), diff --git a/src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp b/src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp index 3b6e33059..86f469d0b 100644 --- a/src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp @@ -42,6 +42,7 @@ #include +const double TOLERANCE = 1.e-7; const double paramTolerance = 1.e-4; const double PI = 3.141592653589793238463; @@ -132,6 +133,9 @@ void SketchPlugin_MacroEllipticArc::attributeChanged(const std::string& theID) myStartPnt = anEllipsePoints[2]; myEndPnt = anEllipsePoints[3]; + if (myCenter->distance(myMajorAxis) < TOLERANCE) + return; // ellipse is not valid + std::shared_ptr anEllipse; if (aNbInitialized == 2) { GeomDir2dPtr aXDir(new GeomAPI_Dir2d(anEllipsePoints[1]->x() - anEllipsePoints[0]->x(), diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index d12e746ea..408781f16 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -421,6 +421,8 @@ tooltip="Passed point coordinates" accept_expressions="0" enable_value="enable_by_preferences"/> + + + + + + + +