g/s/surface: test first poisson candidate against AcceptT

This commit is contained in:
Danny Robson 2020-10-27 15:31:09 +10:00
parent 98d8bd4c8e
commit b2abc7e7f8

View File

@ -55,7 +55,7 @@ namespace cruft::geom::sample {
GeneratorT &&gen,
AcceptT &&accept,
DistanceT &&minimum_distance,
std::size_t candidates_count
std::size_t const candidates_count
) {
using point_type = decltype (sampler.eval (gen));
using value_type = typename point_type::value_type;
@ -63,9 +63,20 @@ namespace cruft::geom::sample {
std::vector<point_type> selected;
std::vector<point_type> candidates;
// prime the found elements list with an initial point we can
// perform distance calculations on
selected.push_back (sampler.eval (gen));
// Prime the found elements list with an initial point we can
// perform distance calculations on.
for (std::size_t i = 0; i < candidates_count; ++i) {
auto const p = sampler.eval (gen);
if (!accept (p))
continue;
selected.push_back (sampler.eval (gen));
break;
}
// We couldn't find an initial candidate so abort.
if (selected.empty ())
return selected;
// keep trying to add one more new point
while (1) {