0

I have a TopoDS_Face object which comes from a translation of an IGES file. If I parse the IGES file using my own algorithm (written in C) which search for the faces then the loop(s) pointed to by the face and finally the edges in the loop, I can determine whether the face is planar or non-planar(semi-cylindrical in bends). This is done by checking if the edge is a line or an arc based on the form number in the underlying NURBS(entity 126). A line has form 1 and an arc has form 2.

What methods/functions or other mechanism can be used in Open Cascade to determine whether a TopoDS_Face is planar or semi-cylindrical(bends)?

Minathe
  • 630
  • 1
  • 5
  • 21

1 Answers1

1

You can use BRepAdaptor_Surface class to get the type of TopoDS_Face surface:

BRepAdaptor_Surface surface = BRepAdaptor_Surface(face);
if (surface.GetType() == GeomAbs_Plane)
{
  // Surface is a plane
}
else
{
  // Surface is not a plane
}

Update:

The alternate way to define planar surface or not is using a curvature value. For planar surfaces a mean curvature should be equal to 0.

BRepAdaptor_Surface surface = BRepAdaptor_Surface(face);

double u = (surface.FirstUParameter() + surface.LastUParameter()) / 2.0;
double v = (surface.FirstVParameter() + surface.LastVParameter()) / 2.0;

BRepLProp_SLProps surfaceProps(surface, u, v, 2, gp::Resolution());
if (surfaceProps.MeanCurvature() == 0.0)
{
  // Surface is a plane
}
else
{
  // Surface is not a plane
}
  • Added a `cout` to print PLANAR or NON-PLANAR but the output is always NON-PLANAR where it should print PLANAR 12 times and NON-PLANAR twice. – Minathe Apr 08 '19 at 11:12
  • It seems that in the CAD model is no information about surfaces types. In this case a surface curvature value can help. Look at the answer update. – Alexander Trotsenko Apr 08 '19 at 12:06
  • `BRepLProp_SLProps surfaceProps(surface, u, v, 2, gp::Resolution());` there is no method called surfaceProps – Minathe Apr 08 '19 at 12:22
  • That's true because `surfaceProps` is the object name. At this line a `BRepLProp_SLProps` constructor's called. – Alexander Trotsenko Apr 08 '19 at 14:14