mirror of https://github.com/CGAL/cgal
Merge pull request #5444 from sgiraudot/Poisson-Kernel_compatibility-GF
[Poisson Reconstruction] Compatibility with Simple Cartesian
This commit is contained in:
commit
3407e3d693
|
|
@ -61,6 +61,17 @@ struct NT_converter < NT1, double >
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template < class NT1 >
|
||||||
|
struct NT_converter < NT1, float >
|
||||||
|
: public CGAL::cpp98::unary_function< NT1, float >
|
||||||
|
{
|
||||||
|
float
|
||||||
|
operator()(const NT1 &a) const
|
||||||
|
{
|
||||||
|
return static_cast<float>(to_double(a));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct NT_converter < double, double >
|
struct NT_converter < double, double >
|
||||||
: public CGAL::cpp98::unary_function< double, double >
|
: public CGAL::cpp98::unary_function< double, double >
|
||||||
|
|
@ -72,6 +83,17 @@ struct NT_converter < double, double >
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct NT_converter < float, float >
|
||||||
|
: public CGAL::cpp98::unary_function< float, float >
|
||||||
|
{
|
||||||
|
const float &
|
||||||
|
operator()(const float &a) const
|
||||||
|
{
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template < class NT1, bool b >
|
template < class NT1, bool b >
|
||||||
struct NT_converter < NT1, Interval_nt<b> >
|
struct NT_converter < NT1, Interval_nt<b> >
|
||||||
: public CGAL::cpp98::unary_function< NT1, Interval_nt<b> >
|
: public CGAL::cpp98::unary_function< NT1, Interval_nt<b> >
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ compute_average_spacing(const typename NeighborQuery::Kernel::Point_3& query, //
|
||||||
boost::make_function_output_iterator
|
boost::make_function_output_iterator
|
||||||
([&](const Point& p)
|
([&](const Point& p)
|
||||||
{
|
{
|
||||||
sum_distances += std::sqrt(CGAL::squared_distance (query,p));
|
sum_distances += CGAL::approximate_sqrt(CGAL::squared_distance (query,p));
|
||||||
++ i;
|
++ i;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,16 @@ namespace Poisson {
|
||||||
|
|
||||||
template <class Tr>
|
template <class Tr>
|
||||||
class Constant_sizing_field {
|
class Constant_sizing_field {
|
||||||
double sq_radius_bound;
|
typedef typename Tr::FT FT;
|
||||||
|
FT sq_radius_bound;
|
||||||
public:
|
public:
|
||||||
double cell_radius_bound() const { return CGAL::sqrt(sq_radius_bound); }
|
FT cell_radius_bound() const { return CGAL::approximate_sqrt(sq_radius_bound); }
|
||||||
|
|
||||||
Constant_sizing_field(double sq_radius_bound = 0.)
|
Constant_sizing_field(FT sq_radius_bound = 0.)
|
||||||
: sq_radius_bound(sq_radius_bound) {}
|
: sq_radius_bound(sq_radius_bound) {}
|
||||||
|
|
||||||
template <typename Point>
|
template <typename Point>
|
||||||
double operator()(const Point&) const { return sq_radius_bound; }
|
FT operator()(const Point&) const { return sq_radius_bound; }
|
||||||
}; // end class Constant_sizing_field
|
}; // end class Constant_sizing_field
|
||||||
|
|
||||||
} // end namespace Poisson
|
} // end namespace Poisson
|
||||||
|
|
|
||||||
|
|
@ -110,18 +110,19 @@ struct Poisson_visitor {
|
||||||
// The wrapper stores only pointers to the two functors.
|
// The wrapper stores only pointers to the two functors.
|
||||||
template <typename F1, typename F2>
|
template <typename F1, typename F2>
|
||||||
struct Special_wrapper_of_two_functions_keep_pointers {
|
struct Special_wrapper_of_two_functions_keep_pointers {
|
||||||
|
typedef typename F2::FT FT;
|
||||||
F1 *f1;
|
F1 *f1;
|
||||||
F2 *f2;
|
F2 *f2;
|
||||||
Special_wrapper_of_two_functions_keep_pointers(F1* f1, F2* f2)
|
Special_wrapper_of_two_functions_keep_pointers(F1* f1, F2* f2)
|
||||||
: f1(f1), f2(f2) {}
|
: f1(f1), f2(f2) {}
|
||||||
|
|
||||||
template <typename X>
|
template <typename X>
|
||||||
double operator()(const X& x) const {
|
FT operator()(const X& x) const {
|
||||||
return (std::max)((*f1)(x), CGAL::square((*f2)(x)));
|
return (std::max)((*f1)(x), CGAL::square((*f2)(x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename X>
|
template <typename X>
|
||||||
double operator()(const X& x) {
|
FT operator()(const X& x) {
|
||||||
return (std::max)((*f1)(x), CGAL::square((*f2)(x)));
|
return (std::max)((*f1)(x), CGAL::square((*f2)(x)));
|
||||||
}
|
}
|
||||||
}; // end struct Special_wrapper_of_two_functions_keep_pointers<F1, F2>
|
}; // end struct Special_wrapper_of_two_functions_keep_pointers<F1, F2>
|
||||||
|
|
@ -211,7 +212,7 @@ private:
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::atomic<Cache_state> m_state;
|
std::atomic<Cache_state> m_state;
|
||||||
std::array<double, 9> m_bary;
|
std::array<FT, 9> m_bary;
|
||||||
public:
|
public:
|
||||||
Cached_bary_coord() : m_state (UNINITIALIZED) { }
|
Cached_bary_coord() : m_state (UNINITIALIZED) { }
|
||||||
|
|
||||||
|
|
@ -242,8 +243,8 @@ private:
|
||||||
|
|
||||||
void set_initialized() { m_state = INITIALIZED; }
|
void set_initialized() { m_state = INITIALIZED; }
|
||||||
|
|
||||||
const double& operator[] (const std::size_t& idx) const { return m_bary[idx]; }
|
const FT& operator[] (const std::size_t& idx) const { return m_bary[idx]; }
|
||||||
double& operator[] (const std::size_t& idx) { return m_bary[idx]; }
|
FT& operator[] (const std::size_t& idx) { return m_bary[idx]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wrapper for thread safety of maintained cell hint for fast
|
// Wrapper for thread safety of maintained cell hint for fast
|
||||||
|
|
|
||||||
|
|
@ -94,9 +94,10 @@ namespace CGAL {
|
||||||
typedef typename boost::property_traits<PointMap>::value_type Point;
|
typedef typename boost::property_traits<PointMap>::value_type Point;
|
||||||
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
typedef typename Kernel_traits<Point>::Kernel Kernel;
|
||||||
typedef typename Kernel::Sphere_3 Sphere;
|
typedef typename Kernel::Sphere_3 Sphere;
|
||||||
|
typedef typename Kernel::FT FT;
|
||||||
|
|
||||||
typedef CGAL::Poisson_reconstruction_function<Kernel> Poisson_reconstruction_function;
|
typedef CGAL::Poisson_reconstruction_function<Kernel> Poisson_reconstruction_function;
|
||||||
typedef CGAL::Surface_mesh_default_triangulation_3 STr;
|
typedef typename CGAL::Surface_mesher::Surface_mesh_default_triangulation_3_generator<Kernel>::Type STr;
|
||||||
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
|
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
|
||||||
typedef CGAL::Implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;
|
typedef CGAL::Implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;
|
||||||
|
|
||||||
|
|
@ -106,10 +107,10 @@ namespace CGAL {
|
||||||
|
|
||||||
Point inner_point = function.get_inner_point();
|
Point inner_point = function.get_inner_point();
|
||||||
Sphere bsphere = function.bounding_sphere();
|
Sphere bsphere = function.bounding_sphere();
|
||||||
double radius = std::sqrt(bsphere.squared_radius());
|
FT radius = CGAL::approximate_sqrt(bsphere.squared_radius());
|
||||||
|
|
||||||
double sm_sphere_radius = 5.0 * radius;
|
FT sm_sphere_radius = 5.0 * radius;
|
||||||
double sm_dichotomy_error = sm_distance * spacing / 1000.0;
|
FT sm_dichotomy_error = sm_distance * spacing / 1000.0;
|
||||||
|
|
||||||
Surface_3 surface(function,
|
Surface_3 surface(function,
|
||||||
Sphere (inner_point, sm_sphere_radius * sm_sphere_radius),
|
Sphere (inner_point, sm_sphere_radius * sm_sphere_radius),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue