MeshCellIndex[mreg,d]
gives the cell indices for cells of dimension d in the mesh region mreg.
MeshCellIndex[mreg,cellspec]
gives the cell indices for the cells specified by cellspec.
MeshCellIndex
MeshCellIndex[mreg,d]
gives the cell indices for cells of dimension d in the mesh region mreg.
MeshCellIndex[mreg,cellspec]
gives the cell indices for the cells specified by cellspec.
Details
- MeshCellIndex is often used to get the cell index {d,i} from a symbolic cell h[{i1,…}].
- The cell indices returned have the form {d,i}, where d is dimension and i a positive integer.
- The mesh region mreg can be either MeshRegion or BoundaryMeshRegion.
- The cell specification cellspec follows the standard form described for MeshRegion and BoundaryMeshRegion.
- MeshCellCount can be used to find the maximum number of cell indices for each dimension.
Examples
open all close allBasic Examples (1)
Find the cell index for different symbolic cells:
mr = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Triangle[{1, 2, 3}]]MeshCellIndex[mr, {Triangle[{1, 2, 3}]}]MeshCellIndex[mr, {Line[{1, 2}], Line[{2, 3}], Line[{3, 1}]}]MeshCellIndex[mr, {Point[1], Point[2], Point[3]}]Scope (8)
Get the cell indices for a MeshRegion in 1D:
ℛ = MeshRegion[{{0}, {1}, {2}}, {Line[{1, 2}], Point[3]}]MeshCellIndex[ℛ, 0]MeshCellIndex[ℛ, {Line[{1, 2}]}]Get the cell indices for a MeshRegion in 2D:
ℛ = MeshRegion[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, Polygon[{1, 2, 3, 4}]]MeshCellIndex[ℛ, 1]Index of the top line segment:
MeshCellIndex[ℛ, {Line[{3, 4}]}]Use it to highlight just that segment:
HighlightMesh[ℛ, %]Get the cell indices for a MeshRegion in 3D:
ℛ = MeshRegion[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}}, Tetrahedron[{{1, 2, 3, 5}, {1, 3, 4, 5}}], MeshCellStyle -> 2 -> Opacity[0.3]]MeshCellIndex[ℛ, 2]MeshCellIndex[ℛ, {Point[5]}]Get the cell indices for a BoundaryMeshRegion in 1D:
ℛ = ConvexHullMesh[RandomReal[1, {5, 1}]]Only the boundary points are cells:
MeshCellIndex[ℛ, 0]Get the cell indices for a BoundaryMeshRegion in 2D:
ℛ = ConvexHullMesh[RandomReal[1, {6, 2}]]MeshCellIndex[ℛ, 1]Get the cell indices for a BoundaryMeshRegion in 3D:
ℛ = ConvexHullMesh[RandomReal[1, {10, 3}]]MeshCellIndex[ℛ, 2]Use All to get indices for cells of all dimensions:
ℛ = MeshRegion[{{0, 0}, {1, 0}, {1, 1}}, Polygon[{1, 2, 3}]]MeshCellIndex[ℛ, All]Works with large mesh regions:
ℛ = DiscretizeRegion[Disk[], MaxCellMeasure -> 10 ^ -5]MeshCellCount[ℛ]Length[MeshCellIndex[ℛ, 0]] == MeshCellCount[ℛ, 0]Properties & Relations (4)
MeshCells gives the cells corresponding to cell indices:
mr = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Polygon[{1, 2, 3}]]mci = MeshCellIndex[mr, 1]MeshCells[mr, mci]MeshCellIndex gives the cell indices corresponding to MeshCells:
mr = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Polygon[{1, 2, 3}]]mc = MeshCells[mr, 1]The corresponding cell indices:
MeshCellIndex[mr, mc]HighlightMesh can use cell indices as input:
mr = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Polygon[{1, 2, 3}]]mc = MeshCellIndex[mr, {Line[{1, 2}], Point[{3}]}]HighlightMesh[mr, mc]The length of a MeshCellIndex output is MeshCellCount evaluated with the same input:
mr = DelaunayMesh[RandomReal[1, {10, 2}]]{Length[MeshCellIndex[mr, 1]], MeshCellCount[mr, 1]}Possible Issues (1)
When coordinates are unused, they are removed from the MeshRegion representation:
mr = MeshRegion[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, Polygon[{1, 2, 4}]]MeshCellIndex[mr, Polygon[{1, 2, 4}]]Use the indices as if the third coordinate was never given:
MeshCellIndex[mr, Polygon[{1, 2, 3}]]Related Guides
History
Text
Wolfram Research (2014), MeshCellIndex, Wolfram Language function, https://reference.wolfram.com/language/ref/MeshCellIndex.html.
CMS
Wolfram Language. 2014. "MeshCellIndex." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MeshCellIndex.html.
APA
Wolfram Language. (2014). MeshCellIndex. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MeshCellIndex.html
BibTeX
@misc{reference.wolfram_2026_meshcellindex, author="Wolfram Research", title="{MeshCellIndex}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/MeshCellIndex.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_meshcellindex, organization={Wolfram Research}, title={MeshCellIndex}, year={2014}, url={https://reference.wolfram.com/language/ref/MeshCellIndex.html}, note=[Accessed: 12-June-2026]}