$ show cnr-isti-vclab/PyMeshLab
PyMeshLab is a Python library that provides bindings to the core functionality of MeshLab, a mature C++ application for processing and editing large 3D triangle meshes and point clouds. The library exposes a MeshSet class that wraps hundreds of geometry processing filters (e.g., simplification, smoothing, Boolean operations, surface reconstruction, parameterization) via a dynamic method registration pattern—each filter becomes an method on MeshSet at import time. The architecture relies on a pybind11-based C++ extension module that communicates with MeshLab's filter plugins, VCG library, Eigen, and Qt. Users can load meshes in many standard formats (OBJ, PLY, STL, etc.), apply filters with typed parameters (including custom types like PercentageValue and Color), and export results. The project includes comprehensive documentation, automated tests with sample meshes, and cross-platform build scripts for Linux, macOS, and Windows. While the library is tightly coupled to the MeshLab submodule, its design patterns—such as dynamic filter registration and reusable parameter wrappers—demonstrate solid engineering for bridging C++ and Python.
The LLM identified 4 files worth highlighting for reuse:
This module dynamically registers each MeshLab filter as a method on the MeshSet class at import time, using `filter_list()` and `__getattr__`. This pattern allows the library to expose hundreds of backend functions with minimal Python code, and could be adapted for any project that needs to automatically mirror a large set of C++ functions into Python methods.
Implements the PercentageValue class, a parameter type that holds a float value interpreted as a percentage relative to the mesh's bounding box diagonal. This enables scale-invariant parameter specification – a reusable pattern for any 3D geometry library needing user-friendly, relative sizing.
Implements the PureValue class, which wraps a string or number for filter parameters that have no natural bounded range. It demonstrates a clean way to pass flexible user input (e.g., a custom label string) through a typed interface, reusable for generic parameter handling in pybind11 projects.
This file contains the pybind11 bindings for the MeshSet C++ class. It shows how to expose a complex, stateful C++ object with many methods (filter application, I/O, layer management) to Python. The pattern of adding methods via `def` and `def_static` with autogenerated docstrings from the C++ side is a blueprint for wrapping large C++ libraries.