Welcome to entente’s documentation!¶
entente package¶
Submodules¶
entente.cgal_search module¶
cgal_search provides spatial search for vertices and faces. This is implemented atop CGAL’s axis-aligned-bounding-box search tree.
CGAL is a heavy dependency and therefore is optional. Before using this module, you must install CGAL and its Python bindings (which take quite some time to build).
On Mac OS:
brew install cgal swig
pip install cgal-bindings
# wait approximately one year
Note: The AABB tree is in the GPLv3-licensed portion of CGAL
-
entente.cgal_search.
create_aabb_tree
(mesh)[source]¶ Create a CGAL AABB tree from the given mesh.
Reports suggest trees may rely on some shared internal storage in CGAL, so to be conservative, finish using one before creating another.
See also
Returns: A CGAL AABB tree. Return type: CGAL.CGAL_AABB_tree
-
entente.cgal_search.
faces_nearest_to_points
(mesh, query_points, ret_points=False)[source]¶ Find the triangular faces on a mesh which are nearest to the given query points.
Parameters: - query_points (np.arraylike) – The points to query, with shape kx3
- ret_points (bool) – When True, return both the indices of the nearest faces and the closest points to the query points, which are not necessarily vertices. When False, return only the face indices.
Returns: face indices as kx1 np.ndarray, or when ret_points is True, a tuple also including the coordinates of the closest points as kx3 np.ndarray.
Return type: object
entente.cli module¶
entente.equality module¶
Utilities related to mesh equality.
-
entente.equality.
attr_has_same_shape
(first_obj, second_obj, attr)[source]¶ Given two objects, check if the given arraylike attributes of those objects have the same shape. If one object has an attribute value of
None
, the other must too.Parameters: - first_obj (obj) – A object with an arraylike
attr
attribute. - second_obj (obj) – Another object with an arraylike
attr
attribute. - attr (str) – The name of the attribute to test.
Returns: True if attributes are the same shape
Return type: bool
- first_obj (obj) – A object with an arraylike
-
entente.equality.
attr_is_equal
(first_obj, second_obj, attr)[source]¶ Given two objects, check if the given arraylike attributes of those objects are equal. If one object has an attribute value of
None
, the other must too.Parameters: - first_obj (obj) – A object with an arraylike attr attribute.
- second_obj (obj) – Another object with an arraylike attr attribute.
- attr (str) – The name of the attribute to test.
Returns: True if attributes are equal
Return type: bool
-
entente.equality.
have_same_topology
(first_mesh, second_mesh)[source]¶ Given two meshes, check if they have the same vertex count and same faces. In other words, check if they have the same topology.
Parameters: - first_mesh (lace.mesh.Mesh) – A mesh.
- second_mesh (lace.mesh.Mesh) – Another mesh.
Returns: True if meshes have the same topology
Return type: bool
entente.geometry module¶
Functions relating to mesh geometry.
-
entente.geometry.
compute_barycentric_coordinates
(vertices_of_tris, points)[source]¶ Compute barycentric coordinates for the projection of a set of points to a given set of triangles specfied by their vertices.
These barycentric coordinates can refer to points outside the triangle. This happens when one of the coordinates is negative. However they can’t specify points outside the triangle’s plane. (That requires tetrahedral coordinates.)
The returned coordinates supply a linear combination which, applied to the vertices, returns the projection of the original point the plane of the triangle.
Parameters: - vertices_of_tris (np.arraylike) – A set of triangle vertices as kx3x3.
- points (np.arraylike) – Coordinates of points as kx3.
Returns: Barycentric coordinates as kx3
Return type: np.ndarray
Note
A function with this signature probably belongs in blmath.
entente.landmarks module¶
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.
entente.shuffle module¶
entente.validation module¶
-
entente.validation.
validate_shape
(a, *shape, **kwargs)[source]¶ Check that the given argument has the expected shape. Shape dimensions can be ints or -1 for a wildcard. The wildcard dimensions are returned, which allows them to be used for subsequent validation or elsewhere in the function.
Parameters: - a (np.arraylike) – An array-like input.
- shape (list) – Shape to validate. To require 3 by 1, pass 3. To require n by 3, pass -1, 3.
- name (str) – Variable name to embed in the error message.
Returns: The wildcard dimension (if one) or a tuple of wildcard dimensions (if more than one).
Return type: object
-
entente.validation.
validate_shape_from_ns
(namespace, name, *shape)[source]¶ Convenience function for invoking validate_shape() with a locals() dict.
Parameters: - namespace (dict) – A subscriptable object, typically locals().
- name (str) – Key to pull from namespace.
- shape (list) – Shape to validate. To require 3 by 1, pass 3. To require n by 3, pass -1, 3.
Returns: The wildcard dimension (if one) or a tuple of wildcard dimensions (if more than one).
Return type: object
Example
validate_shape_from_namespace(locals(), ‘points’, -1, 3)