Foldover-free maps
Implementation of the Foldover-free maps in 50 lines of code paper by Garanzha et al.
Usage
import mouette as M
untangler = M.parametrization.WinslowInjectiveEmbedding(mesh, uv_init, lmbd=1.)
untangler.run()
See this script for a full example.
Method
Given a triangulation \(M=(V,T)\) of a disk-topology object and some initial \(uv\)-coordinates on the vertices of \(M\), this method optimizes the \(uv\)-coordinates under fixed boundary so that no triangle is inverted in the final \(uv\)-mapping. This is done through the optimization of an energy function that acts on jacobian matrices \(J \in \mathbb{R}^2\) of each triangle elements:
where:
and \(\chi\) is a regularization function:
\(\varepsilon\) is chosen during optimization as a decreasing sequence.
WinslowInjectiveEmbedding(mesh, uv_init, verbose=True, **kwargs)
Bases: BaseParametrization
Foldover-free map to the plane: computes an injective embedding in the plane starting from the provided \(uv\)-coordinates by minimizing the regularized Winslow functionnal
of Garanzha et al. [1]. This class is essentially a wrapper around the untangle
function.
Warning
The input mesh should have the topology of a disk.
UV coordinates are computed per vertex and not per corner. See mouette.attributes.scatter_vertices_to_corners
for conversion.
References
[1] Foldover-free maps in 50 lines of code, Garanzha et al., ACM ToG 2021
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh
|
SurfaceMesh
|
the supporting mesh. Should be a surface with disk topology. |
required |
uv_init
|
ArrayAttribute
|
array of initial uv-coordinates per vertices. np.array of shape (V,2) or mouette.ArrayAttribute object. |
required |
verbose
|
bool
|
verbose mode. Defaults to True. |
True
|
Other Parameters:
Name | Type | Description |
---|---|---|
stop_if_positive |
bool
|
whether to stop the optimization as soon as all determinants are positive. Defaults to False. |
solver_verbose |
bool
|
Verbose tag for the L-BFGS solver. Defaults to False. |
Attributes:
Name | Type | Description |
---|---|---|
uvs |
Attribute
|
an attribute containing the uv-coordinates of the parametrization |
flat_mesh
property
A flat representation of the mesh where uv-coordinates are copied to xy.
Returns:
Name | Type | Description |
---|---|---|
SurfaceMesh |
SurfaceMesh
|
the flat mesh |
run()
Calls the solver.
Raises:
Type | Description |
---|---|
Exception
|
fails if the mesh is not a triangulation of a topological disk |
untangle(points, locked, triangles, ref_jacs, verbose=False, **kwargs)
Minimizes the regularized Winslow functional to untangle a 2D triangulation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points
|
ndarray[float]
|
Initial position of points in 2D. Should be of shape (2*V,) |
required |
locked
|
ndarray[bool]
|
Which points have a fixed position. Should be of shape (V,) |
required |
triangles
|
ndarray[int]
|
Indices of triangles. Should be of shape (T,3) |
required |
ref_jacs
|
ndarray[float]
|
Perfect element to consider for Jacobian computation for each triangle. Should be of shape (T,2,2). |
required |
verbose
|
(bool, optional)
|
Verbose mode. Defaults to False. |
False
|
Other Parameters:
Name | Type | Description |
---|---|---|
areas |
ndarray[float]
|
Areas of triangles in original mesh. Used as a weighting term in the energy's summation. Should be of shape (T,). Defaults to np.ones(T). |
weight_angles |
float
|
weight coefficient for the angle conservation term (f). Defaults to 1. |
weight_areas |
float
|
weight coefficient for the area conservation term (g). Defaults to 1. |
iter_max |
int
|
Maximum number of iterations in the L-BFGS solver. Defaults to 10000. |
n_eps_update |
int
|
number of updates of the regularization's epsilon. Defaults to 10. |
stop_if_positive |
bool
|
enable early stopping as soon as all dets are positive. Defaults to False. |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray[float]: final positions of points in 2D, in shape (2V,) |
References
[1] Foldover-free maps in 50 lines of code, Garanzha et al., ACM ToG 2021