
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "tutorial/08_widgets/h_spline-widget.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_tutorial_08_widgets_h_spline-widget.py>`
        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_08_widgets_h_spline-widget.py:


Spline Widget
~~~~~~~~~~~~~


A spline widget can be enabled and disabled by the
:func:`pyvista.Plotter.add_spline_widget` and
:func:`pyvista.Plotter.clear_spline_widgets` methods respectively.
This widget allows users to interactively create a poly line (spline) through
a scene and use that spline.

A common task with splines is to slice a volumetric dataset using an irregular
path. To do this, we have added a convenient helper method which leverages the
:func:`pyvista.DataSetFilters.slice_along_line` filter named
:func:`pyvista.Plotter.add_mesh_slice_spline`.

.. GENERATED FROM PYTHON SOURCE LINES 17-21

.. code-block:: Python


    import numpy as np
    import pyvista as pv








.. GENERATED FROM PYTHON SOURCE LINES 22-42

.. code-block:: Python


    mesh = pv.Wavelet()

    # initial spline to seed the example
    points = np.array(
        [
            [-8.64208925, -7.34294559, -9.13803458],
            [-8.25601497, -2.54814702, 0.93860914],
            [-0.30179377, -3.21555997, -4.19999019],
            [3.24099167, 2.05814768, 3.39041509],
            [4.39935227, 4.18804542, 8.96391132],
        ]
    )

    pl = pv.Plotter()
    pl.add_mesh(mesh.outline(), color="black")
    pl.add_mesh_slice_spline(mesh, initial_points=points, n_handles=5)
    pl.camera_position = [(30, -42, 30), (0.0, 0.0, 0.0), (-0.09, 0.53, 0.84)]
    pl.show()








.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /tutorial/08_widgets/images/sphx_glr_h_spline-widget_001.png
        :alt: h spline widget
        :srcset: /tutorial/08_widgets/images/sphx_glr_h_spline-widget_001.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/runner/work/pyvista-tutorial/pyvista-tutorial/doc/source/tutorial/08_widgets/images/sphx_glr_h_spline-widget_001.vtksz






.. GENERATED FROM PYTHON SOURCE LINES 43-46

And here is a screen capture of a user interacting with this

.. image:: ../../images/gifs/spline-widget.gif

.. GENERATED FROM PYTHON SOURCE LINES 48-55

.. raw:: html

    <center>
      <a target="_blank" href="https://colab.research.google.com/github/pyvista/pyvista-tutorial/blob/gh-pages/notebooks/tutorial/08_widgets/h_spline-widget.ipynb">
        <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/ width="150px">
      </a>
    </center>


.. rst-class:: sphx-glr-timing

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


.. _sphx_glr_download_tutorial_08_widgets_h_spline-widget.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: binder-badge

      .. image:: images/binder_badge_logo.svg
        :target: https://mybinder.org/v2/gh/pyvista/pyvista-tutorial/gh-pages?urlpath=lab/tree/notebooks/tutorial/08_widgets/h_spline-widget.ipynb
        :alt: Launch binder
        :width: 150 px

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: h_spline-widget.ipynb <h_spline-widget.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: h_spline-widget.py <h_spline-widget.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: h_spline-widget.zip <h_spline-widget.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
