#ifndef EZ3D_STL_WRITE_H #define EZ3D_STL_WRITE_H #include #include #include "triangle.h" typedef struct { FILE *f; int ascii; uint32_t ntri; /* facets written so far */ const char *path; long count_offset; /* file offset of the binary facet-count field */ } stl_writer_t; /* Open the output; writes the 80-byte binary header (or "solid" prologue) * with a placeholder facet count that stl_close() back-patches. */ int stl_open(stl_writer_t *w, const char *path, int ascii); /* Emit one triangle; the facet normal is computed here. */ void stl_tri(stl_writer_t *w, const vertex_t *a, const vertex_t *b, const vertex_t *c); /* Back-patch the facet count and close. Returns facets written, or -1. */ long stl_close(stl_writer_t *w); #endif /* EZ3D_STL_WRITE_H */