mirror of https://github.com/CGAL/cgal
Fix iterator determinism in Poisson
This commit is contained in:
parent
6ae64e7a73
commit
0409e2b48d
|
|
@ -47,6 +47,7 @@
|
|||
#include <boost/array.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/iterator/indirect_iterator.hpp>
|
||||
|
||||
/*!
|
||||
\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 <typename Iterator>
|
||||
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,9 +404,15 @@ public:
|
|||
// then the cell is considered as small enough, and the first sizing
|
||||
// field, more costly, is not evaluated.
|
||||
|
||||
typedef Filter_iterator<typename Triangulation::Input_point_iterator,
|
||||
Poisson_skip_vertices> Some_points_iterator;
|
||||
Poisson_skip_vertices skip(1.-approximation_ratio);
|
||||
//make it deterministic
|
||||
Random random(0);
|
||||
double ratio = 1.-approximation_ratio;
|
||||
|
||||
std::vector<typename Triangulation::Input_point_iterator> 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;
|
||||
|
|
@ -425,11 +420,8 @@ public:
|
|||
|
||||
CGAL::Timer sizing_field_timer; sizing_field_timer.start();
|
||||
Poisson_reconstruction_function<Geom_traits>
|
||||
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<Geom_traits>() );
|
||||
coarse_poisson_function.compute_implicit_function(solver, Poisson_visitor(),
|
||||
0.);
|
||||
|
|
|
|||
Loading…
Reference in New Issue