Skip to content

Commit 3407e3d

Browse files
committed
Merge pull request #5444 from sgiraudot/Poisson-Kernel_compatibility-GF
[Poisson Reconstruction] Compatibility with Simple Cartesian
2 parents ea05d96 + 848aa7d commit 3407e3d

File tree

5 files changed

+39
-14
lines changed

5 files changed

+39
-14
lines changed

Number_types/include/CGAL/NT_converter.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ struct NT_converter < NT1, double >
6161
}
6262
};
6363

64+
template < class NT1 >
65+
struct NT_converter < NT1, float >
66+
: public CGAL::cpp98::unary_function< NT1, float >
67+
{
68+
float
69+
operator()(const NT1 &a) const
70+
{
71+
return static_cast<float>(to_double(a));
72+
}
73+
};
74+
6475
template <>
6576
struct NT_converter < double, double >
6677
: public CGAL::cpp98::unary_function< double, double >
@@ -72,6 +83,17 @@ struct NT_converter < double, double >
7283
}
7384
};
7485

86+
template <>
87+
struct NT_converter < float, float >
88+
: public CGAL::cpp98::unary_function< float, float >
89+
{
90+
const float &
91+
operator()(const float &a) const
92+
{
93+
return a;
94+
}
95+
};
96+
7597
template < class NT1, bool b >
7698
struct NT_converter < NT1, Interval_nt<b> >
7799
: public CGAL::cpp98::unary_function< NT1, Interval_nt<b> >

Point_set_processing_3/include/CGAL/compute_average_spacing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ compute_average_spacing(const typename NeighborQuery::Kernel::Point_3& query, //
8181
boost::make_function_output_iterator
8282
([&](const Point& p)
8383
{
84-
sum_distances += std::sqrt(CGAL::squared_distance (query,p));
84+
sum_distances += CGAL::approximate_sqrt(CGAL::squared_distance (query,p));
8585
++ i;
8686
}));
8787

Poisson_surface_reconstruction_3/include/CGAL/Poisson_mesh_cell_criteria_3.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@ namespace Poisson {
2727

2828
template <class Tr>
2929
class Constant_sizing_field {
30-
double sq_radius_bound;
30+
typedef typename Tr::FT FT;
31+
FT sq_radius_bound;
3132
public:
32-
double cell_radius_bound() const { return CGAL::sqrt(sq_radius_bound); }
33+
FT cell_radius_bound() const { return CGAL::approximate_sqrt(sq_radius_bound); }
3334

34-
Constant_sizing_field(double sq_radius_bound = 0.)
35+
Constant_sizing_field(FT sq_radius_bound = 0.)
3536
: sq_radius_bound(sq_radius_bound) {}
3637

3738
template <typename Point>
38-
double operator()(const Point&) const { return sq_radius_bound; }
39+
FT operator()(const Point&) const { return sq_radius_bound; }
3940
}; // end class Constant_sizing_field
4041

4142
} // end namespace Poisson

Poisson_surface_reconstruction_3/include/CGAL/Poisson_reconstruction_function.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,19 @@ struct Poisson_visitor {
110110
// The wrapper stores only pointers to the two functors.
111111
template <typename F1, typename F2>
112112
struct Special_wrapper_of_two_functions_keep_pointers {
113+
typedef typename F2::FT FT;
113114
F1 *f1;
114115
F2 *f2;
115116
Special_wrapper_of_two_functions_keep_pointers(F1* f1, F2* f2)
116117
: f1(f1), f2(f2) {}
117118

118119
template <typename X>
119-
double operator()(const X& x) const {
120+
FT operator()(const X& x) const {
120121
return (std::max)((*f1)(x), CGAL::square((*f2)(x)));
121122
}
122123

123124
template <typename X>
124-
double operator()(const X& x) {
125+
FT operator()(const X& x) {
125126
return (std::max)((*f1)(x), CGAL::square((*f2)(x)));
126127
}
127128
}; // end struct Special_wrapper_of_two_functions_keep_pointers<F1, F2>
@@ -211,7 +212,7 @@ class Poisson_reconstruction_function
211212
{
212213
private:
213214
std::atomic<Cache_state> m_state;
214-
std::array<double, 9> m_bary;
215+
std::array<FT, 9> m_bary;
215216
public:
216217
Cached_bary_coord() : m_state (UNINITIALIZED) { }
217218

@@ -242,8 +243,8 @@ class Poisson_reconstruction_function
242243

243244
void set_initialized() { m_state = INITIALIZED; }
244245

245-
const double& operator[] (const std::size_t& idx) const { return m_bary[idx]; }
246-
double& operator[] (const std::size_t& idx) { return m_bary[idx]; }
246+
const FT& operator[] (const std::size_t& idx) const { return m_bary[idx]; }
247+
FT& operator[] (const std::size_t& idx) { return m_bary[idx]; }
247248
};
248249

249250
// Wrapper for thread safety of maintained cell hint for fast

Poisson_surface_reconstruction_3/include/CGAL/poisson_surface_reconstruction.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ namespace CGAL {
9494
typedef typename boost::property_traits<PointMap>::value_type Point;
9595
typedef typename Kernel_traits<Point>::Kernel Kernel;
9696
typedef typename Kernel::Sphere_3 Sphere;
97+
typedef typename Kernel::FT FT;
9798

9899
typedef CGAL::Poisson_reconstruction_function<Kernel> Poisson_reconstruction_function;
99-
typedef CGAL::Surface_mesh_default_triangulation_3 STr;
100+
typedef typename CGAL::Surface_mesher::Surface_mesh_default_triangulation_3_generator<Kernel>::Type STr;
100101
typedef CGAL::Surface_mesh_complex_2_in_triangulation_3<STr> C2t3;
101102
typedef CGAL::Implicit_surface_3<Kernel, Poisson_reconstruction_function> Surface_3;
102103

@@ -106,10 +107,10 @@ namespace CGAL {
106107

107108
Point inner_point = function.get_inner_point();
108109
Sphere bsphere = function.bounding_sphere();
109-
double radius = std::sqrt(bsphere.squared_radius());
110+
FT radius = CGAL::approximate_sqrt(bsphere.squared_radius());
110111

111-
double sm_sphere_radius = 5.0 * radius;
112-
double sm_dichotomy_error = sm_distance * spacing / 1000.0;
112+
FT sm_sphere_radius = 5.0 * radius;
113+
FT sm_dichotomy_error = sm_distance * spacing / 1000.0;
113114

114115
Surface_3 surface(function,
115116
Sphere (inner_point, sm_sphere_radius * sm_sphere_radius),

0 commit comments

Comments
 (0)