OCCT-Light 0.1
C ABI and C++ veneer for multi-language CAD workflows
Loading...
Searching...
No Matches
occtl_de.h File Reference

OCCT-Light: unified data-exchange dispatch. More...

#include <stddef.h>
#include <stdint.h>
#include "occtl_core.h"
#include "occtl_topo.h"
Include dependency graph for occtl_de.h:
This graph shows which files directly or indirectly include this file:

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)
 

Detailed Description

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.

Macro Definition Documentation

◆ OCCTL_DE_FORMAT_INFO_INIT

#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 Documentation

◆ 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.

See also
occtl_de_format_info_at, occtl_de_format_info_by_id

Function Documentation

◆ occtl_de_format_count()

occtl_status_t occtl_de_format_count ( size_t *  out_count)

Returns the number of supported format descriptors.

Parameters
[out]out_countBorrows it. Receives the supported-format count.
Return values
OCCTL_OKSuccess.
OCCTL_INVALID_ARGUMENTout_count is NULL.

\par Thread Safety Yes.

See also
occtl_de_format_info_at

◆ occtl_de_format_extensions()

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.

Parameters
[in]format_idBorrows it. Stable lowercase format id.
[out]out_extensionsBorrows it. Length cap; may be NULL.
[in]capCapacity of out_extensions.
[out]out_countBorrows it. Receives the extension count.
Return values
OCCTL_OKSuccess.
OCCTL_INVALID_ARGUMENTformat_id or out_count is NULL.
OCCTL_NOT_FOUNDformat_id is not supported by this build.
OCCTL_BUFFER_TOO_SMALLcap < out_count and out_extensions is non-NULL.

\par Thread Safety Yes.

See also
occtl_de_format_info_by_id

◆ occtl_de_format_id_from_path()

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.

Parameters
[in]pathBorrows it. NUL-terminated UTF-8 path. Must be non-NULL.
[out]out_format_idBorrows it (caller-allocated slot). Receives a borrowed format id, or NULL when no extension matches. Must be non-NULL.
Return values
OCCTL_OKOn success. out_format_id may receive NULL.
OCCTL_INVALID_ARGUMENTpath or out_format_id is NULL.

\par Thread Safety Yes.

See also
occtl_de_format_ids

◆ occtl_de_format_ids()

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.

Parameters
[out]out_format_idsBorrows it. Length cap; may be NULL.
[in]capCapacity of out_format_ids.
[out]out_countBorrows it. Receives the supported-format count.
Return values
OCCTL_OKSuccess.
OCCTL_INVALID_ARGUMENTout_count is NULL.
OCCTL_BUFFER_TOO_SMALLcap < out_count and out_format_ids non-NULL.

\par Thread Safety Yes.

See also
occtl_de_format_id_from_path

◆ occtl_de_format_info_at()

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.

Parameters
[in]indexZero-based format index.
[out]out_infoBorrows it. Receives borrowed static strings and writes OCCTL_DE_FORMAT_INFO_VERSION_1 to out_info->struct_version.
Return values
OCCTL_OKSuccess.
OCCTL_INVALID_ARGUMENTout_info is NULL.
OCCTL_OUT_OF_RANGEindex is not a supported format index.

\par Thread Safety Yes.

See also
occtl_de_format_count, occtl_de_format_info_by_id

◆ occtl_de_format_info_by_id()

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.

Parameters
[in]format_idBorrows it. Stable lowercase format id.
[out]out_infoBorrows it. Receives borrowed static strings and writes OCCTL_DE_FORMAT_INFO_VERSION_1 to out_info->struct_version.
Return values
OCCTL_OKSuccess.
OCCTL_INVALID_ARGUMENTformat_id or out_info is NULL.
OCCTL_NOT_FOUNDformat_id is not supported by this build.

\par Thread Safety Yes.

See also
occtl_de_format_ids

◆ occtl_de_format_info_init()

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.

Parameters
[out]infoBorrows it. NULL-tolerant; no-op when NULL.

\par Thread Safety Yes.

See also
occtl_de_format_info_at, occtl_de_format_info_by_id

◆ occtl_de_read()

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.

Parameters
[in]pathBorrows it. NUL-terminated UTF-8 path.
[out]out_graphOwns it. Receives a new graph on success.
[out]out_rootBorrows it. Receives the NodeId of the root.
Return values
OCCTL_OKOn success.
OCCTL_INVALID_ARGUMENTAny pointer argument is NULL.
OCCTL_UNSUPPORTEDFormat unknown or matching module not linked.
OCCTL_IO_ERRORFilesystem failure.
OCCTL_FORMAT_ERRORFile contents malformed.

\par Thread Safety Yes.

See also
occtl_de_write

◆ occtl_de_read_memory()

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.

Parameters
[in]format_idBorrows it. Stable lowercase format id.
[in]dataBorrows it. Readable byte buffer containing provider-native data for format_id.
[in]sizeNumber of bytes available at data. Must be > 0.
[out]out_graphOwns it. Receives a new graph on success; NULL on failure.
[out]out_rootBorrows it. Receives the NodeId of the root entity.
Return values
OCCTL_OKOn success.
OCCTL_INVALID_ARGUMENTformat_id, data, out_graph, or out_root is NULL, or size is zero.
OCCTL_UNSUPPORTEDFormat unknown or not readable in this build.
OCCTL_IO_ERRORTemporary stream or provider failure.
OCCTL_FORMAT_ERRORPayload contents malformed.
OCCTL_TOPOLOGY_INVALIDPayload decoded but could not be ingested into BRepGraph.

\par Thread Safety Yes.

See also
occtl_de_write_memory, occtl_de_read

◆ occtl_de_write()

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.

Parameters
[in]graphBorrows it. Must be non-NULL.
[in]rootRoot node id.
[in]pathBorrows it. NUL-terminated UTF-8 path; overwritten if exists.
Return values
OCCTL_OKOn success.
OCCTL_INVALID_ARGUMENTgraph or path is NULL.
OCCTL_UNSUPPORTEDFormat unknown or matching module not linked.
OCCTL_NOT_FOUNDroot is invalid or removed.
OCCTL_IO_ERRORFilesystem failure.

\par Thread Safety Yes (read-only on graph).

See also
occtl_de_read

◆ occtl_de_write_memory()

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.

Parameters
[in]graphBorrows it. Must be non-NULL.
[in]rootRoot node id to serialise.
[in]format_idBorrows it. Stable lowercase format id.
[out]out_dataBorrows it. Writable output buffer, or NULL for sizing.
[in]capacitySize of out_data in bytes.
[out]out_sizeBorrows it. Receives the required byte count.
Return values
OCCTL_OKOn success.
OCCTL_INVALID_ARGUMENTgraph, format_id, or out_size is NULL.
OCCTL_UNSUPPORTEDFormat unknown or not writable in this build.
OCCTL_NOT_FOUNDroot is invalid or removed.
OCCTL_BUFFER_TOO_SMALLout_data is non-NULL and capacity is smaller than out_size.
OCCTL_IO_ERRORTemporary stream or provider failure.

\par Thread Safety Yes (read-only on graph).

See also
occtl_de_read_memory, occtl_de_write