Write STL to string


I'm wondering if there is a way to write the Stereolithography (STL) data from a TopoDS_Shape to a container in program memory instead of to a file on disk.

I'm building an application where one component needs to read an STL file for a lot of objects and I don't want the disk I/O overhead.



Forum supervisor's picture

Hello John,

We have sent a private reply to you - please, check your mailbox.

Best regards,

Forum supervisor

Hugues Delorme's picture

Hello John,

You can use the gmio library.

gmio supports writting the internal triangulation of TopoDS_Shape objects, see here for the list of supported OpenCascade classes.

gmio works on "abstract" streams it's not limited to files.

You can easily provide a stream of your own that writes to a memory block.

Note that gmio provides also ready-to-use streams for QIODevice and C++ std streams.