Write the name of a solid into STL.

Hello everyone,

is it possible to specify what will be written on the first line of an STL file?

When I run

TopoDS_Shape shape;
// (Get the shape from an assembly...)
BRepMesh_IncrementalMesh BMesh(shape, 0.1, Standard_True);

the first line of the STL file says "solid shape, STL ascii file, created with Open CASCADE Technology".
However, I would like to decide what will follow after the "solid" keyword.

Of course, I could copy it line-by-line into a new file and change the line but that sounds like an unnecessarily complicated approach.


Kirill Gavrilov's picture

There is no such an option in STL writer, yet. But it should be pretty simple to implement - you can contribute a patch to OCCT or use support services.

By the way, in case of Binary format, you don't need to re-write entire file - the header section at the very beginning of file is always 80 bytes long, which can be easily overwritten afterwards.

Hugues Delorme's picture

Hello Dominik,

You can use the gmio library for that.

Call function gmio_stl_write() or gmio_stl_write_file() with :

You can also tune the float format and precision of the output (see stla_float32_format and stla_float32_prec).