- massive fix of const-correctness in Surface_mesher, Mesh_3 and

Head_mesher.
  (A nice feature of C++ is that, when you need to add *one* const
   somewhere, then you have to fix const-correctness of all the World!)
This commit is contained in:
Laurent Rineau 2006-09-13 13:31:45 +00:00
parent a4093cb563
commit 66b7d8b7f9
14 changed files with 83 additions and 68 deletions

View File

@ -1,3 +1,9 @@
13 September 2006 Laurent Rineau
- massive fix of const-correctness in Surface_mesher, Mesh_3 and
Head_mesher.
(A nice feature of C++ is that, when you need to add *one* const
somewhere, then you have to fix const-correctness of all the World!)
12 July 2006 Laurent Rineau 12 July 2006 Laurent Rineau
- new class Volume_mesher_default_triangulation_3 - new class Volume_mesher_default_triangulation_3
- new test, of io operators. It uses Volume_mesher_default_triangulation_3. - new test, of io operators. It uses Volume_mesher_default_triangulation_3.

View File

@ -1,3 +1,9 @@
13 September 2006 Laurent Rineau
- massive fix of const-correctness in Surface_mesher, Mesh_3 and
Head_mesher.
(A nice feature of C++ is that, when you need to add *one* const
somewhere, then you have to fix const-correctness of all the World!)
10 August 2006 Laurent Rineau 10 August 2006 Laurent Rineau
- added a public member function - added a public member function
Bbox bbox() const; Bbox bbox() const;

View File

@ -28,21 +28,21 @@ namespace CGAL {
> >
class Multi_surface_3 class Multi_surface_3
{ {
Surface_a& surf_a; const Surface_a& surf_a;
Surface_b& surf_b; const Surface_b& surf_b;
public: public:
Multi_surface_3(Surface_a& surface_a, Surface_b& surface_b) Multi_surface_3(const Surface_a& surface_a, const Surface_b& surface_b)
: surf_a(surface_a), surf_b(surface_b) : surf_a(surface_a), surf_b(surface_b)
{ {
} }
Surface_a& surface_a() const Surface_a& surface_a() const
{ {
return surf_a; return surf_a;
} }
Surface_b& surface_b() const Surface_b& surface_b() const
{ {
return surf_b; return surf_b;
} }

View File

@ -54,7 +54,7 @@ public:
criteria.set_criteria(criterion_vector); criteria.set_criteria(criterion_vector);
} }
bool is_bad (const Facet& f, Quality& q) bool is_bad (const Facet& f, Quality& q) const
{ {
return criteria.is_bad(f, q); return criteria.is_bad(f, q);
} }

View File

@ -70,7 +70,7 @@ namespace CGAL {
{ {
} }
Object operator()(Surface_3& surface, Segment_3 s) const Object operator()(const Surface_3& surface, Segment_3 s) const
{ {
const Object obj = oracle_a.intersect_3_object()(surface.surface_a(), s); const Object obj = oracle_a.intersect_3_object()(surface.surface_a(), s);
if( obj.is_empty() ) if( obj.is_empty() )
@ -78,14 +78,14 @@ namespace CGAL {
return obj; return obj;
} }
Object operator()(Surface_3& surface, const Ray_3& r) const { Object operator()(const Surface_3& surface, const Ray_3& r) const {
const Object obj = oracle_a.intersect_3_object()(surface.surface_a(), r); const Object obj = oracle_a.intersect_3_object()(surface.surface_a(), r);
if( obj.is_empty() ) if( obj.is_empty() )
return oracle_b.intersect_3_object()(surface.surface_b(), r); return oracle_b.intersect_3_object()(surface.surface_b(), r);
return obj; return obj;
} }
Object operator()(Surface_3& surface, const Line_3& l) const { Object operator()(const Surface_3& surface, const Line_3& l) const {
const Object obj = oracle_a.intersect_3_object()(surface.surface_a(), l); const Object obj = oracle_a.intersect_3_object()(surface.surface_a(), l);
if( obj.is_empty() ) if( obj.is_empty() )
return oracle_b.intersect_3_object()(surface.surface_b(), l); return oracle_b.intersect_3_object()(surface.surface_b(), l);
@ -105,7 +105,7 @@ namespace CGAL {
// Random points // Random points
template <typename OutputIteratorPoints> template <typename OutputIteratorPoints>
OutputIteratorPoints operator() (Surface_3& surface, OutputIteratorPoints operator() (const Surface_3& surface,
OutputIteratorPoints out, OutputIteratorPoints out,
int n = 20) // WARNING: why 20? int n = 20) // WARNING: why 20?
{ {
@ -119,17 +119,17 @@ namespace CGAL {
} }
}; // end nested class Construct_initial_points }; // end nested class Construct_initial_points
Intersect_3 intersect_3_object() Intersect_3 intersect_3_object() const
{ {
return Intersect_3(oracle_a, oracle_b); return Intersect_3(oracle_a, oracle_b);
} }
Construct_initial_points construct_initial_points_object() Construct_initial_points construct_initial_points_object() const
{ {
return Construct_initial_points(oracle_a, oracle_b); return Construct_initial_points(oracle_a, oracle_b);
} }
bool is_in_volume(Surface_3& surface, const Point_3& p) bool is_in_volume(const Surface_3& surface, const Point_3& p) const
{ {
return( oracle_a.is_in_volume(surface.surface_a(), p) || return( oracle_a.is_in_volume(surface.surface_a(), p) ||
oracle_b.is_in_volume(surface.surface_b(), p) ); oracle_b.is_in_volume(surface.surface_b(), p) );

View File

@ -198,7 +198,7 @@ namespace CGAL {
// debug function // debug function
static std::string debug_point(const Surface_3& surface, static std::string debug_point(const Surface_3& surface,
const Point& p) const Point& p)
{ {
std::stringstream s; std::stringstream s;
s << p << " (distance=" s << p << " (distance="
@ -210,7 +210,7 @@ namespace CGAL {
} }
static CGAL::Sign surf_equation (Surface_3 surface, static CGAL::Sign surf_equation (Surface_3 surface,
const Point& p) const Point& p)
{ {
return CGAL::sign(surface(p)); return CGAL::sign(surface(p));
} // @TODO, @WARNING: we use x(), y() and z() } // @TODO, @WARNING: we use x(), y() and z()
@ -287,9 +287,9 @@ namespace CGAL {
class Construct_initial_points class Construct_initial_points
{ {
Self& oracle; const Self& oracle;
public: public:
Construct_initial_points(Self& oracle) : oracle(oracle) Construct_initial_points(const Self& oracle) : oracle(oracle)
{ {
} }
@ -356,17 +356,17 @@ namespace CGAL {
} }
}; // end nested class Construct_initial_points }; // end nested class Construct_initial_points
Construct_initial_points construct_initial_points_object() Construct_initial_points construct_initial_points_object() const
{ {
return Construct_initial_points(*this); return Construct_initial_points(*this);
} }
Intersect_3 intersect_3_object() Intersect_3 intersect_3_object() const
{ {
return Intersect_3(visitor); return Intersect_3(visitor);
} }
bool is_in_volume(const Surface_3& surface, const Point& p) bool is_in_volume(const Surface_3& surface, const Point& p) const
{ {
return Intersect_3::surf_equation(surface, p)<0.; return Intersect_3::surf_equation(surface, p)<0.;
} }

View File

@ -31,7 +31,7 @@ namespace CGAL {
*/ */
struct Point_surface_indices_visitor struct Point_surface_indices_visitor
{ {
const int i; int i;
Point_surface_indices_visitor(const int index) : i(index) Point_surface_indices_visitor(const int index) : i(index)
{ {

View File

@ -92,27 +92,27 @@ public:
friend class Intersect_3; friend class Intersect_3;
class Intersect_3 { class Intersect_3 {
Self& self; const Self& self;
public: public:
Intersect_3(Self& self) : self(self) Intersect_3(const Self& self) : self(self)
{ {
} }
Object operator()(Surface_3& surface, Segment_3 s) const Object operator()(const Surface_3& surface, const Segment_3& s) const
{ {
return self.intersect_segment_surface(surface.subfacets_octree, s); return self.intersect_segment_surface(surface.subfacets_octree, s);
} }
Object operator()(Surface_3& surface, Ray_3& r) const { Object operator()(const Surface_3& surface, const Ray_3& r) const {
return self.intersect_ray_surface(surface.subfacets_octree, r); return self.intersect_ray_surface(surface.subfacets_octree, r);
} }
Object operator()(Surface_3& surface, Line_3& l) const { Object operator()(const Surface_3& surface, const Line_3& l) const {
return self.intersect_line_surface(surface.subfacets_octree, l); return self.intersect_line_surface(surface.subfacets_octree, l);
} }
}; };
Intersect_3 intersect_3_object() Intersect_3 intersect_3_object() const
{ {
return Intersect_3(*this); return Intersect_3(*this);
} }
@ -123,18 +123,18 @@ public:
class Construct_initial_points class Construct_initial_points
{ {
Self& self; const Self& self;
public: public:
Construct_initial_points(Self& self) : self(self) Construct_initial_points(const Self& self) : self(self)
{ {
} }
template <typename OutputIteratorPoints> template <typename OutputIteratorPoints>
OutputIteratorPoints operator() (Surface_3& surface, OutputIteratorPoints operator() (const Surface_3& surface,
OutputIteratorPoints out, OutputIteratorPoints out,
int n = 20) // WARNING: why 20? int n = 20) const // WARNING: why 20?
{ {
for (typename std::vector<Point>::iterator vit = for (typename std::vector<Point>::const_iterator vit =
surface.input_points.begin(); surface.input_points.begin();
vit != surface.input_points.end() && n > 0; vit != surface.input_points.end() && n > 0;
++vit, --n) ++vit, --n)
@ -148,12 +148,12 @@ public:
} }
}; };
Construct_initial_points construct_initial_points_object() Construct_initial_points construct_initial_points_object() const
{ {
return Construct_initial_points(*this); return Construct_initial_points(*this);
} }
bool is_in_volume(Surface_3& surface, const Point& p) bool is_in_volume(const Surface_3& surface, const Point& p)
{ {
typename CGAL::Random_points_on_sphere_3<Point, typename CGAL::Random_points_on_sphere_3<Point,
Point_creator> random_point(FT(1)); Point_creator> random_point(FT(1));
@ -185,7 +185,8 @@ public:
// return CGAL::Object(); // return CGAL::Object();
// } // }
CGAL::Object intersect_segment_surface(Subfacets_octree& data_struct, Segment_3 s) CGAL::Object intersect_segment_surface(const Subfacets_octree& data_struct,
const Segment_3& s) const
{ {
// debug: test if segment is degenerate // debug: test if segment is degenerate
// (can happen, because of rounding in circumcenter computations) // (can happen, because of rounding in circumcenter computations)
@ -224,7 +225,8 @@ public:
/* return data_struct.intersection (s.vertex(0), s.vertex(1)); // Marie */ /* return data_struct.intersection (s.vertex(0), s.vertex(1)); // Marie */
} }
CGAL::Object intersect_ray_surface(Subfacets_octree& data_struct, Ray_3 &r) CGAL::Object intersect_ray_surface(const Subfacets_octree& data_struct,
const Ray_3 &r) const
{ {
// debug: for detecting whether Marie's code works // debug: for detecting whether Marie's code works
// (we compare with our basic intersection function) // (we compare with our basic intersection function)
@ -259,7 +261,8 @@ public:
} }
CGAL::Object intersect_line_surface(Subfacets_octree&, Line_3 &) CGAL::Object intersect_line_surface(const Subfacets_octree&,
const Line_3 &) const
{ {
CGAL_assertion(false); CGAL_assertion(false);
return CGAL::Object(); return CGAL::Object();

View File

@ -74,14 +74,14 @@ namespace CGAL {
#endif #endif
} }
const Visitor& get_visitor() const Visitor& get_visitor() const
{ {
return visitor; return visitor;
} }
// Predicates and Constructions // Predicates and Constructions
bool is_in_volume(const Surface_3& sphere, const Point& p) bool is_in_volume(const Surface_3& sphere, const Point& p) const
{ {
typename GT::Has_on_bounded_side_3 on_bounded_side_of_sphere = typename GT::Has_on_bounded_side_3 on_bounded_side_of_sphere =
GT().has_on_bounded_side_3_object(); GT().has_on_bounded_side_3_object();
@ -91,7 +91,7 @@ namespace CGAL {
class Intersect_3 class Intersect_3
{ {
Self& oracle; const Self& oracle;
boost::tuple<int, FT, FT> boost::tuple<int, FT, FT>
intersection_line_sphere_lambda(const Surface_3& sphere, intersection_line_sphere_lambda(const Surface_3& sphere,
@ -222,7 +222,7 @@ namespace CGAL {
}; };
public: public:
Intersect_3(Self& oracle) : oracle(oracle) Intersect_3(const Self& oracle) : oracle(oracle)
{ {
} }
@ -387,9 +387,9 @@ namespace CGAL {
class Construct_initial_points class Construct_initial_points
{ {
Self& oracle; const Self& oracle;
public: public:
Construct_initial_points(Self& oracle) : oracle(oracle) Construct_initial_points(const Self& oracle) : oracle(oracle)
{ {
} }
@ -397,7 +397,7 @@ namespace CGAL {
template <typename OutputIteratorPoints> template <typename OutputIteratorPoints>
OutputIteratorPoints operator() (const Surface_3& sphere, OutputIteratorPoints operator() (const Surface_3& sphere,
OutputIteratorPoints out, OutputIteratorPoints out,
int n = 20) // WARNING: why 20? int n = 20) const // WARNING: why 20?
{ {
const Point center = const Point center =
GT().construct_center_3_object()(sphere); GT().construct_center_3_object()(sphere);
@ -424,12 +424,12 @@ namespace CGAL {
} }
}; // end nested class Construct_initial_points }; // end nested class Construct_initial_points
Construct_initial_points construct_initial_points_object() Construct_initial_points construct_initial_points_object() const
{ {
return Construct_initial_points(*this); return Construct_initial_points(*this);
} }
Intersect_3 intersect_3_object() Intersect_3 intersect_3_object() const
{ {
return Intersect_3(*this); return Intersect_3(*this);
} }

View File

@ -51,11 +51,11 @@ namespace CGAL {
criteria = c; criteria = c;
} }
bool is_bad (const Facet& f, Quality& q ) { bool is_bad (const Facet& f, Quality& q ) const {
bool bad = false; bool bad = false;
int i = 0; int i = 0;
q.resize(criteria.size()); q.resize(criteria.size());
for (typename Criteria::iterator cit = criteria.begin(); cit != for (typename Criteria::const_iterator cit = criteria.begin(); cit !=
criteria.end(); ++cit) criteria.end(); ++cit)
if ((*cit)->is_bad (f, q[i++])) if ((*cit)->is_bad (f, q[i++]))
bad = true; bad = true;

View File

@ -75,9 +75,9 @@ namespace CGAL {
// Constructor // Constructor
Surface_mesher_base (C2T3& co, Surface_mesher_base (C2T3& co,
Surface& s, const Surface& s,
Surface_mesh_traits mesh_traits, const Surface_mesh_traits& mesh_traits,
Criteria& c) : const Criteria& c) :
Triangulation_mesher_level_traits_3<Tr>(co.triangulation()), Triangulation_mesher_level_traits_3<Tr>(co.triangulation()),
c2t3(co), c2t3(co),
tr(co.triangulation()), tr(co.triangulation()),
@ -93,9 +93,9 @@ namespace CGAL {
protected: protected:
C2T3& c2t3; C2T3& c2t3;
Tr& tr; // Associated triangulation reference Tr& tr; // Associated triangulation reference
Surface& surf; // Surface const Surface& surf; // Surface
Surface_mesh_traits meshtraits; // Surface mesh traits const Surface_mesh_traits& meshtraits; // Surface mesh traits
Criteria& criteria; // Meshing criteria const Criteria& criteria; // Meshing criteria
Bad_facets facets_to_refine; // Set of facets to refine Bad_facets facets_to_refine; // Set of facets to refine
public: public:
@ -659,9 +659,9 @@ namespace CGAL {
public: public:
Surface_mesher(C2T3& c2t3, Surface_mesher(C2T3& c2t3,
Surface& surface, const Surface& surface,
Surface_mesh_traits mesh_traits, const Surface_mesh_traits& mesh_traits,
Criteria& criteria) const Criteria& criteria)
: Base(c2t3, surface, mesh_traits, criteria), : Base(c2t3, surface, mesh_traits, criteria),
Mesher_lvl(null_mesher_level), Mesher_lvl(null_mesher_level),
initialized(false) initialized(false)

View File

@ -102,9 +102,9 @@ namespace CGAL {
public: public:
Surface_mesher_manifold_base (C2T3& c2t3, Surface_mesher_manifold_base (C2T3& c2t3,
Surface& surface, const Surface& surface,
SurfaceMeshTraits mesh_traits, const SurfaceMeshTraits& mesh_traits,
Criteria& criteria) const Criteria& criteria)
: SMMBB(c2t3, surface, mesh_traits, criteria), : SMMBB(c2t3, surface, mesh_traits, criteria),
bad_vertices_initialized(false) bad_vertices_initialized(false)
{ {

View File

@ -184,9 +184,9 @@ namespace CGAL {
public: public:
Surface_mesher_regular_edges_base(C2T3& c2t3, Surface_mesher_regular_edges_base(C2T3& c2t3,
Surface& surface, const Surface& surface,
SurfaceMeshTraits mesh_traits, const SurfaceMeshTraits& mesh_traits,
Criteria& criteria) const Criteria& criteria)
: SMB(c2t3, surface, mesh_traits, criteria), : SMB(c2t3, surface, mesh_traits, criteria),
bad_edges_initialized(false) bad_edges_initialized(false)
{ {

View File

@ -126,8 +126,8 @@ template <typename C2T3,
typename Criteria, typename Criteria,
typename Tag> typename Tag>
void make_surface_mesh(C2T3& c2t3, void make_surface_mesh(C2T3& c2t3,
Surface& surface, const Surface& surface,
Criteria criteria, const Criteria& criteria,
Tag tag, Tag tag,
int initial_number_of_points = 20) // TODO: document int initial_number_of_points = 20) // TODO: document
// this parameter // this parameter
@ -143,9 +143,9 @@ template <typename C2T3,
typename Criteria, typename Criteria,
typename Tag> typename Tag>
void make_surface_mesh(C2T3& c2t3, void make_surface_mesh(C2T3& c2t3,
typename SurfaceMeshTraits_3::Surface_3& surface, const typename SurfaceMeshTraits_3::Surface_3& surface,
SurfaceMeshTraits_3 surface_mesh_traits, const SurfaceMeshTraits_3& surface_mesh_traits,
Criteria criteria, const Criteria& criteria,
Tag, Tag,
int initial_number_of_points = 20) int initial_number_of_points = 20)
{ {