]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make cylindrical faces processable by "Vertical faces" filter.
authorazv <azv@opencascade.com>
Tue, 30 Jul 2019 09:53:45 +0000 (12:53 +0300)
committerazv <azv@opencascade.com>
Wed, 31 Jul 2019 08:16:50 +0000 (11:16 +0300)
src/FiltersPlugin/FiltersPlugin_VerticalFace.cpp
src/FiltersPlugin/Test/TestFilter_VerticalFaces.py
src/FiltersPlugin/Test/TestFilter_VerticalFaces_Exclude.py

index 9d1883126d501924c7a2b3dcaa086018bc924c39..38bbab5b7dd82c975fe2a428c7668333833ccd91 100644 (file)
@@ -35,12 +35,25 @@ bool FiltersPlugin_VerticalFace::isSupported(GeomAPI_Shape::ShapeType theType) c
 bool FiltersPlugin_VerticalFace::isOk(const GeomShapePtr& theShape, const ResultPtr&,
                                       const ModelAPI_FiltersArgs& theArgs) const
 {
-  if (!theShape->isFace() || !theShape->isPlanar())
-    return false;
+  static const double THE_TOLERANCE = 1.e-7;
+
+  bool isVertical = false;
+  if (!theShape->isFace())
+    return isVertical;
 
   GeomFacePtr aFace(new GeomAPI_Face(theShape));
 
   GeomPlanePtr aPlane = aFace->getPlane();
-  GeomDirPtr aDir = aPlane->direction();
-  return fabs(aDir->z()) <= 1.e-7;
+  if (aPlane) {
+    GeomDirPtr aDir = aPlane->direction();
+    isVertical = fabs(aDir->z()) <= THE_TOLERANCE;
+  }
+  else {
+    GeomCylinderPtr aCylinder = aFace->getCylinder();
+    if (aCylinder) {
+      GeomDirPtr aDir = aCylinder->axis();
+      isVertical = fabs(fabs(aDir->z()) - 1.0) <= THE_TOLERANCE;
+    }
+  }
+  return isVertical;
 }
index b60dfdbc268de8b5a1d01f0c327455afe8613607..1f754c20a3e4da2682c080dff61536753e9b6c91 100644 (file)
@@ -53,7 +53,7 @@ Reference = {
     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Right"): True,
     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Left"): True,
     # Faces of the cylinder
-    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): False,
+    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): True,
     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"): False,
     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_3"): False,
     # Edges and vertices are not applicable
index 655d10295190966223d65d487f8f97bbdd5421a6..da6057cd997671aed221e38d96f4912735880f89 100644 (file)
@@ -53,7 +53,7 @@ Reference = {
     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Right"): False,
     model.selection("FACE", "LinearCopy_1_1_3/MF:Translated&Box_1_1/Left"): False,
     # Faces of the cylinder
-    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): True,
+    model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_1"): False,
     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_2"): True,
     model.selection("FACE", "Translation_1_1/MF:Translated&Cylinder_1_1/Face_3"): True,
     # Edges and vertices are not applicable