From 12aa281c9fb9fc4f6ec1e4d26b02e8d022129832 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 29 May 2015 12:37:18 +0300 Subject: [PATCH] Issue #583: Provide validator for cylindrical face --- src/ConstructionPlugin/axis_widget.xml | 1 + src/GeomAPI/GeomAPI_Face.cpp | 8 ++++++++ src/GeomAPI/GeomAPI_Face.h | 3 +++ src/GeomValidators/GeomValidators_Face.cpp | 1 + 4 files changed, 13 insertions(+) diff --git a/src/ConstructionPlugin/axis_widget.xml b/src/ConstructionPlugin/axis_widget.xml index 38638ecf5..97796f302 100644 --- a/src/ConstructionPlugin/axis_widget.xml +++ b/src/ConstructionPlugin/axis_widget.xml @@ -25,6 +25,7 @@ icon=":icons/circle.png" tooltip="Select a cylindrical object" shape_types="face solid shell"> + diff --git a/src/GeomAPI/GeomAPI_Face.cpp b/src/GeomAPI/GeomAPI_Face.cpp index b56959835..4b3004759 100644 --- a/src/GeomAPI/GeomAPI_Face.cpp +++ b/src/GeomAPI/GeomAPI_Face.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include GeomAPI_Face::GeomAPI_Face() @@ -69,6 +70,13 @@ bool GeomAPI_Face::isPlanar() const return isPlanar.IsPlanar() == Standard_True; } +bool GeomAPI_Face::isCylindrical() const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape)); + return aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) == Standard_True; +} + std::shared_ptr GeomAPI_Face::getPlane() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); diff --git a/src/GeomAPI/GeomAPI_Face.h b/src/GeomAPI/GeomAPI_Face.h index 96d637fde..7a22c9429 100644 --- a/src/GeomAPI/GeomAPI_Face.h +++ b/src/GeomAPI/GeomAPI_Face.h @@ -30,6 +30,9 @@ public: /// Returns true if the face is a planar face bool isPlanar() const; + /// Returns true if the face is a cylindrical face + bool isCylindrical() const; + /// Returns the base plane of the face (if it is planar) with location in the center of the face std::shared_ptr getPlane() const; }; diff --git a/src/GeomValidators/GeomValidators_Face.cpp b/src/GeomValidators/GeomValidators_Face.cpp index 0fe74f808..95d100d70 100644 --- a/src/GeomValidators/GeomValidators_Face.cpp +++ b/src/GeomValidators/GeomValidators_Face.cpp @@ -57,6 +57,7 @@ bool GeomValidators_Face::isValid(const AttributePtr& theAttribute, aValid = aGeomFace->isPlanar(); break; case GeomAbs_Cylinder: + aValid = aGeomFace->isCylindrical(); break; default: break; -- 2.30.2