]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #17924: filter F5 on geometry for faces
authorazv <azv@opencascade.com>
Fri, 1 Nov 2019 09:35:47 +0000 (12:35 +0300)
committerazv <azv@opencascade.com>
Fri, 1 Nov 2019 09:36:20 +0000 (12:36 +0300)
Extend comparison of underlying geometry to surfaces of extrusion and revolution to work correctly on elliptical arcs.

src/FiltersPlugin/CMakeLists.txt
src/FiltersPlugin/Test/Test17924.py [new file with mode: 0644]
src/GeomAPI/GeomAPI_Face.cpp

index 1f01c4e4447535f7dd1b15fc0bb7370e6f3afdeb..9e997727641f50a16659da68c671a0c3a321fe72 100644 (file)
@@ -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 (file)
index 0000000..2ec411e
--- /dev/null
@@ -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)
index 4af6f9fb10db5a3749e0c9242a87c7bf34be3d87..c6b76d2bd62a286ac34917d5ee2497afafab7941 100644 (file)
@@ -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"
 #include <Geom_OffsetSurface.hxx>
 #include <Geom_Plane.hxx>
 #include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_SurfaceOfLinearExtrusion.hxx>
+#include <Geom_SurfaceOfRevolution.hxx>
 #include <Geom_SweptSurface.hxx>
 #include <Geom_ToroidalSurface.hxx>
 #include <GeomAdaptor_HSurface.hxx>
+#include <GeomAPI_ExtremaCurveCurve.hxx>
 #include <GeomLib_IsPlanarSurface.hxx>
 #include <IntPatch_ImpImpIntersection.hxx>
 #include <IntTools_Context.hxx>
@@ -174,7 +178,28 @@ bool GeomAPI_Face::isSameGeometry(const std::shared_ptr<GeomAPI_Shape> 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;