#include <CGAL/HalfedgeDS_items_2.h>
#include <CGAL/HalfedgeDS_list.h>
#include <CGAL/HalfedgeDS_decorator.h>
#include <cstddef>
#include <cassert>
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( std::next(&*h) );
return HDS::halfedge_handle( std::prev(&*h));
}
Halfedge_const_handle
opposite()
const {
Halfedge_const_handle h = HDS::halfedge_handle(this);
if ( nxt & 1)
return HDS::halfedge_handle( std::next(&*h));
return HDS::halfedge_handle( std::prev(&*h));
}
Halfedge_handle next() {
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) {
assert(( std::prev(&*h) == &* HDS::halfedge_handle(this)) ||
( std::next(&*h)== &* HDS::halfedge_handle(this)));
if ( std::prev(&*h) == &* HDS::halfedge_handle(this))
nxt |= 1;
else
nxt &= (~ std::ptrdiff_t(1));
}
void set_next( Halfedge_handle h) {
assert( ((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();
assert( decorator.is_valid());
return 0;
}