|
OCCT-Light 0.1
C ABI and C++ veneer for multi-language CAD workflows
|
OCCT-Light: STL file I/O (stereolithography mesh format). More...


Go to the source code of this file.
Classes | |
| struct | occtl_io_stl_write_options |
Macros | |
| #define | OCCTL_IO_STL_WRITE_OPTIONS_VERSION_1 1u |
| #define | OCCTL_IO_STL_WRITE_OPTIONS_INIT {OCCTL_IO_STL_WRITE_OPTIONS_VERSION_1, NULL, 0} |
Typedefs | |
| typedef struct occtl_io_stl_write_options | occtl_io_stl_write_options_t |
Functions | |
| void | occtl_io_stl_write_options_init (occtl_io_stl_write_options_t *options) |
| occtl_status_t | occtl_io_stl_read (const char *path, occtl_graph_t **out_graph, occtl_node_id_t *out_root) |
| occtl_status_t | occtl_io_stl_read_memory (const uint8_t *data, size_t size, occtl_graph_t **out_graph, occtl_node_id_t *out_root) |
| occtl_status_t | occtl_io_stl_write (const occtl_graph_t *graph, occtl_node_id_t root, const char *path, const occtl_io_stl_write_options_t *options) |
| occtl_status_t | occtl_io_stl_write_memory (const occtl_graph_t *graph, occtl_node_id_t root, const occtl_io_stl_write_options_t *options, uint8_t *out_data, size_t capacity, size_t *out_size) |
OCCT-Light: STL file I/O (stereolithography mesh format).
Reads and writes STL files (binary and ASCII) via OCCT's DESTL_Provider / DESTL_ConfigurationNode.
STL is mesh-only (no B-spline preservation) — the caller should tessellate with #occtl_mesh_build beforehand if the source is a precise geometry.
UIDs are not preserved across the round-trip — the STL file format has no identity slot. Use occtl_uid_to_bytes / occtl_uid_from_bytes for an out-of-band UID handshake if persistent identity is required.
| typedef struct occtl_io_stl_write_options occtl_io_stl_write_options_t |
Options for occtl_io_stl_write and occtl_io_stl_write_memory. Pass NULL for defaults (binary output).
| occtl_status_t occtl_io_stl_read | ( | const char * | path, |
| occtl_graph_t ** | out_graph, | ||
| occtl_node_id_t * | out_root | ||
| ) |
Reads an STL file and ingests it into a freshly-created graph.
| [in] | path | Borrows it. NUL-terminated UTF-8 path to the file. Must be non-NULL. |
| [out] | out_graph | Owns it. Receives a new graph on success; NULL on failure. |
| [out] | out_root | Borrows it. Receives the NodeId of the root entity. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | path, out_graph, or out_root is NULL. |
| OCCTL_IO_ERROR | File not found or unreadable. |
| OCCTL_FORMAT_ERROR | File contents were not a valid STL stream. |
\par Thread Safety Yes.
| occtl_status_t occtl_io_stl_read_memory | ( | const uint8_t * | data, |
| size_t | size, | ||
| occtl_graph_t ** | out_graph, | ||
| occtl_node_id_t * | out_root | ||
| ) |
Reads an STL payload from caller-owned memory into a freshly-created graph.
| [in] | data | Borrows it. Readable byte buffer containing STL data. Must be non-NULL when size is non-zero. |
| [in] | size | Number of bytes available at data. Must be > 0. |
| [out] | out_graph | Owns it. Receives a new graph on success; NULL on failure. |
| [out] | out_root | Borrows it. Receives the NodeId of the root entity. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | data, out_graph, or out_root is NULL, or size is zero. |
| OCCTL_FORMAT_ERROR | Payload contents were not a valid STL stream. |
| OCCTL_TOPOLOGY_INVALID | Payload decoded but could not be ingested into BRepGraph. |
\par Thread Safety Yes.
| occtl_status_t occtl_io_stl_write | ( | const occtl_graph_t * | graph, |
| occtl_node_id_t | root, | ||
| const char * | path, | ||
| const occtl_io_stl_write_options_t * | options | ||
| ) |
Writes the topology rooted at root to an STL file.
Format (binary/ASCII) is taken from options; pass NULL for default binary output.
| [in] | graph | Borrows it. Must be non-NULL. |
| [in] | root | Root node id to serialise. |
| [in] | path | Borrows it. NUL-terminated UTF-8 path; existing file is overwritten. |
| [in] | options | Borrows it. May be NULL. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | graph or path is NULL; or options has invalid fields (non-NULL p_next, ascii_mode not in {0,1}). |
| OCCTL_NOT_FOUND | root is invalid or has been removed. |
| OCCTL_VERSION_MISMATCH | options has an unsupported struct_version. |
| OCCTL_IO_ERROR | Filesystem failure or unwritable file. |
\par Thread Safety Yes (read-only on graph).
| occtl_status_t occtl_io_stl_write_memory | ( | const occtl_graph_t * | graph, |
| occtl_node_id_t | root, | ||
| const occtl_io_stl_write_options_t * | options, | ||
| uint8_t * | out_data, | ||
| size_t | capacity, | ||
| size_t * | out_size | ||
| ) |
Writes the topology rooted at root to caller-owned memory.
Use the standard two-call buffer pattern: call once with out_data NULL and capacity zero to receive the required byte count in out_size, then call again with a buffer of at least that size.
| [in] | graph | Borrows it. Must be non-NULL. |
| [in] | root | Root node id to serialise. |
| [in] | options | Borrows it. May be NULL. |
| [out] | out_data | Borrows it. Writable output buffer, or NULL for sizing. |
| [in] | capacity | Size of out_data in bytes. |
| [out] | out_size | Borrows it. Receives the required byte count. |
| OCCTL_OK | On success. Sizing calls also return OK. |
| OCCTL_INVALID_ARGUMENT | graph or out_size is NULL; or options has invalid fields (non-NULL p_next, ascii_mode not in {0,1}). |
| OCCTL_NOT_FOUND | root is invalid or has been removed. |
| OCCTL_VERSION_MISMATCH | options has an unsupported struct_version. |
| OCCTL_BUFFER_TOO_SMALL | out_data is non-NULL and capacity is smaller than out_size. |
| OCCTL_IO_ERROR | OCCT failed to serialise the shape. |
\par Thread Safety Yes (read-only on graph).
| void occtl_io_stl_write_options_init | ( | occtl_io_stl_write_options_t * | options | ) |
Initialises options to default values matching OCCTL_IO_STL_WRITE_OPTIONS_INIT.
NULL-tolerant.
| [out] | options | Borrows it. May be NULL (no-op). |
\par Thread Safety Yes.