Salome HOME
Avoid error messages while constructing ellipse/elliptic arc when major axis is degen...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_MacroEllipse.cpp
index e1e79e3aedac61736e6a65b37a920ec6cba00d3e..630b735cef0f956daff11f63a1b0b21db302aeed 100644 (file)
@@ -44,6 +44,7 @@
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_PointBuilder.h>
 
+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<GeomAPI_Ellipse2d> anEllipse;
     if (aNbInitialized == 2) {
       GeomDir2dPtr aXDir(new GeomAPI_Dir2d(anEllipsePoints[1]->x() - anEllipsePoints[0]->x(),
@@ -380,5 +384,9 @@ AISObjectPtr SketchPlugin_MacroEllipse::getAISObject(AISObjectPtr thePrevious)
   if (!anAIS)
     anAIS.reset(new GeomAPI_AISObject());
   anAIS->createShape(aCompound);
+
+  // Modify attributes
+  SketchPlugin_Tools::customizeFeaturePrs(anAIS, boolean(AUXILIARY_ID())->value());
+
   return anAIS;
 }