From 6dce44a08e0505613a25d6d093f153d69045b1ce Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 23 Jun 2020 15:56:22 +0300 Subject: [PATCH] Fix for #19707 : fatal error gp_Dir() input vector has zero norm when loading python dump. Make sketch invalid if the a base plane was selected and after this referencing result disappears. --- src/Model/Model_Update.cpp | 7 ++++ src/ModelAPI/CMakeLists.txt | 1 + src/ModelAPI/Test/Test19707.py | 62 ++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 src/ModelAPI/Test/Test19707.py diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 659b7ca9a..bd9c7bfda 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -904,6 +904,13 @@ void Model_Update::updateArguments(FeaturePtr theFeature) { bool isObligatory = aFactory->isCase(theFeature, theFeature->data()->id(aSel)); if (isObligatory) aState = ModelAPI_StateInvalidArgument; + } else if (theFeature->getKind() == "Sketch" && aSel->id() == "External" && + aSel->isInitialized()) { + // #19703 : if sketch plane was selected, but after context disappears, it must become invalid + aSel->update(); + if (aSel->isInvalid()) { + aState = ModelAPI_StateInvalidArgument; + } } } // update the selection list attributes if any diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 461b1aa2e..4f04867ec 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -260,4 +260,5 @@ ADD_UNIT_TESTS(TestConstants.py Test19031.py Test19058.py Test19217.py + Test19707.py ) diff --git a/src/ModelAPI/Test/Test19707.py b/src/ModelAPI/Test/Test19707.py new file mode 100644 index 000000000..1c3b3a5c5 --- /dev/null +++ b/src/ModelAPI/Test/Test19707.py @@ -0,0 +1,62 @@ +# Copyright (C) 2014-2020 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() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-59.0465954847056, -128.5053642637967, 53.14364970069066, -170.5009266857805) +SketchLine_2 = Sketch_1.addLine(53.14364970069066, -170.5009266857805, 137.6705343466976, -112.5874503884433) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(137.6705343466976, -112.5874503884433, 64.87485797099055, -26.90480166687218) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(64.87485797099055, -26.90480166687218, 3.969957323886124, -72.35673939469255) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchLine_5 = Sketch_1.addLine(3.969957323886124, -72.35673939469255, -79.2369959888606, -34.8592213882167) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint()) +SketchLine_6 = Sketch_1.addLine(-79.2369959888606, -34.8592213882167, -59.0465954847056, -128.5053642637967) +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint()) +SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_6.endPoint()) +SketchLine_7 = Sketch_1.addLine(53.14364970069066, -170.5009266857805, 3.969957323886124, -72.35673939469255) +SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_7.endPoint()) +SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_7.startPoint(), SketchLine_1.endPoint()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 10, 0) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_3")) +SketchCircle_1 = Sketch_2.addCircle(110.5461396183937, -4.403937604408839, 25.15832463432426) +model.do() +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2r")], model.selection(), 10, 0) +model.end() + +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Sketch_2.feature())) +assert(aFactory.validate(Extrusion_2.feature())) + +# update the first extrusion to make the second bas plane selection invalid +model.begin() +Extrusion_1.setBase([model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_7f-SketchLine_5f-SketchLine_6f")]) +model.end() + +# check that the second sketch and extrusion become invalid +assert(len(Sketch_2.results()) == 0) +assert(len(Extrusion_2.results()) == 0) -- 2.39.2