11 #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ 12 #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ 14 #include <boost/iterator/iterator_facade.hpp> 20 namespace skeleton_blocker {
27 template<
typename SkeletonBlockerComplex>
28 class Vertex_iterator :
public boost::iterator_facade< Vertex_iterator <SkeletonBlockerComplex>
29 , typename SkeletonBlockerComplex::Vertex_handle const
30 , boost::forward_traversal_tag
31 , typename SkeletonBlockerComplex::Vertex_handle const> {
32 friend class boost::iterator_core_access;
34 typedef typename SkeletonBlockerComplex::boost_vertex_iterator boost_vertex_iterator;
35 typedef typename SkeletonBlockerComplex::Vertex_handle Vertex_handle;
37 const SkeletonBlockerComplex* complex;
38 std::pair<boost_vertex_iterator, boost_vertex_iterator> vertexIterator;
46 vertexIterator(vertices(complex_->skeleton)) {
47 if (!finished() && !is_active()) {
56 complex(complex_), vertexIterator(vertices(complex_->skeleton)) {
57 vertexIterator.first = vertexIterator.second;
65 Vertex_handle dereference()
const {
66 return (Vertex_handle(*(vertexIterator.first)));
70 return vertexIterator == other.vertexIterator && complex == other.complex;
74 return dereference() < other.dereference();
78 bool finished()
const {
79 return vertexIterator.first == vertexIterator.second;
82 void goto_next_valid() {
83 ++vertexIterator.first;
84 if (!finished() && !is_active()) {
89 bool is_active()
const {
90 return ((*complex)[Vertex_handle(*vertexIterator.first)]).is_active();
94 template<
typename SkeletonBlockerComplex>
95 class Neighbors_vertices_iterator :
public boost::iterator_facade < Neighbors_vertices_iterator<SkeletonBlockerComplex>
96 , typename SkeletonBlockerComplex::Vertex_handle const
97 , boost::forward_traversal_tag
98 , typename SkeletonBlockerComplex::Vertex_handle const> {
99 friend class boost::iterator_core_access;
101 typedef SkeletonBlockerComplex Complex;
102 typedef typename Complex::boost_adjacency_iterator boost_adjacency_iterator;
103 typedef typename Complex::Vertex_handle Vertex_handle;
104 typedef typename Complex::Edge_handle Edge_handle;
107 const Complex* complex;
110 boost_adjacency_iterator current_;
111 boost_adjacency_iterator end_;
114 Neighbors_vertices_iterator() : complex(NULL) { }
116 Neighbors_vertices_iterator(
const Complex* complex_, Vertex_handle v_) :
119 tie(current_, end_) = adjacent_vertices(v.vertex, complex->skeleton);
125 Neighbors_vertices_iterator(
const Complex* complex_, Vertex_handle v_,
int end) :
128 tie(current_, end_) = adjacent_vertices(v.vertex, complex->skeleton);
133 if (current_ != end_)
137 Vertex_handle dereference()
const {
138 return (Vertex_handle(*current_));
141 bool equal(
const Neighbors_vertices_iterator& other)
const {
142 return (complex == other.complex) && (v == other.v) && (current_ == other.current_) && (end_ == other.end_);
154 namespace skbl = skeleton_blocker;
158 #endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ Iterator on the vertices of a simplicial complex.
Definition: Skeleton_blockers_vertices_iterators.h:28
Definition: SimplicialComplexForAlpha.h:14
Vertex_iterator(const SkeletonBlockerComplex *complex_, int end)
Definition: Skeleton_blockers_vertices_iterators.h:55