From 774a84e18661b69ddf851c5b05574d763bac93df Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 30 Nov 2018 15:22:42 +0300 Subject: [PATCH] Issue #2810: crash creating arc fillet Detect the case when the fillet arc cannot be constructed. --- src/SketchPlugin/CMakeLists.txt | 1 + src/SketchPlugin/SketchPlugin_Fillet.cpp | 8 ++++ src/SketchPlugin/Test/Test2810.py | 48 ++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/SketchPlugin/Test/Test2810.py diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index fd6cd6381..8c8860762 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -191,6 +191,7 @@ ADD_UNIT_TESTS( Test2654.py Test2711.py Test2741.py + Test2810.py TestArcBehavior.py TestConstraintAngle.py TestConstraintCoincidence.py diff --git a/src/SketchPlugin/SketchPlugin_Fillet.cpp b/src/SketchPlugin/SketchPlugin_Fillet.cpp index 3373df8c6..852d006e5 100644 --- a/src/SketchPlugin/SketchPlugin_Fillet.cpp +++ b/src/SketchPlugin/SketchPlugin_Fillet.cpp @@ -104,6 +104,10 @@ void SketchPlugin_Fillet::execute() // create feature for fillet arc FeaturePtr aFilletArc = createFilletArc(); + if (!aFilletArc) { + setError("Error: unable to create a fillet arc."); + return; + } // collect features referred to the edges participating in fillet AttributePoint2DPtr aFilletPoints[2]; @@ -308,6 +312,10 @@ FeaturePtr SketchPlugin_Fillet::createFilletArc() if (!myBaseFeatures[0] || !myBaseFeatures[1]) calculateFilletParameters(); + // fix for issue #2810 (sometimes, myCenterXY is NULL, fillet should report an error) + if (!myCenterXY) + return FeaturePtr(); + // Create arc feature. FeaturePtr aFilletArc = sketch()->addFeature(SketchPlugin_Arc::ID()); diff --git a/src/SketchPlugin/Test/Test2810.py b/src/SketchPlugin/Test/Test2810.py new file mode 100644 index 000000000..413153337 --- /dev/null +++ b/src/SketchPlugin/Test/Test2810.py @@ -0,0 +1,48 @@ +## Copyright (C) 2018-20xx 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 +## + +""" + Test2810.py + Test case for issue #2810 "crash creating arc fillet" +""" + +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchArc_1 = Sketch_1.addArc(10, 10, 11, 10, 10, 11, False) +SketchLine_1 = Sketch_1.addLine(12, 10, 12, 9) +model.do() + +Sketch_1.setFixed(SketchArc_1.results()[1]) +Sketch_1.setFixed(SketchLine_1.result()) + +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.startPoint()) +model.do() + +SketchFillet = Sketch_1.setFillet(SketchArc_1.startPoint()) +model.do() + +assert(Sketch_1.feature().error() != "") + +model.end() -- 2.39.2