.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/simplify.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_simplify.py: Compare Decimation Methods -------------------------- This example compares various decimation methods .. GENERATED FROM PYTHON SOURCE LINES 8-27 .. code-block:: Python import time import pyvista as pv from pyvista import examples import fast_simplification # load an example mesh mesh = examples.download_louis_louvre() # nice camera angle cpos = [ (6.264157141857314, -6.959267635766402, 11.71668951132694), (1.3291685457683413, 2.267162128740896, 12.263240938610595), (0.0023825740958850136, -0.05786378450796799, 0.9983216444528751), ] .. GENERATED FROM PYTHON SOURCE LINES 28-29 Compare decimation times .. GENERATED FROM PYTHON SOURCE LINES 29-73 .. code-block:: Python reduction = 0.9 print("Approach Time Elapsed") tstart = time.time() fas_sim = fast_simplification.simplify_mesh(mesh, target_reduction=reduction) fast_sim_time = time.time() - tstart print(f"Fast Quadratic Simplification {fast_sim_time:8.4f} seconds") tstart = time.time() dec_std = mesh.decimate(reduction) dec_std_time = time.time() - tstart print(f"vtkQuadricDecimation {dec_std_time:8.4f} seconds") tstart = time.time() dec_pro = mesh.decimate_pro(reduction) dec_pro_time = time.time() - tstart print(f"vtkDecimatePro {dec_pro_time:8.4f} seconds") pl = pv.Plotter(shape=(2, 2), window_size=(1000, 1000), theme=pv.themes.DocumentTheme()) pl.add_text("Original", "upper_right", color="k") pl.add_mesh(mesh, show_edges=True) pl.camera_position = cpos pl.subplot(0, 1) pl.add_text( f"Fast-Quadric-Mesh-Simplification\n{fast_sim_time:8.4f} seconds", "upper_right", color="k", ) pl.add_mesh(fas_sim, show_edges=True) pl.camera_position = cpos pl.subplot(1, 0) pl.add_mesh(dec_std, show_edges=True) pl.add_text(f"vtkQuadricDecimation\n{dec_std_time:8.4f} seconds", "upper_right", color="k") pl.camera_position = cpos pl.subplot(1, 1) pl.add_mesh(dec_pro, show_edges=True) pl.add_text(f"vtkDecimatePro\n{dec_pro_time:8.4f} seconds", "upper_right", color="k") pl.camera_position = cpos pl.show() .. image-sg:: /examples/images/sphx_glr_simplify_001.png :alt: simplify :srcset: /examples/images/sphx_glr_simplify_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Approach Time Elapsed Fast Quadratic Simplification 0.5010 seconds vtkQuadricDecimation 2.4565 seconds vtkDecimatePro 1.9173 seconds .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.140 seconds) .. _sphx_glr_download_examples_simplify.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: simplify.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: simplify.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: simplify.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_