Overview
MeshMash uses a simple, flexible representation for triangular meshes that enables efficient spectral processing. The library accepts meshes in multiple formats but internally works with a standardized tuple-based representation.Core Mesh Format
At its core, a mesh in MeshMash is represented as a tuple of two NumPy arrays:Vertices
The vertices array is an(n, 3) NumPy array where:
nis the number of vertices in the mesh- Each row contains the
(x, y, z)coordinates of a vertex
Faces
The faces array is an(m, 3) NumPy array where:
mis the number of triangular faces- Each row contains indices into the vertices array that form a triangle
Mesh Interpretation
MeshMash provides theinterpret_mesh() function to convert various mesh formats into the standard representation:
Type Definition
TheMesh type in MeshMash is defined as:
vertices and faces attributes.
The
interpret_mesh() function will raise a ValueError if the input is neither a tuple nor an object with vertices and faces attributes.Working with Mesh Data
Converting to PyVista
MeshMash integrates with PyVista for visualization and additional mesh operations:Extracting Mesh Edges
Get the edges of a mesh as an array:Creating an Adjacency Matrix
Convert a mesh to a sparse adjacency matrix with edge lengths as weights:Mesh Utilities
Subsetting Meshes
Extract a portion of a mesh based on vertex indices:Combining Meshes
Merge multiple meshes into a single mesh:Finding Connected Components
Get the largest connected component:Best Practices
Memory Efficiency: The tuple-based representation is memory-efficient and works well with NumPy’s vectorized operations. For very large meshes, consider using appropriate data types (e.g.,
np.float32 instead of np.float64).Related Functions
interpret_mesh()- Convert various formats to standard mesh tuplemesh_to_poly()- Convert to PyVista PolyDatapoly_to_mesh()- Convert from PyVista to mesh tuplefix_mesh()- Repair mesh topology using pymeshfixscale_mesh()- Scale mesh coordinates by a factor