{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import subprocess\nimport sys\n\nif \"google.colab\" in sys.modules:\n subprocess.run(\"apt-get update\", shell=True, check=True)\n subprocess.run(\"apt-get install -qq xvfb libgl1-mesa-glx\", shell=True, check=True)\n subprocess.run(\"pip install pyvista[all] -qq\", shell=True, check=True)\n\n import pyvista as pv\n\n # Seems that only static plotting is supported by colab at the moment\n pv.global_theme.jupyter_backend = \"static\"\n pv.global_theme.notebook = True\n pv.start_xvfb()\nelse:\n %matplotlib inline\n from pyvista import set_plot_theme\n\n set_plot_theme(\"document\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Spline Widget\n=============\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\np = pv.Plotter()\np.add_mesh(mesh.outline(), color='black')\np.add_mesh_slice_spline(mesh, initial_points=points, n_handles=5)\np.camera_position = [(30, -42, 30), (0.0, 0.0, 0.0), (-0.09, 0.53, 0.84)]\np.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