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,
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 / 2on each side oforiginalongnormal. This is sometimes called a “thick slice” because it yields a volumetric subset of the input rather than a 2D cross-section likeslice().Added in version 0.48.
Changed in version 0.49: Points that a
PolyDatainput keeps apart are no longer merged, unless it holds triangle strips.- Parameters:
- thickness
float Total slab thickness measured perpendicular to
normal. Must be strictly positive. Half ofthicknessis applied on each side oforigin.- normal
VectorLikeFloat|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.- origin
VectorLikeFloat, 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. IfTrue, 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 thecell_dataattribute that tracks the original cell IDs of the input dataset.- plane
PolyData, optional Plane()mesh to use for defining the slab orientation. Use this as an alternative to settingoriginandnormal. The mean of the plane’s normal vectors is used for thenormalparameter and the mean of the plane’s points is used for theoriginparameter.
- thickness
- Returns:
pyvista.DataSet|pyvista.MultiBlockClipped dataset. A
PolyDatagives aPolyDataand aPointSetgives aPointSet; every other dataset gives anUnstructuredGrid. AMultiBlockgives aMultiBlockwhose blocks each follow that rule, nested blocks included.
- Raises:
ValueErrorIf
thicknessis not strictly positive, or ifnormalis 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)