DataObjectFilters.clip_box#
- DataObjectFilters.clip_box(
- bounds: float | VectorLike[float] | PolyData | None = None,
- invert: bool = True,
- factor: float = 0.35,
- progress_bar: bool = False,
- merge_points: bool = True,
- crinkle: bool = False,
Clip a dataset by a bounding box defined by the bounds.
If no bounds are given, a corner of the dataset bounds will be removed.
A
PolyDatais clipped with vtkBoxClipDataSet, which splits the cells the box cuts into simplices, and aPointSetis clipped the same way through its vertices. All other inputs, that isImageData,RectilinearGrid,StructuredGrid,ExplicitStructuredGrid, andUnstructuredGrid, are clipped by the six box planes in turn with the same clipper asclip(), which keeps hexahedra and other cell types.Changed in version 0.49:
ImageData,RectilinearGrid,StructuredGrid,ExplicitStructuredGrid, andUnstructuredGridinputs are clipped by the six box planes instead of vtkBoxClipDataSet, so cells the box does not cut keep their type instead of being split into tetrahedra, and the output normally has fewer cells and points for the same clipped volume, whatevermerge_pointsis. Calltriangulate()on the output for an all-tetrahedra mesh as before.A
PolyDatainput gives aPolyDatainstead of anUnstructuredGrid, with the same points and cells.
- Parameters:
- boundssequence[
float],optional Length 6 sequence of floats:
(x_min, x_max, y_min, y_max, z_min, z_max). Length 3 sequence of floats: distances from the min coordinate of the input mesh. Single float value: uniform distance from the min coordinate. Length 12 sequence of length 3 sequence of floats: a plane collection (normal, center, and so on).pyvista.PolyData: if a poly mesh is passed that represents a box with 6 faces that all form a standard box, then planes will be extracted from the box to define the clipping region.- invertbool, default:
True Flag on whether to flip/invert the clip.
- factor
float, default: 0.35 If bounds are not given this is the factor along each axis to extract the default box.
- progress_barbool, default:
False Display a progress bar to indicate progress.
- merge_pointsbool, default:
True If
True, coinciding points of independently defined mesh elements will be merged. It has no effect on the inputs clipped by the box planes wheninvert=False, which produce no coinciding points to merge.- crinklebool, default:
False Crinkle the clip by extracting the entire cells along the clip. This adds the
"cell_ids"array to thecell_dataattribute that tracks the original cell IDs of the original dataset.
- boundssequence[
- Returns:
pyvista.DataSet|pyvista.MultiBlockClipped dataset. A
PolyDatagives aPolyDataand aPointSetgives aPointSet, clipped through its vertices; every other dataset gives anUnstructuredGrid. AMultiBlockgives aMultiBlockwhose blocks each follow that rule, nested blocks included.
Examples#
Download Python source code | Download Jupyter notebook
Clip a corner of a cube. The bounds of a cube are normally
[-0.5, 0.5, -0.5, 0.5, -0.5, 0.5], and this removes 1/8 of
the cube’s surface.
>>> import pyvista as pv
>>> cube = pv.Cube().triangulate().subdivide(3)
>>> clipped_cube = cube.clip_box([0, 1, 0, 1, 0, 1])
>>> clipped_cube.plot()
Used In#
Gallery Examples