|
OCCT-Light 0.1
C ABI and C++ veneer for multi-language CAD workflows
|
OCCT-Light: unified data-exchange dispatch. More...


Go to the source code of this file.
Classes | |
| struct | occtl_de_format_info |
Macros | |
| #define | OCCTL_DE_FORMAT_INFO_VERSION_1 1u |
| #define | OCCTL_DE_FORMAT_INFO_INIT {OCCTL_DE_FORMAT_INFO_VERSION_1, NULL, NULL, NULL, 0, 0, 0, 0, 0} |
Typedefs | |
| typedef struct occtl_de_format_info | occtl_de_format_info_t |
Functions | |
| void | occtl_de_format_info_init (occtl_de_format_info_t *info) |
| occtl_status_t | occtl_de_read (const char *path, occtl_graph_t **out_graph, occtl_node_id_t *out_root) |
| occtl_status_t | occtl_de_read_memory (const char *format_id, const uint8_t *data, size_t size, occtl_graph_t **out_graph, occtl_node_id_t *out_root) |
| occtl_status_t | occtl_de_write (const occtl_graph_t *graph, occtl_node_id_t root, const char *path) |
| occtl_status_t | occtl_de_write_memory (const occtl_graph_t *graph, occtl_node_id_t root, const char *format_id, uint8_t *out_data, size_t capacity, size_t *out_size) |
| occtl_status_t | occtl_de_format_ids (const char **out_format_ids, size_t cap, size_t *out_count) |
| occtl_status_t | occtl_de_format_count (size_t *out_count) |
| occtl_status_t | occtl_de_format_info_at (size_t index, occtl_de_format_info_t *out_info) |
| occtl_status_t | occtl_de_format_info_by_id (const char *format_id, occtl_de_format_info_t *out_info) |
| occtl_status_t | occtl_de_format_extensions (const char *format_id, const char **out_extensions, size_t cap, size_t *out_count) |
| occtl_status_t | occtl_de_format_id_from_path (const char *path, const char **out_format_id) |
OCCT-Light: unified data-exchange dispatch.
Mirrors OCCT's DE_Wrapper. Reads / writes a file by routing based on path extension to whichever io_* module is enabled at link time. When no io_* module is enabled this module compiles but every operation returns OCCTL_UNSUPPORTED.
Format ids are stable lowercase tokens: "brep", "step", "iges", "stl", "obj", and "gltf" when the matching io_* modules are enabled.
| #define OCCTL_DE_FORMAT_INFO_INIT {OCCTL_DE_FORMAT_INFO_VERSION_1, NULL, NULL, NULL, 0, 0, 0, 0, 0} |
Static initializer for occtl_de_format_info_t.
| typedef struct occtl_de_format_info occtl_de_format_info_t |
Borrowed description of one supported data-exchange format.
String fields are library-owned and remain valid for the process lifetime. Producers set struct_version to OCCTL_DE_FORMAT_INFO_VERSION_1 and p_next to NULL.
\par Thread Safety Yes.
| occtl_status_t occtl_de_format_count | ( | size_t * | out_count | ) |
Returns the number of supported format descriptors.
| [out] | out_count | Borrows it. Receives the supported-format count. |
| OCCTL_OK | Success. |
| OCCTL_INVALID_ARGUMENT | out_count is NULL. |
\par Thread Safety Yes.
| occtl_status_t occtl_de_format_extensions | ( | const char * | format_id, |
| const char ** | out_extensions, | ||
| size_t | cap, | ||
| size_t * | out_count | ||
| ) |
Enumerates the lowercase extensions for a supported format id.
Extensions include the leading dot. Two-call buffer: pass out_extensions as NULL with cap=0 to size. Returned strings are library-owned and remain valid for the process lifetime.
| [in] | format_id | Borrows it. Stable lowercase format id. |
| [out] | out_extensions | Borrows it. Length cap; may be NULL. |
| [in] | cap | Capacity of out_extensions. |
| [out] | out_count | Borrows it. Receives the extension count. |
| OCCTL_OK | Success. |
| OCCTL_INVALID_ARGUMENT | format_id or out_count is NULL. |
| OCCTL_NOT_FOUND | format_id is not supported by this build. |
| OCCTL_BUFFER_TOO_SMALL | cap < out_count and out_extensions is non-NULL. |
\par Thread Safety Yes.
| occtl_status_t occtl_de_format_id_from_path | ( | const char * | path, |
| const char ** | out_format_id | ||
| ) |
Returns the format id for path.
The returned string is library-owned (one of the static tokens enumerated by occtl_de_format_ids) and never needs freeing.
| [in] | path | Borrows it. NUL-terminated UTF-8 path. Must be non-NULL. |
| [out] | out_format_id | Borrows it (caller-allocated slot). Receives a borrowed format id, or NULL when no extension matches. Must be non-NULL. |
| OCCTL_OK | On success. out_format_id may receive NULL. |
| OCCTL_INVALID_ARGUMENT | path or out_format_id is NULL. |
\par Thread Safety Yes.
| occtl_status_t occtl_de_format_ids | ( | const char ** | out_format_ids, |
| size_t | cap, | ||
| size_t * | out_count | ||
| ) |
Enumerates the stable lowercase format ids the build supports.
Two-call buffer: pass out_format_ids as NULL with cap=0 to size. The returned strings are library-owned and remain valid for the process lifetime.
| [out] | out_format_ids | Borrows it. Length cap; may be NULL. |
| [in] | cap | Capacity of out_format_ids. |
| [out] | out_count | Borrows it. Receives the supported-format count. |
| OCCTL_OK | Success. |
| OCCTL_INVALID_ARGUMENT | out_count is NULL. |
| OCCTL_BUFFER_TOO_SMALL | cap < out_count and out_format_ids non-NULL. |
\par Thread Safety Yes.
| occtl_status_t occtl_de_format_info_at | ( | size_t | index, |
| occtl_de_format_info_t * | out_info | ||
| ) |
Returns metadata for the index-th supported format.
| [in] | index | Zero-based format index. |
| [out] | out_info | Borrows it. Receives borrowed static strings and writes OCCTL_DE_FORMAT_INFO_VERSION_1 to out_info->struct_version. |
| OCCTL_OK | Success. |
| OCCTL_INVALID_ARGUMENT | out_info is NULL. |
| OCCTL_OUT_OF_RANGE | index is not a supported format index. |
\par Thread Safety Yes.
| occtl_status_t occtl_de_format_info_by_id | ( | const char * | format_id, |
| occtl_de_format_info_t * | out_info | ||
| ) |
Returns metadata for a supported format id.
| [in] | format_id | Borrows it. Stable lowercase format id. |
| [out] | out_info | Borrows it. Receives borrowed static strings and writes OCCTL_DE_FORMAT_INFO_VERSION_1 to out_info->struct_version. |
| OCCTL_OK | Success. |
| OCCTL_INVALID_ARGUMENT | format_id or out_info is NULL. |
| OCCTL_NOT_FOUND | format_id is not supported by this build. |
\par Thread Safety Yes.
| void occtl_de_format_info_init | ( | occtl_de_format_info_t * | info | ) |
Runtime initialiser for occtl_de_format_info_t.
Sets all fields to OCCTL_DE_FORMAT_INFO_INIT.
| [out] | info | Borrows it. NULL-tolerant; no-op when NULL. |
\par Thread Safety Yes.
| occtl_status_t occtl_de_read | ( | const char * | path, |
| occtl_graph_t ** | out_graph, | ||
| occtl_node_id_t * | out_root | ||
| ) |
Reads a file and ingests it into a freshly-created graph.
Format is dispatched by extension. When the format is recognised but the matching io_* module is not linked, returns OCCTL_UNSUPPORTED.
| [in] | path | Borrows it. NUL-terminated UTF-8 path. |
| [out] | out_graph | Owns it. Receives a new graph on success. |
| [out] | out_root | Borrows it. Receives the NodeId of the root. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | Any pointer argument is NULL. |
| OCCTL_UNSUPPORTED | Format unknown or matching module not linked. |
| OCCTL_IO_ERROR | Filesystem failure. |
| OCCTL_FORMAT_ERROR | File contents malformed. |
\par Thread Safety Yes.
| occtl_status_t occtl_de_read_memory | ( | const char * | format_id, |
| const uint8_t * | data, | ||
| size_t | size, | ||
| occtl_graph_t ** | out_graph, | ||
| occtl_node_id_t * | out_root | ||
| ) |
Reads a memory payload and ingests it into a freshly-created graph.
Format is selected by explicit stable format id instead of a path extension. The dispatch still uses OCCT's data-exchange providers internally, so format support matches occtl_de_format_ids.
| [in] | format_id | Borrows it. Stable lowercase format id. |
| [in] | data | Borrows it. Readable byte buffer containing provider-native data for format_id. |
| [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 | format_id, data, out_graph, or out_root is NULL, or size is zero. |
| OCCTL_UNSUPPORTED | Format unknown or not readable in this build. |
| OCCTL_IO_ERROR | Temporary stream or provider failure. |
| OCCTL_FORMAT_ERROR | Payload contents malformed. |
| OCCTL_TOPOLOGY_INVALID | Payload decoded but could not be ingested into BRepGraph. |
\par Thread Safety Yes.
| occtl_status_t occtl_de_write | ( | const occtl_graph_t * | graph, |
| occtl_node_id_t | root, | ||
| const char * | path | ||
| ) |
Writes the topology rooted at root to a file, dispatched by extension.
| [in] | graph | Borrows it. Must be non-NULL. |
| [in] | root | Root node id. |
| [in] | path | Borrows it. NUL-terminated UTF-8 path; overwritten if exists. |
| OCCTL_OK | On success. |
| OCCTL_INVALID_ARGUMENT | graph or path is NULL. |
| OCCTL_UNSUPPORTED | Format unknown or matching module not linked. |
| OCCTL_NOT_FOUND | root is invalid or removed. |
| OCCTL_IO_ERROR | Filesystem failure. |
\par Thread Safety Yes (read-only on graph).
| occtl_status_t occtl_de_write_memory | ( | const occtl_graph_t * | graph, |
| occtl_node_id_t | root, | ||
| const char * | format_id, | ||
| uint8_t * | out_data, | ||
| size_t | capacity, | ||
| size_t * | out_size | ||
| ) |
Writes the topology rooted at root to caller-owned memory.
Format is selected by explicit stable format id. Two-call buffer pattern: call with out_data == NULL and capacity == 0 to learn the required byte count in out_size, allocate a buffer, then call again with capacity at least out_size.
| [in] | graph | Borrows it. Must be non-NULL. |
| [in] | root | Root node id to serialise. |
| [in] | format_id | Borrows it. Stable lowercase format id. |
| [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. |
| OCCTL_INVALID_ARGUMENT | graph, format_id, or out_size is NULL. |
| OCCTL_UNSUPPORTED | Format unknown or not writable in this build. |
| OCCTL_NOT_FOUND | root is invalid or removed. |
| OCCTL_BUFFER_TOO_SMALL | out_data is non-NULL and capacity is smaller than out_size. |
| OCCTL_IO_ERROR | Temporary stream or provider failure. |
\par Thread Safety Yes (read-only on graph).