pyvista.PolyData.verts

Contents

pyvista.PolyData.verts#

property PolyData.verts: NumpyArray[int][source]#

Return or set the vertex padded connectivity array.

Like all padded VTK connectivity arrays, the array is structured as:

[n0, p0_0, p0_1, ..., p0_n, n1, p1_0, p1_1, ..., p1_n, ...]

where n0 is the number of points in vertex 0, and pX_Y is the Y’th point in vertex X.

Vertices can be a single VERTEX cell with connectivity to a single point, or a POLY_VERTEX with connectivity to multiple points.

For example, a single vertex and poly-vertex with five points might be represented as:

[1, 0, 5, 3, 2, 4, 1, 5]

Where the two separate vertex cells are [1, 0] and [5, 3, 2, 4, 1, 5].

Returns:
numpy.ndarray

Array of vertex cell connectivity.

See also

n_verts
lines, faces, strips

Padded connectivity arrays for other PolyData cell types.

Examples

Create a point cloud polydata and return the vertex cells.

>>> import pyvista as pv
>>> import numpy as np
>>> rng = np.random.default_rng(seed=0)
>>> points = rng.random((5, 3))
>>> pdata = pv.PolyData(points)
>>> pdata.verts
array([1, 0, 1, 1, 1, 2, 1, 3, 1, 4])

Set vertex cells. Note how the mesh plots both the surface mesh and the additional vertices in a single plot.

>>> mesh = pv.Plane(i_resolution=3, j_resolution=3)
>>> mesh.verts = np.vstack(
...     (
...         np.ones(mesh.n_points, dtype=np.int64),
...         np.arange(mesh.n_points),
...     )
... ).T
>>> mesh.plot(
...     color='lightblue',
...     render_points_as_spheres=True,
...     point_size=60,
... )
../../../_images/pyvista-PolyData-verts-4edcbbf0793d4e60_00_00.png

Vertex cells can also be set to a CellArray. The following verts assignment is equivalent to the one above.

>>> mesh.verts = pv.CellArray.from_regular_cells(
...     np.arange(mesh.n_points).reshape((-1, 1))
... )