From: mpv Date: Wed, 16 Sep 2020 15:41:15 +0000 (+0300) Subject: Fix for the issue #19932 : Fillet fails in python with all in features Fuse inputs X-Git-Tag: V9_6_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=db0bda841e8d70e188a800f3a662d259246d4a20;p=modules%2Fshaper.git Fix for the issue #19932 : Fillet fails in python with all in features Fuse inputs Support the whole feature referencing in searching of the new context. --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 369fb52a7..e0b1a84cc 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -2052,24 +2052,28 @@ ResultPtr Model_AttributeSelection::newestContext( //if (aResult->groupName() == ModelAPI_ResultBody::group()) { // try to search newer context by the concealment references // take references to all results: root one, any sub - std::list allRes; + std::list allRes; ResultPtr aCompContext; ResultBodyPtr aCompBody = ModelAPI_Tools::bodyOwner(aResult, true); if (aCompBody.get()) { - ModelAPI_Tools::allSubs(aCompBody, allRes); - allRes.push_back(aCompBody); + std::list allSub; + ModelAPI_Tools::allSubs(aCompBody, allSub); + for(std::list::iterator anIt = allSub.begin(); anIt != allSub.end(); anIt++) + allRes.push_back((*anIt)->data()); + allRes.push_back(aCompBody->data()); aCompContext = aCompBody; } if (allRes.empty()) - allRes.push_back(aResult); + allRes.push_back(aResult->data()); + allRes.push_back(aResult->document()->feature(aResult)->data()); bool aFoundReferernce = false; - for (std::list::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) { - ResultPtr aResCont = *aSub; - ResultBodyPtr aResBody = std::dynamic_pointer_cast(aResCont); + for (std::list::iterator aSub = allRes.begin(); aSub != allRes.end(); aSub++) { + DataPtr aResCont = *aSub; + ResultBodyPtr aResBody = std::dynamic_pointer_cast(aResCont->owner()); if (aResBody.get() && aResBody->numberOfSubs() > 0 && aResBody != aCompContext) continue; // only lower and higher level subs are counted - const std::set& aRefs = aResCont->data()->refsToMe(); + const std::set& aRefs = aResCont->refsToMe(); std::set::const_iterator aRef = aRefs.begin(); for (; !aFindNewContext && aRef != aRefs.end(); aRef++) { if (!aRef->get() || !(*aRef)->owner().get()) diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 4f8899641..0934b4d05 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -265,4 +265,5 @@ ADD_UNIT_TESTS(TestConstants.py Test19707.py Test19726.py Test19912.py + Test19932.py ) diff --git a/src/ModelAPI/Test/Test19932.py b/src/ModelAPI/Test/Test19932.py new file mode 100644 index 000000000..219a56205 --- /dev/null +++ b/src/ModelAPI/Test/Test19932.py @@ -0,0 +1,52 @@ +# 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() +### Create Part +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +### Create Sketch +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +### Create SketchCircle +SketchCircle_1 = Sketch_1.addCircle(-10, 10, 20) +model.do() +### Create Sketch +Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +### Create SketchCircle +SketchCircle_2 = Sketch_2.addCircle(10, -10, 20) +model.do() +### Create Extrusion +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r")], model.selection(), 20, 0) +### Create Extrusion +Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2r")], model.selection(), 10, 0) +### Create Fuse +Fuse_1 = model.addFuse(Part_1_doc, [model.selection("COMPOUND", "all-in-Extrusion_1"), model.selection("COMPOUND", "all-in-Extrusion_2")], removeEdges = True, keepSubResults = True) +### Create Fillet +Fillet_1 = model.addFillet(Part_1_doc, [model.selection("FACE", "Extrusion_1_1/To_Face")], 1, keepSubResults = True) +model.end() + +# check the fillet validity +from ModelAPI import * +aFactory = ModelAPI_Session.get().validators() +assert(aFactory.validate(Fillet_1.feature())) + +assert(model.checkPythonDump())