PolyData.face_offsets

PolyData.face_offsets#

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

Return the offsets array of the polygonal faces.

The offsets array has n_faces + 1 values and stores the index into face_connectivity at which each face begins. The point ids of face i are face_connectivity[face_offsets[i]:face_offsets[i + 1]].

Vertices, lines, faces, and strips are held in four separate cell arrays, each with its own offsets and connectivity. len(face_offsets) - 1 is therefore n_faces, which is only equal to n_cells for a mesh made up of faces alone.

Added in version 0.49.

Returns:
numpy.ndarray

Array of face offsets with n_faces + 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 face_connectivity; to replace both at once, assign a pyvista.CellArray to faces. See the examples below.

Examples#

Download Python source code | Download Jupyter notebook

>>> import pyvista as pv
>>> points = pv.Rectangle().points
>>> mesh = pv.PolyData.from_regular_faces(points, [[0, 1, 2], [1, 3, 2]])
>>> mesh.face_offsets
array([0, 3, 6]...)

The offsets and connectivity together describe each face.

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

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

Assign a new array instead. Here the six connectivity ids are re-partitioned into three 2-point cells.

>>> mesh.face_offsets = [0, 2, 4, 6]
>>> mesh.n_faces
3

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

>>> mesh.faces = pv.CellArray.from_arrays([0, 4], [0, 1, 3, 2])
>>> mesh.n_faces
1

See Also#

face_connectivity

Point ids that define the faces.

n_faces

Number of faces, one less than the size of this array.

faces

Faces in the legacy padded format.

regular_faces

Faces as a 2D array, when every face has the same size.

vert_offsets, line_offsets, strip_offsets

Offsets arrays of the other PolyData cell types.

pyvista.UnstructuredGrid.cell_offsets

Equivalent property for an unstructured grid.