Reading IGES curved surfaces as BREPs

I'm trying to use OCCT to read IGES files so I can translate them into our proprietary data format, which is BREP-based.  I originally used IGESControl_Reader.TransferRoots() and .OneShape() to create an entity tree, which I parsed recursively.  That works great for flat-sided objects, but it fails miserably for curved surfaces like cylinders.  When reading a half-cylinder as a Face, I'm given only the four corner points.  How am I supposed to know that the edges making up that wire are curved instead of straight?  Is there a way to have OCCT automatically tessellate or otherwise convert the curved surfaces into flat faces for me?  I tried using IGESToBRep_Reader, but the TransferRoots() call keeps segfaulting on me inside IGESToBRep_Actor::Transfer().

What's the best way for me to retrieve an accurate representation of these curved faces?  I'm not afraid tessellating surfaces myself if I can somehow get the proper 3D description.

I'm having a terrible time trying to find any documentation that describes how all of the dozens of IGES classes all work together.

Ben Hollingsworth's picture

OK, I think I figured out how to work around it.  I'm back to using IGESControl_Reader, but now I'm creating a BRepMesh_IncrementalMesh and then retrieving a BRep_Tool::Triangulation for each face, which solves my problem of not following the contour of curved faces.  I do occasionally run into a face for which there is no triangulation, and in those cases, I assume the face is flat and retrieve its wire(s) to represent the outline of the face.

This seems to be working so far for small models, but creating the BRepMesh takes a horribly long time for large models.  Is there any way for me to recognize which faces are curved so that I can just generate a mesh for those faces and not waste the time tessellating the flat faces that I could be importing natively?

Worse yet, the mesh that's created for some surfaces, such as half-cylinders, is horribly overly complex.  If I could somehow find out that the surface was a half-cylinder, I could convert it to a BREP on my own with a small fraction of the flat faces.

What's the best way to accomplish this?