PolyData.face_offsets#
- property PolyData.face_offsets: NumpyArray[int][source]#
Return the offsets array of the polygonal faces.
The offsets array has
n_faces + 1values and stores the index intoface_connectivityat which each face begins. The point ids of faceiareface_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) - 1is thereforen_faces, which is only equal ton_cellsfor a mesh made up of faces alone.Added in version 0.49.
- Returns:
numpy.ndarrayArray of face offsets with
n_faces + 1values.
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.
>>> mesh.face_connectivity[mesh.face_offsets[0] : mesh.face_offsets[1]]
array([0, 1, 2]...)
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_connectivityPoint ids that define the faces.
n_facesNumber of faces, one less than the size of this array.
facesFaces in the legacy padded format.
regular_facesFaces as a 2D array, when every face has the same size.
vert_offsets,line_offsets,strip_offsetsOffsets arrays of the other
PolyDatacell types.pyvista.UnstructuredGrid.cell_offsetsEquivalent property for an unstructured grid.