Added nil to variant, before removing the boost::optional

This commit is contained in:
Michal Kleinbort 2012-01-08 11:09:52 +00:00
parent 7ece7b3c83
commit 751f44787b
4 changed files with 117 additions and 128 deletions

View File

@ -50,7 +50,8 @@ public:
//type of td map items type
enum Type
{
TD_ACTIVE_TRAPEZOID = 0,
NIL = 0,
TD_ACTIVE_TRAPEZOID,
TD_INACTIVE_TRAPEZOID,
TD_ACTIVE_EDGE,
TD_INACTIVE_EDGE,
@ -104,6 +105,9 @@ public:
//MICHAL: in order to compile need to rename typedefs
//struct nil { };
typedef unsigned char nil;
//! type of Td_active_edge
typedef Td_active_edge<Self> Td_active_edge;
@ -123,7 +127,8 @@ public:
typedef Td_inactive_fictitious_vertex<Self> Td_inactive_fictitious_vertex;
//! type of td map item (Td_halfedge, Td_vertex or Td_trapezoid)
typedef boost::variant< Td_active_trapezoid, Td_inactive_trapezoid,
typedef boost::variant< nil,
Td_active_trapezoid, Td_inactive_trapezoid,
Td_active_edge, Td_inactive_edge,
Td_active_vertex, Td_active_fictitious_vertex,
Td_inactive_vertex, Td_inactive_fictitious_vertex > Td_map_item;
@ -892,22 +897,6 @@ public:
~Td_traits(void)
{
if (m_p_vtx_at_lt_inf) {
delete m_p_vtx_at_lt_inf;
m_p_vtx_at_lt_inf = 0;
}
if (m_p_vtx_at_rt_inf) {
delete m_p_vtx_at_rt_inf;
m_p_vtx_at_rt_inf = 0;
}
if (m_p_he_at_btm_inf) {
delete m_p_he_at_btm_inf;
m_p_he_at_btm_inf = 0;
}
if (m_p_he_at_top_inf) {
delete m_p_he_at_top_inf;
m_p_he_at_top_inf = 0;
}
}
public:
@ -996,33 +985,33 @@ public:
}
}
//returns true if the trapezoid is a point or a curve
bool is_degenerate(const Td_map_item& tr) const
{
switch (tr.which())
{
case TD_ACTIVE_TRAPEZOID:
case TD_INACTIVE_TRAPEZOID:
return false;
default:
return true;
}
}
////returns true if the trapezoid is a point or a curve
//bool is_degenerate(const Td_map_item& tr) const
//{
// switch (tr.which())
// {
// case TD_ACTIVE_TRAPEZOID:
// case TD_INACTIVE_TRAPEZOID:
// return false;
// default:
// return true;
// }
//}
//returns true if the trapezoid is a point
bool is_degenerate_point(const Td_map_item& tr) const //MICHAL: TBR
{
switch (tr.which())
{
case TD_ACTIVE_VERTEX:
case TD_ACTIVE_FICTITIOUS_VERTEX:
case TD_INACTIVE_VERTEX:
case TD_INACTIVE_FICTITIOUS_VERTEX:
return true;
default:
return false;
}
}
////returns true if the trapezoid is a point
//bool is_degenerate_point(const Td_map_item& tr) const //MICHAL: TBR
//{
// switch (tr.which())
// {
// case TD_ACTIVE_VERTEX:
// case TD_ACTIVE_FICTITIOUS_VERTEX:
// case TD_INACTIVE_VERTEX:
// case TD_INACTIVE_FICTITIOUS_VERTEX:
// return true;
// default:
// return false;
// }
//}
//returns true if the map item is a vertex
bool is_td_vertex(const Td_map_item& tr) const
@ -1041,18 +1030,18 @@ public:
//returns true if the trapezoid is a curve
bool is_degenerate_curve(const Td_map_item& tr) const //MICHAL: TBR
{
switch (tr.which())
{
case TD_ACTIVE_EDGE:
case TD_INACTIVE_EDGE:
return true;
default:
return false;
}
}
////returns true if the trapezoid is a curve
//bool is_degenerate_curve(const Td_map_item& tr) const //MICHAL: TBR
//{
// switch (tr.which())
// {
// case TD_ACTIVE_EDGE:
// case TD_INACTIVE_EDGE:
// return true;
// default:
// return false;
// }
//}
//returns true if the map item is an edge
bool is_td_edge(const Td_map_item& tr) const
@ -1225,22 +1214,15 @@ public:
//static Td_map_item blank_item() const { return m_blank; }
static Vertex_const_handle empty_vtx_handle() { return m_empty_vtx_handle; }
static Halfedge_const_handle empty_he_handle() { return m_empty_he_handle; }
static Vertex_const_handle vtx_at_left_infinity();
static Vertex_const_handle vtx_at_right_infinity();
static Halfedge_const_handle he_at_bottom_infinity();
static Halfedge_const_handle he_at_top_infinity();
//static Td_map_item empty_map_item() { return m_empty_map_item; }
private:
//static Td_map_item m_blank;
static Vertex_const_handle m_empty_vtx_handle;
static Halfedge_const_handle m_empty_he_handle;
static Vertex_const_handle* m_p_vtx_at_lt_inf;
static Vertex_const_handle* m_p_vtx_at_rt_inf;
static Halfedge_const_handle* m_p_he_at_btm_inf;
static Halfedge_const_handle* m_p_he_at_top_inf;
//static Td_map_item m_empty_map_item;
};
} //namespace CGAL

View File

@ -23,45 +23,6 @@
namespace CGAL {
template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Vertex_const_handle
Td_traits<Traits,Arrangement_on_surface_2>::vtx_at_left_infinity()
{
// static Vertex_const_handle* m_p_vtx_at_lt_inf;
if (!m_p_vtx_at_lt_inf)
m_p_vtx_at_lt_inf = new Vertex_const_handle();
return *m_p_vtx_at_lt_inf;
}
template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Vertex_const_handle
Td_traits<Traits,Arrangement_on_surface_2>::vtx_at_right_infinity()
{
// static Vertex_const_handle* m_p_vtx_at_rt_inf;
if (!m_p_vtx_at_rt_inf)
m_p_vtx_at_rt_inf = new Vertex_const_handle();
return *m_p_vtx_at_rt_inf;
}
template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Halfedge_const_handle
Td_traits<Traits,Arrangement_on_surface_2>::he_at_bottom_infinity()
{
// static Halfedge_const_handle* m_p_he_at_btm_inf;
if (!m_p_he_at_btm_inf)
m_p_he_at_btm_inf = new Halfedge_const_handle();
return *m_p_he_at_btm_inf;
}
template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Halfedge_const_handle
Td_traits<Traits,Arrangement_on_surface_2>::he_at_top_infinity()
{
// static Halfedge_const_handle* m_p_he_at_top_inf;
if (!m_p_he_at_top_inf)
m_p_he_at_top_inf = new Halfedge_const_handle();
return *m_p_he_at_top_inf;
}
/*
template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Td_map_item
@ -75,20 +36,8 @@ template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Halfedge_const_handle
Td_traits<Traits,Arrangement_on_surface_2>::m_empty_he_handle = Halfedge_const_handle();
template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Vertex_const_handle *
Td_traits<Traits,Arrangement_on_surface_2>::m_p_vtx_at_lt_inf = 0;
template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Vertex_const_handle *
Td_traits<Traits,Arrangement_on_surface_2>::m_p_vtx_at_rt_inf = 0;
template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Halfedge_const_handle *
Td_traits<Traits,Arrangement_on_surface_2>::m_p_he_at_btm_inf = 0;
template <class Traits,class Arrangement_on_surface_2>
typename Td_traits<Traits,Arrangement_on_surface_2>::Halfedge_const_handle *
Td_traits<Traits,Arrangement_on_surface_2>::m_p_he_at_top_inf = 0;
//template <class Traits,class Arrangement_on_surface_2>
//typename Td_traits<Traits,Arrangement_on_surface_2>::Td_map_item
//Td_traits<Traits,Arrangement_on_surface_2>::m_empty_map_item = Td_map_item();
} //namespace CGAL

View File

@ -110,6 +110,9 @@ public:
//type of td_map_item
typedef typename Traits::Td_map_item Td_map_item;
//type of nil
typedef typename Traits::nil nil;
//type of Td_active_trapezoid
typedef typename Traits::Td_active_trapezoid Td_active_trapezoid;
@ -757,6 +760,12 @@ public:
class rb_visitor : public boost::static_visitor< boost::optional<Td_map_item> >
{
public:
boost::optional<Td_map_item> operator()(nil& t) const
{
CGAL_assertion(false);
return boost::none;
}
template < typename T >
boost::optional<Td_map_item> operator()(T& t) const
{
@ -769,6 +778,11 @@ public:
public:
set_rb_visitor (boost::optional<Td_map_item> rb) : m_rb(rb) {}
void operator()(nil& t) const
{
CGAL_assertion(false);
}
template < typename T >
void operator()(T& t) const
{
@ -781,6 +795,12 @@ public:
class rt_visitor : public boost::static_visitor< boost::optional<Td_map_item> >
{
public:
boost::optional<Td_map_item> operator()(nil& t) const
{
CGAL_assertion(false);
return boost::none;
}
template < typename T >
boost::optional<Td_map_item> operator()(T& t) const
{
@ -793,6 +813,11 @@ public:
public:
set_rt_visitor (boost::optional<Td_map_item> rt) : m_rt(rt) {}
void operator()(nil& t) const
{
CGAL_assertion(false);
}
template < typename T >
void operator()(T& t) const
{
@ -805,6 +830,12 @@ public:
class lb_visitor : public boost::static_visitor< boost::optional<Td_map_item> >
{
public:
boost::optional<Td_map_item> operator()(nil& t) const
{
CGAL_assertion(false);
return boost::none;
}
template < typename T >
boost::optional<Td_map_item> operator()(T& t) const
{
@ -817,6 +848,11 @@ public:
public:
set_lb_visitor (boost::optional<Td_map_item> lb) : m_lb(lb) {}
void operator()(nil& t) const
{
CGAL_assertion(false);
}
template < typename T >
void operator()(T& t) const
{
@ -829,6 +865,12 @@ public:
class lt_visitor : public boost::static_visitor< boost::optional<Td_map_item> >
{
public:
boost::optional<Td_map_item> operator()(nil& t) const
{
CGAL_assertion(false);
return boost::none;
}
template < typename T >
boost::optional<Td_map_item> operator()(T& t) const
{
@ -840,7 +882,12 @@ public:
{
public:
set_lt_visitor (boost::optional<Td_map_item> lt) : m_lt(lt) {}
void operator()(nil& t) const
{
CGAL_assertion(false);
}
template < typename T >
void operator()(T& t) const
{
@ -901,6 +948,12 @@ public:
class dag_node_visitor : public boost::static_visitor< Dag_node* >
{
public:
Dag_node* operator()(nil& t) const
{
CGAL_assertion(false);
return NULL;
}
template < typename T >
Dag_node* operator()(T& t) const
{
@ -913,6 +966,11 @@ public:
public:
set_dag_node_visitor(Dag_node* node):m_node(node) {}
void operator()(nil& t) const
{
CGAL_assertion(false);
}
template < typename T >
void operator()(T& t) const
{

View File

@ -115,14 +115,14 @@ std::ostream& write(std::ostream &out,const Td_X_trapezoid<Traits>& t,
else pad=true;
out << name[j];
// identify neighbours
if (traits.is_degenerate_point(t) && value[j])
if (traits.is_td_vertex(t) && value[j])
out << "=" << value[j]->top();
}
out << ")" << std::flush;
if (t.is_active())
{
if (!traits.is_degenerate(t))
if (traits.is_td_trapezoid(t))
{
if (t.is_unbounded())
{
@ -140,7 +140,7 @@ std::ostream& write(std::ostream &out,const Td_X_trapezoid<Traits>& t,
else
out << ",T";
}
else if (traits.is_degenerate_curve(t))
else if (traits.is_td_edge(t))
out << ",C";
else // if (t.is_degenerate_point())
out << ",P";
@ -226,7 +226,7 @@ std::ostream& operator<<(std::ostream &out,const Td_X_trapezoid<Traits>& t)
{
out << name[j];
// identify neighbours
if (traits.is_degenerate_point(t) && value[j])
if (traits.is_td_vertex(t) && value[j])
out << "=" << value[j]->top();
out << " ";
}
@ -234,7 +234,7 @@ std::ostream& operator<<(std::ostream &out,const Td_X_trapezoid<Traits>& t)
if (t.is_active())
{
if (!traits.is_degenerate(t))
if (traits.is_td_trapezoid(t))
{
if (t.is_unbounded())
{
@ -251,7 +251,7 @@ std::ostream& operator<<(std::ostream &out,const Td_X_trapezoid<Traits>& t)
else
out << ",T";
}
else if (traits.is_degenerate_curve(t))
else if (traits.is_td_edge(t))
out << ",C";
else // if (t.is_degenerate_point())
out << ",P";