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;
42 std::shared_ptr<LinkType> link_;
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 {
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_;
159 bool equal(
const Triangle_iterator& other)
const {
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;
Iterator on the edges of a simplicial complex.
Definition: Skeleton_blockers_edges_iterators.h:88
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:432
Class that represents a geometric complex that can be simplified. The class allows access to points o...
Definition: Skeleton_blocker_geometric_complex.h:29
Iterator over the triangles that are adjacent to a vertex of the simplicial complex.
Definition: Skeleton_blockers_triangles_iterators.h:31
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
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:106
Triangle_iterator(const SkeletonBlockerComplex *complex, bool is_end)
ugly hack to get an iterator to the end
Definition: Skeleton_blockers_triangles_iterators.h:146
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor used in boost ...
Definition: SkeletonBlockerDS.h:47