pyvista.DataSet.point_neighbors#

DataSet.point_neighbors(ind: int) List[int][ソース]#

ind番目の点の近傍点を返します.

パラメータ:
indint

ポイントIDです.

戻り値:
List[int]

ind番目のポイントの近隣ポイントIDのリスト.

0番目の点の近傍点を返します.

>>> import pyvista as pv
>>> mesh = pv.Sphere(theta_resolution=10)
>>> mesh.point_neighbors(0)
[2, 226, 198, 170, 142, 114, 86, 254, 58, 30]

それらをプロットします.

>>> 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=40
... )
>>>
>>> # Get the point neighbors and plot them
>>> neighbors = mesh.point_neighbors(0)
>>> _ = pl.add_point_labels(
...     mesh.points[neighbors],
...     labels=[f"{i}" for i in neighbors],
...     text_color="red",
...     font_size=40,
... )
>>> pl.camera_position = "xy"
>>> pl.camera.zoom(7.0)
>>> pl.show()
../../../_images/pyvista-DataSet-point_neighbors-1_00_00.png