- π§ Dispatch-based mesh I/O: Read PyVista datasets, convert between PyVista, Trimesh, MeshIO, and Warp meshes, and write registered objects by file suffix.
- ποΈ Wrap sidecars: Load and save Faceform Wrap landmark and polygon-selection JSON files with predictable sidecar naming.
- π Surface helpers: Select named OBJ groups, extract surfaces, compute edge lengths, orient normals, and compute geodesic paths.
- π§± Tetrahedral helpers: Repair tetra winding and estimate per-cell volume fractions against a closed triangular surface.
- π Data transfer: Move arrays from triangle cells to triangle points, then from triangle points to tetrahedral points.
- π οΈ External integrations: Wrap PyMeshFix, TetWild, and Faceform Wrap project templates while keeping the core APIs small.
uv add liblaf-melonMelon requires Python 3.12 or newer and pulls in mesh-processing libraries such as PyVista, Trimesh, MeshIO, Warp, and PyTetWild.
import numpy as np
import pyvista as pv
from liblaf.melon import io, tet, tri, xfer
surface = pv.Sphere(theta_resolution=16, phi_resolution=16)
io.save(surface, "surface.vtp")
loaded = io.load_polydata("surface.vtp")
edge_lengths = tri.edge_length(loaded)
tetmesh = pv.UnstructuredGrid(
np.array([4, 0, 1, 2, 3]),
np.array([pv.CellType.TETRA]),
np.array(
[
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
]
),
)
tetmesh = tet.fix_winding(tetmesh)
loaded.point_data["distance"] = np.linalg.norm(loaded.points, axis=1)
xfer.tri_point_to_tet_point(loaded, tetmesh, {"distance": -1.0})You can use GitHub Codespaces for online development:
Or clone it for local development:
gh repo clone liblaf/melon
cd melon
mise run install
UV_FROZEN=1 uv run pytest -q
UV_FROZEN=1 mise run lint
UV_FROZEN=1 mise run docs:buildContributions of all types are welcome. For bugs, API ideas, or mesh workflow improvements, open an issue on GitHub.
- π Grapes - Supercharge your Python with rich logging, precise timing, and seamless serialization.
- π Tangerine - Squeeze dynamic content into your files with Tangerine's template magic.
- π Apple - Differentiable physics simulation with elastic energy models and finite elements.
- π Cherries - Sweet experiment tracking with Comet, DVC, and Git integration.

