.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorial/06_vtk/c_vtk_algorithms.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 or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_tutorial_06_vtk_c_vtk_algorithms.py: Using VTK Algorithms ~~~~~~~~~~~~~~~~~~~~ In this exercise, you will use a VTK Algorithm directly to filter a PyVista mesh. VTK algorithms (filters) follow a standard flow for most cases: 1. Instantiate the algorithm 2. Set the input data object or connection: ``.SetInputDataObject(mesh)`` 3. Adjust algorithm parameters with the setter methods, e.g., ``SetParameterName(value)`` 4. Call ``.Update()`` to run the algorithm 5. Retrieve the output of the algorithm: ``output = alg.GetOutput()`` Let's see if we can try a few VTK algorithms with that standard workflow. .. GENERATED FROM PYTHON SOURCE LINES 17-22 .. code-block:: Python import pyvista as pv from pyvista import examples import vtk .. GENERATED FROM PYTHON SOURCE LINES 23-24 Here is a sample mesh .. GENERATED FROM PYTHON SOURCE LINES 24-27 .. code-block:: Python mesh = examples.load_random_hills() mesh .. raw:: html
PolyDataInformation
N Cells19602
N Points10000
N Strips0
X Bounds-1.000e+01, 1.000e+01
Y Bounds-2.309e-14, 2.000e+01
Z Bounds1.416e-01, 7.483e+00
N Arrays2
NameFieldTypeN CompMinMax
NormalsPointsfloat323-8.663e-019.999e-01
ElevationPointsfloat3211.416e-017.483e+00

PolyDataInformation
N Cells0
N Points0
N Strips0
X Bounds1.000e+299, -1.000e+299
Y Bounds1.000e+299, -1.000e+299
Z Bounds1.000e+299, -1.000e+299
N Arrays0

.. GENERATED FROM PYTHON SOURCE LINES 49-56 .. code-block:: Python alg.SetInputDataObject(mesh) alg.SetGenerateFaces(False) alg.Update() outline = pv.wrap(alg.GetOutput()) outline .. raw:: html
PolyDataInformation
N Cells12
N Points8
N Strips0
X Bounds-1.000e+01, 1.000e+01
Y Bounds-2.309e-14, 2.000e+01
Z Bounds1.416e-01, 7.483e+00
N Arrays0

.. GENERATED FROM PYTHON SOURCE LINES 57-60 .. note:: Note that the about filter can be replaced with a ``.outline()`` filter in PyVista .. GENERATED FROM PYTHON SOURCE LINES 62-68 .. code-block:: Python p = pv.Plotter() p.add_mesh(mesh) p.add_mesh(outline, color='k') p.show() .. image-sg:: /tutorial/06_vtk/images/sphx_glr_c_vtk_algorithms_002.png :alt: c vtk algorithms :srcset: /tutorial/06_vtk/images/sphx_glr_c_vtk_algorithms_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 69-76 Find your own filter ^^^^^^^^^^^^^^^^^^^^ Take a look at VTK's examples and documentation to find a filter you'd like to apply to your mesh. The instructors will be around to help you implement. See https://kitware.github.io/vtk-examples/site/Python/ .. GENERATED FROM PYTHON SOURCE LINES 78-85 .. raw:: html