{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Spline Widget\n\nA spline widget can be enabled and disabled by the\n`pyvista.Plotter.add_spline_widget`{.interpreted-text role=\"func\"} and\n`pyvista.Plotter.clear_spline_widgets`{.interpreted-text role=\"func\"}\nmethods respectively. This widget allows users to interactively create a\npoly line (spline) through a scene and use that spline.\n\nA common task with splines is to slice a volumetric dataset using an\nirregular path. To do this, we have added a convenient helper method\nwhich leverages the\n`pyvista.DataSetFilters.slice_along_line`{.interpreted-text role=\"func\"}\nfilter named `pyvista.Plotter.add_mesh_slice_spline`{.interpreted-text\nrole=\"func\"}.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport pyvista as pv"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh = pv.Wavelet()\n\n# initial spline to seed the example\npoints = np.array(\n    [\n        [-8.64208925, -7.34294559, -9.13803458],\n        [-8.25601497, -2.54814702, 0.93860914],\n        [-0.30179377, -3.21555997, -4.19999019],\n        [3.24099167, 2.05814768, 3.39041509],\n        [4.39935227, 4.18804542, 8.96391132],\n    ]\n)\n\npl = pv.Plotter()\npl.add_mesh(mesh.outline(), color=\"black\")\npl.add_mesh_slice_spline(mesh, initial_points=points, n_handles=5)\npl.camera_position = [(30, -42, 30), (0.0, 0.0, 0.0), (-0.09, 0.53, 0.84)]\npl.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "And here is a screen capture of a user interacting with this\n\n![image](../../images/gifs/spline-widget.gif)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "```{=html}\n<center>\n  <a target=\"_blank\" href=\"https://colab.research.google.com/github/pyvista/pyvista-tutorial/blob/gh-pages/notebooks/tutorial/08_widgets/h_spline-widget.ipynb\">\n    <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/ width=\"150px\">\n  </a>\n</center>\n```\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.11"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}