API Reference

Python module to interface with wrapped meshfix

class pymeshfix.MeshFix(*args)

Bases: object

Cleans and tetrahedralize surface meshes using MeshFix

Parameters

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_holes()

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.

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

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

mesh

Return the surface mesh

plot(show_holes=True, **kwargs)

Plot the mesh.

Parameters
  • 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.

Parameters
  • 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

Notes

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

Parameters
  • 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’.

Notes

Binary files write much faster than ASCII.

write(filename, binary=True)

DEPRECATED

Python/Cython wrapper for MeshFix by Marco Attene