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

OCCT-Light: STEP file I/O (ISO 10303-21). More...

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

Go to the source code of this file.

Classes

struct  occtl_io_step_read_options
 
struct  occtl_io_step_write_options
 

Macros

#define OCCTL_IO_STEP_READ_OPTIONS_VERSION_1   1u
 
#define OCCTL_IO_STEP_WRITE_OPTIONS_VERSION_1   1u
 
#define OCCTL_IO_STEP_READ_OPTIONS_INIT   {OCCTL_IO_STEP_READ_OPTIONS_VERSION_1, NULL, 1, 1, 1}
 
#define OCCTL_IO_STEP_WRITE_OPTIONS_INIT
 

Typedefs

typedef enum occtl_io_step_length_unit occtl_io_step_length_unit_t
 
typedef enum occtl_io_step_schema occtl_io_step_schema_t
 
typedef struct occtl_io_step_read_options occtl_io_step_read_options_t
 
typedef struct occtl_io_step_write_options occtl_io_step_write_options_t
 

Enumerations

enum  occtl_io_step_length_unit { OCCTL_IO_STEP_UNIT_MM = 0 , OCCTL_IO_STEP_UNIT_M = 1 , OCCTL_IO_STEP_UNIT_INCH = 2 , OCCTL_IO_STEP_UNIT_RESERVED_FUTURE = 0x7fffffff }
 
enum  occtl_io_step_schema { OCCTL_IO_STEP_SCHEMA_AP203 = 0 , OCCTL_IO_STEP_SCHEMA_AP214 = 1 , OCCTL_IO_STEP_SCHEMA_AP242 = 2 , OCCTL_IO_STEP_SCHEMA_RESERVED_FUTURE = 0x7fffffff }
 

Functions

void occtl_io_step_read_options_init (occtl_io_step_read_options_t *options)
 
void occtl_io_step_write_options_init (occtl_io_step_write_options_t *options)
 
occtl_status_t occtl_io_step_read (const char *path, occtl_graph_t **out_graph, occtl_node_id_t *out_root, const occtl_io_step_read_options_t *options)
 
occtl_status_t occtl_io_step_read_memory (const uint8_t *data, size_t size, occtl_graph_t **out_graph, occtl_node_id_t *out_root, const occtl_io_step_read_options_t *options)
 
occtl_status_t occtl_io_step_write (const occtl_graph_t *graph, occtl_node_id_t root, const char *path, const occtl_io_step_write_options_t *options)
 
occtl_status_t occtl_io_step_write_memory (const occtl_graph_t *graph, occtl_node_id_t root, const occtl_io_step_write_options_t *options, uint8_t *out_data, size_t capacity, size_t *out_size)
 

Detailed Description

OCCT-Light: STEP file I/O (ISO 10303-21).

Reads and writes STEP AP203 / AP214 / AP242 files via OCCT's DESTEP_Provider / DESTEP_ConfigurationNode. OCAF is linked privately and never reaches the public surface.

UIDs are not preserved across the round-trip — the STEP file format has its own entity-id metadata. Use occtl_uid_to_bytes / occtl_uid_from_bytes for an out-of-band UID handshake if persistent identity is required.

Macro Definition Documentation

◆ OCCTL_IO_STEP_WRITE_OPTIONS_INIT

#define OCCTL_IO_STEP_WRITE_OPTIONS_INIT
Value:
{OCCTL_IO_STEP_WRITE_OPTIONS_VERSION_1, \
NULL, \
1, \
1}
@ OCCTL_IO_STEP_UNIT_MM
Definition occtl_io_step.h:49
@ OCCTL_IO_STEP_SCHEMA_AP242
Definition occtl_io_step.h:62

Typedef Documentation

◆ occtl_io_step_length_unit_t

Length unit for STEP file I/O.

◆ occtl_io_step_read_options_t

Options for occtl_io_step_read. Pass NULL for defaults.

◆ occtl_io_step_schema_t

STEP schema version for write.

◆ occtl_io_step_write_options_t

Options for occtl_io_step_write. Pass NULL for defaults.

Enumeration Type Documentation

◆ occtl_io_step_length_unit

Length unit for STEP file I/O.

Enumerator
OCCTL_IO_STEP_UNIT_MM 

Millimetres (default).

OCCTL_IO_STEP_UNIT_M 

Metres.

OCCTL_IO_STEP_UNIT_INCH 

Inches.

◆ occtl_io_step_schema

STEP schema version for write.

Enumerator
OCCTL_IO_STEP_SCHEMA_AP203 

AP203 (configuration-controlled 3D design).

OCCTL_IO_STEP_SCHEMA_AP214 

AP214 (core data for automotive).

OCCTL_IO_STEP_SCHEMA_AP242 

AP242 (managed model-based 3D engineering, default).

Function Documentation

◆ occtl_io_step_read()

occtl_status_t occtl_io_step_read ( const char *  path,
occtl_graph_t **  out_graph,
occtl_node_id_t out_root,
const occtl_io_step_read_options_t options 
)

Reads a STEP 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).
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_IO_ERRORFile not found or unreadable.
OCCTL_FORMAT_ERRORFile contents were not a valid STEP stream.

\par Thread Safety Yes.

See also
occtl_io_step_write, occtl_de_read

◆ occtl_io_step_read_memory()

occtl_status_t occtl_io_step_read_memory ( const uint8_t *  data,
size_t  size,
occtl_graph_t **  out_graph,
occtl_node_id_t out_root,
const occtl_io_step_read_options_t options 
)

Reads a STEP payload from caller-owned memory into a freshly-created graph.

Caller owns the returned graph and must release it via occtl_graph_free.

Parameters
[in]dataBorrows it. Readable byte buffer containing STEP data. Must be non-NULL when size is non-zero.
[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.
[in]optionsBorrows it. May be NULL for defaults.
Return values
OCCTL_OKOn success.
OCCTL_INVALID_ARGUMENTdata, out_graph, or out_root is NULL, or size is zero; or options has invalid fields (non-NULL p_next, non-0/1 flags).
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_IO_ERRORTemporary stream failure.
OCCTL_FORMAT_ERRORPayload contents were not a valid STEP stream.
OCCTL_TOPOLOGY_INVALIDPayload decoded but could not be ingested into BRepGraph.

\par Thread Safety Yes.

See also
occtl_io_step_write_memory, occtl_io_step_read

◆ occtl_io_step_read_options_init()

void occtl_io_step_read_options_init ( occtl_io_step_read_options_t options)

Initialises options to default values matching OCCTL_IO_STEP_READ_OPTIONS_INIT.

NULL-tolerant.

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

\par Thread Safety Yes.

See also
occtl_io_step_read

◆ occtl_io_step_write()

occtl_status_t occtl_io_step_write ( const occtl_graph_t graph,
occtl_node_id_t  root,
const char *  path,
const occtl_io_step_write_options_t options 
)

Writes the topology rooted at root to a STEP file.

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).
OCCTL_NOT_FOUNDroot is invalid or has been removed.
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_OUT_OF_RANGEoptions has unsupported unit or schema enum.
OCCTL_IO_ERRORFilesystem failure or unwritable file.

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

See also
occtl_io_step_read, occtl_de_write

◆ occtl_io_step_write_memory()

occtl_status_t occtl_io_step_write_memory ( const occtl_graph_t graph,
occtl_node_id_t  root,
const occtl_io_step_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.

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]optionsBorrows it. May be NULL for defaults.
[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 or out_size is NULL; or options has invalid fields (non-NULL p_next, non-0/1 flags).
OCCTL_NOT_FOUNDroot is invalid or has been removed.
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_OUT_OF_RANGEoptions has unsupported unit or schema enum.
OCCTL_BUFFER_TOO_SMALLout_data is non-NULL and capacity is smaller than out_size.
OCCTL_IO_ERROROCCT failed to serialise the shape.

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

See also
occtl_io_step_read_memory, occtl_io_step_write

◆ occtl_io_step_write_options_init()

void occtl_io_step_write_options_init ( occtl_io_step_write_options_t options)

Initialises options to default values matching OCCTL_IO_STEP_WRITE_OPTIONS_INIT.

NULL-tolerant.

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

\par Thread Safety Yes.

See also
occtl_io_step_write