X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Face.cpp;h=826b8477ae7a5ebb95545ea5dc3040489a29ac0a;hb=3d28bcbab2f3ed0e40295e64f4e836caebc19fca;hp=a455a0aaa8b89cfa6f24fdfe7038b63d5ca27905;hpb=c852965b2300f81aea972fe2a8013f495c61cba3;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Face.cpp b/src/GeomAPI/GeomAPI_Face.cpp index a455a0aaa..826b8477a 100644 --- a/src/GeomAPI/GeomAPI_Face.cpp +++ b/src/GeomAPI/GeomAPI_Face.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: GeomAPI_Face.cpp // Created: 2 Dec 2014 // Author: Artem ZHIDKOV @@ -11,8 +13,12 @@ #include #include #include +#include #include #include +#include +#include +#include GeomAPI_Face::GeomAPI_Face() : GeomAPI_Shape() @@ -61,25 +67,42 @@ bool GeomAPI_Face::isPlanar() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); 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; } -std::shared_ptr GeomAPI_Face::getPlane() const +bool GeomAPI_Face::isCylindrical() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); 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_Face::getPlane() const +{ + const TopoDS_Shape& aShape = const_cast(this)->impl(); + BRepAdaptor_Surface aSurfAdapt(TopoDS::Face(aShape)); - if (!aSurf->IsKind(STANDARD_TYPE(Geom_Plane))) + if (aSurfAdapt.GetType() != GeomAbs_Plane) return std::shared_ptr(); // Obtain central point double aUMin, aUMax, aVMin, aVMax; - aSurf->Bounds(aUMin, aUMax, aVMin, aVMax); + aUMin = aSurfAdapt.FirstUParameter(); + aUMax = aSurfAdapt.LastUParameter(); + aVMin = aSurfAdapt.FirstVParameter(); + aVMax = aSurfAdapt.LastVParameter(); gp_Pnt aCentralPnt; gp_Vec aDU, aDV; - aSurf->D1((aUMin+aUMax)*0.5, (aVMin+aVMax)*0.5, aCentralPnt, aDU, aDV); + aSurfAdapt.D1((aUMin+aUMax)*0.5, (aVMin+aVMax)*0.5, aCentralPnt, aDU, aDV); std::shared_ptr aCenter( new GeomAPI_Pnt(aCentralPnt.X(), aCentralPnt.Y(), aCentralPnt.Z()));