23 #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ 24 #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ 26 #include <boost/iterator/iterator_facade.hpp> 31 namespace skeleton_blocker {
38 template<
typename Complex,
typename LinkType>
40 < Triangle_around_vertex_iterator <Complex, LinkType>
41 , typename Complex::Simplex const
42 , boost::forward_traversal_tag
43 , typename Complex::Simplex const> {
44 friend class boost::iterator_core_access;
47 typedef typename LinkType::Vertex_handle Vertex_handle;
48 typedef typename LinkType::Root_vertex_handle Root_vertex_handle;
49 typedef typename LinkType::Simplex Simplex;
50 typedef typename Complex::Complex_edge_iterator Complex_edge_iterator_;
52 const Complex* complex_;
54 std::shared_ptr<LinkType> link_;
55 Complex_edge_iterator_ current_edge_;
60 complex_(complex), v_(v), link_(
new LinkType(*complex, v_)),
61 current_edge_(link_->edge_range().begin()),
62 is_end_(current_edge_ == link_->edge_range().end()) { }
68 complex_(complex), v_(v), link_(0), is_end_(true) { }
74 complex_(0), v_(-1), link_(0), is_end_(true) { }
78 complex_ = other.complex_;
79 is_end_ = other.is_end_;
83 current_edge_ = other.current_edge_;
88 return (complex_ == other.complex_) && ((finished() && other.finished()) || current_edge_ == other.current_edge_);
91 Simplex dereference()
const {
92 Root_vertex_handle v1 = (*link_)[*current_edge_].first();
93 Root_vertex_handle v2 = (*link_)[*current_edge_].second();
94 return Simplex(v_, *(complex_->get_address(v1)), *(complex_->get_address(v2)));
102 bool finished()
const {
103 return is_end_ || (current_edge_ == link_->edge_range().end());
113 template<
typename SkeletonBlockerComplex>
115 Triangle_iterator <SkeletonBlockerComplex>,
116 typename SkeletonBlockerComplex::Simplex const
117 , boost::forward_traversal_tag
118 , typename SkeletonBlockerComplex::Simplex const> {
119 friend class boost::iterator_core_access;
121 typedef typename SkeletonBlockerComplex::Vertex_handle Vertex_handle;
122 typedef typename SkeletonBlockerComplex::Root_vertex_handle Root_vertex_handle;
123 typedef typename SkeletonBlockerComplex::Simplex Simplex;
124 typedef typename SkeletonBlockerComplex::Superior_triangle_around_vertex_iterator STAVI;
125 typedef typename SkeletonBlockerComplex::Complex_vertex_iterator Complex_vertex_iterator;
127 const SkeletonBlockerComplex* complex_;
128 Complex_vertex_iterator current_vertex_;
129 STAVI current_triangle_;
138 current_vertex_(complex->vertex_range().begin()),
139 current_triangle_(complex, *current_vertex_),
141 assert(!complex->empty());
147 void gotoFirstTriangle() {
148 if (!is_finished() && current_triangle_.finished()) {
160 current_vertex_(complex->vertex_range().end()),
165 complex_ = other.complex_;
166 Complex_vertex_iterator current_vertex_;
167 STAVI current_triangle_;
172 bool both_are_finished = is_finished() && other.is_finished();
173 bool both_arent_finished = !is_finished() && !other.is_finished();
175 return (complex_ == other.complex_) && (both_are_finished || ((both_arent_finished) &&
176 current_vertex_ == other.current_vertex_ &&
177 current_triangle_ == other.current_triangle_));
180 Simplex dereference()
const {
181 return *current_triangle_;
187 void goto_next_vertex() {
189 assert(current_triangle_.finished());
191 assert(!is_finished());
195 if (!is_finished()) {
196 current_triangle_ = STAVI(complex_, *current_vertex_);
197 if (current_triangle_.finished())
204 if (!current_triangle_.finished()) {
206 if (current_triangle_.finished())
209 assert(!is_finished());
215 bool is_finished()
const {
216 return is_end_ || current_vertex_ == complex_->vertex_range().end();
222 namespace skbl = skeleton_blocker;
226 #endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ Triangle_around_vertex_iterator(const Complex *complex, Vertex_handle v, bool is_end)
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:67
Definition: SimplicialComplexForAlpha.h:26
Triangle_around_vertex_iterator()
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:73
Iterator over the triangles of the simplicial complex.
Definition: Skeleton_blockers_triangles_iterators.h:114
Iterator over the triangles that are adjacent to a vertex of the simplicial complex.
Definition: Skeleton_blockers_triangles_iterators.h:39
Triangle_iterator(const SkeletonBlockerComplex *complex, bool is_end)
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:158