2018-04-19 13:49:55 +10:00
|
|
|
#include "cmdopt.hpp"
|
2018-04-27 16:33:18 +10:00
|
|
|
#include "functor.hpp"
|
2018-04-26 17:44:16 +10:00
|
|
|
#include "geom/aabb.hpp"
|
2018-11-26 14:08:50 +11:00
|
|
|
#include "geom/sample/surface.hpp"
|
2018-04-19 13:49:55 +10:00
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <iostream>
|
2018-04-26 17:44:16 +10:00
|
|
|
#include <random>
|
|
|
|
|
|
|
|
|
2018-04-19 13:49:55 +10:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::extent2f area {256, 256};
|
2018-04-19 13:49:55 +10:00
|
|
|
float distance = 5.f;
|
|
|
|
int samples = 15;
|
|
|
|
|
2018-08-05 14:42:02 +10:00
|
|
|
cruft::cmdopt::parser opts;
|
|
|
|
opts.add<cruft::cmdopt::option::value<float>> ('w', "width", "width of the space to fill", area.w);
|
|
|
|
opts.add<cruft::cmdopt::option::value<float>> ('h', "height", "height of the space to fill", area.h);
|
|
|
|
opts.add<cruft::cmdopt::option::value<float>> ('d', "distance", "minimum distance between samples", distance);
|
|
|
|
opts.add<cruft::cmdopt::option::value<int>> ('s', "samples", "number of samples per iteration", samples);
|
2018-04-19 13:49:55 +10:00
|
|
|
|
|
|
|
opts.scan (argc, argv);
|
|
|
|
|
|
|
|
std::cout << "<svg height='" << area.h << "' width='" << area.h << "'>";
|
2018-11-26 14:08:50 +11:00
|
|
|
namespace sample = cruft::geom::sample;
|
|
|
|
for (auto const &p: sample::poisson (sample::surface {area},
|
|
|
|
std::default_random_engine (),
|
|
|
|
cruft::functor::constant (distance),
|
|
|
|
samples))
|
2018-04-26 17:44:16 +10:00
|
|
|
{
|
2018-04-19 13:49:55 +10:00
|
|
|
std::cout << "<circle cx='" << p.x << "' cy='" << p.y << "' r='1' />";
|
2018-04-26 17:44:16 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "</svg>\n";
|
2018-04-19 13:49:55 +10:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|