DataSet.find_cells_intersecting_line

DataSet.find_cells_intersecting_line#

DataSet.find_cells_intersecting_line(
pointa: VectorLike[float],
pointb: VectorLike[float],
tolerance: float | None = None,
) NumpyArray[int][source]#

Find the index of cells that intersect a line.

Line is defined from pointa to pointb.

Warning

This filter internally builds and caches a vtkStaticCellLocator. If the mesh’s geometry is modified, the cache will no longer be valid.

Parameters:
pointasequence[float]

Length 3 coordinate of the start of the line.

pointbsequence[float]

Length 3 coordinate of the end of the line.

tolerancefloat, optional

The absolute tolerance to use to find cells along line. The default value is the epsilon (eps) of float32 dtype using numpy.finfo.

Returns:
numpy.ndarray

Index or indices of the cells that intersect the line.

Examples#

Download Python source code | Download Jupyter notebook

>>> import pyvista as pv
>>> mesh = pv.Sphere()
>>> cell_ids = mesh.find_cells_intersecting_line([0.0, 0, 0], [1.0, 0, 0])
>>> sorted(cell_ids.tolist())
[86, 1653]

See Also#

DataSet.find_closest_point
DataSet.find_closest_cell
DataSet.find_containing_cell
DataSet.find_cells_within_bounds
DataSet.find_cells_along_line
DataSet.intersect_with_line
PolyDataFilters.ray_trace