]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #583: Provide validator for cylindrical face
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 29 May 2015 09:37:18 +0000 (12:37 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 29 May 2015 09:37:18 +0000 (12:37 +0300)
src/ConstructionPlugin/axis_widget.xml
src/GeomAPI/GeomAPI_Face.cpp
src/GeomAPI/GeomAPI_Face.h
src/GeomValidators/GeomValidators_Face.cpp

index 38638ecf59aca9a4297041c2ef54a9aca7d4dddf..97796f3025a845ed53ec51095e69b52057c86b77 100644 (file)
@@ -25,6 +25,7 @@
         icon=":icons/circle.png" 
         tooltip="Select a cylindrical object"
         shape_types="face solid shell">
+        <validator id="GeomValidators_Face" parameters="cylinder"/>
       </shape_selector>
     </box>
   </toolbox>
index b569598357b982526ca0221c1332289ac200bbfb..4b300475928fe493a2d309c1eb00efe7e030e57c 100644 (file)
@@ -16,6 +16,7 @@
 #include <BRepAdaptor_Surface.hxx>
 #include <Geom_Surface.hxx>
 #include <Geom_Plane.hxx>
+#include <Geom_CylindricalSurface.hxx>
 #include <GeomLib_IsPlanarSurface.hxx>
 
 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<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
+  Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
+  return aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) == Standard_True;
+}
+
 std::shared_ptr<GeomAPI_Pln> GeomAPI_Face::getPlane() const
 {
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
index 96d637fdea267a17252eeeef6e761a6dd2294ffd..7a22c94294577a215068cb0d21dc689c5aa87773 100644 (file)
@@ -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<GeomAPI_Pln> getPlane() const;
 };
index 0fe74f8082fc6cb2981294994b035494232ce2f7..95d100d706bd4bcd5f5875533fbf8928c569eb51 100644 (file)
@@ -57,6 +57,7 @@ bool GeomValidators_Face::isValid(const AttributePtr& theAttribute,
               aValid = aGeomFace->isPlanar();
               break;
             case GeomAbs_Cylinder:
+              aValid = aGeomFace->isCylindrical();
               break;
             default:
               break;