entente.restore_correspondence module

entente.restore_correspondence.find_permutation(a, b, progress=True)[source]

Given a kxn array a and its permutation b, order the indices of a such that a[find_permutation(a, b)] is equal to b.

The permutation must be along the first axis, such that a[0], a[1], … and b[0], b[1], … have the same elements.

Parameters:
  • a (np.arraylike) – kxn array
  • b (np.arraylike) – kxn array
  • progress (bool) – When True, show a progress bar.
Returns:

Indices of b as kx1

Return type:

np.ndarray

Note

This relies on a brute-force algorithm.

entente.restore_correspondence.restore_correspondence(mesh, reference_mesh, progress=True)[source]

Given mesh which has the same vertex set as a given reference_mesh, but which has lost its correspondence due to the vertices being shuffled, reorder the vertices in mesh so they match the order in reference_mesh.

Parameters:
  • mesh (lace.mesh.Mesh) – A mesh, which will be mutated
  • reference_mesh (lace.mesh.Mesh) – Another mesh with the same set of vertices in the desired order
  • progress (bool) – When True, show a progress bar.
Returns:

vx1 mapping of old face indices to new

Return type:

np.ndarray

Note

This was designed to assist in extracting face ordering and groups from a shuffled mesh that “work” with reference_mesh.

It relies on a brute-force algorithm.