pyvista_wasm.PolyData.clip

Contents

pyvista_wasm.PolyData.clip#

PolyData.clip(normal: str | tuple[float, float, float] = 'x', origin: tuple[float, float, float] | None = None, *, invert: bool = False) PolyData#

Clip the mesh with a plane.

This filter clips the mesh with a plane defined by a normal vector and an origin point using VTK.wasm’s built-in vtkClipPolyData filter with a vtkPlane clip function. Points on one side of the plane are removed. It mirrors the PyVista clip filter API.

Parameters:
  • normal (str or tuple of float, optional) – The normal vector of the clipping plane. Can be a string specifying a cardinal direction (‘x’, ‘y’, ‘z’, ‘-x’, ‘-y’, ‘-z’) or a 3-tuple of floats (nx, ny, nz). Default is ‘x’.

  • origin (tuple of float, optional) – The origin point of the clipping plane as (x, y, z). If not provided, defaults to the center of the mesh’s bounding box.

  • invert (bool, optional) – If True, flip the clipping direction to keep the part that would normally be removed. Default is False.

Returns:

A new mesh with clipped cells removed.

Return type:

PolyData

Examples

>>> import pyvista_wasm as pv
>>> sphere = pv.Sphere()
>>> clipped = sphere.clip(normal='x', origin=(0, 0, 0))
>>> isinstance(clipped, pv.PolyData)
True

Clip along the negative Y axis:

>>> clipped = sphere.clip(normal='-y')
>>> isinstance(clipped, pv.PolyData)
True

Clip with a custom normal vector:

>>> clipped = sphere.clip(normal=(1, 1, 0), origin=(0, 0, 0))
>>> isinstance(clipped, pv.PolyData)
True

Render the clipped mesh:

>>> clipped.plot()