pyvista.PolyDataFilters.intersection#
- PolyDataFilters.intersection( )[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:
- mesh
pyvista.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.
- mesh
- 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()
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 ... )