22 #ifndef GUDHI_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_
23 #define GUDHI_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_
25 #include "boost/iterator/iterator_facade.hpp"
38 template<
typename Complex,
typename LinkType>
40 < Triangle_around_vertex_iterator <Complex,LinkType>
41 , typename Complex::Simplex_handle const
42 , boost::forward_traversal_tag
43 , typename Complex::Simplex_handle const
46 friend class boost::iterator_core_access;
49 typedef typename LinkType::Vertex_handle Vertex_handle;
50 typedef typename LinkType::Root_vertex_handle Root_vertex_handle;
51 typedef typename LinkType::Simplex_handle Simplex_handle;
54 const Complex* complex_;
56 std::shared_ptr<LinkType> link_;
61 complex_(complex),v_(v),link_(
new LinkType(*complex,v_)),
62 current_edge_(link_->edge_range().begin()),
63 is_end_(current_edge_ == link_->edge_range().end()){
70 complex_(complex),v_(v),link_(0),is_end_(true){
77 complex_(0),v_(-1),link_(0),is_end_(true){
83 complex_ = other.complex_;
84 is_end_ = other.is_end_;
88 current_edge_= other.current_edge_;
93 return (complex_==other.complex_) && ((finished() &&other.finished()) || current_edge_ == other.current_edge_);
96 Simplex_handle dereference()
const{
99 return Simplex_handle(v_,*(complex_->get_address(v1)),*(complex_->get_address(v2)));
107 bool finished()
const{
108 return is_end_ || (current_edge_ == link_->edge_range().end());
121 template<
typename SkeletonBlockerComplex>
123 public boost::iterator_facade<
124 Triangle_iterator <SkeletonBlockerComplex>,
125 typename SkeletonBlockerComplex::Simplex_handle const
126 , boost::forward_traversal_tag
127 , typename SkeletonBlockerComplex::Simplex_handle const
130 friend class boost::iterator_core_access;
132 typedef typename SkeletonBlockerComplex::Vertex_handle Vertex_handle;
133 typedef typename SkeletonBlockerComplex::Root_vertex_handle Root_vertex_handle;
134 typedef typename SkeletonBlockerComplex::Simplex_handle Simplex_handle;
135 typedef typename SkeletonBlockerComplex::Superior_triangle_around_vertex_iterator STAVI;
137 const SkeletonBlockerComplex* complex_;
139 STAVI current_triangle_;
148 current_vertex_(complex->vertex_range().begin()),
149 current_triangle_(complex,*current_vertex_),
152 assert(!complex->empty());
158 void gotoFirstTriangle(){
159 if(!is_finished() && current_triangle_.finished()){
171 current_vertex_(complex->vertex_range().end()),
178 complex_ = other.complex_;
180 STAVI current_triangle_;
185 bool equal(
const Triangle_iterator& other)
const{
186 bool both_are_finished = is_finished() && other.is_finished();
187 bool both_arent_finished = !is_finished() && !other.is_finished();
189 return (complex_==other.complex_) &&
190 (both_are_finished ||
191 ( (both_arent_finished) && current_vertex_ == other.current_vertex_ && current_triangle_ == other.current_triangle_));
195 Simplex_handle dereference()
const{
196 return *current_triangle_;
203 void goto_next_vertex(){
204 assert(current_triangle_.finished());
205 assert(!is_finished());
210 current_triangle_ = STAVI(complex_, *current_vertex_);
211 if(current_triangle_.finished())
217 if(!current_triangle_.finished()){
219 if(current_triangle_.finished())
223 assert(!is_finished());
229 bool is_finished()
const{
230 return is_end_ || current_vertex_ == complex_->vertex_range().end();
Triangle_iterator(const SkeletonBlockerComplex *complex, bool is_end)
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:169
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:69
Triangle_around_vertex_iterator()
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:76
Iterator over the triangles that are adjacent to a vertex of the simplicial complex.
Definition: Skeleton_blockers_triangles_iterators.h:39
Iterator on the vertices of a simplicial complex.
Definition: Skeleton_blockers_vertices_iterators.h:38
Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor used in boost ...
Definition: SkeletonBlockerDS.h:50
Iterator over the triangles of the simplicial complex.
Definition: Skeleton_blockers_triangles_iterators.h:122