commit 026453ac365e0acd332634c91088f60639517aec
parent 718e4f5ed4e304281c1af295e803b8261fdc7a0a
Author: Anders Damsgaard <andersd@riseup.net>
Date: Thu, 21 Dec 2017 07:51:26 -0500
Add argument to choose if output plots are generated or not
Diffstat:
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/packing.jl b/src/packing.jl
@@ -84,6 +84,9 @@ end
export irregularPacking!
"""
+ irregularPacking!(simulation[, radius_max, radius_min, sample_limit,
+ thickness, seed, plot_during_packing, verbose)
+
Generate a dense disc packing in 2D using Poisson disc sampling with O(N)
complexity, as described by [Robert Bridson (2007) "Fast Poisson disk sampling
in arbitrary dimensions"](https://doi.org/10.1145/1278780.1278807). The
@@ -97,6 +100,8 @@ in arbitrary dimensions"](https://doi.org/10.1145/1278780.1278807). The
* `sample_limit::Integer=30`: number of points to sample around each grain
before giving up.
* `seed::Integer`: seed value to the pseudo-random number generator.
+* `plot_during_packing::Bool=false`: produce successive plots as the packing is
+ generated. Requires gnuplot (default).
* `verbose::Bool=true`: show diagnostic information to stdout.
"""
function irregularPacking!(simulation::Simulation;
@@ -105,6 +110,7 @@ function irregularPacking!(simulation::Simulation;
sample_limit::Integer=30,
thickness::Real=1.,
seed::Integer=1,
+ plot_during_packing::Bool=false,
verbose::Bool=true)
srand(seed)
@@ -234,9 +240,12 @@ function irregularPacking!(simulation::Simulation;
deleteat!(active_list, i)
end
println("Active points: $(length(active_list))")
- n += 1
- filepostfix = @sprintf("packing.%05d.png", n)
- plotGrains(simulation, filetype=filepostfix, show_figure=false)
+
+ if plot_during_packing
+ n += 1
+ filepostfix = @sprintf("packing.%05d.png", n)
+ plotGrains(simulation, filetype=filepostfix, show_figure=false)
+ end
end
if verbose
info("Generated $(length(simulation.grains) - np_init) points")
diff --git a/test/packing.jl b/test/packing.jl
@@ -54,3 +54,11 @@ Granular.irregularPacking!(sim,
radius_max=.1,
radius_min=.001,
verbose=true)
+
+info("Testing irregular (Poisson-disk) packing generation (intermediate PSD)")
+sim = Granular.createSimulation("poisson3")
+sim.ocean = Granular.createRegularOceanGrid([1, 1, 1], [1., 1., 1.])
+Granular.irregularPacking!(sim,
+ radius_max=.1,
+ radius_min=.01,
+ verbose=true)