#include <CGAL/HalfedgeDS_items_2.h>
#include <CGAL/HalfedgeDS_list.h>
#include <CGAL/HalfedgeDS_decorator.h>
#include <cstddef>
template <class Refs>
class My_halfedge {
public:
typedef Refs HDS;
typedef My_halfedge<Refs> Base_base;
typedef My_halfedge<Refs> Base;
typedef My_halfedge<Refs> Self;
typedef typename Refs::Vertex_handle Vertex_handle;
typedef typename Refs::Vertex_const_handle Vertex_const_handle;
typedef typename Refs::Halfedge Halfedge;
typedef typename Refs::Halfedge_handle Halfedge_handle;
typedef typename Refs::Halfedge_const_handle Halfedge_const_handle;
typedef typename Refs::Face_handle Face_handle;
typedef typename Refs::Face_const_handle Face_const_handle;
private:
std::ptrdiff_t nxt;
public:
My_halfedge() : nxt(0), f( Face_handle()) {}
Halfedge_handle h = HDS::halfedge_handle(this);
if ( nxt & 1)
return HDS::halfedge_handle( &* h + 1);
return HDS::halfedge_handle( &* h - 1);
}
Halfedge_const_handle
opposite()
const {
Halfedge_const_handle h = HDS::halfedge_handle(this);
if ( nxt & 1)
return HDS::halfedge_handle( &* h + 1);
return HDS::halfedge_handle( &* h - 1);
}
return HDS::halfedge_handle((Halfedge*)(nxt & (~ std::ptrdiff_t(1))));
}
Halfedge_const_handle
next()
const {
return Halfedge_const_handle((const Halfedge*)(nxt &
(~ std::ptrdiff_t(1))));
}
void set_opposite( Halfedge_handle h) {
CGAL_precondition(( &* h - 1 == &* HDS::halfedge_handle(this)) ||
( &* h + 1 == &* HDS::halfedge_handle(this)));
if ( &* h - 1 == &* HDS::halfedge_handle(this))
nxt |= 1;
else
nxt &= (~ std::ptrdiff_t(1));
}
void set_next( Halfedge_handle h) {
CGAL_precondition( ((std::ptrdiff_t)(&*h) & 1) == 0);
nxt = ((std::ptrdiff_t)(&*h)) | (nxt & 1);
}
private:
Vertex_handle v;
public:
Vertex_handle vertex() { return v; }
Vertex_const_handle vertex() const { return v; }
void set_vertex( Vertex_handle w) { v = w; }
private:
Face_handle f;
public:
Face_handle face() { return f; }
Face_const_handle face() const { return f; }
void set_face( Face_handle g) { f = g; }
bool is_border() const { return f == Face_handle(); }
};
template <class Refs, class Traits>
struct Halfedge_wrapper {
typedef My_halfedge<Refs> Halfedge;
};
};
struct Traits { typedef int Point_2; };
int main() {
HDS hds;
Decorator decorator(hds);
decorator.create_loop();
CGAL_assertion( decorator.is_valid());
return 0;
}