diff --git a/Mesh_3/changes.txt b/Mesh_3/changes.txt index 4378a102dfe..77913625cbb 100644 --- a/Mesh_3/changes.txt +++ b/Mesh_3/changes.txt @@ -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 - new class Volume_mesher_default_triangulation_3 - new test, of io operators. It uses Volume_mesher_default_triangulation_3. diff --git a/Surface_mesher/changes.txt b/Surface_mesher/changes.txt index 79caf7b3a62..7bb20c9280f 100644 --- a/Surface_mesher/changes.txt +++ b/Surface_mesher/changes.txt @@ -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 - added a public member function Bbox bbox() const; diff --git a/Surface_mesher/include/CGAL/Multi_surface_3.h b/Surface_mesher/include/CGAL/Multi_surface_3.h index 658650f2640..894328b6cca 100644 --- a/Surface_mesher/include/CGAL/Multi_surface_3.h +++ b/Surface_mesher/include/CGAL/Multi_surface_3.h @@ -28,21 +28,21 @@ namespace CGAL { > class Multi_surface_3 { - Surface_a& surf_a; - Surface_b& surf_b; + const Surface_a& surf_a; + const Surface_b& surf_b; 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) { } - Surface_a& surface_a() + const Surface_a& surface_a() const { return surf_a; } - Surface_b& surface_b() + const Surface_b& surface_b() const { return surf_b; } diff --git a/Surface_mesher/include/CGAL/Surface_mesh_default_criteria_3.h b/Surface_mesher/include/CGAL/Surface_mesh_default_criteria_3.h index b38e8a14d8b..93f976d79f3 100644 --- a/Surface_mesher/include/CGAL/Surface_mesh_default_criteria_3.h +++ b/Surface_mesher/include/CGAL/Surface_mesh_default_criteria_3.h @@ -54,7 +54,7 @@ public: 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); } diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Combining_oracle.h b/Surface_mesher/include/CGAL/Surface_mesher/Combining_oracle.h index 6bdd51c112b..3a151a1c0ef 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Combining_oracle.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Combining_oracle.h @@ -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); if( obj.is_empty() ) @@ -78,14 +78,14 @@ namespace CGAL { 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); if( obj.is_empty() ) return oracle_b.intersect_3_object()(surface.surface_b(), r); 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); if( obj.is_empty() ) return oracle_b.intersect_3_object()(surface.surface_b(), l); @@ -105,7 +105,7 @@ namespace CGAL { // Random points template - OutputIteratorPoints operator() (Surface_3& surface, + OutputIteratorPoints operator() (const Surface_3& surface, OutputIteratorPoints out, int n = 20) // WARNING: why 20? { @@ -119,17 +119,17 @@ namespace CGAL { } }; // end nested class Construct_initial_points - Intersect_3 intersect_3_object() + Intersect_3 intersect_3_object() const { 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); } - 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) || oracle_b.is_in_volume(surface.surface_b(), p) ); diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Implicit_surface_oracle_3.h b/Surface_mesher/include/CGAL/Surface_mesher/Implicit_surface_oracle_3.h index 1bfaf3d846e..f3350e04206 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Implicit_surface_oracle_3.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Implicit_surface_oracle_3.h @@ -198,7 +198,7 @@ namespace CGAL { // debug function static std::string debug_point(const Surface_3& surface, - const Point& p) + const Point& p) { std::stringstream s; s << p << " (distance=" @@ -210,7 +210,7 @@ namespace CGAL { } static CGAL::Sign surf_equation (Surface_3 surface, - const Point& p) + const Point& p) { return CGAL::sign(surface(p)); } // @TODO, @WARNING: we use x(), y() and z() @@ -287,9 +287,9 @@ namespace CGAL { class Construct_initial_points { - Self& oracle; + const Self& oracle; 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 - Construct_initial_points construct_initial_points_object() + Construct_initial_points construct_initial_points_object() const { return Construct_initial_points(*this); } - Intersect_3 intersect_3_object() + Intersect_3 intersect_3_object() const { 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.; } diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Point_surface_indices_oracle_visitor.h b/Surface_mesher/include/CGAL/Surface_mesher/Point_surface_indices_oracle_visitor.h index 4e38316dc18..488a38cef95 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Point_surface_indices_oracle_visitor.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Point_surface_indices_oracle_visitor.h @@ -31,7 +31,7 @@ namespace CGAL { */ struct Point_surface_indices_visitor { - const int i; + int i; Point_surface_indices_visitor(const int index) : i(index) { diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Polyhedral_oracle.h b/Surface_mesher/include/CGAL/Surface_mesher/Polyhedral_oracle.h index a2a5141b84e..59fd0b7cc5e 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Polyhedral_oracle.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Polyhedral_oracle.h @@ -92,27 +92,27 @@ public: friend class Intersect_3; class Intersect_3 { - Self& self; + const Self& self; 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); } - 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); } - 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); } }; - Intersect_3 intersect_3_object() + Intersect_3 intersect_3_object() const { return Intersect_3(*this); } @@ -123,18 +123,18 @@ public: class Construct_initial_points { - Self& self; + const Self& self; public: - Construct_initial_points(Self& self) : self(self) + Construct_initial_points(const Self& self) : self(self) { } template - OutputIteratorPoints operator() (Surface_3& surface, + OutputIteratorPoints operator() (const Surface_3& surface, OutputIteratorPoints out, - int n = 20) // WARNING: why 20? + int n = 20) const // WARNING: why 20? { - for (typename std::vector::iterator vit = + for (typename std::vector::const_iterator vit = surface.input_points.begin(); vit != surface.input_points.end() && n > 0; ++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); } - 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 random_point(FT(1)); @@ -185,7 +185,8 @@ public: // 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 // (can happen, because of rounding in circumcenter computations) @@ -224,7 +225,8 @@ public: /* 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 // (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); return CGAL::Object(); diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Sphere_oracle_3.h b/Surface_mesher/include/CGAL/Surface_mesher/Sphere_oracle_3.h index 780723b113b..00641946352 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Sphere_oracle_3.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Sphere_oracle_3.h @@ -74,14 +74,14 @@ namespace CGAL { #endif } - const Visitor& get_visitor() + const Visitor& get_visitor() const { return visitor; } // 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 = GT().has_on_bounded_side_3_object(); @@ -91,7 +91,7 @@ namespace CGAL { class Intersect_3 { - Self& oracle; + const Self& oracle; boost::tuple intersection_line_sphere_lambda(const Surface_3& sphere, @@ -222,7 +222,7 @@ namespace CGAL { }; public: - Intersect_3(Self& oracle) : oracle(oracle) + Intersect_3(const Self& oracle) : oracle(oracle) { } @@ -387,9 +387,9 @@ namespace CGAL { class Construct_initial_points { - Self& oracle; + const Self& oracle; public: - Construct_initial_points(Self& oracle) : oracle(oracle) + Construct_initial_points(const Self& oracle) : oracle(oracle) { } @@ -397,7 +397,7 @@ namespace CGAL { template OutputIteratorPoints operator() (const Surface_3& sphere, OutputIteratorPoints out, - int n = 20) // WARNING: why 20? + int n = 20) const // WARNING: why 20? { const Point center = GT().construct_center_3_object()(sphere); @@ -424,12 +424,12 @@ namespace CGAL { } }; // 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); } - Intersect_3 intersect_3_object() + Intersect_3 intersect_3_object() const { return Intersect_3(*this); } diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Standard_criteria.h b/Surface_mesher/include/CGAL/Surface_mesher/Standard_criteria.h index 504664274ae..91c8c080560 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Standard_criteria.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Standard_criteria.h @@ -51,11 +51,11 @@ namespace CGAL { criteria = c; } - bool is_bad (const Facet& f, Quality& q ) { + bool is_bad (const Facet& f, Quality& q ) const { bool bad = false; int i = 0; q.resize(criteria.size()); - for (typename Criteria::iterator cit = criteria.begin(); cit != + for (typename Criteria::const_iterator cit = criteria.begin(); cit != criteria.end(); ++cit) if ((*cit)->is_bad (f, q[i++])) bad = true; diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher.h b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher.h index b1da4c66f1a..ebc4da52a97 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher.h @@ -75,9 +75,9 @@ namespace CGAL { // Constructor Surface_mesher_base (C2T3& co, - Surface& s, - Surface_mesh_traits mesh_traits, - Criteria& c) : + const Surface& s, + const Surface_mesh_traits& mesh_traits, + const Criteria& c) : Triangulation_mesher_level_traits_3(co.triangulation()), c2t3(co), tr(co.triangulation()), @@ -93,9 +93,9 @@ namespace CGAL { protected: C2T3& c2t3; Tr& tr; // Associated triangulation reference - Surface& surf; // Surface - Surface_mesh_traits meshtraits; // Surface mesh traits - Criteria& criteria; // Meshing criteria + const Surface& surf; // Surface + const Surface_mesh_traits& meshtraits; // Surface mesh traits + const Criteria& criteria; // Meshing criteria Bad_facets facets_to_refine; // Set of facets to refine public: @@ -659,9 +659,9 @@ namespace CGAL { public: Surface_mesher(C2T3& c2t3, - Surface& surface, - Surface_mesh_traits mesh_traits, - Criteria& criteria) + const Surface& surface, + const Surface_mesh_traits& mesh_traits, + const Criteria& criteria) : Base(c2t3, surface, mesh_traits, criteria), Mesher_lvl(null_mesher_level), initialized(false) diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_manifold.h b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_manifold.h index 4a3ffac73f8..77b05d657e1 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_manifold.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_manifold.h @@ -102,9 +102,9 @@ namespace CGAL { public: Surface_mesher_manifold_base (C2T3& c2t3, - Surface& surface, - SurfaceMeshTraits mesh_traits, - Criteria& criteria) + const Surface& surface, + const SurfaceMeshTraits& mesh_traits, + const Criteria& criteria) : SMMBB(c2t3, surface, mesh_traits, criteria), bad_vertices_initialized(false) { diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_regular_edges.h b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_regular_edges.h index 52c649f0373..ad6c4d60296 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_regular_edges.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Surface_mesher_regular_edges.h @@ -184,9 +184,9 @@ namespace CGAL { public: Surface_mesher_regular_edges_base(C2T3& c2t3, - Surface& surface, - SurfaceMeshTraits mesh_traits, - Criteria& criteria) + const Surface& surface, + const SurfaceMeshTraits& mesh_traits, + const Criteria& criteria) : SMB(c2t3, surface, mesh_traits, criteria), bad_edges_initialized(false) { diff --git a/Surface_mesher/include/CGAL/make_surface_mesh.h b/Surface_mesher/include/CGAL/make_surface_mesh.h index 74bc34054c5..f60a0bb82be 100644 --- a/Surface_mesher/include/CGAL/make_surface_mesh.h +++ b/Surface_mesher/include/CGAL/make_surface_mesh.h @@ -126,8 +126,8 @@ template void make_surface_mesh(C2T3& c2t3, - Surface& surface, - Criteria criteria, + const Surface& surface, + const Criteria& criteria, Tag tag, int initial_number_of_points = 20) // TODO: document // this parameter @@ -143,9 +143,9 @@ template void make_surface_mesh(C2T3& c2t3, - typename SurfaceMeshTraits_3::Surface_3& surface, - SurfaceMeshTraits_3 surface_mesh_traits, - Criteria criteria, + const typename SurfaceMeshTraits_3::Surface_3& surface, + const SurfaceMeshTraits_3& surface_mesh_traits, + const Criteria& criteria, Tag, int initial_number_of_points = 20) {