Skip to content

Commit 80f1583

Browse files
MaelRLmaxGimeno
authored andcommitted
Minor doc improvements
1 parent fa83880 commit 80f1583

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

Surface_mesh_simplification/include/CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Bounded_distance_placement.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,23 @@
2424

2525
#include <boost/optional.hpp>
2626

27+
#include <vector>
28+
#include <type_traits>
29+
2730
namespace CGAL {
2831
namespace Surface_mesh_simplification {
2932

3033
// An AABB tree can also be passed to the placement instead, see undocumented specialization below
3134
template<typename BasePlacement, typename GeomTraits>
3235
class Bounded_distance_placement
3336
{
37+
typedef GeomTraits Geom_traits;
38+
typedef typename Geom_traits::FT FT;
39+
3440
typedef typename GeomTraits::Triangle_3 Triangle;
3541
typedef std::vector<Triangle> Triangle_container;
3642
typedef typename Triangle_container::iterator TC_iterator;
43+
3744
typedef CGAL::AABB_triangle_primitive<GeomTraits, TC_iterator> Primitive;
3845
typedef CGAL::AABB_traits<GeomTraits, Primitive> Traits;
3946
typedef CGAL::AABB_tree<Traits> AABB_tree;
@@ -42,8 +49,7 @@ class Bounded_distance_placement
4249
template <typename Profile>
4350
void initialize_tree(const Profile& profile) const
4451
{
45-
typedef typename Profile::Geom_traits Geom_traits;
46-
typedef typename Geom_traits::Triangle_3 Triangle;
52+
CGAL_static_assertion((std::is_same<GeomTraits, typename Profile::Geom_traits>::value));
4753

4854
typedef typename Profile::Triangle_mesh Triangle_mesh;
4955
typedef typename boost::graph_traits<Triangle_mesh>::halfedge_descriptor halfedge_descriptor;
@@ -71,7 +77,7 @@ class Bounded_distance_placement
7177
}
7278

7379
public:
74-
Bounded_distance_placement(const double dist,
80+
Bounded_distance_placement(const FT dist,
7581
const BasePlacement& placement = BasePlacement())
7682
:
7783
m_sq_threshold_dist(CGAL::square(dist)),
@@ -89,7 +95,6 @@ class Bounded_distance_placement
8995
boost::optional<typename Profile::Point>
9096
operator()(const Profile& profile) const
9197
{
92-
typedef typename Profile::Geom_traits Geom_traits;
9398
typedef typename Profile::Point Point;
9499

95100
boost::optional<typename Profile::Point> op = m_base_placement(profile);
@@ -123,7 +128,7 @@ class Bounded_distance_placement
123128
}
124129

125130
private:
126-
const double m_sq_threshold_dist;
131+
const FT m_sq_threshold_dist;
127132
mutable const AABB_tree* m_tree_ptr;
128133

129134
const BasePlacement m_base_placement;
@@ -133,10 +138,11 @@ class Bounded_distance_placement
133138
template<typename BasePlacement, typename AABBTraits>
134139
class Bounded_distance_placement<BasePlacement, CGAL::AABB_tree<AABBTraits> >
135140
{
136-
typedef CGAL::AABB_tree<AABBTraits> AABB_tree;
141+
typedef CGAL::AABB_tree<AABBTraits> AABB_tree;
142+
typedef typename AABB_tree::AABB_traits::FT FT;
137143

138144
public:
139-
Bounded_distance_placement(const double dist,
145+
Bounded_distance_placement(const FT dist,
140146
const AABB_tree& tree,
141147
const BasePlacement& placement = BasePlacement())
142148
:
@@ -174,7 +180,7 @@ class Bounded_distance_placement<BasePlacement, CGAL::AABB_tree<AABBTraits> >
174180
}
175181

176182
private:
177-
const double m_sq_threshold_dist;
183+
const FT m_sq_threshold_dist;
178184
mutable const AABB_tree* m_tree_ptr;
179185

180186
const BasePlacement m_base_placement;

Surface_mesh_simplification/test/Surface_mesh_simplification/test_edge_collapse_bounded_distance.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
namespace SMS = CGAL::Surface_mesh_simplification;
2323

2424
typedef CGAL::Simple_cartesian<double> Kernel;
25+
2526
typedef Kernel::Point_3 Point_3;
2627
typedef CGAL::Surface_mesh<Point_3> Surface;
2728

@@ -48,7 +49,7 @@ int main(int argc, char** argv)
4849

4950
Point_3 cmin = (bbox.min)();
5051
Point_3 cmax = (bbox.max)();
51-
const double diag = std::sqrt(CGAL::squared_distance(cmin, cmax));
52+
const double diag = CGAL::approximate_sqrt(CGAL::squared_distance(cmin, cmax));
5253

5354
Surface mesh_cpy = ref_mesh; // need a copy to keep the AABB tree valid
5455
Surface small_mesh = ref_mesh;

0 commit comments

Comments
 (0)