PolyDataFilters.clip_closed_surface

PolyDataFilters.clip_closed_surface#

PolyDataFilters.clip_closed_surface(
normal: VectorLikeFloat | _NormalsLiteral | None = None,
*,
origin: VectorLikeFloat | None = None,
tolerance: float = 1e-06,
inplace: bool = False,
progress_bar: bool = False,
plane: PolyData | None = None,
) → PolyData[source]#

Clip a closed polydata surface with a plane.

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.

This currently only supports one plane but could be implemented to handle a plane collection.

It will produce a new closed surface by creating new polygonal faces where the input data was clipped.

Non-manifold surfaces should not be used as input for this filter. The input surface should have no open edges, and must not have any edges that are shared by more than two faces. In addition, the input surface should not self-intersect, meaning that the faces of the surface should only touch at their edges.

Parameters:
normalVectorLikeFloat | 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.

originVectorLikeFloat, optional

The center (x, y, z) coordinate of the plane on which the clip occurs. The default is the center of the dataset.

tolerancefloat, optional

The tolerance for creating new points while clipping. If the tolerance is too small, then degenerate triangles might be produced.

inplacebool, default: False

Updates mesh in-place.

progress_barbool, default: False

Display a progress bar to indicate progress.

planePolyData, optional

Plane() mesh to use for clipping. 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.

Added in version 0.47.

Returns:
pyvista.PolyData

The clipped mesh. The point and cell data of the input are not carried over to it.

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 sphere in the negative Z direction centered at the origin. This will leave behind half a sphere in the negative Z direction.

>>> import pyvista as pv
>>> sphere = pv.Sphere()
>>> clipped_mesh = sphere.clip_closed_surface('-z')
>>> clipped_mesh.plot(show_edges=True, line_width=3)
../../../_images/pyvista-PolyDataFilters-clip_closed_surface-29a5543e157e8b02_00_00.png

Clip the sphere at the XY plane and leave behind half the sphere in the positive Z direction. Shift the clip upwards to leave a smaller mesh behind.

>>> clipped_mesh = sphere.clip_closed_surface('z', origin=[0, 0, 0.3])
>>> clipped_mesh.plot(show_edges=True, line_width=3)
../../../_images/pyvista-PolyDataFilters-clip_closed_surface-29a5543e157e8b02_01_00.png