From: azv Date: Tue, 30 Jul 2019 09:53:45 +0000 (+0300) Subject: Make cylindrical faces processable by "Vertical faces" filter. X-Git-Tag: VEDF2019Lot4~66 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7767d697f98dd9cb07fd0c8ac1ef3b1d77dc82e0;p=modules%2Fshaper.git Make cylindrical faces processable by "Vertical faces" filter. --- diff --git a/src/FiltersPlugin/FiltersPlugin_VerticalFace.cpp b/src/FiltersPlugin/FiltersPlugin_VerticalFace.cpp index 9d1883126..38bbab5b7 100644 --- a/src/FiltersPlugin/FiltersPlugin_VerticalFace.cpp +++ b/src/FiltersPlugin/FiltersPlugin_VerticalFace.cpp @@ -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; } diff --git a/src/FiltersPlugin/Test/TestFilter_VerticalFaces.py b/src/FiltersPlugin/Test/TestFilter_VerticalFaces.py index b60dfdbc2..1f754c20a 100644 --- a/src/FiltersPlugin/Test/TestFilter_VerticalFaces.py +++ b/src/FiltersPlugin/Test/TestFilter_VerticalFaces.py @@ -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 diff --git a/src/FiltersPlugin/Test/TestFilter_VerticalFaces_Exclude.py b/src/FiltersPlugin/Test/TestFilter_VerticalFaces_Exclude.py index 655d10295..da6057cd9 100644 --- a/src/FiltersPlugin/Test/TestFilter_VerticalFaces_Exclude.py +++ b/src/FiltersPlugin/Test/TestFilter_VerticalFaces_Exclude.py @@ -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