API Reference

Python module to interface with wrapped meshfix

class pymeshfix.MeshFix(*args)

Bases: object

Cleans and tetrahedralize surface meshes using MeshFix


args (pyvista.PolyData or (np.ndarray, np.ndarray)) – Either a pyvista surface mesh pyvista.PolyData or a (n x 3) vertex array and (n x 3) face array (indices of the triangles).


Extract the boundaries of the holes in this mesh to a new PyVista mesh of lines.

load_arrays(v, f)

Loads triangular mesh from vertex and face numpy arrays.

Both vertex and face arrays should be 2D arrays with each vertex containing XYZ data and each face containing three points.

  • v (np.ndarray) – n x 3 vertex array.

  • f (np.ndarray) – n x 3 face array.


Return the surface mesh

plot(show_holes=True, **kwargs)

Plot the mesh.

  • show_holes (bool, optional) – Shows boundaries. Default True

  • **kwargs (keyword arguments) – Additional keyword arguments.

repair(verbose=False, joincomp=False, remove_smallest_components=True)

Performs mesh repair using MeshFix’s default repair process.

  • verbose (bool, optional) – Enables or disables debug printing. Disabled by default.

  • joincomp (bool, optional) – Attempts to join nearby open components.

  • remove_smallest_components (bool, optional) – Remove all but the largest isolated component from the mesh before beginning the repair process. Default True


Vertex and face arrays are updated inplace. Access them with: meshfix.v meshfix.f

save(filename, binary=True)

Writes a surface mesh to disk.

Written file may be an ASCII or binary ply, stl, or vtk mesh file.

This is a a simple wrapper for PyVista’s save method

  • filename (str) – Filename of mesh to be written. Filetype is inferred from the extension of the filename unless overridden with ftype. Can be one of the following types (.ply, .stl, .vtk)

  • ftype (str, optional) – Filetype. Inferred from filename unless specified with a three character string. Can be one of the following: ‘ply’, ‘stl’, or ‘vtk’.


Binary files write much faster than ASCII.

write(filename, binary=True)


Python/Cython wrapper for MeshFix by Marco Attene