Salome HOME
Issue #2998: Add help description for automatic creation of constraints
[modules/shaper.git] / src / FiltersPlugin / FiltersPlugin_VerticalFace.cpp
index 97235249f66144c888292877208d6bacecd3fb71..38bbab5b7dd82c975fe2a428c7668333833ccd91 100644 (file)
 #include <GeomAPI_Shell.h>
 #include <GeomAPI_Cylinder.h>
 
+#include <cmath>
+
 bool FiltersPlugin_VerticalFace::isSupported(GeomAPI_Shape::ShapeType theType) const
 {
   return theType == GeomAPI_Shape::FACE;
 }
 
-bool FiltersPlugin_VerticalFace::isOk(
-  const GeomShapePtr& theShape, const ModelAPI_FiltersArgs& theArgs) const
+bool FiltersPlugin_VerticalFace::isOk(const GeomShapePtr& theShape, const ResultPtr&,
+                                      const ModelAPI_FiltersArgs& theArgs) const
 {
+  static const double THE_TOLERANCE = 1.e-7;
+
+  bool isVertical = false;
   if (!theShape->isFace())
-    return false;
-  if (theShape->isPlanar()) {
-    GeomFacePtr aFace(new GeomAPI_Face(theShape));
+    return isVertical;
 
-    GeomPlanePtr aPlane = aFace->getPlane();
+  GeomFacePtr aFace(new GeomAPI_Face(theShape));
+
+  GeomPlanePtr aPlane = aFace->getPlane();
+  if (aPlane) {
     GeomDirPtr aDir = aPlane->direction();
-    return fabs(aDir->z()) <= 1.e-7;
+    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 false;
+  return isVertical;
 }