From 799e7b7d87e8431e7605b217f17931bcc2088267 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Wed, 20 May 2020 16:34:04 +0300 Subject: [PATCH] Issue #3241: Filter "On geometry" does not work for non-canonical surfaces Improve checking of faces on the same underlying surface. --- src/FiltersPlugin/CMakeLists.txt | 1 + src/FiltersPlugin/Test/Test3241.py | 74 ++++++++++++++++++++++++++++++ src/GeomAPI/GeomAPI_Face.cpp | 2 + 3 files changed, 77 insertions(+) create mode 100644 src/FiltersPlugin/Test/Test3241.py diff --git a/src/FiltersPlugin/CMakeLists.txt b/src/FiltersPlugin/CMakeLists.txt index bcec89ff8..5db375f3e 100644 --- a/src/FiltersPlugin/CMakeLists.txt +++ b/src/FiltersPlugin/CMakeLists.txt @@ -200,6 +200,7 @@ ADD_UNIT_TESTS( TestFilter_TopoConnectedFaces_Prop_Exclude_Face3.py Test2946.py Test2951.py + Test3241.py Test17924.py Test17962.py TestFilter_OnLine_Multi.py diff --git a/src/FiltersPlugin/Test/Test3241.py b/src/FiltersPlugin/Test/Test3241.py new file mode 100644 index 000000000..ea375c2bb --- /dev/null +++ b/src/FiltersPlugin/Test/Test3241.py @@ -0,0 +1,74 @@ +# Copyright (C) 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 GeomAPI import * +from SketchAPI import * + +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")) +SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_1 = SketchProjection_1.createdFeature() +SketchCircle_1 = Sketch_1.addCircle(0, 0, 40) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center()) +SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], 40) +model.do() +Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2f"), 10, False) +Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1")) +SketchProjection_2 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchCircle_1"), True) +SketchPoint_2 = SketchProjection_2.createdFeature() +SketchCircle_2 = Sketch_2.addCircle(0, 0, 50) +SketchConstraintCoincidence_2 = Sketch_2.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchCircle_2.center()) +SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_2.results()[1], 50) +model.do() +Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_1"), 10, False) +Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2")) +SketchProjection_3 = Sketch_3.addProjection(model.selection("VERTEX", "Sketch_1/SketchCircle_1"), True) +SketchPoint_3 = SketchProjection_3.createdFeature() +SketchCircle_3 = Sketch_3.addCircle(0, 0, 53) +SketchConstraintCoincidence_3 = Sketch_3.setCoincident(SketchAPI_Point(SketchPoint_3).coordinates(), SketchCircle_3.center()) +SketchConstraintRadius_3 = Sketch_3.setRadius(SketchCircle_3.results()[1], 53) +model.do() +Filling_1_objects = [model.selection("EDGE", "Sketch_1/SketchCircle_1_2"), model.selection("EDGE", "Sketch_2/SketchCircle_2_2"), model.selection("EDGE", "Sketch_3/SketchCircle_3_2")] +Filling_1 = model.addFilling(Part_1_doc, Filling_1_objects) +Sketch_4 = model.addSketch(Part_1_doc, model.standardPlane("XOY")) +SketchProjection_4 = Sketch_4.addProjection(model.selection("VERTEX", "PartSet/Origin"), False) +SketchPoint_4 = SketchProjection_4.createdFeature() +SketchProjection_5 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OX"), True) +SketchLine_1 = SketchProjection_5.createdFeature() +SketchMultiRotation_1 = Sketch_4.addRotation([SketchLine_1.result()], SketchAPI_Point(SketchPoint_4).coordinates(), 360, 12, True) +[SketchLine_1, SketchLine_2, SketchLine_3, SketchLine_4, SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8, SketchLine_9, SketchLine_10, SketchLine_11, SketchLine_12] = SketchMultiRotation_1.rotated() +model.do() +Edge_1 = model.addEdge(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], False) +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Edge_1")], model.selection(), model.selection("FACE", "Plane_2"), 0, model.selection(), 0) +Split_1 = model.addSplit(Part_1_doc, [model.selection("FACE", "Filling_1_1")], [model.selection("COMPOUND", "Extrusion_1_1")], keepSubResults = True) +FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Split_1_1_1")])]) +model.end() + +Reference = {} +ResultSplit = Split_1.result().resultSubShapePair()[0] +exp = GeomAPI_ShapeExplorer(ResultSplit.shape(), GeomAPI_Shape.FACE) +while exp.more(): + Reference[model.selection(ResultSplit, exp.current())] = True + exp.next() +model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/GeomAPI/GeomAPI_Face.cpp b/src/GeomAPI/GeomAPI_Face.cpp index 23f18f5dc..4df502275 100644 --- a/src/GeomAPI/GeomAPI_Face.cpp +++ b/src/GeomAPI/GeomAPI_Face.cpp @@ -144,6 +144,8 @@ bool GeomAPI_Face::isSameGeometry(const std::shared_ptr theShape) Handle(Geom_Surface) anOwnSurf = baseSurface(anOwnFace); Handle(Geom_Surface) anOtherSurf = baseSurface(anOtherFace); + if (anOwnSurf == anOtherSurf) + return true; // case of two elementary surfaces if (anOwnSurf->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) && -- 2.39.2