DataObjectFilters.compute_cell_sizes#
- DataObjectFilters.compute_cell_sizes(
- *,
- length: bool = True,
- area: bool = True,
- volume: bool = True,
- progress_bar: bool = False,
- vertex_count: bool = False,
Compute sizes for 0D (vertex count), 1D (length), 2D (area) and 3D (volume) cells.
- Parameters:
- lengthbool, default:
True Specify whether or not to compute the length of 1D cells. This generates a
'Length'cell data array.- areabool, default:
True Specify whether or not to compute the area of 2D cells. This generates an
'Area'cell data array.- volumebool, default:
True Specify whether or not to compute the volume of 3D cells. This generates a
'Volume'cell data array.- progress_barbool, default:
False Display a progress bar to indicate progress.
- vertex_countbool, default:
False Specify whether or not to compute sizes for vertex and polyvertex cells (0D cells). The computed value is the number of points in the cell. This generates a
'VertexCount'cell data array.
- lengthbool, default:
- Returns:
- output
DataSet|MultiBlock Dataset with
cell_datacontaining the"VertexCount","Length","Area", and"Volume"arrays if set in the parameters. Return type matches input.
- output
Notes#
If cells do not have a dimension (for example, the length of hexahedral cells), the corresponding array will be all zeros.
Examples#
Download Python source code | Download Jupyter notebook
Compute the face area of the example airplane mesh.
>>> from pyvista import examples
>>> surf = examples.load_airplane()
>>> surf = surf.compute_cell_sizes(length=False, volume=False)
>>> surf.plot(show_edges=True, scalars='Area')
Create a mesh with cells of various dimensions.
>>> mesh_0D = examples.cells.Vertex()
>>> mesh_1D = examples.cells.Line()
>>> mesh_2D = examples.cells.Quadrilateral()
>>> mesh_3D = examples.cells.Hexahedron()
>>> mesh = mesh_0D + mesh_1D + mesh_2D + mesh_3D
Compute all arrays and compare them.
>>> sizes = mesh.compute_cell_sizes(vertex_count=True)
>>> sizes['VertexCount']
pyvista_ndarray([1., 0., 0., 0.])
>>> sizes['Length']
pyvista_ndarray([0., 1., 0., 0.])
>>> sizes['Area']
pyvista_ndarray([0., 0., 1., 0.])
>>> sizes['Volume']
pyvista_ndarray([0., 0., 0., 1.])
Used In#
API Examples
DataObject.copy_attributes(1 use)DataObjectFilters.cell_data_to_point_data(1 use)Icosphere(1 use)SolidSphereGeneric(1 use)
Gallery Examples