pyvista.PolyDataFilters.clean#
- PolyDataFilters.clean(
- point_merging=True,
- tolerance=None,
- lines_to_points=True,
- polys_to_lines=True,
- strips_to_polys=True,
- inplace=False,
- absolute=True,
- progress_bar=False,
- **kwargs,
Clean the mesh.
This merges duplicate points, removes unused points, and/or removes degenerate cells.
- Parameters:
- point_mergingbool,
optional
Enables point merging.
True
by default.- tolerance
float
,optional
Set merging tolerance. When enabled merging is set to absolute distance. If
absolute
isFalse
, then the merging tolerance is a fraction of the bounding box length. The aliasmerge_tol
is also excepted.- lines_to_pointsbool,
optional
Enable or disable the conversion of degenerate lines to points. Enabled by default.
- polys_to_linesbool,
optional
Enable or disable the conversion of degenerate polys to lines. Enabled by default.
- strips_to_polysbool,
optional
Enable or disable the conversion of degenerate strips to polys.
- inplacebool, default:
False
Updates mesh in-place.
- absolutebool,
optional
Control if
tolerance
is an absolute distance or a fraction.- progress_barbool, default:
False
Display a progress bar to indicate progress.
- **kwargs
dict
,optional
Accepts for
merge_tol
to replace thetolerance
keyword argument. This may be deprecated in future.
- point_mergingbool,
- Returns:
pyvista.PolyData
Cleaned mesh.
Examples
Create a mesh with a degenerate face and then clean it, removing the degenerate face
>>> import pyvista as pv >>> import numpy as np >>> points = np.array( ... [[0, 0, 0], [0, 1, 0], [1, 0, 0]], dtype=np.float32 ... ) >>> faces = np.array([3, 0, 1, 2, 3, 0, 2, 2]) >>> mesh = pv.PolyData(points, faces) >>> mout = mesh.clean() >>> mout.faces array([3, 0, 1, 2])