PolyData.vert_connectivity

PolyData.vert_connectivity#

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

Return the connectivity array of the vertex cells.

The connectivity array stores the point ids of every vertex cell, one cell after another and without any padding. Use vert_offsets to determine where each vertex cell begins and ends.

Vertices, lines, faces, and strips are held in four separate cell arrays, each with its own offsets and connectivity.

Added in version 0.49.

Returns:
numpy.ndarray

Point ids that define the vertex cells.

Notes#

The returned array is read-only and cannot be modified in place. To change the connectivity, assign a new array to this property. The input is copied, so the mesh never aliases an array that may be modified later. To replace the offsets and connectivity together, assign a pyvista.CellArray to verts.

Where that copy is too expensive, assign a pyvista.CellArray built with from_arrays() and deep=False to verts, and keep a reference to the connectivity array. The mesh then wraps that array, so writing to it changes the vertex cells without any copy. Nothing validates the point ids written this way.

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_connectivity
array([0, 1, 2]...)

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

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

Assign a new array instead. Here the order of the vertex cells is reversed.

>>> mesh.vert_connectivity = [2, 1, 0]
>>> mesh.vert_connectivity
array([2, 1, 0]...)

For a mesh large enough that the copy matters, keep the connectivity array and edit it in place.

>>> import numpy as np
>>> connectivity = np.array([0, 1, 2], dtype=pv.ID_TYPE)
>>> mesh.verts = pv.CellArray.from_arrays(
...     [0, 1, 2, 3], connectivity, deep=False
... )
>>> connectivity[:] = [2, 0, 1]
>>> mesh.vert_connectivity
array([2, 0, 1]...)

See Also#

vert_offsets

Index into this array at which each vertex cell begins.

n_verts

Number of vertex cells.

verts

Vertex cells in the legacy padded format.

line_connectivity, face_connectivity, strip_connectivity

Connectivity arrays of the other PolyData cell types.