pyvista.PolyDataFilters.intersection

pyvista.PolyDataFilters.intersection#

PolyDataFilters.intersection(
mesh,
split_first=True,
split_second=True,
progress_bar=False,
)[source]#

Compute the intersection between two meshes.

Note

This method returns the surface intersection from two meshes (which often resolves as a line), whereas the PolyDataFilters.boolean_intersection() filter returns the “volume” intersection between two closed (manifold) meshes.

Parameters:
meshpyvista.PolyData

The mesh to intersect with.

split_firstbool, default: True

If True, return the first input mesh split by the intersection with the second input mesh.

split_secondbool, default: True

If True, return the second input mesh split by the intersection with the first input mesh.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.PolyData

The intersection line.

pyvista.PolyData

The first mesh split along the intersection. Returns the original first mesh if split_first=False.

pyvista.PolyData

The second mesh split along the intersection. Returns the original second mesh if split_second=False.

Examples

Intersect two spheres, returning the intersection and both spheres which have new points/cells along the intersection line.

>>> import pyvista as pv
>>> import numpy as np
>>> s1 = pv.Sphere(phi_resolution=15, theta_resolution=15)
>>> s2 = s1.copy()
>>> s2.points += np.array([0.25, 0, 0])
>>> intersection, s1_split, s2_split = s1.intersection(s2)
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(s1, style='wireframe')
>>> _ = pl.add_mesh(s2, style='wireframe')
>>> _ = pl.add_mesh(intersection, color='r', line_width=10)
>>> pl.show()
../../../_images/pyvista-PolyDataFilters-intersection-1_00_00.png

The mesh splitting takes additional time and can be turned off for either mesh individually.

>>> intersection, _, s2_split = s1.intersection(
...     s2, split_first=False, split_second=True
... )