- 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
- new class 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
- added a public member function
Bbox bbox() const;

View File

@ -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;
}

View File

@ -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);
}

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);
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 <typename OutputIteratorPoints>
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) );

View File

@ -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.;
}

View File

@ -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)
{

View File

@ -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 <typename OutputIteratorPoints>
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<Point>::iterator vit =
for (typename std::vector<Point>::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<Point,
Point_creator> 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();

View File

@ -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<int, FT, FT>
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 <typename OutputIteratorPoints>
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);
}

View File

@ -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;

View File

@ -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<Tr>(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)

View File

@ -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)
{

View File

@ -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)
{

View File

@ -126,8 +126,8 @@ template <typename C2T3,
typename Criteria,
typename Tag>
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 <typename C2T3,
typename Criteria,
typename Tag>
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)
{