]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Avoid error messages while constructing ellipse/elliptic arc when major axis is degen...
authorazv <azv@opencascade.com>
Fri, 31 Jan 2020 14:40:17 +0000 (17:40 +0300)
committerazv <azv@opencascade.com>
Fri, 31 Jan 2020 14:40:50 +0000 (17:40 +0300)
src/SketchPlugin/SketchPlugin_MacroEllipse.cpp
src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp
src/SketchPlugin/plugin-Sketch.xml

index 2cf1cbc7f011bcf9ff4c7a6e314d46c57f395705..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(),
index 3b6e33059e0cd07188700c202c5af09c2234ac1e..86f469d0bf6fa67132ce6e1a4a15b5382d1de651 100644 (file)
@@ -42,6 +42,7 @@
 #include <GeomAlgoAPI_PointBuilder.h>
 
 
+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<GeomAPI_Ellipse2d> anEllipse;
   if (aNbInitialized == 2) {
     GeomDir2dPtr aXDir(new GeomAPI_Dir2d(anEllipsePoints[1]->x() - anEllipsePoints[0]->x(),
index d12e746ea1616956c50296e468de8480baaec6c0..408781f166c776275800dbd6df2631bce2db1b28 100644 (file)
                                      tooltip="Passed point coordinates"
                                      accept_expressions="0"
                                      enable_value="enable_by_preferences"/>
+            <validator id="GeomValidators_Different" parameters="first_point,second_point,passed_point"/>
+            <validator id="SketchPlugin_DifferentPointReference" parameters="first_point_ref,second_point_ref"/>
           </box>
           <box id="by_major_axis_and_point"
                icon="icons/Sketch/ellipse_axes_32x32.png"
                                      tooltip="Passed point coordinates"
                                      accept_expressions="0"
                                      enable_value="enable_by_preferences"/>
+            <validator id="GeomValidators_Different" parameters="first_point_1,second_point_1,passed_point_1"/>
+            <validator id="SketchPlugin_DifferentPointReference" parameters="first_point_ref_1,second_point_ref_1"/>
           </box>
         </toolbox>
         <labelvalue id="major_radius"
                    default="false"
                    obligatory="0"
                    change_visual_attributes="true"/>
+        <validator id="GeomValidators_Different" parameters="center,major_axis_point"/>
+        <validator id="SketchPlugin_DifferentPointReference" parameters="center_ref,major_axis_point_ref"/>
+        <validator id="GeomValidators_Different" parameters="start_point,end_point"/>
+        <validator id="SketchPlugin_DifferentPointReference" parameters="start_point_ref,end_point_ref"/>
       </feature>
     </group>