MeshCells
Details
- MeshCells is often used to get the symbolic cell h[{i1,…}] from a cell index {d,i}.
- The cells returned have the form h[{i1,…}] where ik are coordinate index indicating point ik in the list of coordinates given by MeshCoordinates.
- 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 cells for each dimension.
Examples
open all close allBasic Examples (3)
Mesh cells for a MeshRegion in 1D:
ℛ = MeshRegion[{{0}, {1}, {2}}, {Line[{1, 2}], Point[3]}]The 0D cells also include the end points of the line:
MeshCells[ℛ, 0]HighlightMesh[ℛ, Style[0, Red]]MeshCells[ℛ, 1]Mesh cells for a MeshRegion in 2D:
ℛ = MeshRegion[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, Polygon[{1, 2, 3, 4}]]The 0D cells include all the corner points:
MeshCells[ℛ, 0]HighlightMesh[ℛ, Style[0, Red]]The 1D cells include all the edges:
MeshCells[ℛ, 1]HighlightMesh[ℛ, Style[1, Red]]The only 2D cell is used as input:
MeshCells[ℛ, 2]Mesh cells 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]]MeshCells[ℛ, 0]HighlightMesh[ℛ, Style[0, Red]]MeshCells[ℛ, 1]HighlightMesh[ℛ, Style[1, Red]]MeshCells[ℛ, 2]HighlightMesh[ℛ, Style[2, Opacity[0.2, Red]]]Scope (7)
Mesh cells for a MeshRegion in 1D:
ℛ = MeshRegion[{{0}, {1}, {2}}, {Line[{1, 2}], Point[3]}]The 0D cells also include the end points of the line:
MeshCells[ℛ, 0]HighlightMesh[ℛ, Style[0, Red]]MeshCells[ℛ, 1]Mesh cells for a MeshRegion in 2D:
ℛ = MeshRegion[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, Polygon[{1, 2, 3, 4}]]The 0D cells include all the corner points:
MeshCells[ℛ, 0]HighlightMesh[ℛ, Style[0, Red]]The 1D cells include all the edges:
MeshCells[ℛ, 1]HighlightMesh[ℛ, Style[1, Red]]The only 2D cell is used as input:
MeshCells[ℛ, 2]HighlightMesh[ℛ, Style[2, Red]]Mesh cells 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]]MeshCells[ℛ, 0]HighlightMesh[ℛ, Style[0, Red]]MeshCells[ℛ, 1]HighlightMesh[ℛ, Style[1, Red]]MeshCells[ℛ, 2]HighlightMesh[ℛ, Style[2, Opacity[0.2, Red]]]ℛ = MeshRegion[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, {Polygon[{1, 2, 3}], Line[{3, 4}]}]MeshCells[ℛ, 2 | 1]The indices given in MeshCells correspond to MeshCoordinates:
ℛ = DelaunayMesh[RandomReal[1, {25, 2}]]{pts, polys} = {MeshCoordinates[ℛ], MeshCells[ℛ, 2]};Construct a MeshRegion directly:
MeshRegion[pts, polys]Create a GraphicsComplex:
Graphics[{FaceForm[LightBlue], EdgeForm[Gray], GraphicsComplex[pts, polys]}]Specify a list of 1D cell primitives:
ℛ = 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]]MeshCells[ℛ, {1, {2, 5, 6}}]HighlightMesh[ℛ, Style[%, Red]]Alternatively, you can specify a head and indices:
MeshCells[ℛ, {Line[{1, 2, 5, 1}]}]HighlightMesh[ℛ, Style[%, Red]]ℛ = 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]]MeshCells[ℛ, {2, {2, 5}}]HighlightMesh[ℛ, Style[%, Red]]Applications (1)
Extract the lines from a MeshRegion to make a wireframe mesh:
ℛ = DelaunayMesh[RandomReal[1, {8, 3}]]The indices given in MeshCells correspond to MeshCoordinates:
{pts, lines} = {MeshCoordinates[ℛ], MeshCells[ℛ, 1]};MeshRegion[pts, lines]Properties & Relations (1)
The indices in MeshCells refer to the MeshCoordinates:
mr = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Triangle[{1, 2, 3}]]l = MeshCells[mr, {1, 1}]HighlightMesh[mr, Style[l, Red]]Possible Issues (1)
Culling of unused coordinates may change cell indices:
mr = MeshRegion[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, Polygon[{1, 2, 4}]]The cell indices refer to MeshCoordinates, not the input coordinates:
MeshCoordinates[mr]MeshCells[mr, 2]Related Guides
History
Text
Wolfram Research (2014), MeshCells, Wolfram Language function, https://reference.wolfram.com/language/ref/MeshCells.html.
CMS
Wolfram Language. 2014. "MeshCells." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/MeshCells.html.
APA
Wolfram Language. (2014). MeshCells. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MeshCells.html
BibTeX
@misc{reference.wolfram_2026_meshcells, author="Wolfram Research", title="{MeshCells}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/MeshCells.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_meshcells, organization={Wolfram Research}, title={MeshCells}, year={2014}, url={https://reference.wolfram.com/language/ref/MeshCells.html}, note=[Accessed: 13-June-2026]}