From: mpv Date: Thu, 17 Sep 2020 15:20:29 +0000 (+0300) Subject: Fix for the issue #19989 : Sketch in error after edit and apply on Fuse (without... X-Git-Tag: V9_6_0a1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ba71135a8b45672f032240b22086d4b17b7b0b97;p=modules%2Fshaper.git Fix for the issue #19989 : Sketch in error after edit and apply on Fuse (without having changed anything) --- diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index fd33d7724..7e8c253b6 100644 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -336,7 +336,22 @@ void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape, TDF_Label anAccess2 = std::dynamic_pointer_cast( ModelAPI_Session::get()->moduleDocument())->generalLabel(); TDF_Label anOriginalLabel; + TopTools_ListOfShape anOldList; if (!isShapeInTree(aData->shapeLab(), anAccess2, aShapeOld, anOriginalLabel)) { + if (aShapeOld.ShapeType() == TopAbs_COMPOUND) { // check this could be a compund by a whole feature selection + for(TopoDS_Iterator aCompIter(aShapeOld); aCompIter.More(); aCompIter.Next()) { + if (isShapeInTree(aData->shapeLab(), anAccess2, aCompIter.Value(), anOriginalLabel)) { + anOldList.Append(aCompIter.Value()); + } else { + anOldList.Clear(); + break; + } + } + } + } else { + anOldList.Append(aShapeOld); + } + if (anOldList.IsEmpty()) { if (aBuilder->NamedShape()->Get().IsNull()) { // store as primitive if alone anyway aBuilder->Generated(aShapeNew); } @@ -345,8 +360,10 @@ void Model_BodyBuilder::storeModified(const GeomShapePtr& theOldShape, myBuilders.erase(0); aBuilder = builder(0); } - - aBuilder->Modify(aShapeOld, aShapeNew); + TopTools_ListIteratorOfListOfShape anOldIter(anOldList); + for(; anOldIter.More(); anOldIter.Next()) { + aBuilder->Modify(anOldIter.Value(), aShapeNew); + } // store information about the external document reference to restore old shape on open storeExternalReference(anOriginalLabel, aBuilder->NamedShape()->Label()); } diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 0934b4d05..dd2f4acd9 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -266,4 +266,5 @@ ADD_UNIT_TESTS(TestConstants.py Test19726.py Test19912.py Test19932.py + Test19989.py ) diff --git a/src/ModelAPI/Test/Test19989.py b/src/ModelAPI/Test/Test19989.py new file mode 100644 index 000000000..c38a59db6 --- /dev/null +++ b/src/ModelAPI/Test/Test19989.py @@ -0,0 +1,51 @@ +# 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() +Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY")) +SketchCircle_1 = Sketch_1.addCircle(12, 10, 8) +model.do() +Sketch_2 = model.addSketch(partSet, model.defaultPlane("XOY")) +SketchCircle_2 = Sketch_2.addCircle(24, 10, 8) +model.do() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 10, 0) +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_2/Face-SketchCircle_2_2r")], model.selection(), 12, 0) +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1"), model.selection("COMPOUND", "all-in-Extrusion_2")], keepSubResults = True) +ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), [model.selection("COMPOUND", "all-in-Fuse_1")]) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Fuse_1_1/Modified_Face&Extrusion_1_1/To_Face")) +SketchCircle_3 = Sketch_3.addCircle(32, 10, 2) +ExtrusionCut_1.setNestedSketch(Sketch_3) +Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Extrusion_2_1/To_Face")]) +model.end() + +# cause the update in the history for the group +model.begin() +Part_1_doc.setCurrentFeature(Fuse_1.feature(), True) +model.do() +Part_1_doc.setCurrentFeature(Group_1.feature(), True) +model.end() + +assert(ExtrusionCut_1.feature().firstResult().shape().isSubShape(Group_1.groupList().value(0).value())) + +assert(model.checkPythonDump())