From 90b8e5b49e8654b43df7f8f5cac9dd183c881f48 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Fri, 5 Mar 2021 23:20:55 +0300 Subject: [PATCH] Issue #24015: Align major ellipse axis Fix crash on computation of the intersection point for two identical lines. --- src/GeomAPI/GeomAPI_Lin2d.cpp | 4 +-- src/SketchPlugin/CMakeLists.txt | 1 + src/SketchPlugin/Test/Test24015.py | 49 ++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/SketchPlugin/Test/Test24015.py diff --git a/src/GeomAPI/GeomAPI_Lin2d.cpp b/src/GeomAPI/GeomAPI_Lin2d.cpp index f0a876a8a..8d0278b31 100644 --- a/src/GeomAPI/GeomAPI_Lin2d.cpp +++ b/src/GeomAPI/GeomAPI_Lin2d.cpp @@ -80,8 +80,8 @@ const std::shared_ptr GeomAPI_Lin2d::intersect( const std::shared_ptr& theLine) const { IntAna2d_AnaIntersection anInter(*MY_LIN2D, theLine->impl()); - if (!anInter.IsDone() || anInter.IsEmpty()) - return std::shared_ptr(); + if (!anInter.IsDone() || anInter.NbPoints() == 0) + return std::shared_ptr(); const gp_Pnt2d& aResult = anInter.Point(1).Value(); return std::shared_ptr(new GeomAPI_Pnt2d(aResult.X(), aResult.Y())); } diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 285ac997d..938382105 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -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 index 000000000..c972d2b34 --- /dev/null +++ b/src/SketchPlugin/Test/Test24015.py @@ -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() == "") -- 2.39.2