Refinement

TriRefinement

Meshes.TriRefinementType
TriRefinement([pred])

Refinement of polygonal meshes into triangles. A n-gon for which the predicate pred holds true is subdivided into n triangles. The method refines all n-gons if the pred is ommited.

source
grid = CartesianGrid(10, 10)

# refine three times
ref1 = refine(grid, TriRefinement())
ref2 = refine(ref1, TriRefinement())
ref3 = refine(ref2, TriRefinement())

fig = Mke.Figure(size = (800, 800))
viz(fig[1,1], grid, showsegments = true)
viz(fig[1,2], ref1, showsegments = true)
viz(fig[2,1], ref2, showsegments = true)
viz(fig[2,2], ref3, showsegments = true)
fig
Example block output

QuadRefinement

Meshes.QuadRefinementType
QuadRefinement()

Refinement of polygonal meshes into quadrangles. A n-gon is subdivided into n quadrangles.

source
grid = CartesianGrid(10, 10)

# refine three times
ref1 = refine(grid, QuadRefinement())
ref2 = refine(ref1, QuadRefinement())
ref3 = refine(ref2, QuadRefinement())

fig = Mke.Figure(size = (800, 800))
viz(fig[1,1], grid, showsegments = true)
viz(fig[1,2], ref1, showsegments = true)
viz(fig[2,1], ref2, showsegments = true)
viz(fig[2,2], ref3, showsegments = true)
fig
Example block output

RegularRefinement

Meshes.RegularRefinementType
RegularRefinement(f₁, f₂, ..., fₙ)

Refine each dimension of the grid by given factors f₁, f₂, ..., fₙ.

Examples

refine(grid2D, RegularRefinement(2, 3))
refine(grid3D, RegularRefinement(2, 3, 1))
source
grid = CartesianGrid(10, 10)

# refine three times
ref1 = refine(grid, RegularRefinement(2, 2))
ref2 = refine(ref1, RegularRefinement(3, 2))
ref3 = refine(ref2, RegularRefinement(2, 3))

fig = Mke.Figure(size = (800, 800))
viz(fig[1,1], grid, showsegments = true)
viz(fig[1,2], ref1, showsegments = true)
viz(fig[2,1], ref2, showsegments = true)
viz(fig[2,2], ref3, showsegments = true)
fig
Example block output

Catmull-Clark

# define a cube in R^3
points = [(0,0,0),(1,0,0),(1,1,0),(0,1,0),(0,0,1),(1,0,1),(1,1,1),(0,1,1)]
connec = connect.([(1,4,3,2),(5,6,7,8),(1,2,6,5),(3,4,8,7),(1,5,8,4),(2,3,7,6)])
mesh   = SimpleMesh(points, connec)

# refine three times
ref1 = refine(mesh, CatmullClarkRefinement())
ref2 = refine(ref1, CatmullClarkRefinement())
ref3 = refine(ref2, CatmullClarkRefinement())

fig = Mke.Figure(size = (800, 800))
viz(fig[1,1], mesh, showsegments = true)
viz(fig[1,2], ref1, showsegments = true)
viz(fig[2,1], ref2, showsegments = true)
viz(fig[2,2], ref3, showsegments = true)
fig
Example block output

TriSubdivision

grid = CartesianGrid(10, 10)

# refine three times
ref1 = refine(grid, TriSubdivision())
ref2 = refine(ref1, TriSubdivision())
ref3 = refine(ref2, TriSubdivision())

fig = Mke.Figure(size = (800, 800))
viz(fig[1,1], grid, showsegments = true)
viz(fig[1,2], ref1, showsegments = true)
viz(fig[2,1], ref2, showsegments = true)
viz(fig[2,2], ref3, showsegments = true)
fig
Example block output