pymeshfix.MeshFix#
- class pymeshfix.MeshFix(*args, verbose: bool = False)#
Clean and tetrahedralize surface meshes using MeshFix.
- Parameters:
args (pyvista.PolyData | (np.ndarray, np.ndarray) | pathlib.Path | str) – Either a pyvista surface mesh
pyvista.PolyDataor an x 3vertex array andn x 3face array (indices of the triangles). Also supports reading directly from a file.verbose (bool, default: False) – Set this to
Trueto enable additional output from MeshFix.
Examples
Create a meshfix object from a pyvista mesh.
>>> from pyvista import examples >>> from pymeshfix import MeshFix >>> cow = examples.download_cow() >>> mfix = MeshFix(cow)
Create a meshfix object from two numpy arrays. This example is incomplete as it does not contain the entire array.
>>> import numpy as np >>> points = np.array( ... [ ... [3.71636, 2.343387, 0.0], ... [4.126565, 0.642027, 0.0], ... [3.454971, 2.169877, 0.0], ... ..., ... [4.12616, 2.12093, 1.17252], ... [4.133175, 2.175231, 1.259323], ... [4.232341, 1.903079, 0.534362], ... ], ... dtype=float32, ... ) >>> faces = np.array( ... [ ... [210, 252, 251], ... [250, 251, 252], ... [201, 253, 210], ... ..., ... [1965, 2193, 2194], ... [2391, 2398, 970], ... [966, 961, 970], ... ] ... ) >>> mfix = MeshFix(points, faces)
Methods
MeshFix.clean([max_iters, inner_loops])Remove degenerate triangles and self-intersections.
MeshFix.degeneracy_removal([max_iter])Remove degenerate triangles.
Extract the boundaries of the holes in this mesh to a new PyVista mesh of lines.
MeshFix.fill_holes([n_edges, refine])Fill small boundary loops (holes) in the mesh.
MeshFix.intersection_removal([max_iter])Remove self-intersecting triangles.
Attempt to join nearby open components.
MeshFix.load_arrays(v, f)Load triangular mesh from vertex and face numpy arrays.
MeshFix.plot([show_holes])Plot the mesh.
Remove all but the largest connected component.
MeshFix.repair([joincomp, ...])Perform mesh repair using MeshFix's default repair process.
MeshFix.save(filename[, binary])Write the points and faces as a surface mesh to disk using PyVista.
Attributes
Return the indices of the faces of the mesh.
Return the surface mesh.
Return the number of boundaries (holes) in this mesh.
Return the points of the mesh.