Creating TopoDS_Shape objects from triangles

Hi,

BRAND new with the API. My inputs are two STL files. I need to know how to get the data (essentially a bunch of triangles, one shape per file) into TopoDS_Shape objects so I can do boolean operations on them?

Is that even possible?

Rob

rob@finitesolutions.com's picture

I should say that I already have code which can open an STL file (binary or ascii) and read in the triangle data. I don't need that part, but I'm happy to replace what I have with other stuff if it's easy. So I guess to simplify the problem my inputs are arrays of vertices, where each three vertices represents one triangle.

It is assumed that the arrays represent completely enclosed 3D geometries. How do I go from those arrays of triangles to a TopoDS_Shape, so I can use the boolean operations?

Rob Bachrach's picture

You can try creating edges for your triangles from your triangle
points, connecting those edges to make wires, creating faces from
the edges, and then shells from the faces. You can then perform
boolean operations on the shells or create solids from the shells
and perform boolean operations on the solids. Understand that the
boolean operations may be slow since there could be a large number
of faces in your geometry.

The classes you will be concerned with are the BRepBuilderAPI_MakeXXX
where XXX is Edge, Wire, Face, Shell, and Solid.

Some shortcuts could be to use BRepBuilderAPI_MakePolygon to create
a wire directly from 3 points (note that the points must be planar).

I hope this gets you started.

rob@finitesolutions.com's picture

It does. I wonder if it's possible to use those classes from VB.NET or C#...

Jonathan Hill's picture

Hi,

I have a set of C# wrapper classes (but not using P/Invoke) which would allow to load in IGES or STEP file and add shapes etc. in .NET using VS 2005.

Jonathan