Salome HOME
Fix for issue #1000
[modules/shaper.git] / src / GeomAPI / GeomAPI_Face.cpp
index ba111a67d1936924af2049b606c934f33b45f4f9..826b8477ae7a5ebb95545ea5dc3040489a29ac0a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Face.cpp
 // Created:     2 Dec 2014
 // Author:      Artem ZHIDKOV
@@ -14,6 +16,9 @@
 #include <BRepAdaptor_Surface.hxx>
 #include <Geom_Surface.hxx>
 #include <Geom_Plane.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <GeomLib_IsPlanarSurface.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
 
 GeomAPI_Face::GeomAPI_Face()
   : GeomAPI_Shape()
@@ -62,9 +67,23 @@ bool GeomAPI_Face::isPlanar() const
 {
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
   Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
-  if (aSurf->IsKind(STANDARD_TYPE(Geom_Plane)))
-    return true;
-  return false;
+  Handle(Geom_RectangularTrimmedSurface) aTrimmed = 
+    Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf);
+  if (!aTrimmed.IsNull())
+    aSurf = aTrimmed->BasisSurface();
+  GeomLib_IsPlanarSurface isPlanar(aSurf);
+  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));
+  Handle(Geom_RectangularTrimmedSurface) aTrimmed = 
+    Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf);
+  if (!aTrimmed.IsNull())
+    aSurf = aTrimmed->BasisSurface();
+  return aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) == Standard_True;
 }
 
 std::shared_ptr<GeomAPI_Pln> GeomAPI_Face::getPlane() const