Overview
Thesplit module provides functions and classes for splitting large meshes into smaller submeshes for parallel processing, and stitching the results back together. This is particularly useful when working with meshes that exceed memory limits or when you want to parallelize operations across mesh regions.
Functions
fit_mesh_split
Splits a mesh into submeshes based on spectral graph partitioning.The mesh to split. Can be a Mesh object, adjacency matrix (numpy array), or sparse adjacency matrix (csr_array).
Maximum number of vertices allowed in each submesh.
Minimum number of vertices required for a submesh to be considered.
Maximum number of splitting rounds to perform.
Whether to print progress information during splitting.
np.ndarray - An array mapping each vertex to its submesh ID. Vertices not assigned to any submesh have value -1.
apply_mesh_split
Applies a submesh mapping to create separate mesh objects.The original mesh to split.
The vertex-to-submesh mapping returned by
fit_mesh_split.list[Mesh] - A list of submesh tuples, each containing (vertices, faces).
fit_overlapping_mesh_split
Splits a mesh into overlapping submeshes, which is useful for processing that requires local context.The mesh to split.
Distance (in mesh units) to extend each submesh beyond its boundary for overlap.
Maximum number of vertices in each core submesh (before adding overlap).
Maximum number of splitting rounds.
list[np.ndarray] - A list of vertex index arrays, one for each overlapping submesh.
fit_mesh_split_lap
Splits a mesh using cotangent Laplacian bisection instead of graph Laplacian. This method can produce better splits for irregular meshes by considering geometric properties.The mesh to split.
Maximum number of vertices allowed in each submesh.
Minimum number of vertices required for a submesh to be considered.
Maximum number of splitting rounds to perform.
Whether to use robust Laplacian computation.
Mollification factor for robust Laplacian.
Whether to print progress information.
np.ndarray - An array mapping each vertex to its submesh ID.
graph_laplacian_split
Performs a single bisection of a mesh using the graph Laplacian. This is the low-level splitting primitive used byfit_mesh_split.
Sparse adjacency matrix representing the mesh connectivity.
Data type for computations.
tuple[np.ndarray, np.ndarray] - Two arrays containing indices for each half of the split.
get_submesh_borders
Identifies border vertices in a submesh (vertices on the boundary where the mesh was cut).The submesh to analyze.
np.ndarray - Array of vertex indices that lie on the submesh boundary.
This function currently requires the input mesh to be manifold.
Classes
MeshStitcher
A class for splitting meshes, applying functions to submeshes in parallel, and stitching results back together.The mesh to process.
Verbosity level. 0 or False for silent, 1 for basic progress, 2+ for detailed timing.
Number of parallel jobs. -1 uses all available cores, 1 disables parallelization.
Methods
split_mesh
Splits the mesh into overlapping submeshes.Maximum vertices per submesh.
Minimum vertices for a submesh to be considered.
Distance to extend submesh boundaries for overlap.
Maximum splitting iterations.
Limit the number of overlap neighbors to include. None means no limit.
Whether to verify each submesh is fully connected.
list[Mesh] - List of overlapping submeshes.
apply
Applies a function to each submesh in parallel and optionally stitches results.Function to apply. Should take a mesh as first argument and return a feature array with one row per vertex.
Additional positional arguments to pass to the function.
Value to use for vertices not assigned to any submesh.
Whether to stitch results back into a single array. If False, returns list of per-submesh results.
Additional keyword arguments to pass to the function.
np.ndarray or list - Stitched feature array (if stitch=True) or list of per-submesh results.
subset_apply
Applies a function only to submeshes containing specified vertices.Function to apply to relevant submeshes.
Vertex indices that determine which submeshes to process.
Additional positional arguments to pass to the function.
If True, return only features for the specified indices. If False, return features for all vertices.
Value for unprocessed vertices.
Additional keyword arguments to pass to the function.
np.ndarray - Feature array for all vertices (or just specified indices if reindex=True).
apply_on_features
Applies a function to each submesh along with corresponding feature data.Function to apply. Should take (mesh, features) as first two arguments.
Feature array with one row per vertex in the original mesh.
Additional positional arguments to pass to the function.
Value for unprocessed vertices.
Additional keyword arguments to pass to the function.
np.ndarray - Stitched feature array.
stitch_features
Stitches per-submesh feature arrays back into a single array for the full mesh.List of feature arrays, one per submesh. Can contain None for submeshes that weren’t processed.
Value to use for vertices not in any submesh.
np.ndarray - Feature array with one row per vertex in the original mesh.
Usage Example
Here’s a complete example showing how to use MeshStitcher to process a large mesh in parallel:Notes
- The splitting algorithm uses spectral graph partitioning based on the mesh Laplacian
- Overlapping submeshes ensure smooth transitions when stitching results
- The
MeshStitcherclass handles the complexity of managing submesh boundaries and overlaps - All parallel operations use joblib for efficient CPU utilization
- When stitching, only the non-overlapping portions of each submesh are used to avoid duplication