DataSetFilters.clip_surface

DataSetFilters.clip_surface#

DataSetFilters.clip_surface(
surface: DataSet | _vtk.vtkDataSet,
*,
invert: bool = True,
value: float = 0.0,
compute_distance: bool = False,
progress_bar: bool = False,
crinkle: bool = False,
) → _OutputDataSet[source]#

Clip any mesh type using a pyvista.PolyData surface mesh.

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

The clipped mesh type matches the input type for PointSet and PolyData, otherwise the output type is UnstructuredGrid. Geometry of the input dataset will be preserved where possible. Geometries near the clip intersection will be triangulated/tessellated.

Parameters:
surfacepyvista.PolyData

The PolyData surface mesh to use as a clipping function. If this input mesh is not a pyvista.PolyData, the external surface will be extracted.

invertbool, default: True

Flag on whether to flip/invert the clip.

valuefloat, default: 0.0

Set the clipping value of the implicit function (if clipping with implicit function) or scalar value (if clipping with scalars).

compute_distancebool, default: False

Compute the implicit distance from the mesh onto the input dataset. A new array called 'implicit_distance' will be added to the output clipped mesh. For ImageData with a closed surface and value=0, this also makes the clip evaluate the distance at every point instead of classifying points as inside or outside with a stencil and evaluating it only at the points of cells the surface passes through, where the classification is checked against it.

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 the cell_data attribute that tracks the original cell IDs of the original dataset.

Returns:
DataSet

Clipped mesh. A PolyData gives a PolyData and a PointSet gives a PointSet; every other dataset gives an UnstructuredGrid.

Notes#

This filter is not available on a MultiBlock. Use clip() or clip_box() for a composite, or apply this filter to each block with generic_filter().

Examples#

Download Python source code | Download Jupyter notebook

Clip a cube with a sphere.

>>> import pyvista as pv
>>> sphere = pv.Sphere(center=(-0.4, -0.4, -0.4))
>>> cube = pv.Cube().triangulate().subdivide(3)
>>> clipped = cube.clip_surface(sphere)
>>> clipped.plot(show_edges=True, cpos='xy', line_width=3)
../../../_images/pyvista-DataSetFilters-clip_surface-69517b21be2eaea0_00_00.png