How check if a surface is planar

Hello,

I have the problem to check if a "face" of an imported shape is a plane face.

I have checked the face with :

TopoDS_Face aFace = TopoDS::Face(aSubShape);
Handle(Geom_Surface) Surface = BRep_Tool::Surface(aFace);
if (Surface->IsKind(STANDARD_TYPE(Geom_Plane))) {...}

In this way no faces was idetified as "plane". This work only for solid builded in my application with extrusione and so on, but it doesn't work for surface read from IGES.

Have anyone a way to check if a surface is a "Plane" surface ?

Thank

Dennis G.'s picture

Hello Antonio!

You might do the following:

#include
.
.
.
GeomAdaptor_Surface theGASurface(Surface);
if(theGASurface.GetType() == GeomAbs_Plane)
{
// do stuff
}

Best regards,

Dennis

Marco Balen's picture

Hello Dennis,

I have tried your suggestion and the behaviour is the same.

I am checking the plane :

- building a plane with 3 points of UV system of the bounded surface
- checking that some other 3 points lies on the surface

this is the code :

if (Surface->IsKind(STANDARD_TYPE(Geom_BoundedSurface)) ){
gp_Pnt Orig = Surface->Value(0,0);
gp_Pnt Uv = Surface->Value(1,0);
gp_Pnt Vv = Surface->Value(0,1);

gce_MakePln PlnMaker(Orig,Uv,Vv);
if (PlnMaker.IsDone()) {
ThePlane = PlnMaker.Value();
double D1=ThePlane.Distance(Surface->Value(0.5,0.));
double D2=ThePlane.Distance(Surface->Value(0.,0.5));
double D3=ThePlane.Distance(Surface->Value(1.,1.));
if (D1

Christian Van der Velden's picture

There is a GeomLib_IsPlanarSurface class that requires a Handle(Geom_Surface) and tolerance.
Cheers, Chris

Marco Balen's picture

This class works well for me.

Thanks