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 k triangles with the nearest centroids are tested, so a point must be close to the surface compared with the triangle size.

Parameters:
triaTriaMesh

Triangle mesh.

pointsnp.ndarray

Query points of shape (n_points, 3).

kint, default=8

Number of candidate triangles per point.

Returns:
closestnp.ndarray

Closest surface point for each query point, shape (n_points, 3).

tria_idxnp.ndarray

Index of the triangle that contains each closest point.

Raises:
ValueError

If k is not a positive integer.

Parameters:
Return type:

tuple[ndarray, ndarray]

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

Oriented manifold triangle mesh.

target_lengthfloat, default=None

Target edge length. Defaults to the mean edge length of the input.

iterationsint, default=5

Number of split, collapse, flip, smooth and project iterations.

max_roundsint, default=10

Maximum number of rounds per operation and iteration. Later rounds do little, and what is left carries over to the next iteration.

Returns:
TriaMesh

Remeshed surface, oriented like the input. A 2D mesh stays 2D.

Raises:
ValueError

If the mesh is not manifold or not oriented, or if the target length is not a finite positive number.

Parameters:
Return type:

TriaMesh

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.