CellArray#

class CellArray(*args, **kwargs)[source]#

PyVista wrapping of vtkCellArray.

Provides convenience functions to simplify creating a CellArray from a NumPy array or list.

Parameters:
cellsnp.ndarray or list, optional

Import an array of data with the legacy vtkCellArray layout: each cell is stored as its point count followed by that many point indices, with cells concatenated back-to-back (for example [3, 0, 1, 2, 4, 0, 1, 2, 3] for a triangle followed by a quad).

Examples#

Download Python source code | Download Jupyter notebook

Create a cell array containing two triangles from the traditional interleaved format

>>> from pyvista.core.cell import CellArray
>>> cellarr = CellArray([3, 0, 1, 2, 3, 3, 4, 5])

Create a cell array containing two triangles from separate offsets and connectivity arrays

>>> from pyvista.core.cell import CellArray
>>> offsets = [0, 3, 6]
>>> connectivity = [0, 1, 2, 3, 4, 5]
>>> cellarr = CellArray.from_arrays(offsets, connectivity)

Inheritance#

Wraps vtkCellArray.

Attributes#

CellArray.cell_connectivity

Return the connectivity array.

CellArray.cell_offsets

Return the offsets array.

CellArray.cells

Return a NumPy array of the cells.

CellArray.connectivity_array

Return the array with the point ids that define the cells' connectivity.

CellArray.n_cells

Return the number of cells.

CellArray.offset_array

Return the array used to store cell offsets.

CellArray.regular_cells

Return a (n_cells, cell_size)-shaped array of point indices for equal-sized faces.

Methods#

CellArray.from_arrays(offsets, connectivity)

Construct a CellArray from offsets and connectivity arrays.

CellArray.from_irregular_cells(cells)

Construct a CellArray from cells which may have different sizes.

CellArray.from_regular_cells(cells[, deep])

Construct a CellArray from cells which all have the same size.