DataObjectFilters.clip#
- DataObjectFilters.clip(
- normal: VectorLike[float] | _NormalsLiteral | None = None,
- origin: VectorLike[float] | None = None,
- invert: bool = True,
- value: float = 0.0,
- inplace: bool = False,
- return_clipped: bool = False,
- progress_bar: bool = False,
- crinkle: bool = False,
- plane: PolyData | None = None,
Clip a dataset by a plane by specifying the origin and normal.
The origin and normal may be set explicitly or implicitly using a
Plane().If no parameters are given, the clip will occur in the center of the dataset along the x-axis.
- Parameters:
- normal
VectorLike[float] |str,optional Length-3 vector for the normal vector 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
VectorLike[float],optional The center
(x, y, z)coordinate of the plane on which the clip occurs. The default is the center of the dataset.- invertbool, default:
True If
True, remove mesh parts in thenormaldirection fromorigin. IfFalse, remove parts in the opposite direction.- value
float, default: 0.0 Set the clipping value along the normal direction.
- inplacebool, default:
False Updates mesh in-place. Only
PolyData,PointSetandUnstructuredGridinputs support this; any other input raisesTypeError.- return_clippedbool, default:
False Return both unclipped and clipped parts of the dataset.
- progress_barbool, default:
False Display a progress bar to indicate progress.
- 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.- plane
PolyData,optional Plane()mesh to use for clipping. 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.Added in version 0.47.
- normal
- Returns:
- output
DataSet|MultiBlock|tuple[DataSet|MultiBlock,DataSet|MultiBlock] Clipped mesh when
return_clipped=False, or a tuple of the kept and the removed mesh when it isTrue. APolyDatagives aPolyDataand aPointSetgives aPointSet; every other dataset gives anUnstructuredGrid. AMultiBlockgives aMultiBlockwhose blocks each follow that rule, nested blocks included.
- output
Examples#
Download Python source code | Download Jupyter notebook
Clip a cube along the +X direction. triangulate is used as
the cube is initially composed of quadrilateral faces and
subdivide only works on triangles.
>>> import pyvista as pv
>>> cube = pv.Cube().triangulate().subdivide(3)
>>> clipped_cube = cube.clip()
>>> clipped_cube.plot()
Clip a cube in the +Z direction. This leaves half a cube below the XY plane.
>>> import pyvista as pv
>>> cube = pv.Cube().triangulate().subdivide(3)
>>> clipped_cube = cube.clip('z')
>>> clipped_cube.plot()
See Clipping With a Surface for more examples using this filter.
Used In#
Docstring Examples
Renderer.set_color_cycler(1 use)StructuredSphere(1 use)download_electronics_cooling(1 use)fit_plane_to_points(1 use)plot_compare(1 use)
Gallery Examples