liblaf.melon.io
¶
I/O dispatchers and mesh-format conversion helpers.
Modules:
-
abc–Reusable dispatchers for readers, writers, and converters.
-
pyvista–PyVista readers, writers, and conversion dispatchers.
-
trimesh–Trimesh conversion and writer registration.
-
utils– -
vtk– -
warp–Warp mesh conversion helpers.
-
wrap–JSON sidecar helpers for Faceform Wrap projects.
Classes:
-
AbstractConverter–Callable that converts one object into another mesh representation.
-
AbstractReader–Callable that loads an object from a path.
-
AbstractWriter–Callable that writes an object to a path.
-
ConverterDispatcher–Single-dispatch conversion registry with identity conversion built in.
-
ReaderDispatcher–Dispatch readers by file suffix with an optional fallback reader.
-
VTKHDFTemporalUnstructuredGridWriter– -
WriterDispatcher–Dispatch writers first by file suffix and then by object type.
Functions:
-
load_landmarks–Load Wrap landmark points from JSON.
-
load_polygons–Load selected polygon indices from JSON.
-
save_landmarks–Save landmark points in Wrap-compatible JSON format.
-
save_polygons–Save selected polygon indices for Wrap projects.
Attributes:
-
as_multiblock(ConverterDispatcher[MultiBlock]) –Convert supported scene objects to [
pyvista.MultiBlock][liblaf.melon.io.pyvista.MultiBlock]. -
as_polydata(ConverterDispatcher[PolyData]) –Convert supported mesh objects to [
pyvista.PolyData][liblaf.melon.io.pyvista.PolyData]. -
as_trimesh(ConverterDispatcher[Trimesh]) –Convert supported triangular mesh objects to [
trimesh.Trimesh][liblaf.melon.io.trimesh.Trimesh]. -
as_unstructured_grid(ConverterDispatcher[UnstructuredGrid]) –Convert supported volume meshes to [
pyvista.UnstructuredGrid][liblaf.melon.io.pyvista.UnstructuredGrid]. -
as_warp_mesh(ConverterDispatcher[Mesh]) –Convert supported triangular meshes to [
warp.Mesh][liblaf.melon.io.warp.Mesh]. -
load_multiblock(ReaderDispatcher[MultiBlock]) –Load a multi-block PyVista dataset.
-
load_polydata(ReaderDispatcher[PolyData]) –Load a surface mesh as [
pyvista.PolyData][liblaf.melon.io.pyvista.PolyData]. -
load_unstructured_grid(ReaderDispatcher[UnstructuredGrid]) –Load an unstructured volume mesh with PyVista.
-
save(WriterDispatcher[Any]) –Write registered mesh and scene objects to disk based on path suffix.
as_multiblock
module-attribute
¶
as_multiblock: ConverterDispatcher[MultiBlock] = (
ConverterDispatcher(pv.MultiBlock)
)
Convert supported scene objects to [pyvista.MultiBlock][liblaf.melon.io.pyvista.MultiBlock].
as_polydata
module-attribute
¶
as_polydata: ConverterDispatcher[PolyData] = (
ConverterDispatcher(pv.PolyData)
)
Convert supported mesh objects to [pyvista.PolyData][liblaf.melon.io.pyvista.PolyData].
as_trimesh
module-attribute
¶
as_trimesh: ConverterDispatcher[Trimesh] = (
ConverterDispatcher(tm.Trimesh)
)
Convert supported triangular mesh objects to [trimesh.Trimesh][liblaf.melon.io.trimesh.Trimesh].
as_unstructured_grid
module-attribute
¶
as_unstructured_grid: ConverterDispatcher[
UnstructuredGrid
] = ConverterDispatcher(pv.UnstructuredGrid)
Convert supported volume meshes to [pyvista.UnstructuredGrid][liblaf.melon.io.pyvista.UnstructuredGrid].
as_warp_mesh
module-attribute
¶
as_warp_mesh: ConverterDispatcher[Mesh] = (
ConverterDispatcher(wp.Mesh)
)
Convert supported triangular meshes to [warp.Mesh][liblaf.melon.io.warp.Mesh].
load_multiblock
module-attribute
¶
load_multiblock: ReaderDispatcher[MultiBlock] = (
ReaderDispatcher(pv.MultiBlock)
)
Load a multi-block PyVista dataset.
load_polydata
module-attribute
¶
load_polydata: ReaderDispatcher[PolyData] = (
ReaderDispatcher(pv.PolyData)
)
Load a surface mesh as [pyvista.PolyData][liblaf.melon.io.pyvista.PolyData].
load_unstructured_grid
module-attribute
¶
load_unstructured_grid: ReaderDispatcher[
UnstructuredGrid
] = ReaderDispatcher(pv.UnstructuredGrid)
Load an unstructured volume mesh with PyVista.
save
module-attribute
¶
save: WriterDispatcher[Any] = WriterDispatcher()
Write registered mesh and scene objects to disk based on path suffix.
AbstractConverter
¶
Bases: Protocol
flowchart TD
liblaf.melon.io.AbstractConverter[AbstractConverter]
click liblaf.melon.io.AbstractConverter href "" "liblaf.melon.io.AbstractConverter"
Callable that converts one object into another mesh representation.
-
API Reference
melonioConverterDispatcherregister -
API Reference
melonioabcConverterDispatcherregister
-
API Reference
melonioConverterDispatcherregister -
API Reference
melonioabcConverterDispatcherregister
Methods:
-
__call__–
AbstractReader
¶
Bases: Protocol
flowchart TD
liblaf.melon.io.AbstractReader[AbstractReader]
click liblaf.melon.io.AbstractReader href "" "liblaf.melon.io.AbstractReader"
Callable that loads an object from a path.
-
API Reference
melonioReaderDispatcherfallback -
API Reference
melonioReaderDispatcherregistry -
API Reference
melonioReaderDispatcherregister -
API Reference
melonioReaderDispatcherregister_fallback -
API Reference
melonioabcReaderDispatcherfallback -
API Reference
melonioabcReaderDispatcherregistry -
API Reference
melonioabcReaderDispatcherregister -
API Reference
melonioabcReaderDispatcherregister_fallback
-
API Reference
melonioReaderDispatcher -
API Reference
melonioReaderDispatcherregister -
API Reference
melonioReaderDispatcherregister_fallback -
API Reference
melonioabcReaderDispatcher -
API Reference
melonioabcReaderDispatcherregister -
API Reference
melonioabcReaderDispatcherregister_fallback
Methods:
-
__call__–
AbstractWriter
¶
Bases: Protocol
flowchart TD
liblaf.melon.io.AbstractWriter[AbstractWriter]
click liblaf.melon.io.AbstractWriter href "" "liblaf.melon.io.AbstractWriter"
Callable that writes an object to a path.
-
API Reference
melonioWriterDispatcherregister -
API Reference
melonioabcWriterDispatcherregister
-
API Reference
melonioWriterDispatcherregister -
API Reference
melonioabcWriterDispatcherregister
Methods:
-
__call__–
ConverterDispatcher
¶
Single-dispatch conversion registry with identity conversion built in.
The target type is registered as an identity conversion, so callers can pass through objects that are already in the requested representation.
Examples:
>>> converter = ConverterDispatcher(str)
>>> converter("mesh")
'mesh'
>>> @converter.register(int)
... def _from_int(obj, /, **kwargs):
... return str(obj)
>>> converter(42)
'42'
Parameters:
-
to_type(type[T]) –Target type returned unchanged when the input already has that runtime type.
-
registry(_SingleDispatchCallable[T], default:<dynamic>) –Underlying
functools.singledispatchregistry.
-
API Reference
melonioas_multiblock -
API Reference
melonioas_polydata -
API Reference
melonioas_trimesh -
API Reference
melonioas_unstructured_grid -
API Reference
melonioas_warp_mesh -
API Reference
meloniopyvistaas_multiblock -
API Reference
meloniopyvistaas_polydata -
API Reference
meloniopyvistaas_unstructured_grid -
API Reference
meloniopyvistamultiblockas_multiblock -
API Reference
meloniopyvistapolydataas_polydata -
API Reference
meloniopyvistaunstructured_gridas_unstructured_grid -
API Reference
meloniotrimeshas_trimesh -
API Reference
meloniowarpas_warp_mesh
-
API Reference
melonioas_multiblock -
API Reference
melonioas_polydata -
API Reference
melonioas_trimesh -
API Reference
melonioas_unstructured_grid -
API Reference
melonioas_warp_mesh -
API Reference
meloniopyvistaas_multiblock -
API Reference
meloniopyvistaas_polydata -
API Reference
meloniopyvistaas_unstructured_grid -
API Reference
meloniopyvistamultiblockas_multiblock -
API Reference
meloniopyvistapolydataas_polydata -
API Reference
meloniopyvistaunstructured_gridas_unstructured_grid -
API Reference
meloniotrimeshas_trimesh -
API Reference
meloniowarpas_warp_mesh
Methods:
Attributes:
-
registry(_SingleDispatchCallable[T]) –Underlying
functools.singledispatchregistry. -
to_type(type[T]) –Target type returned unchanged when the input already has that runtime type.
registry
class-attribute
instance-attribute
¶
registry: _SingleDispatchCallable[T] = attrs.field(
default=attrs.Factory(
_default_registry, takes_self=True
)
)
Underlying functools.singledispatch registry.
to_type
instance-attribute
¶
to_type: type[T]
Target type returned unchanged when the input already has that runtime type.
register
¶
register[F](
cls: _RegType, converter: AbstractConverter[F, T]
) -> AbstractConverter[F, T]
register[F](
cls: _RegType, converter: None = None
) -> Callable[
[AbstractConverter[F, T]],
AbstractConverter[F, T],
]
Source code in src/liblaf/melon/io/abc/_converter.py
ReaderDispatcher
¶
Dispatch readers by file suffix with an optional fallback reader.
Raises:
-
KeyError–If the path suffix is unknown and no fallback reader exists.
Attributes:
Parameters:
-
to_type(type[T]) – -
fallback(AbstractReader[T] | None, default:None) – -
registry(dict[str, AbstractReader[T]], default:<class 'dict'>) –dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
-
API Reference
melonioload_multiblock -
API Reference
melonioload_polydata -
API Reference
melonioload_unstructured_grid -
API Reference
meloniopyvistaload_multiblock -
API Reference
meloniopyvistaload_polydata -
API Reference
meloniopyvistaload_unstructured_grid -
API Reference
meloniopyvistamultiblockload_multiblock -
API Reference
meloniopyvistapolydataload_polydata -
API Reference
meloniopyvistaunstructured_gridload_unstructured_grid
-
API Reference
melonioload_multiblock -
API Reference
melonioload_polydata -
API Reference
melonioload_unstructured_grid -
API Reference
meloniopyvistaload_multiblock -
API Reference
meloniopyvistaload_polydata -
API Reference
meloniopyvistaload_unstructured_grid -
API Reference
meloniopyvistamultiblockload_multiblock -
API Reference
meloniopyvistapolydataload_polydata -
API Reference
meloniopyvistaunstructured_gridload_unstructured_grid
Methods:
registry
class-attribute
instance-attribute
¶
registry: dict[str, AbstractReader[T]] = attrs.field(
factory=dict
)
__call__
¶
Source code in src/liblaf/melon/io/abc/_reader.py
register
¶
register(
suffixes: Iterable[str], reader: AbstractReader[T]
) -> AbstractReader[T]
register(
suffixes: Iterable[str], reader: None = None
) -> Callable[[AbstractReader[T]], AbstractReader[T]]
Source code in src/liblaf/melon/io/abc/_reader.py
register_fallback
¶
register_fallback(
reader: AbstractReader[T],
) -> AbstractReader[T]
VTKHDFTemporalUnstructuredGridWriter
¶
Methods:
-
__enter__– -
__exit__– -
append– -
dataset– -
dataset_offsets– -
dataset_tail_equal– -
group–
Attributes:
__enter__
¶
__enter__() -> Self
Source code in src/liblaf/melon/io/vtk/_temporal_unstructured_grid.py
__exit__
¶
__exit__(
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
traceback: TracebackType | None,
) -> None
Source code in src/liblaf/melon/io/vtk/_temporal_unstructured_grid.py
append
¶
append(
mesh: UnstructuredGrid,
time: SupportsFloat | None = None,
) -> None
Source code in src/liblaf/melon/io/vtk/_temporal_unstructured_grid.py
dataset
¶
dataset(
name: str, data: ArrayLike | None = None
) -> Dataset
Source code in src/liblaf/melon/io/vtk/_temporal_unstructured_grid.py
dataset_offsets
¶
Source code in src/liblaf/melon/io/vtk/_temporal_unstructured_grid.py
dataset_tail_equal
¶
Source code in src/liblaf/melon/io/vtk/_temporal_unstructured_grid.py
WriterDispatcher
¶
Dispatch writers first by file suffix and then by object type.
Registered writers receive a pathlib.Path. Parent directories are created
before the writer is called, which keeps concrete writer implementations
focused on serialization.
Raises:
-
KeyError–If no writer registry exists for the path suffix.
-
NotImplementedError–If the suffix exists but the object type is not registered for that suffix.
Parameters:
-
registry(dict[str, _SingleDispatchCallable[None]], default:<class 'dict'>) –dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)
Methods:
Attributes:
registry
class-attribute
instance-attribute
¶
__call__
¶
Source code in src/liblaf/melon/io/abc/_writer.py
register
¶
register(
cls: _RegType,
suffixes: Iterable[str],
writer: AbstractWriter[T],
) -> AbstractWriter[T]
register(
cls: _RegType,
suffixes: Iterable[str],
writer: None = None,
) -> Callable[[AbstractWriter[T]], AbstractWriter[T]]
Source code in src/liblaf/melon/io/abc/_writer.py
load_landmarks
¶
Load Wrap landmark points from JSON.
Non-JSON mesh paths are mapped to a sibling .landmarks.json file. Missing
files return an empty (0, 3) array so annotation workflows can start from
an unmarked mesh.
Parameters:
-
path(StrPath) –Landmark JSON file or mesh path whose landmark sidecar should be inferred.
Returns:
-
Float[ndarray, 'L 3']–Landmark coordinates in
x,y,zorder.
Source code in src/liblaf/melon/io/wrap/_landmarks.py
load_polygons
¶
Load selected polygon indices from JSON.
Parameters:
-
path(StrPath) –JSON file containing polygon indices.
Returns:
-
Integer[ndarray, ' N']–One-dimensional
int32array of selected polygon indices. Missing files -
Integer[ndarray, ' N']–return an empty array.
Source code in src/liblaf/melon/io/wrap/_polygons.py
save_landmarks
¶
Save landmark points in Wrap-compatible JSON format.
Parameters:
-
landmarks(Float[ArrayLike, 'L 3']) –Array-like landmark coordinates with shape
(n, 3). -
path(StrPath) –Landmark JSON file or mesh path whose landmark sidecar should be inferred.
Source code in src/liblaf/melon/io/wrap/_landmarks.py
save_polygons
¶
save_polygons(
polygons: Bool[ArrayLike, " full"]
| Integer[ArrayLike, " selection"],
path: StrPath,
) -> None
Save selected polygon indices for Wrap projects.
Boolean masks are converted to their selected indices before serialization.
Parameters:
-
polygons(Bool[ArrayLike, ' full'] | Integer[ArrayLike, ' selection']) –Boolean mask over all polygons or explicit polygon indices.
-
path(StrPath) –JSON file to write.