-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cpp
52 lines (42 loc) · 1.34 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
////////////////////////////////////////////////////////////////////////////////
#include "poisson_disk.hpp"
#include "vec.h"
#include "chrono.h"
// -----------------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <vector>
////////////////////////////////////////////////////////////////////////////////
typedef PoissonSampling<double, 3> Sampler3D;
void write_samples(const std::vector<Vec3d> &pts, std::ostream &out) {
out << pts.size() << std::endl;
for (Vec3d x : pts) {
out << x[0] << " " << x[1] << " " << x[2] << std::endl;
}
out << std::endl;
}
int main(int argc, char** argv) {
if (argc < 3) {
std::cout << "Usage: " << argv[0] << " min_dist out_file" << std::endl;
return 0;
}
Chrono timer("Timer");
Vec3d unit_box = Vec::constant<double, 3>(1);
double min_dist = std::stod(argv[1]);
std::cout << "- Initialization..." << std::endl;
Sampler3D sampler(min_dist, unit_box);
std::cout << "- Sampling (Naive)..." << std::endl;
std::vector<Vec3d> result_naive;
timer.tic();
sampler.naive(result_naive);
timer.toc();
std::cout << "- Sampling (Bridson)..." << std::endl;
std::vector<Vec3d> result;
timer.tic();
sampler.box(30, result);
timer.toc();
std::cout << "- Saving result..." << std::endl;
std::ofstream fout(argv[2]);
write_samples(result, fout);
return 0;
}