12 #ifndef SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
13 #define SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
15 #include <gudhi/Debug_utils.h>
17 #include <boost/iterator/iterator_facade.hpp>
33 template<
class SimplexTree>
35 Simplex_tree_simplex_vertex_iterator<SimplexTree>,
36 typename SimplexTree::Vertex_handle const, boost::forward_traversal_tag,
37 typename SimplexTree::Vertex_handle const> {
55 friend class boost::iterator_core_access;
58 return sib_ == other.sib_ && v_ == other.v_;
67 sib_ = sib_->oncles();
79 template<
class SimplexTree>
81 Simplex_tree_boundary_simplex_iterator<SimplexTree>,
82 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
87 using Static_vertex_vector =
typename SimplexTree::Static_vertex_vector;
104 template<
class SimplexHandle>
113 GUDHI_CHECK(st_->contiguous_vertices(),
"The set of vertices is not { 0, ..., n } without holes");
115 next_ = sib->parent();
116 sib_ = sib->oncles();
117 if (sib_ !=
nullptr) {
121 if (sib_->oncles() ==
nullptr)
122 sh_ = sib_->members_.begin() + next_;
124 sh_ = sib_->find(next_);
126 sh_ = sib_->find(next_);
132 friend class boost::iterator_core_access;
135 return sh_ == other.sh_;
138 Simplex_handle
const& dereference()
const {
144 if (sib_ ==
nullptr) {
149 Siblings * for_sib = sib_;
150 Siblings * new_sib = sib_->oncles();
151 auto rit = suffix_.rbegin();
153 if (new_sib ==
nullptr) {
155 if (rit == suffix_.rend()) {
157 sh_ = for_sib->members_.begin() + last_;
162 sh_ = for_sib->members_.begin() + *rit;
163 for_sib = sh_->second.children();
169 for (; rit != suffix_.rend(); ++rit) {
170 sh_ = for_sib->find(*rit);
171 for_sib = sh_->second.children();
173 sh_ = for_sib->find(last_);
174 suffix_.push_back(next_);
175 next_ = sib_->parent();
182 Static_vertex_vector suffix_;
191 template<
class SimplexTree>
193 Simplex_tree_boundary_opposite_vertex_simplex_iterator<SimplexTree>,
194 std::pair<typename SimplexTree::Simplex_handle, typename SimplexTree::Vertex_handle> const, boost::forward_traversal_tag> {
199 using Static_vertex_vector =
typename SimplexTree::Static_vertex_vector;
217 template<
class SimplexHandle>
226 GUDHI_CHECK(st_->contiguous_vertices(),
"The set of vertices is not { 0, ..., n } without holes");
228 next_ = sib->parent();
229 sib_ = sib->oncles();
230 if (sib_ !=
nullptr) {
233 if (sib_->oncles() ==
nullptr)
235 baov_.first = sib_->members_.begin() + next_;
237 baov_.first = sib_->find(next_);
239 baov_.first = sib_->find(next_);
245 friend class boost::iterator_core_access;
249 return (baov_.first == other.baov_.first);
252 std::pair<Simplex_handle, Vertex_handle>
const& dereference()
const {
257 if (sib_ ==
nullptr) {
261 Siblings * for_sib = sib_;
262 Siblings * new_sib = sib_->oncles();
263 auto rit = suffix_.rbegin();
265 if (new_sib ==
nullptr) {
267 if (rit == suffix_.rend()) {
268 baov_.second = baov_.first->first;
270 baov_.first = for_sib->members_.begin() + last_;
275 baov_.first = for_sib->members_.begin() + *rit;
276 for_sib = baov_.first->second.children();
282 for (; rit != suffix_.rend(); ++rit) {
283 baov_.first = for_sib->find(*rit);
284 for_sib = baov_.first->second.children();
286 baov_.first = for_sib->find(last_);
287 suffix_.push_back(next_);
288 next_ = sib_->parent();
290 baov_.second = suffix_.back();
296 Static_vertex_vector suffix_;
298 std::pair<Simplex_handle, Vertex_handle> baov_;
306 template<
class SimplexTree>
308 Simplex_tree_complex_simplex_iterator<SimplexTree>,
309 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
324 if (st ==
nullptr || st->
root() ==
nullptr || st->
root()->members().empty()) {
327 sh_ = st->
root()->members().begin();
330 sib_ = sh_->second.children();
331 sh_ = sib_->members().begin();
336 friend class boost::iterator_core_access;
340 if (other.st_ ==
nullptr) {
341 return (st_ ==
nullptr);
343 if (st_ ==
nullptr) {
346 return (&(sh_->second) == &(other.sh_->second));
349 Simplex_handle
const& dereference()
const {
356 if (sh_ == sib_->members().end()) {
357 if (sib_->oncles() ==
nullptr) {
361 sh_ = sib_->oncles()->members().find(sib_->parent());
362 sib_ = sib_->oncles();
366 sib_ = sh_->second.children();
367 sh_ = sib_->members().begin();
380 template<
class SimplexTree>
382 Simplex_tree_skeleton_simplex_iterator<SimplexTree>,
383 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
402 if (st ==
nullptr || st->
root() ==
nullptr || st->
root()->members().empty()) {
405 sh_ = st->
root()->members().begin();
407 while (st->
has_children(sh_) && curr_dim_ < dim_skel_) {
408 sib_ = sh_->second.children();
409 sh_ = sib_->members().begin();
415 friend class boost::iterator_core_access;
419 if (other.st_ ==
nullptr) {
420 return (st_ ==
nullptr);
422 if (st_ ==
nullptr) {
425 return (&(sh_->second) == &(other.sh_->second));
428 Simplex_handle
const& dereference()
const {
435 if (sh_ == sib_->members().end()) {
436 if (sib_->oncles() ==
nullptr) {
440 sh_ = sib_->oncles()->members().find(sib_->parent());
441 sib_ = sib_->oncles();
445 while (st_->
has_children(sh_) && curr_dim_ < dim_skel_) {
446 sib_ = sh_->second.children();
447 sh_ = sib_->members().begin();
Iterator over the simplices of the boundary of a simplex and their opposite vertices.
Definition: Simplex_tree_iterators.h:194
Iterator over the simplices of the boundary of a simplex.
Definition: Simplex_tree_iterators.h:82
Iterator over the simplices of a simplicial complex.
Definition: Simplex_tree_iterators.h:309
Iterator over the vertices of a simplex in a SimplexTree.
Definition: Simplex_tree_iterators.h:37
Iterator over the simplices of the skeleton of a given dimension of the simplicial complex.
Definition: Simplex_tree_iterators.h:383
Simplex Tree data structure for representing simplicial complexes.
Definition: Simplex_tree.h:95
Dictionary::iterator Simplex_handle
Handle type to a simplex contained in the simplicial complex represented by the simplex tree.
Definition: Simplex_tree.h:175
Vertex_handle null_vertex() const
Returns a Vertex_handle different from all Vertex_handles associated to the vertices of the simplicia...
Definition: Simplex_tree.h:646
bool has_children(SimplexHandle sh) const
Returns true if the node in the simplex tree pointed by the given simplex handle has children.
Definition: Simplex_tree.h:742
Siblings * root()
Definition: Simplex_tree.h:1032
Simplex_tree_siblings< Simplex_tree, Dictionary > Siblings
Set of nodes sharing a same parent in the simplex tree.
Definition: Simplex_tree.h:127
Options::Vertex_handle Vertex_handle
Type for the vertex handle.
Definition: Simplex_tree.h:110
static Siblings * self_siblings(SimplexHandle sh)
Definition: Simplex_tree.h:1023
static Simplex_handle null_simplex()
Returns a Simplex_handle different from all Simplex_handles associated to the simplices in the simpli...
Definition: Simplex_tree.h:635
Gudhi namespace.
Definition: SimplicialComplexForAlpha.h:14
static const bool stable_simplex_handles
If true, Simplex_handle will not be invalidated after insertions or removals.
Definition: SimplexTreeOptions.h:39
static constexpr bool contiguous_vertices
If true, the list of vertices present in the complex must always be 0, ..., num_vertices-1,...
Definition: SimplexTreeOptions.h:35
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15