Skip to content

Repository files navigation

✨ 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

importnumpyasnpimportpyvistaaspvfromliblaf.melonimportio, tet, tri, xfersurface=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

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages