22 #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_
23 #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_
25 #include <boost/iterator/iterator_facade.hpp>
37 template<
typename Complex,
typename LinkType>
39 < Triangle_around_vertex_iterator <Complex, LinkType>
40 , typename Complex::Simplex_handle const
41 , boost::forward_traversal_tag
42 , typename Complex::Simplex_handle const> {
43 friend class boost::iterator_core_access;
46 typedef typename LinkType::Vertex_handle Vertex_handle;
47 typedef typename LinkType::Root_vertex_handle Root_vertex_handle;
48 typedef typename LinkType::Simplex_handle Simplex_handle;
53 std::shared_ptr<LinkType> link_;
59 complex_(complex), v_(v), link_(
new LinkType(*complex, v_)),
60 current_edge_(link_->edge_range().begin()),
61 is_end_(current_edge_ == link_->edge_range().end()) { }
67 complex_(complex), v_(v), link_(0), is_end_(true) { }
73 complex_(0), v_(-1), link_(0), is_end_(true) { }
77 complex_ = other.complex_;
78 is_end_ = other.is_end_;
82 current_edge_ = other.current_edge_;
87 return (complex_ == other.complex_) && ((finished() && other.finished()) || current_edge_ == other.current_edge_);
101 bool finished()
const {
102 return is_end_ || (current_edge_ == link_->edge_range().end());
112 template<
typename SkeletonBlockerComplex>
114 Triangle_iterator <SkeletonBlockerComplex>,
115 typename SkeletonBlockerComplex::Simplex_handle const
116 , boost::forward_traversal_tag
117 , typename SkeletonBlockerComplex::Simplex_handle const> {
118 friend class boost::iterator_core_access;
120 typedef typename SkeletonBlockerComplex::Vertex_handle Vertex_handle;
121 typedef typename SkeletonBlockerComplex::Root_vertex_handle Root_vertex_handle;
122 typedef typename SkeletonBlockerComplex::Simplex_handle Simplex_handle;
123 typedef typename SkeletonBlockerComplex::Superior_triangle_around_vertex_iterator STAVI;
124 typedef typename SkeletonBlockerComplex::Complex_vertex_iterator Complex_vertex_iterator;
126 const SkeletonBlockerComplex* complex_;
127 Complex_vertex_iterator current_vertex_;
128 STAVI current_triangle_;
137 current_vertex_(complex->vertex_range().begin()),
138 current_triangle_(complex, *current_vertex_),
140 assert(!complex->empty());
146 void gotoFirstTriangle() {
147 if (!is_finished() && current_triangle_.finished()) {
159 current_vertex_(complex->vertex_range().end()),
164 complex_ = other.complex_;
165 Complex_vertex_iterator current_vertex_;
166 STAVI current_triangle_;
170 bool equal(
const Triangle_iterator& other)
const {
171 bool both_are_finished = is_finished() && other.is_finished();
172 bool both_arent_finished = !is_finished() && !other.is_finished();
174 return (complex_ == other.complex_) && (both_are_finished || ((both_arent_finished) &&
175 current_vertex_ == other.current_vertex_ && current_triangle_ == other.current_triangle_));
179 return *current_triangle_;
185 void goto_next_vertex() {
186 assert(current_triangle_.finished());
187 assert(!is_finished());
191 if (!is_finished()) {
192 current_triangle_ = STAVI(complex_, *current_vertex_);
193 if (current_triangle_.finished())
200 if (!current_triangle_.finished()) {
202 if (current_triangle_.finished())
205 assert(!is_finished());
211 bool is_finished()
const {
212 return is_end_ || current_vertex_ == complex_->vertex_range().end();
220 #endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_
Triangle_iterator(const SkeletonBlockerComplex *complex, bool is_end)
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:157
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:66
Triangle_around_vertex_iterator()
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:72
virtual boost::optional< Vertex_handle > get_address(Root_vertex_handle id) const
Given an Id return the address of the vertex having this Id in the complex.
Definition: Skeleton_blocker_complex.h:441
Iterator over the triangles that are adjacent to a vertex of the simplicial complex.
Definition: Skeleton_blockers_triangles_iterators.h:38
Abstract simplex used in Skeleton blockers data-structure.
Definition: Skeleton_blocker_simplex.h:50
Iterator on the edges of a simplicial complex.
Definition: Skeleton_blockers_edges_iterators.h:96
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:113