Hi, I’m new to Julia and wondering how to loop through the generated voronoi cells to implement the MLBG algorithm.
using GLMakie
using DelaunayTriangulation
using Interpolations
using Plots
function perform_computations(axis, time_range, mean_data, std_data, mean_color, fig)
# band!(time_range, mean_data - std_data, mean_data + std_data, color=GLMakie.RGBA(mean_color, 0.6), label="Error")
lines!(axis, time_range, mean_data, color=GLMakie.RGBA(mean_color, 1.0), label="Mean")
# xlims!(axis, [0, 50])
time_range_dense = range(1, stop=length(time_range), length=length(time_range) * 20)
itp_mean = interpolate((time_range,), mean_data, Gridded(Linear()))
itp_lower = interpolate((time_range,), mean_data - std_data, Gridded(Linear()))
itp_upper = interpolate((time_range,), mean_data + std_data, Gridded(Linear()))
plot_ys_mean = [itp_mean(t) for t in time_range_dense]
plot_ys_lower = [itp_lower(t) for t in time_range_dense]
plot_ys_upper = [itp_upper(t) for t in time_range_dense]
ax = Axis(fig[1, 2])
GLMakie.scatter!(axis, time_range_dense, plot_ys_mean, color=:blue, label="Interpolation", markersize=3)
error_ranges = plot_ys_upper .- plot_ys_lower
tri = DelaunayTriangulation.triangulate(points; rng)
vorn = voronoi(tri)
end
end
I need to loop through each of voronoi cells check if the density is lesser and update
stippleList ← initialize stipple list repeat
vd ← computeVoronoiDiagram(stippleList) newStippleList ← empty list
for all Voronoi cell vc ∈ vd do
density ← vc.sumDensity if density < Tl then
// remove point
else if density < Tu then
// keep point
newStippleList.add(vc.centroid)
else
// split point
splitPoints ← splitCell(vc) newStippleList.add(splitPoints)
end if end for
stippleList ← newStippleList until no splitting or merging
endfunction
Can anyone help me with this