PolyData.face_connectivity#
- property PolyData.face_connectivity: NumpyArray[int][source]#
Return the connectivity array of the polygonal faces.
The connectivity array stores the point ids of every face, one face after another and without any padding. Use
face_offsetsto determine where each face 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.ndarrayPoint ids that define the faces.
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 faces.
Where that copy is too expensive, assign a pyvista.CellArray built with
from_arrays() and deep=False to faces, and
keep a reference to the connectivity array. The mesh then wraps that array, so
writing to it changes the faces without any copy. Nothing validates the point
ids written this way.
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_connectivity
array([0, 1, 2, 1, 3, 2]...)
The array is read-only and writing to it raises a ValueError.
>>> mesh.face_connectivity.flags['WRITEABLE']
False
Assign a new array instead. Here the winding of both triangles is reversed.
>>> mesh.face_connectivity = [2, 1, 0, 2, 3, 1]
>>> mesh.face_connectivity
array([2, 1, 0, 2, 3, 1]...)
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, 1, 3, 2], dtype=pv.ID_TYPE)
>>> mesh.faces = pv.CellArray.from_arrays([0, 3, 6], connectivity, deep=False)
>>> connectivity[:] = [0, 2, 1, 1, 2, 3]
>>> mesh.face_connectivity
array([0, 2, 1, 1, 2, 3]...)
Note that arrays derived from the old topology, such as 'Normals', are not
recomputed by either approach and should be removed or regenerated.
See Also#
face_offsetsIndex into this array at which each face begins.
n_facesNumber of faces.
facesFaces in the legacy padded format.
vert_connectivity,line_connectivity,strip_connectivityConnectivity arrays of the other
PolyDatacell types.pyvista.UnstructuredGrid.cell_connectivityEquivalent property for an unstructured grid.
Used In#
Docstring Examples
PolyData.face_offsets(1 use)