diff --git a/CMakeLists.txt b/CMakeLists.txt index 6264d529..8abd6090 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -451,7 +451,7 @@ target_link_libraries(cruft-util dl) ############################################################################### -foreach (tool cpuid json-clean json-schema json-validate macro scratch) +foreach (tool cpuid json-clean json-schema json-validate poisson macro scratch) add_executable (util_${tool} tools/${tool}.cpp) set_target_properties (util_${tool} PROPERTIES OUTPUT_NAME ${tool}) target_link_libraries (util_${tool} cruft-util) diff --git a/tools/poisson.cpp b/tools/poisson.cpp new file mode 100644 index 00000000..c3dc882a --- /dev/null +++ b/tools/poisson.cpp @@ -0,0 +1,30 @@ +#include "cmdopt.hpp" +#include "geom/sample.hpp" + +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +int +main (int argc, char **argv) +{ + util::extent2i area {256, 256}; + float distance = 5.f; + int samples = 15; + + util::cmdopt::parser opts; + opts.add> ('w', "width", "width of the space to fill", area.w); + opts.add> ('h', "height", "height of the space to fill", area.h); + opts.add> ('d', "distance", "minimum distance between samples", distance); + opts.add> ('s', "samples", "number of samples per iteration", samples); + + opts.scan (argc, argv); + + + std::cout << ""; + for (auto p: util::geom::poisson_sample (area, distance, samples)) + std::cout << ""; + std::cout << ""; + + return EXIT_SUCCESS; +}