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;
}
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
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