pyvista.DataSet.point_cell_ids#

DataSet.point_cell_ids(ind: int) List[int][source]#

Get the cell IDs that use the ind-th point.

Implements vtkDataSet’s GetPointCells.

Parameters:
indint

Point ID.

Returns:
List[int]

List of cell IDs using the ind-th point.

Examples

Get the cell ids using the 0-th point.

>>> import pyvista as pv
>>> mesh = pv.Sphere(theta_resolution=10)
>>> mesh.point_cell_ids(0)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Plot them.

>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(mesh, show_edges=True)
>>>
>>> # Label the 0-th point
>>> _ = pl.add_point_labels(
...     mesh.points[0], ["0"], text_color="blue", font_size=20
... )
>>>
>>> # Get the cells ids using the 0-th point
>>> ids = mesh.point_cell_ids(0)
>>> cells = mesh.extract_cells(ids)
>>> _ = pl.add_mesh(cells, color="red", show_edges=True)
>>> centers = cells.cell_centers().points
>>> _ = pl.add_point_labels(
...     centers,
...     labels=[f"{i}" for i in ids],
...     text_color="white",
...     font_size=20,
...     shape=None,
...     show_points=False,
... )
>>>
>>> # Plot the other cells
>>> others = mesh.extract_cells(
...     [i for i in range(mesh.n_cells) if i not in ids]
... )
>>> _ = pl.add_mesh(others, show_edges=True)
>>>
>>> pl.camera_position = "yx"
>>> pl.camera.zoom(7.0)
>>> pl.show()
../../../_images/pyvista-DataSet-point_cell_ids-1_00_00.png