From: mpv Date: Thu, 31 Oct 2019 09:41:45 +0000 (+0300) Subject: Fix for the issue #17909 : EDF - Problem of fillet X-Git-Tag: V9_5_0a1~167^2~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=21c3c9a7cf12082f5e6701fb17892a8482739336;p=modules%2Fshaper.git Fix for the issue #17909 : EDF - Problem of fillet --- diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 05957293a..96b6a1e6e 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -537,4 +537,5 @@ ADD_UNIT_TESTS(TestExtrusion.py Test17281.py TestChamfer.py Test3033.py + Test17909.py ) diff --git a/src/FeaturesPlugin/Test/Test17909.py b/src/FeaturesPlugin/Test/Test17909.py new file mode 100644 index 000000000..c1e116bf1 --- /dev/null +++ b/src/FeaturesPlugin/Test/Test17909.py @@ -0,0 +1,87 @@ +# Copyright (C) 2014-2019 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 SketchAPI import * +from GeomAlgoAPI import * +from GeomAPI import * +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +model.addParameter(Part_1_doc, "k", "30") +model.addParameter(Part_1_doc, "M", "10") +model.addParameter(Part_1_doc, "h", "20") +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(15, -8.660254037843767, 15, 8.660254037843762) +SketchLine_2 = Sketch_1.addLine(15, 8.660254037843762, 0, 0) +SketchLine_2.setAuxiliary(True) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(0, 0, 15, -8.660254037843767) +SketchLine_3.setAuxiliary(True) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint()) +SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_1.result()) +SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_1.result()) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_3.startPoint()) +SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result()) +SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_3.startPoint(), SketchLine_1.result(), "k/2", True) +SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_1.result()], SketchLine_3.startPoint(), 360, 6, True) +[SketchLine_4, SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8] = SketchMultiRotation_1.rotated() +SketchCircle_1 = Sketch_1.addCircle(0, 0, 10) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], "M") +SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_3.startPoint()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchCircle_1_2r")], model.selection(), "h", 0) +model.do() +# fillet with only one edge to make correct result and put all edges to results sub-tree +Fillet_1_objects = [model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_6][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7]")] +Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 2) +model.do() +# select all edges as a fillet arguments +aResult = Extrusion_1.results()[0].resultSubShapePair()[0] +aShape = aResult.shape() +aShapeExplorer = GeomAPI_ShapeExplorer(aShape, GeomAPI_Shape.EDGE) +aSelectionList = [] +aLocations = {} # for unique locations support +while aShapeExplorer.more(): + # select only vertical lines + anEdge = aShapeExplorer.current() + if not anEdge.edge().isLine() or anEdge.edge().line().direction().z() < 0.999: + aShapeExplorer.next() + continue + aLoc = anEdge.edge().line().location() + aLocStr = str(aLoc.x()) + " " + str(aLoc.y()) + " " + str(aLoc.z()) + if aLocStr in aLocations: + aShapeExplorer.next() + continue + aLocations[aLocStr] = "" + aSelection = model.selection(aResult, aShapeExplorer.current()) # First argument should be result/sub-result, second is sub-shape on this result/sub-result + aSelectionList.append(aSelection) + aShapeExplorer.next() +# Set the fillet arguments: all edges +Fillet_1.setBase(aSelectionList) + +model.end() + +# if in the fillet base edges names the fillet is used, the python dump should fail +assert(model.checkPythonDump()) diff --git a/src/Selector/Selector_Algo.cpp b/src/Selector/Selector_Algo.cpp index 0c860c517..f6035dc72 100644 --- a/src/Selector/Selector_Algo.cpp +++ b/src/Selector/Selector_Algo.cpp @@ -68,6 +68,8 @@ Selector_Algo::Selector_Algo() static TDF_Label findGoodLabelWithShape(const TDF_Label theAccess, const TopoDS_Shape& theShape) { TDF_Label aResult; + TDF_Label aMyOpLab; + bool aMyOpLabIsComputed = false; if (TNaming_Tool::HasLabel(theAccess, theShape)) { // selection and delete evolution are not used for(TNaming_SameShapeIterator aShapes(theShape, theAccess); aShapes.More(); aShapes.Next()) { @@ -75,6 +77,22 @@ static TDF_Label findGoodLabelWithShape(const TDF_Label theAccess, const TopoDS_ if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { if (aNS->Evolution() == TNaming_MODIFY || aNS->Evolution() == TNaming_GENERATED || aNS->Evolution() == TNaming_PRIMITIVE) { + // getting label of this operation to avoid usage of ready shapes of this + if (!aMyOpLabIsComputed) { + aMyOpLab = theAccess; + if (!aMyOpLab.IsNull()) { + int aDepth = aMyOpLab.Depth(); + if (aDepth < 3) + aMyOpLab.Nullify(); + else { + for(; aDepth != 3; aDepth--) + aMyOpLab = aMyOpLab.Father(); + } + } + aMyOpLabIsComputed = true; + } + if (!aMyOpLab.IsNull() && aNS->Label().IsDescendant(aMyOpLab)) + continue; aResult = aNS->Label(); break; } @@ -158,6 +176,17 @@ Selector_Algo* Selector_Algo::select(const TopoDS_Shape theContext, const TopoDS } return NULL; // not found value in the tree, not found context shape in the tree also } + // getting label of this operation to avoid usage of ready shapes of this + TDF_Label aMyOpLab = theAccess; + if (!aMyOpLab.IsNull()) { + int aDepth = aMyOpLab.Depth(); + if (aDepth < 3) + aMyOpLab.Nullify(); + else { + for(; aDepth != 3; aDepth--) + aMyOpLab = aMyOpLab.Father(); + } + } // searching for the base shapes of the value Handle(TNaming_NamedShape) aPrimitiveNS; NCollection_List aModifList; @@ -170,6 +199,10 @@ Selector_Algo* Selector_Algo::select(const TopoDS_Shape theContext, const TopoDS Handle(TNaming_NamedShape) aNS; if (aShapes.Label().FindAttribute(TNaming_NamedShape::GetID(), aNS)) { TNaming_Evolution anEvolution = aNS->Evolution(); + if (anEvolution == TNaming_SELECTED || anEvolution == TNaming_DELETE) + continue; + if (!aMyOpLab.IsNull() && aNS->Label().IsDescendant(aMyOpLab)) + continue; if (anEvolution == TNaming_PRIMITIVE) { // the value shape is declared as PRIMITIVE aPrimitiveNS = aNS; break;