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/array.hpp>
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
|
#include <boost/iterator/indirect_iterator.hpp>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\file Poisson_reconstruction_function.h
|
\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
|
// Given f1 and f2, two sizing fields, that functor wrapper returns
|
||||||
// max(f1, f2*f2)
|
// max(f1, f2*f2)
|
||||||
// The wrapper stores only pointers to the two functors.
|
// 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
|
// then the cell is considered as small enough, and the first sizing
|
||||||
// field, more costly, is not evaluated.
|
// field, more costly, is not evaluated.
|
||||||
|
|
||||||
typedef Filter_iterator<typename Triangulation::Input_point_iterator,
|
//make it deterministic
|
||||||
Poisson_skip_vertices> Some_points_iterator;
|
Random random(0);
|
||||||
Poisson_skip_vertices skip(1.-approximation_ratio);
|
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: "
|
CGAL_TRACE_STREAM << "SPECIAL PASS that uses an approximation of the result (approximation ratio: "
|
||||||
<< approximation_ratio << ")" << std::endl;
|
<< approximation_ratio << ")" << std::endl;
|
||||||
CGAL::Timer approximation_timer; approximation_timer.start();
|
CGAL::Timer approximation_timer; approximation_timer.start();
|
||||||
|
|
||||||
CGAL::Timer sizing_field_timer; sizing_field_timer.start();
|
CGAL::Timer sizing_field_timer; sizing_field_timer.start();
|
||||||
Poisson_reconstruction_function<Geom_traits>
|
Poisson_reconstruction_function<Geom_traits>
|
||||||
coarse_poisson_function(Some_points_iterator(m_tr->input_points_end(),
|
coarse_poisson_function(boost::make_indirect_iterator (some_points.begin()),
|
||||||
skip,
|
boost::make_indirect_iterator (some_points.end()),
|
||||||
m_tr->input_points_begin()),
|
|
||||||
Some_points_iterator(m_tr->input_points_end(),
|
|
||||||
skip),
|
|
||||||
Normal_of_point_with_normal_map<Geom_traits>() );
|
Normal_of_point_with_normal_map<Geom_traits>() );
|
||||||
coarse_poisson_function.compute_implicit_function(solver, Poisson_visitor(),
|
coarse_poisson_function.compute_implicit_function(solver, Poisson_visitor(),
|
||||||
0.);
|
0.);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue