{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "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\n\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()" ] } ], "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.2" } }, "nbformat": 4, "nbformat_minor": 0 }