discretizes a 2D or 3D graphic g into a BoundaryMeshRegion.
BoundaryDiscretizeGraphics[g,patt]
discretizes only the elements in g that match the pattern patt.
BoundaryDiscretizeGraphics
discretizes a 2D or 3D graphic g into a BoundaryMeshRegion.
BoundaryDiscretizeGraphics[g,patt]
discretizes only the elements in g that match the pattern patt.
Details and Options
- BoundaryDiscretizeGraphics discretizes full-dimensional graphics primitives into a boundary representation consisting of piecewise linear elements used in BoundaryMeshRegion.
- Only full-dimensional parts (areas in 2D and volumes in 3D) will be discretized.
- The graphic g can be Graphics, Graphics3D, or individual graphics primitives.
- BoundaryDiscretizeGraphics effectively treats multiple primitives in Graphics and Graphics3D as a union operation.
- Bounded piecewise linear primitives in Graphics (these can be represented exactly):
-
Triangle[…] filled triangle (2D) Polygon[…] filled polygon (2D) Rectangle[…] filled rectangle (2D) Parallelogram[…] filled parallelogram (2D) Simplex[…] simplex (2D) - In addition, SSSTriangle, SASTriangle, ASATriangle, and AASTriangle evaluate to Triangle and can be represented exactly.
- Unbounded piecewise linear primitives in Graphics (only a finite range can be represented):
-
HalfPlane[…] half-space (2D) ConicHullRegion[…] linear cone (2D) - Nonlinear primitives in Graphics (only an approximation can be represented):
-
Disk[…] disk, filled ellipse, sectors (2D) FilledCurve[…] filled closed curve (2D) - Bounded piecewise linear primitives in Graphics3D (these can be represented exactly):
-
Cuboid[…] filled cuboid (3D) Parallelepiped[…] filled parallelepiped (3D) Tetrahedron[…] filled tetrahedron (3D) Hexahedron[…] filled hexahedron (3D) Pyramid[…] filled pyramid (3D) Prism[…] filled prism (3D) Simplex[…] simplex (3D) - Unbounded piecewise linear primitives in Graphics3D (only a finite range can be represented):
-
ConicHullRegion[…] linear cone (3D) - Nonlinear primitives in Graphics3D (only an approximation can be represented):
-
Ball[…] ball or filled sphere (3D) Ellipsoid[…] filled ellipsoid (3D) Cylinder[…] filled cylinder (3D) Cone[…] filled cone (3D) - BoundaryDiscretizeGraphics has the same options as BoundaryMeshRegion, with the following additions and changes:
-
AccuracyGoal Automatic digits of accuracy sought MaxCellMeasure Automatic maximum cell measure Method Automatic method to use PlotRange Automatic the range to include PerformanceGoal $PerformanceGoal whether to consider speed or quality PrecisionGoal Automatic digits of precision sought - With AccuracyGoal->a and PrecisionGoal->p, an attempt will be made to keep the maximum distance between the region reg or the discretized region dreg and any point in RegionSymmetricDifference[reg,dreg] to less than
, where
is the length of the diagonal of the plot range.
Examples
open all close allBasic Examples (3)
Discretize a 2D special region including Disk:
BoundaryDiscretizeGraphics[Disk[]]BoundaryDiscretizeGraphics[Parallelogram[{0, 0}, {{1, 1}, {1, 0}}]]Discretize 3D special regions including Cone:
BoundaryDiscretizeGraphics[Cone[]]BoundaryDiscretizeGraphics[Prism[{{1, 0, 1}, {0, 0, 0}, {2, 0, 0}, {1, 2, 1}, {0, 2, 0}, {2, 2, 0}}]]Discretize a whole 2D Graphics scene, where multiple primitives are taken as a union:
BoundaryDiscretizeGraphics[[image]]Area[%]Scope (15)
Graphics (9)
Discretize a 2D special region including Disk:
BoundaryDiscretizeGraphics[Graphics[{Disk[]}]]BoundaryDiscretizeGraphics[Graphics[{Parallelogram[{0, 0}, {{1, 1}, {1, 0}}]}]]Discretize Graphics with GraphicsComplex containing Line and Polygon:
v = {{0, 0}, {3, 0}, {3, 3}, {0, 3}};g = Graphics /@ {GraphicsComplex[v, Line[{1, 2, 3, 4, 1}]], GraphicsComplex[v, Polygon[{1, 2, 3, 4}]]}BoundaryDiscretizeGraphics /@ gDiscretize Graphics with GraphicsComplex containing Rectangle and Disk:
v = {{0, 0}, {2, 0}, {2, 2}, {0, 2}};g = Graphics /@ {GraphicsComplex[v, Rectangle /@ {1, 2, 3, 4}], GraphicsComplex[v, Disk /@ {1, 2, 3, 4}]}BoundaryDiscretizeGraphics /@ gDiscretize a whole 2D Graphics scene, where multiple primitives are taken as a union:
BoundaryDiscretizeGraphics[[image]]Area[%]Discretize only those primitives that match a pattern:
g = Graphics[{Orange, Triangle[{{2, -1}, {3, 0}, {2, 1}}], Triangle[{{1, -1}, {3, 0}, {1, 1}}], Blue, Rectangle[{0.4, -0.5}, {1.2, 0.5}], Brown, Disk[{0, 0}, 0.5]}]BoundaryDiscretizeGraphics[g, _Triangle | _Disk]Discretize primitives with area < 1:
BoundaryDiscretizeGraphics[g, x_ /; Area[x] < 1]Discretize All primitives:
BoundaryDiscretizeGraphics[g, All]Bounded piecewise linear Graphics primitives can be represented exactly:
g = Graphics[{Triangle[], Rectangle[{0.5, 1}], Polygon[{{1, 0.5}, {3, -0.5}, {2, 0.5}, {3, 1.5}}]}]BoundaryDiscretizeGraphics[g]Unbounded piecewise linear Graphics primitives can only be represented within a finite range:
p = {HalfPlane[{{1, 0}, {2, 1}}, {1, -1}], ConicHullRegion[{{-1, 0}}, {{-1, -1}, {-1, 1}}]};g = Graphics[p, PlotRange -> {{-3, 3}, {-1.5, 1.5}}]BoundaryDiscretizeGraphics[g]Nonlinear Graphics primitives can only be approximately represented:
g = Graphics[{Disk[{3, 0}, {6, 2}], Disk[{2, 0}, 5, {Pi / 4, 7Pi / 4}]}]BoundaryDiscretizeGraphics[g]Use MaxCellMeasure to control the level of discretization:
g = Graphics[{Disk[{0, 0}], Disk[{1.5, 0}]}]Table[BoundaryDiscretizeGraphics[g, MaxCellMeasure -> {"Length" -> m}], {m, {0.9, 0.6, 0.3}}]Graphics3D (6)
Discretize 3D special regions including Cone:
BoundaryDiscretizeGraphics[Graphics3D[{Cone[]}]]BoundaryDiscretizeGraphics[Graphics3D[{Prism[{{1, 0, 1}, {0, 0, 0}, {2, 0, 0}, {1, 2, 1}, {0, 2, 0}, {2, 2, 0}}]}]]3D styling primitives are discarded:
g = Graphics3D[{Orange, Opacity[0.4], EdgeForm[Dashed], Cylinder[]}]BoundaryDiscretizeGraphics[g]Discretize Graphics3D with GraphicsComplex of Polyhedron:
v = {{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}};
i = {{1, 2, 5}, {2, 3, 5}, {3, 4, 5}, {4, 1, 5}, {1, 2, 3, 4}};g = Graphics3D[GraphicsComplex[v, Polyhedron[i]]]BoundaryDiscretizeGraphics[g]Bounded piecewise linear Graphics3D primitives can be represented exactly:
g = Graphics3D[Parallelepiped[{0, 0, 0}, {{1, 0, 0}, {1, 1, 0}, {0, 1, 1}}], Boxed -> False]BoundaryDiscretizeGraphics[g]Nonlinear Graphics3D primitives can only be approximately represented:
BoundaryDiscretizeGraphics[Graphics3D[{Ball[]}]]Use MaxCellMeasure to control the level of discretization:
g = Graphics3D[{Ball[]}]Table[BoundaryDiscretizeGraphics[g, MaxCellMeasure -> m], {m, {0.3, 0.01, 0.001}}]Options (23)
MaxCellMeasure (6)
Discretize with a maximum cell area of 0.1:
g = Graphics[{Disk[{0, 0}], Disk[{1.5, 0}]}]BoundaryDiscretizeGraphics[g, MaxCellMeasure -> 0.1]Discretize with a maximum edge length of 0.5:
g = Graphics[{Disk[{0, 0}], Disk[{1.5, 0}]}]br = BoundaryDiscretizeGraphics[g, MaxCellMeasure -> {"Length" -> 0.5}]This gives the lengths of the sides:
AnnotationValue[{br, 1}, MeshCellMeasure]Discretize with a maximum cell volume of 0.05:
g = Graphics3D[{Ball[]}]BoundaryDiscretizeGraphics[g, MaxCellMeasure -> 0.05]Discretize with a maximum face area of 0.1:
g = Graphics3D[{Ball[]}]br = BoundaryDiscretizeGraphics[g, MaxCellMeasure -> {"Area" -> 0.1}]A Histogram of the face areas:
Histogram[AnnotationValue[{br, 2}, MeshCellMeasure]]Compare different length settings:
g = Graphics[{Disk[{0, 0}], Disk[{1.5, 0}]}]Table[BoundaryDiscretizeGraphics[g, MaxCellMeasure -> {"Length" -> m}], {m, {0.9, 0.6, 0.3}}]Compare different face area settings:
g = Graphics3D[Ball[]]Table[BoundaryDiscretizeGraphics[g, MaxCellMeasure -> {"Area" -> m}], {m, {1, 0.01, 0.003}}]MeshCellHighlight (2)
MeshCellHighlight allows you to specify highlighting for parts of a BoundaryMeshRegion:
BoundaryDiscretizeGraphics[Disk[], MeshCellHighlight -> {{1, All} -> Red, {0, All} -> Black}]Individual cells can be highlighted using their cell index:
BoundaryDiscretizeGraphics[Simplex[2], MeshCellHighlight -> {{1, 1} -> {Thick, Red}, {1, 2} -> {Dashed, Black}}]BoundaryDiscretizeGraphics[Simplex[2], MeshCellHighlight -> {Line[{1, 2}] -> {Thick, Red}, Line[{2, 3}] -> {Dashed, Black}}]MeshCellLabel (3)
MeshCellLabel can be used to label parts of a BoundaryMeshRegion:
BoundaryDiscretizeGraphics[Parallelogram[{0, 0}, {{1, 1}, {1, 0}}], MeshCellLabel -> {0 -> "Index"}]Label the vertices and edges of a rectangle:
BoundaryDiscretizeGraphics[Rectangle[], MeshCellLabel -> {0 -> "Index", 1 -> "Index"}]Individual cells can be labeled using their cell index:
BoundaryDiscretizeGraphics[Rectangle[], MeshCellLabel -> {{0, 1} -> "x", {0, 2} -> "y"}]BoundaryDiscretizeGraphics[Rectangle[], MeshCellLabel -> {Point[1] -> "x", Point[2] -> "y"}]MeshCellMarker (1)
MeshCellMarker can be used to assign values to parts of a BoundaryMeshRegion:
BoundaryDiscretizeGraphics[Rectangle[], MeshCellMarker -> {{0, 1} -> 1, {0, 2} -> 1}]Use MeshCellLabel to show the markers:
BoundaryDiscretizeGraphics[Rectangle[], MeshCellMarker -> {{0, 1} -> 1, {0, 2} -> 2}, MeshCellLabel -> {0 -> "Marker"}]MeshCellShapeFunction (2)
MeshCellShapeFunction allows you to specify functions for parts of a BoundaryMeshRegion:
BoundaryDiscretizeGraphics[Rectangle[], MeshCellShapeFunction -> {0 -> (Disk[#, .1]&)}]Individual cells can be drawn using their cell index:
BoundaryDiscretizeGraphics[Rectangle[], MeshCellShapeFunction -> {{0, 1} -> (Disk[#, .1]&), {0, 2} -> (Disk[#, {.1, .2}]&)}]BoundaryDiscretizeGraphics[Rectangle[], MeshCellShapeFunction -> {Point[1] -> (Disk[#, .1]&), Point[2] -> (Disk[#, {.1, .2}]&)}]MeshCellStyle (2)
MeshCellStyle allows you to specify styling for parts of a BoundaryMeshRegion:
BoundaryDiscretizeGraphics[Disk[], MeshCellStyle -> {{1, All} -> Red, {0, All} -> Black}]Individual cells can be highlighted using their cell index:
BoundaryDiscretizeGraphics[Simplex[2], MeshCellStyle -> {{1, 1} -> {Thick, Red}, {1, 2} -> {Dashed, Black}}]BoundaryDiscretizeGraphics[Simplex[2], MeshCellStyle -> {Line[{1, 2}] -> {Thick, Red}, Line[{2, 3}] -> {Dashed, Black}}]PlotRange (5)
Automatic includes the entire range of a finite region:
g = Graphics[{Triangle[], Disk[{-1, -1}]}];BoundaryDiscretizeGraphics[g, PlotRange -> Automatic]Automatic includes a partial range of an infinite region:
g = Graphics[{HalfPlane[{{1, 0}, {2, 1}}, {1, -1}], ConicHullRegion[{{-1, 0}}, {{-1, -1}, {-1, 1}}]}];BoundaryDiscretizeGraphics[g, PlotRange -> Automatic]Explicit settings are respected:
g = Graphics[{Disk[{0, 0}], Disk[{1.5, 0}]}, PlotRange -> {{-1, 3}, {-1, 1}}]BoundaryDiscretizeGraphics[g]BoundaryDiscretizeGraphics[g, PlotRange -> {{0, 3}, {0, 1}}]g = Graphics[{Disk[], HalfPlane[{{1, 0}, {2, 1}}, {1, -1}]}];BoundaryDiscretizeGraphics[g, PlotRange -> {{-3, 3}, {-3, 3}}]Clipping a solid primitive results in a solid primitive:
g = Graphics3D[{Cone[]}]BoundaryDiscretizeGraphics[g, PlotRange -> {{-1, 1}, {-1, 1}, {-1, 0}}]g = Graphics[{Disk[], HalfPlane[{{1, 0}, {2, 1}}, {1, -1}]}];Table[BoundaryDiscretizeGraphics[g, PlotRange -> pr], {pr, {All, Automatic, Full}}]PlotTheme (2)
Use a theme with grid lines and a legend:
BoundaryDiscretizeGraphics[Graphics[{Parallelogram[{0, 0}, {{1, 1}, {1, 0}}]}], PlotTheme -> "Detailed"]Use a theme to draw a wireframe:
BoundaryDiscretizeGraphics[Graphics[{Parallelogram[{0, 0}, {{1, 1}, {1, 0}}]}], PlotTheme -> "Lines"]Applications (3)
Compute the volume of a graphic by converting it to a geometric region:
p = PolyhedronData["Dodecahedron", "Polyhedron"];ℛ = BoundaryDiscretizeGraphics[p]Volume[ℛ]Convert Text to a geometric region:
t = Text[Style["π", Bold]]BoundaryDiscretizeGraphics[t, _Text, MaxCellMeasure -> 0.1]Convert a country polygon to a geometric region:
BoundaryDiscretizeGraphics[CountryData["USA", {"Polygon", "Mercator"}]]Properties & Relations (9)
Multiple primitives are interpreted as a union:
g = Graphics[{Disk[], Triangle[{{1.3, -1}, {3.3, 0}, {1.3, 1}}], Rectangle[{0.7, -0.5}]}]BoundaryDiscretizeGraphics[g]Bounded linear primitives can be exactly discretized:
g = Graphics[{Triangle[], Rectangle[{0.5, 1}], Polygon[{{1, 0.5}, {3, -0.5}, {2, 0.5}, {3, 1.5}}]}]BoundaryDiscretizeGraphics[g]Unbounded linear primitives can only be represented within a finite range:
p = {HalfPlane[{{1, 0}, {2, 1}}, {1, -1}], ConicHullRegion[{{-1, 0}}, {{-1, -1}, {-1, 1}}]};g = Graphics[p, PlotRange -> {{-3, 3}, {-1.5, 1.5}}]BoundaryDiscretizeGraphics[g]Nonlinear primitives can only be approximately discretized:
g = Graphics[{Disk[{3, 0}, {6, 2}], Disk[{2, 0}, 5, {Pi / 4, 7Pi / 4}]}]BoundaryDiscretizeGraphics[g]Use DiscretizeGraphics to get a MeshRegion representation:
g = Graphics[{Brown, Disk[{1.5, 1}], Orange, Rectangle[]}]{br, mr} = {BoundaryDiscretizeGraphics[g], DiscretizeGraphics[g]}{BoundaryMeshRegionQ[br], MeshRegionQ[mr]}BoundaryDiscretizeRegion can be used to discretize any RegionQ object:
BoundaryDiscretizeRegion[ImplicitRegion[x ^ 2 - y ^ 2 ≤ 1, {{x, -2, 2}, {y, -2, 2}}]]BoundaryDiscretizeGraphics can be used to discretize Graphics and Graphics3D objects:
BoundaryDiscretizeGraphics[Graphics[{Parallelogram[], Disk[{2, 2}]}]]They can both discretize special regions that are also graphics primitives:
{BoundaryDiscretizeRegion[Disk[]], BoundaryDiscretizeGraphics[Disk[]]}Graphics primitives that are also geometric regions can be used without discretization:
r = Disk[{0, 0}, 1];RegionQ[r]Compute directly with the region:
Area[r]Or with its discretized version:
Area[BoundaryDiscretizeGraphics[r]]Rasterize discretizes any rendered expression to Graphics containing a Raster object:
g = Graphics[{Disk[{0, 0}], Circle[{1, 0}]}]Rasterize[g, RasterSize -> {30, 20}, ImageSize -> 100]Image discretizes any rendered expression to an Image object:
g = Graphics[{Disk[{0, 0}], Circle[{1, 0}]}]Image[g, ImageSize -> {30, 20}, Magnification -> 4]Possible Issues (1)
Primitives with Offset coordinates are not discretized:
g = Graphics[{Disk[{1, 1 / 2}, Offset[{10, 40}]], Triangle[]}, Frame -> True]BoundaryDiscretizeGraphics[g]Related Guides
Text
Wolfram Research (2014), BoundaryDiscretizeGraphics, Wolfram Language function, https://reference.wolfram.com/language/ref/BoundaryDiscretizeGraphics.html (updated 2015).
CMS
Wolfram Language. 2014. "BoundaryDiscretizeGraphics." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/BoundaryDiscretizeGraphics.html.
APA
Wolfram Language. (2014). BoundaryDiscretizeGraphics. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BoundaryDiscretizeGraphics.html
BibTeX
@misc{reference.wolfram_2026_boundarydiscretizegraphics, author="Wolfram Research", title="{BoundaryDiscretizeGraphics}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/BoundaryDiscretizeGraphics.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_boundarydiscretizegraphics, organization={Wolfram Research}, title={BoundaryDiscretizeGraphics}, year={2015}, url={https://reference.wolfram.com/language/ref/BoundaryDiscretizeGraphics.html}, note=[Accessed: 13-June-2026]}