NetDEM v1.0
Loading...
Searching...
No Matches
wscvt_sampler.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "mini_map.hpp"
5#include "utils_math.hpp"
6
7namespace netdem {
8
18public:
23 int max_iters{10000};
24
28 double tol{1.0e-4};
29
33 WSCVTSampler(const WSCVTSampler &) = delete;
34
39
49 static WSCVTSampler instance;
50 return instance;
51 }
52
66 VecXT<Vec3d> Get(int num_samples, bool new_random = false) {
67 VecXT<Vec3d> samples;
68 if (new_random) {
69 samples = Create(num_samples);
70 if (samples_map.find(num_samples) == samples_map.end()) {
71 samples_map[num_samples] = samples;
72 }
73 } else {
74 if (samples_map.find(num_samples) == samples_map.end()) {
75 samples = Create(num_samples);
76 samples_map[num_samples] = samples;
77 } else {
78 samples = samples_map[num_samples];
79 }
80 }
81 return samples;
82 }
83
84private:
91 WSCVTSampler() {}
92
99 MiniMap<int, VecXT<Vec3d>> samples_map;
100
111 VecXT<Vec3d> Create(int num_samples) {
112 return SphericalVoronoi::Solve(num_samples, max_iters, tol);
113 }
114};
115
116} // namespace netdem
const Pair< T_key, T_val > * find(const T_key &key) const
Definition mini_map.hpp:37
const Pair< T_key, T_val > * end() const
Definition mini_map.hpp:23
static std::tuple< VecXT< Vec3d >, VecXT< VecXT< int > > > Solve(VecXT< Vec3d > const &vt_seeds)
Compute the Voronoi diagram for a set of seeds with uniform weights.
Definition spherical_voronoi.cpp:16
A class for generating samples from a weighted spherical centroidal Voronoi tessellation.
Definition wscvt_sampler.hpp:17
static WSCVTSampler & GetInstance()
Get a reference to the singleton WSCVTSampler instance.
Definition wscvt_sampler.hpp:48
VecXT< Vec3d > Get(int num_samples, bool new_random=false)
Generate a specified number of sample points.
Definition wscvt_sampler.hpp:66
int max_iters
The maximum number of iterations to perform during tessellation (default: 10000).
Definition wscvt_sampler.hpp:23
double tol
The convergence tolerance for tessellation (default: 1.0e-4).
Definition wscvt_sampler.hpp:28
WSCVTSampler(const WSCVTSampler &)=delete
Delete copy constructor.
WSCVTSampler & operator=(const WSCVTSampler &)=delete
Delete copy assignment operator.
Definition bond_entry.hpp:7
std::vector< T > VecXT
Definition utils_macros.hpp:31