pyvista.Plotter.add_mesh_slice#
- Plotter.add_mesh_slice(
- mesh,
- normal='x',
- generate_triangles=False,
- widget_color=None,
- assign_to_axis=None,
- tubing=False,
- origin_translation=True,
- outline_translation=False,
- implicit=True,
- normal_rotation=True,
- interaction_event=45,
- origin=None,
- outline_opacity=None,
- **kwargs,
Slice a mesh using a plane widget.
Add a mesh to the scene with a plane widget that is used to slice the mesh interactively.
The sliced mesh is saved to the
.plane_sliced_meshes
attribute on the plotter.- Parameters:
- mesh
pyvista.DataSet
orvtk.vtkAlgorithm
The input dataset to add to the scene and slice or algorithm that produces said mesh.
- normal
str
ortuple
(float
),optional
The starting normal vector of the plane.
- generate_trianglesbool,
optional
If this is enabled (
False
by default), the output will be triangles otherwise, the output will be the intersection polygons.- widget_color
ColorLike
,optional
Either a string, RGB sequence, or hex color string. Defaults to
'white'
.- assign_to_axis
str
orint
,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 wiget, 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
, avtkImplicitPlaneWidget
is used and whenFalse
, avtkPlaneWidget
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
whenassign_to_axis
is set.- interaction_event
vtk.vtkCommand.EventIds
,optional
The VTK interaction event to use for triggering the callback.
- origin
tuple
(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.
- **kwargs
dict
,optional
All additional keyword arguments are passed to
Plotter.add_mesh()
to control how the mesh is displayed.
- mesh
- Returns:
vtk.vtkActor
VTK actor of the mesh.
Examples
Shows an interactive plane used specifically for slicing.
>>> import pyvista as pv >>> from pyvista import examples >>> pl = pv.Plotter() >>> mesh = examples.load_channels() >>> _ = pl.add_mesh(mesh.outline()) >>> _ = pl.add_mesh_slice(mesh, normal=[1, 0, 0.3]) >>> pl.show()
For a full example see Plane Widget.