DataObjectFilters.clip_slab

DataObjectFilters.clip_slab#

DataObjectFilters.clip_slab(
thickness: float,
normal: VectorLikeFloat | _NormalsLiteral | None = None,
*,
origin: VectorLikeFloat | None = None,
invert: bool = False,
progress_bar: bool = False,
crinkle: bool = False,
plane: PolyData | None = None,
) → _OutputDataObject[source]#

Clip a dataset by a slab of finite thickness around a plane.

The slab is the volumetric region bounded by two parallel planes offset symmetrically by thickness / 2 on each side of origin along normal. This is sometimes called a “thick slice” because it yields a volumetric subset of the input rather than a 2D cross-section like slice().

Added in version 0.48.

Changed in version 0.49: Points that a PolyData input keeps apart are no longer merged, unless it holds triangle strips.

Parameters:
thicknessfloat

Total slab thickness measured perpendicular to normal. Must be strictly positive. Half of thickness is applied on each side of origin.

normalVectorLikeFloat | str, optional

Length-3 vector defining the slab’s normal direction. Can also be specified as a string conventional direction such as 'x' for (1, 0, 0) or '-x' for (-1, 0, 0), etc. The 'x' direction is used by default.

originVectorLikeFloat, optional

The center (x, y, z) coordinate of the slab. The default is the center of the dataset.

invertbool, default: False

If False (the default), the slab interior is kept. If True, the slab interior is removed and everything outside the two bounding planes is returned.

progress_barbool, default: False

Display a progress bar to indicate progress.

crinklebool, default: False

Crinkle the clip by extracting the entire cells along the slab boundaries. This adds the "cell_ids" array to the cell_data attribute that tracks the original cell IDs of the input dataset.

planePolyData, optional

Plane() mesh to use for defining the slab orientation. Use this as an alternative to setting origin and normal. The mean of the plane’s normal vectors is used for the normal parameter and the mean of the plane’s points is used for the origin parameter.

Returns:
pyvista.DataSet | pyvista.MultiBlock

Clipped dataset. A PolyData gives a PolyData and a PointSet gives a PointSet; every other dataset gives an UnstructuredGrid. A MultiBlock gives a MultiBlock whose blocks each follow that rule, nested blocks included.

Raises:
ValueError

If thickness is not strictly positive, or if normal is a zero vector.

Examples#

Download Python source code | Download Jupyter notebook

Extract a thick slab through the center of a sphere along the z-axis.

>>> import pyvista as pv
>>> sphere = pv.Sphere()
>>> slab = sphere.clip_slab(thickness=0.2, normal='z')
>>> slab.plot(show_edges=True)
../../../_images/pyvista-DataObjectFilters-clip_slab-e1d8e4eed448448e_00_00.png

See Also#

clip
clip_box
slice