-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#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;
}