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

OCCT-Light: glTF 2.0 / GLB file I/O. More...

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

Go to the source code of this file.

Classes

struct  occtl_io_gltf_read_options
 
struct  occtl_io_gltf_write_options
 

Macros

#define OCCTL_IO_GLTF_READ_OPTIONS_VERSION_1   1u
 
#define OCCTL_IO_GLTF_WRITE_OPTIONS_VERSION_1   1u
 
#define OCCTL_IO_GLTF_READ_OPTIONS_INIT    {OCCTL_IO_GLTF_READ_OPTIONS_VERSION_1, NULL, 0, 1, 1, 1, 0, 1, 1, -1}
 
#define OCCTL_IO_GLTF_WRITE_OPTIONS_INIT    {OCCTL_IO_GLTF_WRITE_OPTIONS_VERSION_1, NULL, OCCTL_IO_GLTF_TRANSFORM_COMPACT, 0, 1, 0, 0, 0}
 

Typedefs

typedef enum occtl_io_gltf_transform_format occtl_io_gltf_transform_format_t
 
typedef struct occtl_io_gltf_read_options occtl_io_gltf_read_options_t
 
typedef struct occtl_io_gltf_write_options occtl_io_gltf_write_options_t
 

Enumerations

enum  occtl_io_gltf_transform_format { OCCTL_IO_GLTF_TRANSFORM_COMPACT = 0 , OCCTL_IO_GLTF_TRANSFORM_MAT4 = 1 , OCCTL_IO_GLTF_TRANSFORM_TRS = 2 , OCCTL_IO_GLTF_TRANSFORM_RESERVED_FUTURE = 0x7fffffff }
 

Functions

void occtl_io_gltf_read_options_init (occtl_io_gltf_read_options_t *options)
 
void occtl_io_gltf_write_options_init (occtl_io_gltf_write_options_t *options)
 
occtl_status_t occtl_io_gltf_read (const char *path, occtl_graph_t **out_graph, occtl_node_id_t *out_root, const occtl_io_gltf_read_options_t *options)
 
occtl_status_t occtl_io_gltf_write (const occtl_graph_t *graph, occtl_node_id_t root, const char *path, const occtl_io_gltf_write_options_t *options)
 

Detailed Description

OCCT-Light: glTF 2.0 / GLB file I/O.

Reads and writes glTF 2.0 JSON streams (.gltf) and binary GLB streams (.glb) via OCCT's DEGLTF_Provider / DEGLTF_ConfigurationNode.

glTF is primarily a mesh exchange format. Precise geometry may be tessellated during export; callers that need deterministic triangulation should run occtl_mesh_generate before writing.

UIDs are not preserved across the round-trip in v1. Use occtl_uid_to_bytes / occtl_uid_from_bytes for an out-of-band UID handshake if persistent identity is required.

Typedef Documentation

◆ occtl_io_gltf_read_options_t

Options for occtl_io_gltf_read. Pass NULL for defaults.

◆ occtl_io_gltf_transform_format_t

Transformation encoding used when writing glTF node transforms.

◆ occtl_io_gltf_write_options_t

Options for occtl_io_gltf_write. Pass NULL for defaults.

Enumeration Type Documentation

◆ occtl_io_gltf_transform_format

Transformation encoding used when writing glTF node transforms.

Enumerator
OCCTL_IO_GLTF_TRANSFORM_COMPACT 

Let OCCT choose the most compact representation.

OCCTL_IO_GLTF_TRANSFORM_MAT4 

Always write a 4x4 matrix.

OCCTL_IO_GLTF_TRANSFORM_TRS 

Write translation, rotation quaternion, and scale.

Function Documentation

◆ occtl_io_gltf_read()

occtl_status_t occtl_io_gltf_read ( const char *  path,
occtl_graph_t **  out_graph,
occtl_node_id_t out_root,
const occtl_io_gltf_read_options_t options 
)

Reads a glTF or GLB file and ingests it into a freshly-created graph.

Parameters
[in]pathBorrows it. NUL-terminated UTF-8 path to the file. Must be non-NULL.
[out]out_graphOwns it. Receives a new graph on success; NULL on failure.
[out]out_rootBorrows it. Receives the NodeId of the root entity.
[in]optionsBorrows it. May be NULL for defaults.
Return values
OCCTL_OKOn success.
OCCTL_INVALID_ARGUMENTpath, out_graph, or out_root is NULL; or options has invalid fields (non-NULL p_next, non-0/1 flags, invalid memory_limit_mib).
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_IO_ERRORFile not found, unreadable, or blocked by OCCT reader limits.
OCCTL_FORMAT_ERRORFile contents were not a valid glTF / GLB stream.
OCCTL_TOPOLOGY_INVALIDImported shape could not be ingested into BRepGraph.

\par Thread Safety Yes.

See also
occtl_io_gltf_write, occtl_de_read

◆ occtl_io_gltf_read_options_init()

void occtl_io_gltf_read_options_init ( occtl_io_gltf_read_options_t options)

Initialises options to default values matching OCCTL_IO_GLTF_READ_OPTIONS_INIT.

NULL-tolerant.

Parameters
[out]optionsBorrows it. May be NULL (no-op).

\par Thread Safety Yes.

See also
occtl_io_gltf_read

◆ occtl_io_gltf_write()

occtl_status_t occtl_io_gltf_write ( const occtl_graph_t graph,
occtl_node_id_t  root,
const char *  path,
const occtl_io_gltf_write_options_t options 
)

Writes the topology rooted at root to a glTF or GLB file.

The output container is inferred from path extension: .gltf writes a JSON glTF stream and .glb writes a binary GLB stream.

Parameters
[in]graphBorrows it. Must be non-NULL.
[in]rootRoot node id to serialise.
[in]pathBorrows it. NUL-terminated UTF-8 path; existing file is overwritten.
[in]optionsBorrows it. May be NULL for defaults.
Return values
OCCTL_OKOn success.
OCCTL_INVALID_ARGUMENTgraph or path is NULL; or options has invalid fields (non-NULL p_next, non-0/1 flags, non-zero reserved parallel).
OCCTL_NOT_FOUNDroot is invalid or has been removed.
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_OUT_OF_RANGEoptions has an unsupported transform_format.
OCCTL_IO_ERRORFilesystem failure, unwritable file, or OCCT writer failure.

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

See also
occtl_io_gltf_read, occtl_de_write

◆ occtl_io_gltf_write_options_init()

void occtl_io_gltf_write_options_init ( occtl_io_gltf_write_options_t options)

Initialises options to default values matching OCCTL_IO_GLTF_WRITE_OPTIONS_INIT.

NULL-tolerant.

Parameters
[out]optionsBorrows it. May be NULL (no-op).

\par Thread Safety Yes.

See also
occtl_io_gltf_write