lagrange.serialization

Functions

deserialize_mesh(data[, allow_scene_conversion, ...])

Deserialize a mesh from a bytes buffer.

deserialize_scene(data[, allow_scene_conversion, ...])

Deserialize a scene from a bytes buffer.

deserialize_simple_scene(data[, ...])

Deserialize a simple scene from a bytes buffer.

load_mesh(filename[, allow_scene_conversion, ...])

Load a mesh from a binary file.

load_scene(filename[, allow_scene_conversion, ...])

Load a scene from a binary file.

load_simple_scene(filename[, allow_scene_conversion, ...])

Load a simple scene from a binary file.

mesh_format_version()

Return the current mesh serialization format version.

save_mesh(filename, mesh[, compress, ...])

Save a mesh to a binary file.

save_scene(filename, scene[, compress, ...])

Save a scene to a binary file.

save_simple_scene(filename, scene[, compress, ...])

Save a simple scene to a binary file.

scene_format_version()

Return the current scene serialization format version.

serialize_mesh(mesh[, compress, compression_level, ...])

Serialize a mesh to a bytes buffer.

serialize_scene(scene[, compress, compression_level, ...])

Serialize a scene to a bytes buffer.

serialize_simple_scene(scene[, compress, ...])

Serialize a simple scene to a bytes buffer.

simple_scene_format_version()

Return the current simple scene serialization format version.

Module Contents

lagrange.serialization.deserialize_mesh(data, allow_scene_conversion=False, allow_type_cast=False, quiet=False)

Deserialize a mesh from a bytes buffer.

Auto-detects compression. If the buffer contains a SimpleScene or Scene, it can be converted when allow_scene_conversion is enabled. Type casting can be enabled via allow_type_cast.

Parameters:
  • data (bytes) – A bytes object containing the serialized data.

  • allow_scene_conversion (bool) – Allow converting between meshes and scenes. Defaults to False.

  • allow_type_cast (bool) – Allow casting scalar and index types. Defaults to False.

  • quiet (bool) – Suppress warnings. Defaults to False.

Return SurfaceMesh:

The deserialized mesh.

Return type:

core.SurfaceMesh

lagrange.serialization.deserialize_scene(data, allow_scene_conversion=False, allow_type_cast=False, quiet=False)

Deserialize a scene from a bytes buffer.

Auto-detects compression. If the buffer contains a SurfaceMesh or SimpleScene, it can be converted when allow_scene_conversion is enabled. Type casting can be enabled via allow_type_cast.

Parameters:
  • data (bytes) – A bytes object containing the serialized data.

  • allow_scene_conversion (bool) – Allow converting between meshes and scenes. Defaults to False.

  • allow_type_cast (bool) – Allow casting scalar and index types. Defaults to False.

  • quiet (bool) – Suppress warnings. Defaults to False.

Return Scene:

The deserialized scene.

Return type:

scene.Scene

lagrange.serialization.deserialize_simple_scene(data, allow_scene_conversion=False, allow_type_cast=False, quiet=False)

Deserialize a simple scene from a bytes buffer.

Auto-detects compression. If the buffer contains a SurfaceMesh or Scene, it can be converted when allow_scene_conversion is enabled. Type casting can be enabled via allow_type_cast.

Parameters:
  • data (bytes) – A bytes object containing the serialized data.

  • allow_scene_conversion (bool) – Allow converting between meshes and scenes. Defaults to False.

  • allow_type_cast (bool) – Allow casting scalar and index types. Defaults to False.

  • quiet (bool) – Suppress warnings. Defaults to False.

Return SimpleScene:

The deserialized simple scene.

Return type:

scene.SimpleScene3D

lagrange.serialization.load_mesh(filename, allow_scene_conversion=False, allow_type_cast=False, quiet=False)

Load a mesh from a binary file.

Auto-detects compression. If the file contains a SimpleScene or Scene, it can be converted when allow_scene_conversion is enabled. Type casting can be enabled via allow_type_cast.

Parameters:
  • filename (str | os.PathLike) – Input file path.

  • allow_scene_conversion (bool) – Allow converting between meshes and scenes. Defaults to False.

  • allow_type_cast (bool) – Allow casting scalar and index types. Defaults to False.

  • quiet (bool) – Suppress warnings. Defaults to False.

Return SurfaceMesh:

The loaded mesh.

Return type:

core.SurfaceMesh

lagrange.serialization.load_scene(filename, allow_scene_conversion=False, allow_type_cast=False, quiet=False)

Load a scene from a binary file.

Auto-detects compression. If the file contains a SurfaceMesh or SimpleScene, it can be converted when allow_scene_conversion is enabled. Type casting can be enabled via allow_type_cast.

Parameters:
  • filename (str | os.PathLike) – Input file path.

  • allow_scene_conversion (bool) – Allow converting between meshes and scenes. Defaults to False.

  • allow_type_cast (bool) – Allow casting scalar and index types. Defaults to False.

  • quiet (bool) – Suppress warnings. Defaults to False.

Return Scene:

The loaded scene.

Return type:

scene.Scene

lagrange.serialization.load_simple_scene(filename, allow_scene_conversion=False, allow_type_cast=False, quiet=False)

Load a simple scene from a binary file.

Auto-detects compression. If the file contains a SurfaceMesh or Scene, it can be converted when allow_scene_conversion is enabled. Type casting can be enabled via allow_type_cast.

Parameters:
  • filename (str | os.PathLike) – Input file path.

  • allow_scene_conversion (bool) – Allow converting between meshes and scenes. Defaults to False.

  • allow_type_cast (bool) – Allow casting scalar and index types. Defaults to False.

  • quiet (bool) – Suppress warnings. Defaults to False.

Return SimpleScene:

The loaded simple scene.

Return type:

scene.SimpleScene3D

lagrange.serialization.mesh_format_version()

Return the current mesh serialization format version.

Return type:

int

lagrange.serialization.save_mesh(filename, mesh, compress=True, compression_level=3, num_threads=0)

Save a mesh to a binary file.

Parameters:
  • filename (str | os.PathLike) – Output file path.

  • mesh (lagrange.core.SurfaceMesh) – The mesh to save.

  • compress (bool) – Enable zstd compression. Defaults to True.

  • compression_level (int) – Zstd compression level (1-22). Defaults to 3.

  • num_threads (int) – Number of compression threads. 0 = automatic, 1 = single-threaded. Defaults to 0.

Return type:

None

lagrange.serialization.save_scene(filename, scene, compress=True, compression_level=3, num_threads=0)

Save a scene to a binary file.

Parameters:
  • filename (str | os.PathLike) – Output file path.

  • scene (lagrange.scene.Scene) – The scene to save.

  • compress (bool) – Enable zstd compression. Defaults to True.

  • compression_level (int) – Zstd compression level (1-22). Defaults to 3.

  • num_threads (int) – Number of compression threads. 0 = automatic, 1 = single-threaded. Defaults to 0.

Return type:

None

lagrange.serialization.save_simple_scene(filename, scene, compress=True, compression_level=3, num_threads=0)

Save a simple scene to a binary file.

Parameters:
  • filename (str | os.PathLike) – Output file path.

  • scene (lagrange.scene.SimpleScene3D) – The simple scene to save.

  • compress (bool) – Enable zstd compression. Defaults to True.

  • compression_level (int) – Zstd compression level (1-22). Defaults to 3.

  • num_threads (int) – Number of compression threads. 0 = automatic, 1 = single-threaded. Defaults to 0.

Return type:

None

lagrange.serialization.scene_format_version()

Return the current scene serialization format version.

Return type:

int

lagrange.serialization.serialize_mesh(mesh, compress=True, compression_level=3, num_threads=0)

Serialize a mesh to a bytes buffer.

Parameters:
  • mesh (lagrange.core.SurfaceMesh) – The mesh to serialize.

  • compress (bool) – Enable zstd compression. Defaults to True.

  • compression_level (int) – Zstd compression level (1-22). Defaults to 3.

  • num_threads (int) – Number of compression threads. 0 = automatic, 1 = single-threaded. Defaults to 0.

Return bytes:

A bytes object containing the serialized mesh.

Return type:

bytes

lagrange.serialization.serialize_scene(scene, compress=True, compression_level=3, num_threads=0)

Serialize a scene to a bytes buffer.

Parameters:
  • scene (lagrange.scene.Scene) – The scene to serialize.

  • compress (bool) – Enable zstd compression. Defaults to True.

  • compression_level (int) – Zstd compression level (1-22). Defaults to 3.

  • num_threads (int) – Number of compression threads. 0 = automatic, 1 = single-threaded. Defaults to 0.

Return bytes:

A bytes object containing the serialized scene.

Return type:

bytes

lagrange.serialization.serialize_simple_scene(scene, compress=True, compression_level=3, num_threads=0)

Serialize a simple scene to a bytes buffer.

Parameters:
  • scene (lagrange.scene.SimpleScene3D) – The simple scene to serialize.

  • compress (bool) – Enable zstd compression. Defaults to True.

  • compression_level (int) – Zstd compression level (1-22). Defaults to 3.

  • num_threads (int) – Number of compression threads. 0 = automatic, 1 = single-threaded. Defaults to 0.

Return bytes:

A bytes object containing the serialized simple scene.

Return type:

bytes

lagrange.serialization.simple_scene_format_version()

Return the current simple scene serialization format version.

Return type:

int