Skip to content

liblaf/melon

✨ Features

  • 🧭 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.

πŸ“¦ Installation

uv add liblaf-melon

Melon requires Python 3.12 or newer and pulls in mesh-processing libraries such as PyVista, Trimesh, MeshIO, Warp, and PyTetWild.

πŸš€ Quick Start

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})

⌨️ Local Development

You can use GitHub Codespaces for online development:

Open in GitHub Codespaces

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:build

🀝 Contributing

Contributions of all types are welcome. For bugs, API ideas, or mesh workflow improvements, open an issue on GitHub.

PR Welcome

Contributors

πŸ”— More Projects

  • πŸ‡ 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.

πŸ“ License

Copyright Β© 2025 liblaf.
This project is MIT licensed.

About

πŸ‰ A comprehensive Python library for 3D mesh processing with advanced I/O capabilities, proximity analysis, and integration with external mesh processing tools.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages