| 1 |
""" |
| 2 |
.. _spline_widget_example: |
| 3 |
|
| 4 |
Spline Widget |
| 5 |
~~~~~~~~~~~~~ |
| 6 |
|
| 7 |
|
| 8 |
A spline widget can be enabled and disabled by the |
| 9 |
:func:`pyvista.Plotter.add_spline_widget` and |
| 10 |
:func:`pyvista.Plotter.clear_spline_widgets` methods respectively. |
| 11 |
This widget allows users to interactively create a poly line (spline) through |
| 12 |
a scene and use that spline. |
| 13 |
|
| 14 |
A common task with splines is to slice a volumetric dataset using an irregular |
| 15 |
path. To do this, we have added a convenient helper method which leverages the |
| 16 |
:func:`pyvista.DataObjectFilters.slice_along_line` filter named |
| 17 |
:func:`pyvista.Plotter.add_mesh_slice_spline`. |
| 18 |
""" |
| 19 |
|
| 20 |
import numpy as np |
| 21 |
import pyvista as pv |
| 22 |
|
| 23 |
# %% |
| 24 |
|
| 25 |
mesh = pv.Wavelet() |
| 26 |
|
| 27 |
# initial spline to seed the example |
| 28 |
points = np.array( |
| 29 |
[ |
| 30 |
[-8.64208925, -7.34294559, -9.13803458], |
| 31 |
[-8.25601497, -2.54814702, 0.93860914], |
| 32 |
[-0.30179377, -3.21555997, -4.19999019], |
| 33 |
[3.24099167, 2.05814768, 3.39041509], |
| 34 |
[4.39935227, 4.18804542, 8.96391132], |
| 35 |
], |
| 36 |
) |
| 37 |
|
| 38 |
pl = pv.Plotter() |
| 39 |
pl.add_mesh(mesh.outline(), color='black') |
| 40 |
pl.add_mesh_slice_spline(mesh, initial_points=points, n_handles=5) |
| 41 |
pl.camera_position = pv.CameraPosition( |
| 42 |
position=(30, -42, 30), focal_point=(0.0, 0.0, 0.0), viewup=(-0.09, 0.53, 0.84) |
| 43 |
) |
| 44 |
pl.show() |
| 45 |
# %% |
| 46 |
# .. tags:: widgets |