Remeshing#
Uniform remeshing via the ACVD (Approximate Centroidal Voronoi Diagram) clustering algorithm. Given a target number of clusters, the algorithm redistributes mesh vertices to produce a more uniform cell distribution.
The approach is dimension-agnostic and works for any simplicial manifold:
Weight vertices by incident cell areas
Initialize clusters via area-based region growing
Remove spatially isolated cluster regions
Reconstruct a simplified mesh from cluster adjacency
Note
The output mesh may contain a small percentage (~0.5-1%) of non-manifold edges, which is inherent to the face-mapping approach. Higher cluster counts relative to mesh resolution produce better manifold quality.
from physicsnemo.mesh.remeshing import remesh
from physicsnemo.mesh.primitives.surfaces import sphere_icosahedral
mesh = sphere_icosahedral.load(subdivisions=3)
remeshed = remesh(mesh, n_clusters=100)
print(remeshed.n_cells) # approximately 200 triangles
API Reference#
Mesh remeshing and cell partitioning.
This module provides two complementary algorithms for mesh coarsening:
- Cell partitioning (
partition_cells()): Assigns each cell of a fine mesh to its nearest seed point (by Euclidean centroid distance) and accumulates area, normal, and centroid per cluster. This is a single-step discrete approximation to the restricted Voronoi diagram on the surface. Pure PyTorch, no external dependencies.
- ACVD remeshing (
remesh()): Iterative Approximate Centroidal Voronoi Diagram clustering that creates a new mesh topology with approximately uniform cell distribution. Requires the
pyacvdpackage.
partition_cells is also a natural building block for a pure-PyTorch CVT
(Lloyd’s algorithm iterates: partition -> move seeds to cluster centroids ->
repeat).
Example
>>> from physicsnemo.mesh.primitives.surfaces import sphere_icosahedral
>>> mesh = sphere_icosahedral.load(subdivisions=3)
>>> # Remesh a triangle mesh to ~100 triangles
>>> remeshed = remesh(mesh, n_clusters=100)
>>> assert remeshed.n_cells > 0