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

OCCT-Light: VRML file I/O. More...

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

Go to the source code of this file.

Classes

struct  occtl_io_vrml_read_options
 
struct  occtl_io_vrml_write_options
 

Macros

#define OCCTL_IO_VRML_READ_OPTIONS_VERSION_1   1u
 
#define OCCTL_IO_VRML_WRITE_OPTIONS_VERSION_1   1u
 
#define OCCTL_IO_VRML_READ_OPTIONS_INIT
 
#define OCCTL_IO_VRML_WRITE_OPTIONS_INIT
 

Typedefs

typedef enum occtl_io_vrml_coordinate_system occtl_io_vrml_coordinate_system_t
 
typedef enum occtl_io_vrml_writer_version occtl_io_vrml_writer_version_t
 
typedef enum occtl_io_vrml_representation occtl_io_vrml_representation_t
 
typedef struct occtl_io_vrml_read_options occtl_io_vrml_read_options_t
 
typedef struct occtl_io_vrml_write_options occtl_io_vrml_write_options_t
 

Enumerations

enum  occtl_io_vrml_coordinate_system { OCCTL_IO_VRML_COORDINATE_SYSTEM_Y_UP = 0 , OCCTL_IO_VRML_COORDINATE_SYSTEM_Z_UP = 1 , OCCTL_IO_VRML_COORDINATE_SYSTEM_GLTF = 2 , OCCTL_IO_VRML_COORDINATE_SYSTEM_RESERVED_FUTURE = 0x7fffffff }
 
enum  occtl_io_vrml_writer_version { OCCTL_IO_VRML_WRITER_VERSION_1 = 1 , OCCTL_IO_VRML_WRITER_VERSION_2 = 2 , OCCTL_IO_VRML_WRITER_VERSION_RESERVED_FUTURE = 0x7fffffff }
 
enum  occtl_io_vrml_representation { OCCTL_IO_VRML_REPRESENTATION_SHADED = 0 , OCCTL_IO_VRML_REPRESENTATION_WIREFRAME = 1 , OCCTL_IO_VRML_REPRESENTATION_BOTH = 2 , OCCTL_IO_VRML_REPRESENTATION_RESERVED_FUTURE = 0x7fffffff }
 

Functions

void occtl_io_vrml_read_options_init (occtl_io_vrml_read_options_t *options)
 
void occtl_io_vrml_write_options_init (occtl_io_vrml_write_options_t *options)
 
occtl_status_t occtl_io_vrml_read (const char *path, occtl_graph_t **out_graph, occtl_node_id_t *out_root, const occtl_io_vrml_read_options_t *options)
 
occtl_status_t occtl_io_vrml_write (const occtl_graph_t *graph, occtl_node_id_t root, const char *path, const occtl_io_vrml_write_options_t *options)
 
occtl_status_t occtl_io_vrml_read_memory (const uint8_t *data, size_t size, occtl_graph_t **out_graph, occtl_node_id_t *out_root, const occtl_io_vrml_read_options_t *options)
 
occtl_status_t occtl_io_vrml_write_memory (const occtl_graph_t *graph, occtl_node_id_t root, const occtl_io_vrml_write_options_t *options, uint8_t *out_data, size_t capacity, size_t *out_size)
 

Detailed Description

OCCT-Light: VRML file I/O.

Reads and writes VRML 1.0 / 2.0 files via OCCT's DEVRML_Provider / DEVRML_ConfigurationNode.

VRML is an older scene and mesh exchange format. Precise geometry may be tessellated during export; callers that need deterministic triangulation should run occtl_mesh_generate before writing.

Macro Definition Documentation

◆ OCCTL_IO_VRML_READ_OPTIONS_INIT

#define OCCTL_IO_VRML_READ_OPTIONS_INIT
Value:
{OCCTL_IO_VRML_READ_OPTIONS_VERSION_1, \
NULL, \
1.0, \
1}
@ OCCTL_IO_VRML_COORDINATE_SYSTEM_Z_UP
Definition occtl_io_vrml.h:48
@ OCCTL_IO_VRML_COORDINATE_SYSTEM_Y_UP
Definition occtl_io_vrml.h:47

◆ OCCTL_IO_VRML_WRITE_OPTIONS_INIT

#define OCCTL_IO_VRML_WRITE_OPTIONS_INIT
Value:
{OCCTL_IO_VRML_WRITE_OPTIONS_VERSION_1, \
NULL, \
@ OCCTL_IO_VRML_WRITER_VERSION_2
Definition occtl_io_vrml.h:59
@ OCCTL_IO_VRML_REPRESENTATION_WIREFRAME
Definition occtl_io_vrml.h:69

Typedef Documentation

◆ occtl_io_vrml_coordinate_system_t

Coordinate system used by VRML import/export conversion.

◆ occtl_io_vrml_read_options_t

Options for occtl_io_vrml_read. Pass NULL for defaults.

◆ occtl_io_vrml_representation_t

VRML output representation.

◆ occtl_io_vrml_write_options_t

Options for occtl_io_vrml_write. Pass NULL for defaults.

◆ occtl_io_vrml_writer_version_t

Enumeration Type Documentation

◆ occtl_io_vrml_coordinate_system

Coordinate system used by VRML import/export conversion.

Enumerator
OCCTL_IO_VRML_COORDINATE_SYSTEM_Y_UP 

Y-up coordinates.

OCCTL_IO_VRML_COORDINATE_SYSTEM_Z_UP 

Z-up coordinates.

OCCTL_IO_VRML_COORDINATE_SYSTEM_GLTF 

glTF-compatible coordinates.

◆ occtl_io_vrml_representation

VRML output representation.

Enumerator
OCCTL_IO_VRML_REPRESENTATION_SHADED 

Shaded representation.

OCCTL_IO_VRML_REPRESENTATION_WIREFRAME 

Wireframe representation.

OCCTL_IO_VRML_REPRESENTATION_BOTH 

Shaded and wireframe representation.

◆ occtl_io_vrml_writer_version

VRML writer version.

Enumerator
OCCTL_IO_VRML_WRITER_VERSION_1 

VRML 1.0 output.

OCCTL_IO_VRML_WRITER_VERSION_2 

VRML 2.0 output.

Function Documentation

◆ occtl_io_vrml_read()

occtl_status_t occtl_io_vrml_read ( const char *  path,
occtl_graph_t **  out_graph,
occtl_node_id_t out_root,
const occtl_io_vrml_read_options_t options 
)

Reads a VRML 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-finite/non-positive file_length_unit_m, non-0/1 fill_incomplete).
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_OUT_OF_RANGEoptions has an unsupported coordinate-system value.
OCCTL_IO_ERRORFile not found, unreadable, or blocked by OCCT reader limits.
OCCTL_FORMAT_ERRORFile contents were not a valid VRML stream.
OCCTL_TOPOLOGY_INVALIDImported shape could not be ingested into BRepGraph.

\par Thread Safety Yes.

See also
occtl_io_vrml_write, occtl_de_read

◆ occtl_io_vrml_read_memory()

occtl_status_t occtl_io_vrml_read_memory ( const uint8_t *  data,
size_t  size,
occtl_graph_t **  out_graph,
occtl_node_id_t out_root,
const occtl_io_vrml_read_options_t options 
)

Reads a VRML file from a caller-owned memory buffer.

Delegates to the OCCT VRML provider stream reader; OCCT-Light does not create a filesystem path for this call.

Parameters
[in]dataBorrows it. Byte buffer containing VRML data. Must be non-NULL.
[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 == 0; or options has invalid fields (non-NULL p_next, non-finite/non-positive file_length_unit_m, non-0/1 fill_incomplete).
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_IO_ERROROCCT reader failed.
OCCTL_FORMAT_ERRORBuffer contents were not a valid VRML stream.
OCCTL_TOPOLOGY_INVALIDImported shape could not be ingested into BRepGraph.

\par Thread Safety Yes.

See also
occtl_io_vrml_read, occtl_de_read_memory

◆ occtl_io_vrml_read_options_init()

void occtl_io_vrml_read_options_init ( occtl_io_vrml_read_options_t options)

Initialises options to default values matching OCCTL_IO_VRML_READ_OPTIONS_INIT.

NULL-tolerant.

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

\par Thread Safety Yes.

See also
occtl_io_vrml_read

◆ occtl_io_vrml_write()

occtl_status_t occtl_io_vrml_write ( const occtl_graph_t graph,
occtl_node_id_t  root,
const char *  path,
const occtl_io_vrml_write_options_t options 
)

Writes the topology rooted at root to a VRML 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->p_next is non-NULL.
OCCTL_NOT_FOUNDroot is invalid or has been removed.
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_OUT_OF_RANGEoptions has an unsupported writer_version or representation.
OCCTL_IO_ERRORFilesystem failure, unwritable file, or OCCT writer failure.

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

See also
occtl_io_vrml_read, occtl_de_write

◆ occtl_io_vrml_write_memory()

occtl_status_t occtl_io_vrml_write_memory ( const occtl_graph_t graph,
occtl_node_id_t  root,
const occtl_io_vrml_write_options_t options,
uint8_t *  out_data,
size_t  capacity,
size_t *  out_size 
)

Writes the topology rooted at root to a caller-owned memory buffer in VRML format.

Two-call buffer pattern: pass out_data == NULL with capacity == 0 to learn the required byte count in out_size, then call again with a buffer of at least that 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->p_next is non-NULL.
OCCTL_NOT_FOUNDroot is invalid or has been removed.
OCCTL_VERSION_MISMATCHoptions has an unsupported struct_version.
OCCTL_BUFFER_TOO_SMALLout_data is non-NULL and capacity is too small.
OCCTL_IO_ERROROCCT writer failure.

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

See also
occtl_io_vrml_read_memory, occtl_de_write_memory

◆ occtl_io_vrml_write_options_init()

void occtl_io_vrml_write_options_init ( occtl_io_vrml_write_options_t options)

Initialises options to default values matching OCCTL_IO_VRML_WRITE_OPTIONS_INIT.

NULL-tolerant.

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

\par Thread Safety Yes.

See also
occtl_io_vrml_write