smooth#
- PolyDataFilters.smooth(n_iter=20, relaxation_factor=0.01, convergence=0.0, edge_angle=15, feature_angle=45, boundary_smoothing=True, feature_smoothing=False, inplace=False, progress_bar=False)[source]#
Adjust point coordinates using Laplacian smoothing.
The effect is to “relax” the mesh, making the cells better shaped and the vertices more evenly distributed.
- Parameters:
- n_iter
int
,optional
Number of iterations for Laplacian smoothing.
- relaxation_factor
float
,optional
Relaxation factor controls the amount of displacement in a single iteration. Generally a lower relaxation factor and higher number of iterations is numerically more stable.
- convergence
float
,optional
Convergence criterion for the iteration process. Smaller numbers result in more smoothing iterations. Range from (0 to 1).
- edge_angle
float
,optional
Edge angle to control smoothing along edges (either interior or boundary).
- feature_angle
float
,optional
Feature angle for sharp edge identification.
- boundary_smoothingbool,
optional
Flag to control smoothing of boundary edges. When
True
, boundary edges remain fixed. DefaultTrue
.- feature_smoothingbool,
optional
Flag to control smoothing of feature edges. When
True
, boundary edges remain fixed as defined byfeature_angle
andedge_angle
. DefaultFalse
.- inplacebool,
optional
Updates mesh in-place.
- progress_barbool,
optional
Display a progress bar to indicate progress.
- n_iter
- Returns:
pyvista.PolyData
Smoothed mesh.
Examples
Smooth the edges of an all triangular cube
>>> import pyvista as pv >>> cube = pv.Cube().triangulate().subdivide(5) >>> smooth_cube = cube.smooth(1000, feature_smoothing=False) >>> n_edge_cells = cube.extract_feature_edges().n_cells >>> n_smooth_cells = smooth_cube.extract_feature_edges().n_cells >>> f'Sharp Edges on Cube: {n_edge_cells}' 'Sharp Edges on Cube: 384' >>> f'Sharp Edges on Smooth Cube: {n_smooth_cells}' 'Sharp Edges on Smooth Cube: 12' >>> smooth_cube.plot()
See Surface Smoothing for more examples using this filter.