23 #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ 24 #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ 26 #include <boost/iterator/iterator_facade.hpp> 32 namespace skeleton_blocker {
39 template<
typename SkeletonBlockerComplex>
40 class Vertex_iterator :
public boost::iterator_facade< Vertex_iterator <SkeletonBlockerComplex>
41 , typename SkeletonBlockerComplex::Vertex_handle const
42 , boost::forward_traversal_tag
43 , typename SkeletonBlockerComplex::Vertex_handle const> {
44 friend class boost::iterator_core_access;
46 typedef typename SkeletonBlockerComplex::boost_vertex_iterator boost_vertex_iterator;
47 typedef typename SkeletonBlockerComplex::Vertex_handle Vertex_handle;
49 const SkeletonBlockerComplex* complex;
50 std::pair<boost_vertex_iterator, boost_vertex_iterator> vertexIterator;
58 vertexIterator(vertices(complex_->skeleton)) {
59 if (!finished() && !is_active()) {
68 complex(complex_), vertexIterator(vertices(complex_->skeleton)) {
69 vertexIterator.first = vertexIterator.second;
77 Vertex_handle dereference()
const {
78 return (Vertex_handle(*(vertexIterator.first)));
82 return vertexIterator == other.vertexIterator && complex == other.complex;
86 return dereference() < other.dereference();
90 bool finished()
const {
91 return vertexIterator.first == vertexIterator.second;
94 void goto_next_valid() {
95 ++vertexIterator.first;
96 if (!finished() && !is_active()) {
101 bool is_active()
const {
102 return ((*complex)[Vertex_handle(*vertexIterator.first)]).is_active();
106 template<
typename SkeletonBlockerComplex>
107 class Neighbors_vertices_iterator :
public boost::iterator_facade < Neighbors_vertices_iterator<SkeletonBlockerComplex>
108 , typename SkeletonBlockerComplex::Vertex_handle const
109 , boost::forward_traversal_tag
110 , typename SkeletonBlockerComplex::Vertex_handle const> {
111 friend class boost::iterator_core_access;
113 typedef SkeletonBlockerComplex Complex;
114 typedef typename Complex::boost_adjacency_iterator boost_adjacency_iterator;
115 typedef typename Complex::Vertex_handle Vertex_handle;
116 typedef typename Complex::Edge_handle Edge_handle;
119 const Complex* complex;
122 boost_adjacency_iterator current_;
123 boost_adjacency_iterator end_;
126 Neighbors_vertices_iterator() : complex(NULL) { }
128 Neighbors_vertices_iterator(
const Complex* complex_, Vertex_handle v_) :
131 tie(current_, end_) = adjacent_vertices(v.vertex, complex->skeleton);
137 Neighbors_vertices_iterator(
const Complex* complex_, Vertex_handle v_,
int end) :
140 tie(current_, end_) = adjacent_vertices(v.vertex, complex->skeleton);
145 if (current_ != end_)
149 Vertex_handle dereference()
const {
150 return (Vertex_handle(*current_));
153 bool equal(
const Neighbors_vertices_iterator& other)
const {
154 return (complex == other.complex) && (v == other.v) && (current_ == other.current_) && (end_ == other.end_);
166 namespace skbl = skeleton_blocker;
170 #endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ Iterator on the vertices of a simplicial complex.
Definition: Skeleton_blockers_vertices_iterators.h:40
Definition: SimplicialComplexForAlpha.h:26
Vertex_iterator(const SkeletonBlockerComplex *complex_, int end)
Definition: Skeleton_blockers_vertices_iterators.h:67