decimate#
- PolyDataFilters.decimate(target_reduction, volume_preservation=False, attribute_error=False, scalars=True, vectors=True, normals=False, tcoords=True, tensors=True, scalars_weight=0.1, vectors_weight=0.1, normals_weight=0.1, tcoords_weight=0.1, tensors_weight=0.1, inplace=False, progress_bar=False)[source]#
Reduce the number of triangles in a triangular mesh using
vtkQuadricDecimation
.- Parameters:
- target_reduction
float
Fraction of the original mesh to remove. If
target_reduction
is set to 0.9, this filter will try to reduce the data set to 10% of its original size and will remove 90% of the input triangles.- volume_preservationbool,
optional
Decide whether to activate volume preservation which greatly reduces errors in triangle normal direction. If
False
, volume preservation is disabled and ifattribute_error
is active, these errors can be large. Defaults toFalse
.- attribute_errorbool,
optional
Decide whether to include data attributes in the error metric. If
False
, then only geometric error is used to control the decimation. Defaults toFalse
. IfTrue
, the following flags are used to specify which attributes are to be included in the error calculation.- scalarsbool,
optional
If attribute errors are to be included in the metric (i.e.,
attribute_error
isTrue
), then these flags control which attributes are to be included in the error calculation. Defaults toTrue
.- vectorsbool,
optional
See
scalars
parameter. Defaults toTrue
.- normalsbool,
optional
See
scalars
parameter. Defaults toFalse
.- tcoordsbool,
optional
See
scalars
parameter. Defaults toTrue
.- tensorsbool,
optional
See
scalars
parameter. Defaults toTrue
.- scalars_weight
float
,optional
The scaling weight contribution of the scalar attribute. These values are used to weight the contribution of the attributes towards the error metric. Defaults to 0.1.
- vectors_weight
float
,optional
See
scalars_weight
parameter. Defaults to 0.1.- normals_weight
float
,optional
See
scalars_weight
parameter. Defaults to 0.1.- tcoords_weight
float
,optional
See
scalars_weight
parameter. Defaults to 0.1.- tensors_weight
float
,optional
See
scalars_weight
parameter. Defaults to 0.1.- inplacebool,
optional
Whether to update the mesh in-place.
- progress_barbool,
optional
Display a progress bar to indicate progress.
- target_reduction
- Returns:
pyvista.PolyData
Decimated mesh.
Notes
If you encounter a segmentation fault or other error, consider using
pyvista.PolyDataFilters.clean()
to remove any invalid cells before using this filter.Examples
Decimate a sphere. First plot the sphere.
>>> import pyvista >>> sphere = pyvista.Sphere(phi_resolution=60, theta_resolution=60) >>> sphere.plot(show_edges=True, line_width=2)
Now decimate it by 75% and plot it.
>>> decimated = sphere.decimate(0.75) >>> decimated.plot(show_edges=True, line_width=2)
See Decimation for more examples using this filter.