From: azv Date: Fri, 1 Nov 2019 09:35:47 +0000 (+0300) Subject: Issue #17924: filter F5 on geometry for faces X-Git-Tag: V9_5_0a1~167^2~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=026f5b80ebe2c718246d80f9cb9bea3887406c12;p=modules%2Fshaper.git Issue #17924: filter F5 on geometry for faces Extend comparison of underlying geometry to surfaces of extrusion and revolution to work correctly on elliptical arcs. --- diff --git a/src/FiltersPlugin/CMakeLists.txt b/src/FiltersPlugin/CMakeLists.txt index 1f01c4e44..9e9977276 100644 --- a/src/FiltersPlugin/CMakeLists.txt +++ b/src/FiltersPlugin/CMakeLists.txt @@ -191,4 +191,5 @@ ADD_UNIT_TESTS( TestFilter_TopoConnectedFaces_Prop_Exclude_Face3.py Test2946.py Test2951.py + Test17924.py ) diff --git a/src/FiltersPlugin/Test/Test17924.py b/src/FiltersPlugin/Test/Test17924.py new file mode 100644 index 000000000..2ec411eda --- /dev/null +++ b/src/FiltersPlugin/Test/Test17924.py @@ -0,0 +1,58 @@ +# 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 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")) +SketchEllipticArc_1 = Sketch_1.addEllipticArc(-10.32877055751729, 9.639944794047965, 15.50521682336113, 20.50671907502198, 14.00087220087917, 9.066138556306997, -21.07385236240306, -7.836309501397333, False) +[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_1, SketchLine_2] = SketchEllipticArc_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux") +SketchLine_3 = Sketch_1.addLine(14.00087220087917, 9.066138556306999, -27.08576797296286, 16.56662668932342) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchEllipticArc_1.startPoint(), SketchLine_3.startPoint()) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchEllipticArc_1.result()) +SketchLine_4 = Sketch_1.addLine(-21.07385236240307, -7.836309501397318, 6.541391110246827, 27.42439482327214) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchEllipticArc_1.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchEllipticArc_1.result()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), 50, 0) +FilterFace = model.filters(Part_1_doc, [model.addFilter(name = "OnGeometry", args = [model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchEllipticArc_1")])]) +model.end() + +Reference = { + model.selection("FACE", "Extrusion_1_1_1/From_Face"): False, + model.selection("FACE", "Extrusion_1_1_1/To_Face"): False, + model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchEllipticArc_1"): True, + model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_4"): False, + model.selection("FACE", "Extrusion_1_1_1/Generated_Face&Sketch_1/SketchLine_3"): False, + model.selection("FACE", "Extrusion_1_1_2/To_Face"): False, + model.selection("FACE", "Extrusion_1_1_2/From_Face"): False, + model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchEllipticArc_1"): True, + model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_3"): False, + model.selection("FACE", "Extrusion_1_1_2/Generated_Face&Sketch_1/SketchLine_4"): False, + model.selection("FACE", "Extrusion_1_1_3/To_Face"): False, + model.selection("FACE", "Extrusion_1_1_3/From_Face"): False, + model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_4"): False, + model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchLine_3"): False, + model.selection("FACE", "Extrusion_1_1_3/Generated_Face&Sketch_1/SketchEllipticArc_1"): True +} + +model.checkFilter(Part_1_doc, model, FilterFace, Reference) diff --git a/src/GeomAPI/GeomAPI_Face.cpp b/src/GeomAPI/GeomAPI_Face.cpp index 4af6f9fb1..c6b76d2bd 100644 --- a/src/GeomAPI/GeomAPI_Face.cpp +++ b/src/GeomAPI/GeomAPI_Face.cpp @@ -23,6 +23,7 @@ #include "GeomAPI_Pln.h" #include "GeomAPI_Pnt.h" #include "GeomAPI_Sphere.h" +#include "GeomAPI_Curve.h" #include "GeomAPI_Cylinder.h" #include "GeomAPI_Cone.h" #include "GeomAPI_Torus.h" @@ -40,9 +41,12 @@ #include #include #include +#include +#include #include #include #include +#include #include #include #include @@ -174,7 +178,28 @@ bool GeomAPI_Face::isSameGeometry(const std::shared_ptr theShape) { GeomCylinderPtr anOwnCyl = getCylinder(); GeomCylinderPtr anOtherCyl = anOther->getCylinder(); - return anOwnCyl && anOtherCyl && anOwnCyl->isCoincident(anOtherCyl); + if (anOwnCyl && anOtherCyl) + return anOwnCyl->isCoincident(anOtherCyl); + + // compare two swept surfaces of the same type + if ((anOwnSurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) && + anOtherSurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) || + (anOwnSurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution)) && + anOtherSurf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution)))) { + Handle(Geom_SweptSurface) anOwnSwept = Handle(Geom_SweptSurface)::DownCast(anOwnSurf); + Handle(Geom_SweptSurface) anOtherSwept = Handle(Geom_SweptSurface)::DownCast(anOtherSurf); + + const gp_Dir& anOwnDir = anOwnSwept->Direction(); + const gp_Dir& anOtherDir = anOtherSwept->Direction(); + + if (anOwnDir.IsParallel(anOtherDir, Precision::Angular())) { + Handle(Geom_Curve) anOwnCurve = anOwnSwept->BasisCurve(); + Handle(Geom_Curve) anOtherCurve = anOtherSwept->BasisCurve(); + GeomAPI_ExtremaCurveCurve anExtrema(anOwnCurve, anOtherCurve); + return anExtrema.Extrema().IsParallel() && + anExtrema.TotalLowerDistance() < Precision::Confusion(); + } + } } return false;