DataObjectFilters.slice_implicit

DataObjectFilters.slice_implicit#

DataObjectFilters.slice_implicit(
implicit_function: _vtk.vtkImplicitFunction,
*,
generate_triangles: bool = False,
contour: bool = False,
progress_bar: bool = False,
) → PolyData | MultiBlock[source]#

Slice a dataset by a VTK implicit function.

Parameters:
implicit_functionvtkImplicitFunction

Specify the implicit function to perform the cutting.

generate_trianglesbool, default: False

If True, the output will be triangles. Otherwise the output will be the intersection polygons. If the cutting function is not a plane, the output will be 3D polygons, which might be nice to look at but hard to compute with downstream.

Note

PyVista’s default is False, which differs from vtkCutter’s default of True. The polygon codepath in vtkCutter is significantly slower than the triangulation path: on a 1.3M-cell UnstructuredGrid the polygon path measures ~89 ms/op vs ~20 ms/op with generate_triangles=True (~5x slowdown). Pass generate_triangles=True for the fast path when the output cell shape is not load-bearing for your downstream code.

contourbool, default: False

If True, apply a contour filter after slicing.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.PolyData | pyvista.MultiBlock

Sliced dataset. Every dataset gives a PolyData, and a MultiBlock gives a MultiBlock of PolyData blocks, nested blocks included.

Notes#

A PointSet has no cells to slice, so slicing one raises PointSetDimensionReductionError, whether it is sliced directly or as a block of a MultiBlock.

Changed in version 0.50: A PointSet block raises instead of giving an empty block.

Examples#

Download Python source code | Download Jupyter notebook

Slice the surface of a sphere.

>>> import pyvista as pv
>>> import vtk
>>> sphere = vtk.vtkSphere()
>>> sphere.SetRadius(10)
>>> mesh = pv.Wavelet()
>>> slice = mesh.slice_implicit(sphere)
>>> slice.plot(show_edges=True, line_width=5)
../../../_images/pyvista-DataObjectFilters-slice_implicit-d176953a1b087037_00_00.png
>>> cylinder = vtk.vtkCylinder()
>>> cylinder.SetRadius(10)
>>> mesh = pv.Wavelet()
>>> slice = mesh.slice_implicit(cylinder)
>>> slice.plot(show_edges=True, line_width=5)
../../../_images/pyvista-DataObjectFilters-slice_implicit-d176953a1b087037_01_00.png

See Also#

slice
slice_orthogonal
slice_along_axis
slice_along_line
slice_index()