Converting TopoDS_Shape to internal format

I'm new to OCCT.  I'm trying to use it to read an IGES file and convert it into the internal data structures of the software package that we write.  I think I've figured out the code to read the IGES file into a TopoDS_Shape object.  I can use Shapetype() to see which TopAbs_XXXX type this shape really is.  From there, I'm kind of stuck.

I figured out how to pull the X/Y/Z coordinates out of a vertex and edge, but I can't figure out how to get the geometric details from any of the more complicated shapes so that I can convert them into our software package's internal data structures.  I think the types I need to convert are COMPOUND, COMPSOLID, SOLID, SHELL, FACE, and WIRE.

Can anybody give me some pointers on that?

Laszlo Kudela's picture

Hello Ben,

conversion between geometry and topology in OpenCASCADE can be done by the static functions of the BRep_Tool class. For example, if oyu have a TopoDS_Face "topoFace" and you want to get the Geom_Surface that is behind this TopoDS_Face, you can call:

Handle_Geom_Surface underlyingSurface = BRep_Tool::Surface(topoFace);

this will return you a handle to the underlying geometry. It works similarly for TopoDS_Edges, to get the underlying Geom_Curves. If you have a wire, you have to visit every edge of the wire (e.g. using TopExp) and convert the edges one-by one to curves. Similarly, a shell is a composition of many faces, so you have to visit the invidual faces in the shell to get the underlying geometry. A solid is a composition of shells, a compound is a composition of anything listed before.

I hope this helps.

László

Ben Hollingsworth's picture

Thanks, that helps.  One more question: when traversing a wire, how do I convert the 2D edges into 3D curves?  Is there a translation somewhere that must be applied, or is there an easier way to convert those edge coordinates into global 3D space?