geomfum.shape package#

Subpackages#

Submodules#

geomfum.shape.hierarchical module#

Hierarchical objects.

class geomfum.shape.hierarchical.HierarchicalMesh(*args, **kwargs)[source]#

Bases: WhichRegistryMixins, HierarchicalShape

Hierarchical mesh.

Parameters:
  • low (TriangleMesh) – Low resolution shape.

  • high (TriangleMesh) – High resolution shape.

class geomfum.shape.hierarchical.HierarchicalShape(low, high)[source]#

Bases: ABC

Hierarchical shape.

Parameters:
  • low (Shape) – Low-resolution shape.

  • high (Shape) – High-resolution shape.

extend_basis(set_as_basis=True)[source]#

Extend basis.

See section 3.3. of [MBMR2023] for details.

Parameters:

set_as_basis (bool) – Whether to set as basis.

Returns:

vecs (array-like, shape=[high.n_vertices, spectrum_size]) – Eigenvectors.

References

[MBMR2023]

Filippo Maggioli, Daniele Baieri, Simone Melzi, and Emanuele Rodolà. “ReMatching: Low-Resolution Representations for Scalable Shape

Correspondence.” arXiv, October 30, 2023. https://doi.org/10.48550/arXiv.2305.09274.

abstract scalar_low_high(scalar)[source]#

Transfer scalar from low-resolution to high.

Parameters:

scalar (array-like, shape=[…, low.n_vertices]) – Scalar map on the low-resolution shape.

Returns:

high_scalar (array-like, shape=[…, high.n_vertices]) – Scalar map on the high-resolution shape.

class geomfum.shape.hierarchical.NestedHierarchicalMesh(hshapes)[source]#

Bases: NestedHierarchicalShape

Nested hierachical mesh.

property hmeshes#

Meshes from low to high resolution.

Remarks#

hshapeslist[HierarchicalMesh]

Hierarchical meshes from low to high resolution.

property meshes#

Meshes from low to high resolution.

Remarks#

mesheslist[Mesh]

List of meshes from low to high resolution.

property n_faces#

Number of faces at each level.

Returns:

n_faces (list[int])

property n_vertices#

Number of vertices at each level.

Returns:

n_vertices (list[int])

class geomfum.shape.hierarchical.NestedHierarchicalShape(hshapes)[source]#

Bases: object

Nested hierachical shape.

Parameters:

hshapes (list[HierarchicalShape]) – Hierarchical shapes from low to high resolution.

extend_basis(set_as_basis=True, n_levels=None)[source]#

Extend basis.

See section 3.3. of [MBMR2023] for details.

Parameters:
  • set_as_basis (bool) – Whether to set as basis.

  • n_levels (int) – Number of levels to transfer scalar. If None transfer up to maximum resolution.

Returns:

vecs (list[array-like], shape=[level.n_vertices, spectrum_size]) – Eigenvectors. As many as number of levels.

References

[MBMR2023]

Filippo Maggioli, Daniele Baieri, Simone Melzi, and Emanuele Rodolà. “ReMatching: Low-Resolution Representations for Scalable Shape

Correspondence.” arXiv, October 30, 2023. https://doi.org/10.48550/arXiv.2305.09274.

classmethod from_hierarchical_shape(shape, HierarchicalShape, **kwargs)[source]#

Create nested from hierarchical.

Parameters:
  • shape (Shape.) – High-resolution shape.

  • HierarchicalShape (HierarchicalShape object) – Class for the mapping between two resolutions. Signature: `(high_res_shape, **kwargs).

  • kwargs (dict) – Each must be a list with the proper number of resolution levels.

property highest#

Highest resolution shape.

Returns:

shape (Shape.)

property lowest#

Lowest resolution shape.

Returns:

shape (Shape.)

scalar_low_high(scalar, n_levels=None)[source]#

Transfer scalar from low-resolution to high.

Parameters:
  • scalar (array-like, shape=[…, low.n_vertices]) – Scalar map on the low-resolution shape.

  • n_levels (int) – Number of levels to transfer scalar. If None transfer up to maximum resolution.

Returns:

high_scalar (list[array-like], shape=[…, level.n_vertices]) – Scalar map on the shape at corresponding level. As many as number of levels.

property shapes#

Shapes from low to high resolution.

Remarks#

shapeslist[Shape]

List of shapes from low to high resolution.

geomfum.shape.mesh module#

Definition of triangle mesh.

class geomfum.shape.mesh.TriangleMesh(vertices, faces)[source]#

Bases: Shape

Triangle mesh.

Parameters:
  • vertices (array-like, shape=[n_vertices, 3]) – Vertices of the mesh.

  • faces (array-like, shape=[n_faces, 3]) – Faces of the mesh.

property dist_matrix#

Compute metric distance matrix.

Returns:

_dist_matrix (array-like, shape=[n_vertices, n_vertices]) – Metric distance matrix.

property edge_tangent_vectors#

Compute edge tangent vectors.

Returns:

edge_tangent_vectors (array-like, shape=[n_edges, 2]) – Tangent vectors of the edges, projected onto the local tangent plane.

property edges#

Edges of the mesh.

Returns:

edges (array-like, shape=[n_edges, 2])

equip_with_metric(metric)[source]#

Set the metric for the mesh.

Parameters:

metric (class) – A metric class to use for the mesh.

property face_area_vectors#

Compute face area vectors of a triangular mesh. The face area vector is the vector normal to the face, with a length equal to the area of the face.

Returns:

area_vectors (array-like, shape=[n_faces, 3]) – Per-face area vectors.

property face_areas#

Compute per-face areas.

Returns:

face_areas (array-like, shape=[n_faces]) – Per-face areas.

property face_normals#

Compute face normals of a triangular mesh.

Returns:

normals (array-like, shape=[n_faces, 3]) – Per-face normals.

property face_vertex_coords#

Extract vertex coordinates corresponding to each face.

Returns:

vertices (array-like, shape=[{n_faces}, n_per_face_vertex, 3]) – Coordinates of the ith vertex of that face.

classmethod from_file(filename)[source]#

Instantiate given a file.

Parameters:

filename (str) – Path to the mesh file.

Returns:

mesh (TriangleMesh) – A triangle mesh.

property gradient_matrix#

Compute the gradient operator as a complex sparse matrix.

This code locally fits a linear function to the scalar values at each vertex and its neighbors, extracts the gradient in the tangent plane, and assembles the global sparse matrix that acts as the discrete gradient operator on the mesh.

Returns:

  • grad_op (xgs.sparse.csc_matrix, shape=[n_vertices, n_vertices])

  • grad_op (xgs.sparse.csc_matrix, shape=[n_vertices, n_vertices]) – Complex sparse matrix representing the gradient operator. The real part corresponds to the X component in the local tangent frame, and the imaginary part corresponds to the Y component.

property n_faces#

Number of faces.

Returns:

n_faces (int)

property n_vertices#

Number of vertices.

Returns:

n_vertices (int)

property vertex_areas#

Compute per-vertex areas.

Area of a vertex, approximated as one third of the sum of the area of its adjacent triangles.

Returns:

vertex_areas (array-like, shape=[n_vertices]) – Per-vertex areas.

property vertex_normals#

Compute vertex normals of a triangular mesh.

Returns:

normals (array-like, shape=[n_vertices, 3]) – Normalized per-vertex normals.

property vertex_tangent_frames#

Compute vertex tangent frame.

Returns:

tangent_frame (array-like, shape=[n_vertices, 3, 3]) – Tangent frame of the mesh, where: - [n_vertices, 0, :] are the X basis vectors - [n_vertices, 1, :] are the Y basis vectors - [n_vertices, 2, :] are the vertex normals

geomfum.shape.point_cloud module#

Definition of point cloud.

class geomfum.shape.point_cloud.PointCloud(vertices)[source]#

Bases: Shape

Point cloud.

Parameters:

vertices (array-like, shape=[n_vertices, 3]) – Vertices of the point cloud.

classmethod from_file(filename)[source]#

Instantiate given a file.

Returns:

mesh (PointCloud) – A point cloud.

property n_vertices#

Number of points.

Returns:

n_vertices (int)

Module contents#