CellArray.cell_connectivity#
- property CellArray.cell_connectivity: NumpyArray[int][source]#
Return the connectivity array.
The connectivity array stores the point ids of every cell, one cell after another and without any padding. Use
cell_offsetsto determine where each cell begins and ends.Added in version 0.49.
- Returns:
numpy.ndarrayPoint ids that define the cells.
Notes#
The returned array is read-only and cannot be modified in place. Assign a new
array to this property to change the connectivity, or use from_arrays()
to replace the offsets and connectivity together. The input is copied, so the
cell array never aliases an array that may be modified later.
Where that copy is too expensive, build the cell array with
from_arrays() and deep=False and keep a reference to the connectivity
array. The cell array then wraps that array, so writing to it changes the cells
without any copy. Nothing validates the point ids written this way.
Examples#
Download Python source code | Download Jupyter notebook
>>> import pyvista as pv
>>> cell_array = pv.CellArray.from_arrays([0, 3, 6], [0, 1, 2, 3, 4, 5])
>>> cell_array.cell_connectivity
array([0, 1, 2, 3, 4, 5]...)
>>> cell_array.cell_connectivity = [5, 4, 3, 2, 1, 0]
>>> cell_array.cell_connectivity
array([5, 4, 3, 2, 1, 0]...)
For a cell array 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, 3, 4, 5], dtype=pv.ID_TYPE)
>>> cell_array = pv.CellArray.from_arrays([0, 3, 6], connectivity, deep=False)
>>> connectivity[:] = [5, 4, 3, 2, 1, 0]
>>> cell_array.cell_connectivity
array([5, 4, 3, 2, 1, 0]...)
See Also#
cell_offsetsIndex into this array at which each cell begins.
Used In#
Docstring Examples
CellArray.from_irregular_cells(1 use)