Salome HOME
Make cylindrical faces processable by "Vertical faces" filter.
[modules/shaper.git] / src / FiltersPlugin / FiltersPlugin_VerticalFace.cpp
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;
 }