Note
Click here to download the full example code
Decimation#
Decimate a mesh

Now let’s define a target reduction and compare the
pyvista.PolyData.decimate()
and pyvista.PolyData.decimate_pro()
filters.
target_reduction = 0.7
print(f"Reducing {target_reduction * 100.0} percent out of the original mesh")
Reducing 70.0 percent out of the original mesh
decimated = mesh.decimate(target_reduction)
decimated.plot(cpos=cpos, **dargs)

pro_decimated = mesh.decimate_pro(target_reduction, preserve_topology=True)
pro_decimated.plot(cpos=cpos, **dargs)

Side by side comparison:
p = pv.Plotter(shape=(1, 3))
p.add_mesh(mesh, **dargs)
p.add_text("Input mesh", font_size=24)
p.camera_position = cpos
p.reset_camera()
p.subplot(0, 1)
p.add_mesh(decimated, **dargs)
p.add_text("Decimated mesh", font_size=24)
p.camera_position = cpos
p.reset_camera()
p.subplot(0, 2)
p.add_mesh(pro_decimated, **dargs)
p.add_text("Pro Decimated mesh", font_size=24)
p.camera_position = cpos
p.reset_camera()
p.link_views()
p.show()

Total running time of the script: ( 0 minutes 1.361 seconds)