"""
Decimation
~~~~~~~~~~

Decaimate a mesh

"""
# sphinx_gallery_thumbnail_number = 1
import vtki
from vtki import examples

mesh = examples.download_face()

# Define a camera potion the shows this mesh properly
cpos = [(0.4,-0.07,-0.31), (0.05,-0.13,-0.06), (-.1,1,0.08)]

# Preview the mesh
mesh.plot(cpos=cpos, show_edges=True, color=True)

###############################################################################
#  Now let's define a target reduction and compare the
# :func:`vtki.PolyData.decimate` and :func:`vtki.PolyData.decimate_pro` filters.
target_reduction = 0.7
print('Reducing {} percent out of the original mesh'.format(target_reduction * 100.))

###############################################################################
decimated = mesh.decimate(target_reduction)

decimated.plot(cpos=cpos, show_edges=True)


###############################################################################
pro_decimated = mesh.decimate_pro(target_reduction, preserve_topology=True)

pro_decimated.plot(cpos=cpos, show_edges=True, color=True)

@@ -78,17 +78,17 @@
 umber = 
-1
+4
 %0Aimport 
@@ -271,36 +271,19 @@
 8)%5D%0A
-%0A# Preview the mesh%0Amesh.plo
+dargs = dic
 t(cp
@@ -321,16 +321,55 @@
 =True)%0A%0A
+# Preview the mesh%0Amesh.plot(**dargs)%0A%0A
 ########
@@ -830,34 +830,15 @@
 lot(
-cpos=cpos, show_edges=True
+**dargs
 )%0A%0A%0A
@@ -1017,44 +1017,540 @@
 lot(
-cpos=cpos, show_edges=True, color=True
+**dargs)%0A%0A%0A###############################################################################%0A# Side by side comparison:%0A%0Ap = vtki.Plotter(shape=(1, 3))%0Ap.add_mesh(mesh, **dargs)%0Ap.add_text('Input mesh', font_size=24)%0Ap.camera_position = cpos%0Ap.reset_camera()%0Ap.subplot(0,1)%0Ap.add_mesh(decimated, **dargs)%0Ap.add_text('Decimated mesh', font_size=24)%0Ap.camera_position = cpos%0Ap.reset_camera()%0Ap.subplot(0,2)%0Ap.add_mesh(pro_decimated, **dargs)%0Ap.add_text('Pro Decimated mesh', font_size=24)%0Ap.camera_position = cpos%0Ap.reset_camera()%0Ap.show(
 )%0A

Update decimate example