fixed namespace of boost related constructs and functions

This commit is contained in:
Efi Fogel 2007-04-04 17:12:45 +00:00
parent f0893c0b3f
commit 0fabc7efcd
3 changed files with 333 additions and 295 deletions

View File

@ -16,6 +16,8 @@
//
//
// Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_TYPEDEFS_H
#define CGAL_TYPEDEFS_H

View File

@ -1,5 +1,6 @@
//! \file examples/Envelope_3/ex_envelope_spheres.cpp
// Constructing the lower envelope of a set of spheres read from a file.
#include <CGAL/basic.h>
#ifndef CGAL_USE_CORE
@ -7,7 +8,7 @@
int main()
{
std::cout << "Sorry, this example needs CORE ..." << std::endl;
return (0);
return 0;
}
#else
@ -50,7 +51,7 @@ int main (int argc, char **argv)
if (! in_file.is_open())
{
std::cerr << "Failed to open " << filename << " ..." << std::endl;
return (1);
return 1;
}
// Read the spheres from the file.
@ -66,12 +67,10 @@ int main (int argc, char **argv)
int i;
in_file >> n;
for (i = 0; i < n; i++)
for (i = 0; i < n; ++i)
{
in_file >> x >> y >> z >> sqr_r;
spheres.push_back (Sphere_3 (Rat_point_3 (x, y, z),
Rational (sqr_r)));
spheres.push_back(Sphere_3(Rat_point_3(x, y, z), Rational(sqr_r)));
}
in_file.close();
@ -83,8 +82,7 @@ int main (int argc, char **argv)
<< n << " spheres." << std::endl;
timer.start();
CGAL::lower_envelope_3 (spheres.begin(), spheres.end(),
min_diag);
CGAL::lower_envelope_3(spheres.begin(), spheres.end(), min_diag);
timer.stop();
// Print the dimensions of the minimization diagram.
@ -95,7 +93,7 @@ int main (int argc, char **argv)
std::cout << "Construction took " << timer.time()
<< " seconds." << std::endl;
return (0);
return 0;
}
#endif

View File

@ -16,6 +16,7 @@
//
// Author(s) : Michal Meyerovitch <gorgymic@post.tau.ac.il>
// Baruch Zukerman <baruchzu@post.tau.ac.il>
// Efi Fogel <efif@post.tau.ac.il>
#ifndef CGAL_ENVELOPE_DIVIDE_AND_CONQUER_3_H
#define CGAL_ENVELOPE_DIVIDE_AND_CONQUER_3_H
@ -23,20 +24,6 @@
#define CGAL_ENVELOPE_SAVE_COMPARISONS
#define CGAL_ENVELOPE_USE_BFS_FACE_ORDER
#include <CGAL/Envelope_3/Envelope_base.h>
#include <CGAL/Object.h>
#include <CGAL/enum.h>
#include <CGAL/Arr_observer.h>
#include <CGAL/Envelope_3/Env_overlay_2.h>
#include <CGAL/Envelope_3/Envelope_element_visitor_3.h>
#include <CGAL/Envelope_3/set_dividors.h>
#ifdef CGAL_ENVELOPE_USE_BFS_FACE_ORDER
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <CGAL/graph_traits_Dual_Arrangement_2.h>
#include <CGAL/Arr_face_map.h>
#endif
#include <iostream>
#include <cassert>
#include <list>
@ -45,6 +32,20 @@
#include <map>
#include <time.h>
#include <CGAL/Object.h>
#include <CGAL/enum.h>
#include <CGAL/Arr_observer.h>
#include <CGAL/Envelope_3/Envelope_base.h>
#include <CGAL/Envelope_3/Env_overlay_2.h>
#include <CGAL/Envelope_3/Envelope_element_visitor_3.h>
#include <CGAL/Envelope_3/set_dividors.h>
#ifdef CGAL_ENVELOPE_USE_BFS_FACE_ORDER
#include <CGAL/Arr_face_map.h>
#include <CGAL/graph_traits_Dual_Arrangement_2.h>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#endif
// this base divide & conquer algorithm splits the input into 2 groups,
// calculates the result over the 2 groups, and then merges the results like
// this:
@ -113,24 +114,37 @@ public:
protected:
typedef typename Minimization_diagram_2::Halfedge_const_iterator Halfedge_const_iterator;
typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle;
typedef typename Minimization_diagram_2::Halfedge_iterator Halfedge_iterator;
typedef typename Minimization_diagram_2::Face_handle Face_handle;
typedef typename Minimization_diagram_2::Edge_iterator Edge_iterator;
typedef typename Minimization_diagram_2::Face_iterator Face_iterator;
typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle;
typedef typename Minimization_diagram_2::Vertex_iterator Vertex_iterator;
typedef typename Minimization_diagram_2::Hole_iterator Hole_iterator;
typedef typename Minimization_diagram_2::Ccb_halfedge_circulator Ccb_halfedge_circulator;
typedef typename Minimization_diagram_2::Halfedge_const_iterator
Halfedge_const_iterator;
typedef typename Minimization_diagram_2::Halfedge_handle
Halfedge_handle;
typedef typename Minimization_diagram_2::Halfedge_iterator
Halfedge_iterator;
typedef typename Minimization_diagram_2::Face_handle
Face_handle;
typedef typename Minimization_diagram_2::Edge_iterator
Edge_iterator;
typedef typename Minimization_diagram_2::Face_iterator
Face_iterator;
typedef typename Minimization_diagram_2::Vertex_handle
Vertex_handle;
typedef typename Minimization_diagram_2::Vertex_iterator
Vertex_iterator;
typedef typename Minimization_diagram_2::Hole_iterator
Hole_iterator;
typedef typename Minimization_diagram_2::Ccb_halfedge_circulator
Ccb_halfedge_circulator;
typedef typename Minimization_diagram_2::Halfedge_around_vertex_circulator
Halfedge_around_vertex_circulator;
typedef Arr_observer<Minimization_diagram_2> Md_observer;
typedef typename Minimization_diagram_2::Dcel::Dcel_data_iterator Envelope_data_iterator;
typedef typename Minimization_diagram_2::Dcel::Dcel_data_iterator
Envelope_data_iterator;
#ifdef CGAL_ENVELOPE_USE_BFS_FACE_ORDER
typedef CGAL::Dual<Minimization_diagram_2> Dual_Minimization_diagram_2;
typedef CGAL::Dual<Minimization_diagram_2>
Dual_Minimization_diagram_2;
#endif
public:
@ -196,8 +210,8 @@ public:
// make the general surfaces xy-monotone
std::list<Xy_monotone_surface_3> xy_monotones;
for (; begin != end; ++begin)
traits->make_xy_monotone_3_object()
(*begin, m_is_lower, std::back_inserter(xy_monotones));
traits->make_xy_monotone_3_object()(*begin, m_is_lower,
std::back_inserter(xy_monotones));
// recursively construct the envelope of the xy-monotone parts
construct_lu_envelope_xy_monotones(xy_monotones.begin(),
@ -236,13 +250,13 @@ public:
/*! Access the traits object (const version). */
const Traits* get_traits() const
{
return (traits);
return traits;
}
/*! Access the traits object (non-const version). */
Traits* get_traits()
{
return (traits);
return traits;
}
void reset()
@ -250,8 +264,6 @@ public:
resolver->reset();
}
protected:
// compute the envelope of xy-monotone surfaces in 3D
@ -277,15 +289,18 @@ protected:
return;
}
// divide the surfaces into 2 groups (insert surface to each group alternately)
// divide the surfaces into 2 groups (insert surface to each group
// alternately)
std::list<Xy_monotone_surface_3> group1, group2;
dividor(first, end,
std::back_inserter(group1), std::back_inserter(group2));
// recursively calculate the LU_envelope of the 2 groups
Minimization_diagram_2 result1(traits), result2(traits);
construct_lu_envelope_xy_monotones(group1.begin(), group1.end(), result1, dividor);
construct_lu_envelope_xy_monotones(group2.begin(), group2.end(), result2, dividor);
construct_lu_envelope_xy_monotones(group1.begin(), group1.end(),
result1, dividor);
construct_lu_envelope_xy_monotones(group2.begin(), group2.end(),
result2, dividor);
// merge the results:
merge_envelopes(result1, result2, result);
@ -296,14 +311,17 @@ protected:
CGAL_assertion(is_envelope_valid(result));
}
void deal_with_one_surface(Xy_monotone_surface_3& surf, Minimization_diagram_2& result)
void deal_with_one_surface(Xy_monotone_surface_3& surf,
Minimization_diagram_2& result)
{
typedef std::list<Object> Boundary_list;
typedef std::pair<X_monotone_curve_2, Oriented_side> Boundary_xcurve;
typedef Boundary_list::iterator Boundary_iterator;
Boundary_list boundary;
traits->construct_projected_boundary_2_object()(surf, std::back_inserter(boundary));
traits->
construct_projected_boundary_2_object()(surf,
std::back_inserter(boundary));
if(boundary.empty())
{
@ -321,7 +339,8 @@ protected:
if(assign(boundary_cv, obj))
{
Oriented_side side = boundary_cv.second;
Halfedge_handle he = insert_non_intersecting_curve(result, boundary_cv.first);
Halfedge_handle he =
insert_non_intersecting_curve(result, boundary_cv.first);
if(side == ON_ORIENTED_BOUNDARY)
{
@ -335,8 +354,8 @@ protected:
if(he->face() != he->twin()->face())
{
// new face created.
// 'he' is directed from left to right, so the face to the left of 'he'
// is above 'cv.
// 'he' is directed from left to right, so the face to the left
// of 'he' is above 'cv.
Face_handle f;
if(side == ON_NEGATIVE_SIDE) // the surface is below cv.
{
@ -386,8 +405,8 @@ protected:
{
hi->set_data(surf);
// since all the edges & vertices have their envelope data equal to the
// current surface, we can set is/has equal_data_in_target of all halfedges
// to true
// current surface, we can set is/has equal_data_in_target of all
// halfedges to true
hi->set_is_equal_data_in_target(true);
hi->set_has_equal_data_in_target(true);
}
@ -418,7 +437,8 @@ public:
Overlay_2 overlay;
overlay(result1, result2, result);
CGAL_expensive_assertion_msg(is_valid(result), "after overlay result is not valid");
CGAL_expensive_assertion_msg(is_valid(result),
"after overlay result is not valid");
// make sure the aux flags are correctly set by the overlay
//CGAL_assertion(verify_aux_flags(result));
@ -438,7 +458,8 @@ public:
for (; ei != result.edges_end(); ++ei)
{
Halfedge_handle hh = ei;
// there must be data from at least one map, because all the surfaces are continous
// there must be data from at least one map, because all the surfaces
// are continous
if (!get_aux_is_set(hh, 0) || !get_aux_is_set(hh, 1))
continue;
CGAL_assertion(get_aux_is_set(hh, 0));
@ -505,7 +526,8 @@ public:
bfs_visitor(index_map, faces_to_split, this);
Face_handle first_face = result.faces_begin();
/*if (result.number_of_faces() > 1)
first_face = ++(result.faces_begin());*/
first_face = ++(result.faces_begin());
*/
boost::breadth_first_search(Dual_Minimization_diagram_2(result),
first_face,
@ -538,8 +560,8 @@ public:
}
// here, we have both surfaces.
// we save the face in a list for a later treatment, because the face can change
// and destroy the iterator
// we save the face in a list for a later treatment, because the
// face can change and destroy the iterator
faces_to_split.push_back(fh);
}
#endif
@ -565,7 +587,8 @@ public:
Vertex_handle vh = vi;
if (vh->is_decision_set())
continue;
// there must be data from at least one map, because all the surfaces are continous
// there must be data from at least one map, because all the surfaces
// are continous
CGAL_assertion(get_aux_is_set(vh, 0));
CGAL_assertion(get_aux_is_set(vh, 1));
CGAL_assertion(!aux_has_no_data(vh, 1) || !aux_has_no_data(vh, 0));
@ -583,7 +606,8 @@ public:
}
CGAL_expensive_assertion_msg(result.is_valid(), "after resolve result is not valid");
CGAL_expensive_assertion_msg(result.is_valid(),
"after resolve result is not valid");
// make sure that aux_source and decision are set at all features
// after all resolvings
@ -605,8 +629,9 @@ public:
CGAL_expensive_assertion_msg(result.is_valid(),
"after remove vertices result is not valid");
// update is_equal_data and has_equal_data of halfedge->face and vertex->face
// relations, according to the decision, and the aux similar flags
// update is_equal_data and has_equal_data of halfedge->face and
// vertex->face relations, according to the decision, and the aux
// similar flags
update_flags(result);
// update the envelope surfaces according to the decision and the aux
@ -615,15 +640,18 @@ public:
// make sure that all the flags are correctly set on the envelope result
//CGAL_assertion(verify_flags(result));
CGAL_expensive_assertion_msg(is_valid(result), "after merge result is not valid");
CGAL_expensive_assertion_msg(is_valid(result),
"after merge result is not valid");
}
protected:
void deal_with_faces_to_split(std::list<Face_handle>& faces_to_split, Minimization_diagram_2& result)
void deal_with_faces_to_split(std::list<Face_handle>& faces_to_split,
Minimization_diagram_2& result)
{
// for each face in faces_to_split, find the intersection over the face, and split the face
// for each face in faces_to_split, find the intersection over the face,
// and split the face
typename std::list<Face_handle>::iterator li;
for (li = faces_to_split.begin(); li != faces_to_split.end(); ++li)
{
@ -669,7 +697,8 @@ protected:
}
// todo: should remove the uses of this method from this class
template <class FeatureHandle1, class FeatureHandle2>
bool has_equal_aux_data(unsigned int id, FeatureHandle1 fh1, FeatureHandle2 fh2)
bool has_equal_aux_data(unsigned int id, FeatureHandle1 fh1,
FeatureHandle2 fh2)
{
Envelope_data_iterator begin1, end1, begin2, end2;
get_aux_data_iterators(id, fh1, begin1, end1);
@ -696,7 +725,8 @@ protected:
}
}
for(typename std::list<Halfedge_handle>::iterator ci = edges.begin(); ci != edges.end(); ++ci)
for (typename std::list<Halfedge_handle>::iterator ci = edges.begin();
ci != edges.end(); ++ci)
{
// if the endpoints become isolated after the removal we need to remove
// them if they have the same data as the edge
@ -713,8 +743,10 @@ protected:
h->get_is_equal_aux_data_in_target(0));
bool trg_is_equal_1 = (h->get_is_equal_aux_data_in_face(1) &&
h->get_is_equal_aux_data_in_target(1));
bool src_has_equal_0 = h->twin()->get_has_equal_aux_data_in_target_and_face(0);
bool src_has_equal_1 = h->twin()->get_has_equal_aux_data_in_target_and_face(1);
bool src_has_equal_0 =
h->twin()->get_has_equal_aux_data_in_target_and_face(0);
bool src_has_equal_1 =
h->twin()->get_has_equal_aux_data_in_target_and_face(1);
bool trg_has_equal_0 = h->get_has_equal_aux_data_in_target_and_face(0);
bool trg_has_equal_1 = h->get_has_equal_aux_data_in_target_and_face(1);
@ -724,14 +756,17 @@ protected:
// handle is invalid
if (!remove_src && src->is_isolated())
{
// to be precise we copy from the halfedge-face and halfedge-target relations
// to be precise we copy from the halfedge-face and halfedge-target
// relations
src->set_is_equal_aux_data_in_face(0, src_is_equal_0);
src->set_is_equal_aux_data_in_face(1, src_is_equal_1);
// todo: the has_equal flags should be updated also
// make sure h_face is also src face
CGAL_assertion(h_face == src->face());
// CGAL_assertion(src_has_equal_0 == has_equal_aux_data(0, src, h_face));
// CGAL_assertion(src_has_equal_1 == has_equal_aux_data(1, src, h_face));
// CGAL_assertion(src_has_equal_0 ==
// has_equal_aux_data(0, src, h_face));
// CGAL_assertion(src_has_equal_1 ==
// has_equal_aux_data(1, src, h_face));
src->set_has_equal_aux_data_in_face(0, src_has_equal_0);
src->set_has_equal_aux_data_in_face(1, src_has_equal_1);
}
@ -741,8 +776,10 @@ protected:
trg->set_is_equal_aux_data_in_face(1, trg_is_equal_1);
// make sure h_face is also trg face
CGAL_assertion(h_face == trg->face());
// CGAL_assertion(trg_has_equal_0 == has_equal_aux_data(0, trg, h_face));
// CGAL_assertion(trg_has_equal_1 == has_equal_aux_data(1, trg, h_face));
// CGAL_assertion(trg_has_equal_0 ==
// has_equal_aux_data(0, trg, h_face));
// CGAL_assertion(trg_has_equal_1 ==
// has_equal_aux_data(1, trg, h_face));
trg->set_has_equal_aux_data_in_face(0, trg_has_equal_0);
trg->set_has_equal_aux_data_in_face(1, trg_has_equal_1);
}
@ -798,7 +835,8 @@ protected:
// we check if the decision done on the edge is equal to the decision
// done on the faces. if not, then the envelope surfaces must differ
CGAL_assertion(hh->is_decision_set() && f1->is_decision_set() && f2->is_decision_set());
CGAL_assertion(hh->is_decision_set() && f1->is_decision_set() &&
f2->is_decision_set());
if (hh->get_decision() != f1->get_decision() ||
hh->get_decision() != f2->get_decision())
{
@ -909,8 +947,8 @@ protected:
}*/
CGAL_assertion(vh->is_decision_set());
// if the decision done on the vertex and its incident halfedges are different,
// the envelope differs too.
// if the decision done on the vertex and its incident halfedges are
// different, the envelope differs too.
CGAL_assertion(vh == he1->target() && vh == he2->target());
if (vh->get_decision() != he1->get_decision() ||
vh->get_decision() != he2->get_decision())
@ -1316,8 +1354,6 @@ protected:
}
}
protected:
//***************************************************************************
@ -1429,7 +1465,8 @@ protected:
{
Vertex_handle vh = vi;
/*if (vh->get_is_fake())
continue;*/
continue;
*/
all_ok &= (vh->get_aux_is_set(0));
CGAL_assertion_msg(all_ok, "aux source (0) not set over vertex");
@ -1444,7 +1481,8 @@ protected:
{
Halfedge_handle hh = hi;
/* if (hh->get_is_fake())
continue;*/
* continue;
*/
all_ok &= (hh->get_aux_is_set(0));
CGAL_assertion_msg(all_ok, "aux source (0) not set over edge");
@ -1614,7 +1652,8 @@ protected:
/*new_vertex->set_is_fake(org_he->get_is_fake());*/
// update all new bools
new_he->set_is_equal_aux_data_in_face(0, org_he->get_is_equal_aux_data_in_face(0));
new_he->
set_is_equal_aux_data_in_face(0, org_he->get_is_equal_aux_data_in_face(0));
new_he->twin()->set_is_equal_aux_data_in_face(0, org_he->twin()->get_is_equal_aux_data_in_face(0));
new_he->set_is_equal_aux_data_in_face(1, org_he->get_is_equal_aux_data_in_face(1));
new_he->twin()->set_is_equal_aux_data_in_face(1, org_he->twin()->get_is_equal_aux_data_in_face(1));
@ -1679,8 +1718,7 @@ protected:
public:
// Constructor.
Faces_order_bfs_visitor(const IndexMap& imap,
std::list<Face_handle>& f,
Faces_order_bfs_visitor(const IndexMap& imap, std::list<Face_handle>& f,
Self* b = NULL) :
index_map (&imap),
faces(f),
@ -1708,8 +1746,8 @@ protected:
fh->set_decision(FIRST);
else
// here, we have both surfaces.
// we save the face in a list for a later treatment, because the face can change
// and destroy the iterator
// we save the face in a list for a later treatment, because the
// face can change and destroy the iterator
faces.push_back(fh);
}
};