From a9e2e7942b9c78aba4e0b6d883b213045a8a10ea Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 24 Oct 2017 12:40:16 +0300 Subject: [PATCH] Issue #2280: Trim in the sketch generates a SIGSEGV Avoid setting constraints onto the Projection feature while trimming. --- src/SketchPlugin/CMakeLists.txt | 1 + src/SketchPlugin/SketchPlugin_Trim.cpp | 3 +- src/SketchPlugin/Test/Test2280.py | 54 ++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/SketchPlugin/Test/Test2280.py diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 1fb666420..4b4c0b15c 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -222,6 +222,7 @@ ADD_UNIT_TESTS(TestSketchPointLine.py TestSignedDistancePointPoint.py TestSignedDistancePointLine.py Test2273.py + Test2280.py ) if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE}) diff --git a/src/SketchPlugin/SketchPlugin_Trim.cpp b/src/SketchPlugin/SketchPlugin_Trim.cpp index d67e97c8c..aedc76332 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.cpp +++ b/src/SketchPlugin/SketchPlugin_Trim.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -1416,7 +1417,7 @@ void SketchPlugin_Trim::fillObjectShapes(const ObjectPtr& theObject, std::dynamic_pointer_cast(theSketch); for (int i = 0; i < aSketchComposite->numberOfSubs(); i++) { FeaturePtr aFeature = aSketchComposite->subFeature(i); - if (aFeature.get()) + if (aFeature.get() && aFeature->getKind() != SketchPlugin_Projection::ID()) aFeatures.push_back(aFeature); } ModelGeomAlgo_Point2D::getPointsIntersectedShape(aFeature, aFeatures, aPointsInfo); diff --git a/src/SketchPlugin/Test/Test2280.py b/src/SketchPlugin/Test/Test2280.py new file mode 100644 index 000000000..d96bf8aac --- /dev/null +++ b/src/SketchPlugin/Test/Test2280.py @@ -0,0 +1,54 @@ +## Copyright (C) 2014-2017 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 +## + +""" + Test2280.py + Test case for issue #2280 "Trim in the sketch generates a SIGSEGV" +""" + +from salome.shaper import model +from GeomAPI import GeomAPI_Pnt2d + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 5, 10) +Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "Cylinder_1_1/Face_2")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("EDGE", "Cylinder_1_1/Face_1&Cylinder_1_1/Face_2"), True) +SketchCircle_1 = SketchProjection_1.createdFeature() +SketchCircle_2 = Sketch_1.addCircle(0.0, 10.0, 8.0) +model.do() + +assert(Sketch_1.feature().error() == "") +assert(Sketch_1.solverError().value() == "") +model.testNbSubFeatures(Sketch_1, "SketchArc", 0) +model.testNbSubFeatures(Sketch_1, "SketchCircle", 2) + +# Trim sircle +SketchTrim_1 = Sketch_1.addTrim(SketchCircle_2, GeomAPI_Pnt2d(0.0, 18.0)) +model.do() + +assert(Sketch_1.feature().error() == "") +assert(Sketch_1.solverError().value() == "") +model.testNbSubFeatures(Sketch_1, "SketchArc", 1) +model.testNbSubFeatures(Sketch_1, "SketchCircle", 1) + +model.end() -- 2.39.2