From 0409e2b48dfdbcb9d73e87c95dc5fa2d1ad637a5 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 30 Mar 2020 15:47:45 +0200 Subject: [PATCH] Fix iterator determinism in Poisson --- .../CGAL/Poisson_reconstruction_function.h | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/Poisson_surface_reconstruction_3/include/CGAL/Poisson_reconstruction_function.h b/Poisson_surface_reconstruction_3/include/CGAL/Poisson_reconstruction_function.h index c92c70990a2..5f9e258fbdc 100644 --- a/Poisson_surface_reconstruction_3/include/CGAL/Poisson_reconstruction_function.h +++ b/Poisson_surface_reconstruction_3/include/CGAL/Poisson_reconstruction_function.h @@ -47,6 +47,7 @@ #include #include #include +#include /*! \file Poisson_reconstruction_function.h @@ -104,18 +105,6 @@ struct Poisson_visitor { {} }; -struct Poisson_skip_vertices { - double ratio; - Poisson_skip_vertices(const double ratio = 0) - : ratio(ratio) {} - - template - bool operator()(Iterator it) const { - // make the result deterministic for each iterator - return Random((std::size_t)(&*it)).get_double() < ratio; - } -}; - // Given f1 and f2, two sizing fields, that functor wrapper returns // max(f1, f2*f2) // The wrapper stores only pointers to the two functors. @@ -415,21 +404,24 @@ public: // then the cell is considered as small enough, and the first sizing // field, more costly, is not evaluated. - typedef Filter_iterator Some_points_iterator; - Poisson_skip_vertices skip(1.-approximation_ratio); + //make it deterministic + Random random(0); + double ratio = 1.-approximation_ratio; + std::vector some_points; + for (typename Triangulation::Input_point_iterator + it = m_tr->input_points_begin(); it != m_tr->input_points_end(); ++ it) + if (random.get_double() >= ratio) + some_points.push_back (it); + CGAL_TRACE_STREAM << "SPECIAL PASS that uses an approximation of the result (approximation ratio: " << approximation_ratio << ")" << std::endl; CGAL::Timer approximation_timer; approximation_timer.start(); CGAL::Timer sizing_field_timer; sizing_field_timer.start(); Poisson_reconstruction_function - coarse_poisson_function(Some_points_iterator(m_tr->input_points_end(), - skip, - m_tr->input_points_begin()), - Some_points_iterator(m_tr->input_points_end(), - skip), + coarse_poisson_function(boost::make_indirect_iterator (some_points.begin()), + boost::make_indirect_iterator (some_points.end()), Normal_of_point_with_normal_map() ); coarse_poisson_function.compute_implicit_function(solver, Poisson_visitor(), 0.);