Salome HOME
Issue #24015: Align major ellipse axis
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Fri, 5 Mar 2021 20:20:55 +0000 (23:20 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Fri, 5 Mar 2021 20:21:30 +0000 (23:21 +0300)
Fix crash on computation of the intersection point for two identical lines.

src/GeomAPI/GeomAPI_Lin2d.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/Test/Test24015.py [new file with mode: 0644]

index f0a876a8aa44abe1b981d6204ad44e5450051bda..8d0278b31622fda4e31a0751c830c844a95e96f8 100644 (file)
@@ -80,8 +80,8 @@ const std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Lin2d::intersect(
     const std::shared_ptr<GeomAPI_Lin2d>& theLine) const
 {
   IntAna2d_AnaIntersection anInter(*MY_LIN2D, theLine->impl<gp_Lin2d>());
-  if (!anInter.IsDone() || anInter.IsEmpty())
-  return std::shared_ptr<GeomAPI_Pnt2d>();
+  if (!anInter.IsDone() || anInter.NbPoints() == 0)
+    return std::shared_ptr<GeomAPI_Pnt2d>();
   const gp_Pnt2d& aResult = anInter.Point(1).Value();
   return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aResult.X(), aResult.Y()));
 }
index 285ac997d3e03b4ef6695ff3c87ce16f1937de83..938382105f4a0876664e8caa6d76b88bacfce7fa 100644 (file)
@@ -236,6 +236,7 @@ ADD_UNIT_TESTS(
   Test20274_1.py
   Test20274_2.py
   Test20274_3.py
+  Test24015.py
 
   TestArcBehavior.py
   TestBSplineAddPole.py
diff --git a/src/SketchPlugin/Test/Test24015.py b/src/SketchPlugin/Test/Test24015.py
new file mode 100644 (file)
index 0000000..c972d2b
--- /dev/null
@@ -0,0 +1,49 @@
+# Copyright (C) 2021  CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(-62.43672548686145, -3.439140342201228, 39.05146750980462, 70.99404207935532)
+SketchLine_1.setAuxiliary(True)
+
+### Create SketchEllipse
+SketchEllipse_1 = Sketch_1.addEllipse(-11.02958888389993, 34.2637358599971, -5.505025597864623, 77.21113625278682, 25)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_2, SketchLine_3] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+Sketch_1.setCoincident(SketchLine_1.result(), SketchEllipse_1.center())
+Sketch_1.setLength(SketchLine_3.result(), 50)
+Sketch_1.setLength(SketchLine_2.result(), 100)
+
+### Create SketchConstraintAngle
+Sketch_1.setAngle(SketchLine_1.result(), SketchLine_2.result(), 0, type = "Direct")
+model.do()
+
+model.end()
+
+assert(Sketch_1.feature().error() == "")