pyvista.plotting.widgets.WidgetHelper.add_mesh_clip_plane

pyvista.plotting.widgets.WidgetHelper.add_mesh_clip_plane#

WidgetHelper.add_mesh_clip_plane(
mesh,
normal='x',
invert: bool = False,
widget_color=None,
value=0.0,
assign_to_axis=None,
tubing: bool = False,
origin_translation: bool = True,
outline_translation: bool = False,
implicit: bool = True,
normal_rotation: bool = True,
crinkle: bool = False,
interaction_event: pyvista.InteractionEventType = 'end',
origin=None,
outline_opacity=None,
**kwargs,
)[source]#

Clip a mesh using a plane widget.

Add a mesh to the scene with a plane widget that is used to clip the mesh interactively.

The clipped mesh is saved to the .plane_clipped_meshes attribute on the plotter.

Parameters:
meshpyvista.DataSet or vtk.vtkAlgorithm

The input dataset to add to the scene and clip or algorithm that produces said mesh.

normalstr or tuple(float), optional

The starting normal vector of the plane.

invertbool, optional

Flag on whether to flip/invert the clip.

widget_colorColorLike, optional

Either a string, RGB list, or hex color string.

valuefloat, optional

Set the clipping value along the normal direction. The default value is 0.0.

assign_to_axisstr or int, optional

Assign the normal of the plane to be parallel with a given axis. Options are (0, 'x'), (1, 'y'), or (2, 'z').

tubingbool, optional

When using an implicit plane widget, this controls whether or not tubing is shown around the plane’s boundaries.

origin_translationbool, optional

If False, the plane widget cannot be translated by its origin and is strictly placed at the given origin. Only valid when using an implicit plane.

outline_translationbool, optional

If False, the box widget cannot be translated and is strictly placed at the given bounds.

implicitbool, optional

When True, a vtkImplicitPlaneWidget is used and when False, a vtkPlaneWidget is used.

normal_rotationbool, optional

Set the opacity of the normal vector arrow to 0 such that it is effectively disabled. This prevents the user from rotating the normal. This is forced to False when assign_to_axis is set.

crinklebool, optional

Crinkle the clip by extracting the entire cells along the clip.

interaction_eventInteractionEventType, optional

The VTK interaction event to use for triggering the callback. Accepts either the strings 'start', 'end', 'always' or a vtk.vtkCommand.EventIds.

Changed in version 0.38.0: Now accepts either strings or vtk.vtkCommand.EventIds.

origintuple(float), optional

The starting coordinate of the center of the plane.

outline_opacitybool or float, optional

Set the visible of outline. Only valid when using an implicit plane. Either a bool or float.

Added in version 0.44.0.

**kwargsdict, optional

All additional keyword arguments are passed to pyvista.Plotter.add_mesh() to control how the mesh is displayed.

Returns:
vtk.vtkActor

VTK actor of the mesh.

Examples

Shows an interactive plane used to clip the mesh and store it.

>>> import pyvista as pv
>>> from pyvista import examples
>>> vol = examples.load_airplane()
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh_clip_plane(vol, normal=[0, -1, 0])
>>> pl.show(cpos=[-2.1, 0.6, 1.5])
../../../_images/pyvista-plotting-widgets-WidgetHelper-add_mesh_clip_plane-1_00_00.png
>>> pl.plane_clipped_meshes  

For a full example see Plane Widget.