11 #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ 12 #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ 14 #include <boost/iterator/iterator_facade.hpp> 19 namespace skeleton_blocker {
26 template<
typename Complex,
typename LinkType>
28 < Triangle_around_vertex_iterator <Complex, LinkType>
29 , typename Complex::Simplex const
30 , boost::forward_traversal_tag
31 , typename Complex::Simplex const> {
32 friend class boost::iterator_core_access;
35 typedef typename LinkType::Vertex_handle Vertex_handle;
36 typedef typename LinkType::Root_vertex_handle Root_vertex_handle;
37 typedef typename LinkType::Simplex Simplex;
38 typedef typename Complex::Complex_edge_iterator Complex_edge_iterator_;
40 const Complex* complex_;
42 std::shared_ptr<LinkType> link_;
43 Complex_edge_iterator_ current_edge_;
48 complex_(complex), v_(v), link_(
new LinkType(*complex, v_)),
49 current_edge_(link_->edge_range().begin()),
50 is_end_(current_edge_ == link_->edge_range().end()) { }
56 complex_(complex), v_(v), link_(0), is_end_(true) { }
62 complex_(0), v_(-1), link_(0), is_end_(true) { }
66 complex_ = other.complex_;
67 is_end_ = other.is_end_;
71 current_edge_ = other.current_edge_;
76 return (complex_ == other.complex_) && ((finished() && other.finished()) || current_edge_ == other.current_edge_);
79 Simplex dereference()
const {
80 Root_vertex_handle v1 = (*link_)[*current_edge_].first();
81 Root_vertex_handle v2 = (*link_)[*current_edge_].second();
82 return Simplex(v_, *(complex_->get_address(v1)), *(complex_->get_address(v2)));
90 bool finished()
const {
91 return is_end_ || (current_edge_ == link_->edge_range().end());
101 template<
typename SkeletonBlockerComplex>
103 Triangle_iterator <SkeletonBlockerComplex>,
104 typename SkeletonBlockerComplex::Simplex const
105 , boost::forward_traversal_tag
106 , typename SkeletonBlockerComplex::Simplex const> {
107 friend class boost::iterator_core_access;
109 typedef typename SkeletonBlockerComplex::Vertex_handle Vertex_handle;
110 typedef typename SkeletonBlockerComplex::Root_vertex_handle Root_vertex_handle;
111 typedef typename SkeletonBlockerComplex::Simplex Simplex;
112 typedef typename SkeletonBlockerComplex::Superior_triangle_around_vertex_iterator STAVI;
113 typedef typename SkeletonBlockerComplex::Complex_vertex_iterator Complex_vertex_iterator;
115 const SkeletonBlockerComplex* complex_;
116 Complex_vertex_iterator current_vertex_;
117 STAVI current_triangle_;
126 current_vertex_(complex->vertex_range().begin()),
127 current_triangle_(complex, *current_vertex_),
129 assert(!complex->empty());
135 void gotoFirstTriangle() {
136 if (!is_finished() && current_triangle_.finished()) {
148 current_vertex_(complex->vertex_range().end()),
153 complex_ = other.complex_;
154 Complex_vertex_iterator current_vertex_;
155 STAVI current_triangle_;
160 bool both_are_finished = is_finished() && other.is_finished();
161 bool both_arent_finished = !is_finished() && !other.is_finished();
163 return (complex_ == other.complex_) && (both_are_finished || ((both_arent_finished) &&
164 current_vertex_ == other.current_vertex_ &&
165 current_triangle_ == other.current_triangle_));
168 Simplex dereference()
const {
169 return *current_triangle_;
175 void goto_next_vertex() {
177 assert(current_triangle_.finished());
179 assert(!is_finished());
183 if (!is_finished()) {
184 current_triangle_ = STAVI(complex_, *current_vertex_);
185 if (current_triangle_.finished())
192 if (!current_triangle_.finished()) {
194 if (current_triangle_.finished())
197 assert(!is_finished());
203 bool is_finished()
const {
204 return is_end_ || current_vertex_ == complex_->vertex_range().end();
210 namespace skbl = skeleton_blocker;
214 #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:55
Definition: SimplicialComplexForAlpha.h:14
Triangle_around_vertex_iterator()
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:61
Iterator over the triangles of the simplicial complex.
Definition: Skeleton_blockers_triangles_iterators.h:102
Iterator over the triangles that are adjacent to a vertex of the simplicial complex.
Definition: Skeleton_blockers_triangles_iterators.h:27
Triangle_iterator(const SkeletonBlockerComplex *complex, bool is_end)
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:146