lapy.remesh¶
Isotropic remeshing of triangle meshes after Botsch and Kobbelt.
Each iteration splits long edges, collapses short edges, flips edges towards valence 6, smooths tangentially and projects the vertices back onto the input surface. Every operation runs in rounds over sets of edges whose neighborhoods do not overlap, so a round is a few array operations instead of a loop over the mesh.
- lapy.remesh.closest_points(tria, points, k=8)[source]¶
Find the closest point on a triangle mesh for each query point.
Only the
ktriangles with the nearest centroids are tested, so a point must be close to the surface compared with the triangle size.- Parameters:
- tria
TriaMesh Triangle mesh.
- points
np.ndarray Query points of shape (n_points, 3).
- k
int, default=8 Number of candidate triangles per point.
- tria
- Returns:
- closest
np.ndarray Closest surface point for each query point, shape (n_points, 3).
- tria_idx
np.ndarray Index of the triangle that contains each closest point.
- closest
- Raises:
ValueErrorIf
kis not a positive integer.
- Parameters:
- Return type:
- lapy.remesh.remesh(tria, target_length=None, iterations=5, max_rounds=10)[source]¶
Remesh a triangle mesh to near-equilateral triangles of a given edge length.
This follows the remeshing approach of Botsch and Kobbelt [1]. Edges longer than 4/3 of the target are split at their midpoint, and edges shorter than 4/5 of it are collapsed to their midpoint. A collapse is only done if it keeps the topology, creates no edge longer than 4/3 of the target and tilts no triangle by more than 60 degrees. The topology check is the link condition [2]: the two end points of the edge may share no neighbors other than the two vertices opposite the edge. Edges are then flipped where that brings vertex valences closer to 6, and the vertices are smoothed tangentially and projected back onto the input surface. Boundary vertices stay where they are.
- Parameters:
- tria
TriaMesh Oriented manifold triangle mesh.
- target_length
float, default=None Target edge length. Defaults to the mean edge length of the input.
- iterations
int, default=5 Number of split, collapse, flip, smooth and project iterations.
- max_rounds
int, default=10 Maximum number of rounds per operation and iteration. Later rounds do little, and what is left carries over to the next iteration.
- tria
- Returns:
TriaMeshRemeshed surface, oriented like the input. A 2D mesh stays 2D.
- Raises:
ValueErrorIf the mesh is not manifold or not oriented, or if the target length is not a finite positive number.
- Parameters:
- Return type:
References
[1]M. Botsch and L. Kobbelt. A remeshing approach to multiresolution modeling. In Proceedings of the Eurographics/ACM SIGGRAPH Symposium on Geometry Processing, pages 185-192, 2004. doi:10.1145/1057432.1057457
[2]T. K. Dey, H. Edelsbrunner, S. Guha and D. V. Nekhayev. Topology preserving edge contraction. Publications de l’Institut Mathematique (Beograd), 66(80):23-45, 1999.