PolyData.vert_offsets

PolyData.vert_offsets#

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

Return the offsets array of the vertex cells.

The offsets array has n_verts + 1 values and stores the index into vert_connectivity at which each vertex cell begins. The point ids of vertex cell i are vert_connectivity[vert_offsets[i]:vert_offsets[i + 1]].

Vertices, lines, faces, and strips are held in four separate cell arrays, each with its own offsets and connectivity. len(vert_offsets) - 1 is therefore n_verts, not n_cells.

Added in version 0.49.

Returns:
numpy.ndarray

Array of vertex cell offsets with n_verts + 1 values.

Notes#

The returned array is read-only and cannot be modified in place. To change the offsets, assign a new array to this property. The new offsets must remain consistent with the current vert_connectivity; to replace both at once, assign a pyvista.CellArray to verts. See the examples below.

Examples#

Download Python source code | Download Jupyter notebook

>>> import pyvista as pv
>>> mesh = pv.PolyData([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
>>> mesh.vert_offsets
array([0, 1, 2, 3]...)

The offsets and connectivity together describe each vertex cell.

The array is read-only and writing to it raises a ValueError.

>>> mesh.vert_offsets.flags['WRITEABLE']
False

Assign a new array instead. Here the three point ids are re-partitioned into a single polyvertex cell.

>>> mesh.vert_offsets = [0, 3]
>>> mesh.n_verts
1

To replace the offsets and connectivity together, assign a pyvista.CellArray to verts.

>>> mesh.verts = pv.CellArray.from_arrays([0, 1, 2], [0, 1])
>>> mesh.n_verts
2

See Also#

vert_connectivity

Point ids that define the vertex cells.

n_verts

Number of vertex cells, one less than the size of this array.

verts

Vertex cells in the legacy padded format.

line_offsets, face_offsets, strip_offsets

Offsets arrays of the other PolyData cell types.