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>
32template<
class SimplexTree>
34 Simplex_tree_simplex_vertex_iterator<SimplexTree>,
35 typename SimplexTree::Vertex_handle const, boost::forward_traversal_tag,
36 typename SimplexTree::Vertex_handle const> {
54 friend class boost::iterator_core_access;
57 return sib_ == other.sib_ && v_ == other.v_;
66 sib_ = sib_->oncles();
78template<
class SimplexTree>
80 Simplex_tree_boundary_simplex_iterator<SimplexTree>,
81 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
86 using Static_vertex_vector =
typename SimplexTree::Static_vertex_vector;
103 template<
class SimplexHandle>
112 GUDHI_CHECK(st_->contiguous_vertices(),
"The set of vertices is not { 0, ..., n } without holes");
114 next_ = sib->parent();
115 sib_ = sib->oncles();
116 if (sib_ !=
nullptr) {
120 if (sib_->oncles() ==
nullptr)
121 sh_ = sib_->members_.begin() + next_;
123 sh_ = sib_->find(next_);
125 sh_ = sib_->find(next_);
131 friend class boost::iterator_core_access;
134 return sh_ == other.sh_;
137 Simplex_handle
const& dereference()
const {
143 if (sib_ ==
nullptr) {
148 Siblings
const* for_sib = sib_;
149 Siblings
const* new_sib = sib_->oncles();
150 auto rit = suffix_.rbegin();
152 if (new_sib ==
nullptr) {
154 if (rit == suffix_.rend()) {
156 sh_ = for_sib->members_.begin() + last_;
161 sh_ = for_sib->members_.begin() + *rit;
162 for_sib = sh_->second.children();
168 for (; rit != suffix_.rend(); ++rit) {
169 sh_ = for_sib->find(*rit);
170 for_sib = sh_->second.children();
172 sh_ = for_sib->find(last_);
173 suffix_.push_back(next_);
174 next_ = sib_->parent();
181 Static_vertex_vector suffix_;
182 Siblings
const* sib_;
190template<
class SimplexTree>
192 Simplex_tree_boundary_opposite_vertex_simplex_iterator<SimplexTree>,
193 std::pair<typename SimplexTree::Simplex_handle, typename SimplexTree::Vertex_handle> const, boost::forward_traversal_tag> {
198 using Static_vertex_vector =
typename SimplexTree::Static_vertex_vector;
216 template<
class SimplexHandle>
225 GUDHI_CHECK(st_->contiguous_vertices(),
"The set of vertices is not { 0, ..., n } without holes");
227 next_ = sib->parent();
228 sib_ = sib->oncles();
229 if (sib_ !=
nullptr) {
232 if (sib_->oncles() ==
nullptr)
234 baov_.first = sib_->members_.begin() + next_;
236 baov_.first = sib_->find(next_);
238 baov_.first = sib_->find(next_);
244 friend class boost::iterator_core_access;
248 return (baov_.first == other.baov_.first);
251 std::pair<Simplex_handle, Vertex_handle>
const& dereference()
const {
256 if (sib_ ==
nullptr) {
260 Siblings
const* for_sib = sib_;
261 Siblings
const* new_sib = sib_->oncles();
262 auto rit = suffix_.rbegin();
264 if (new_sib ==
nullptr) {
266 if (rit == suffix_.rend()) {
267 baov_.second = baov_.first->first;
269 baov_.first = for_sib->members_.begin() + last_;
274 baov_.first = for_sib->members_.begin() + *rit;
275 for_sib = baov_.first->second.children();
281 for (; rit != suffix_.rend(); ++rit) {
282 baov_.first = for_sib->find(*rit);
283 for_sib = baov_.first->second.children();
285 baov_.first = for_sib->find(last_);
286 suffix_.push_back(next_);
287 next_ = sib_->parent();
289 baov_.second = suffix_.back();
295 Static_vertex_vector suffix_;
296 Siblings
const* sib_;
297 std::pair<Simplex_handle, Vertex_handle> baov_;
305template<
class SimplexTree>
307 Simplex_tree_complex_simplex_iterator<SimplexTree>,
308 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
323 if (st ==
nullptr || st->
root() ==
nullptr || st->
root()->members().empty()) {
326 sh_ = st->
root()->members().begin();
329 sib_ = sh_->second.children();
330 sh_ = sib_->members().begin();
335 friend class boost::iterator_core_access;
339 if (other.st_ ==
nullptr) {
340 return (st_ ==
nullptr);
342 if (st_ ==
nullptr) {
345 return (&(sh_->second) == &(other.sh_->second));
348 Simplex_handle
const& dereference()
const {
355 if (sh_ == sib_->members().end()) {
356 if (sib_->oncles() ==
nullptr) {
360 sh_ = sib_->oncles()->members().find(sib_->parent());
361 sib_ = sib_->oncles();
365 sib_ = sh_->second.children();
366 sh_ = sib_->members().begin();
379template<
class SimplexTree>
381 Simplex_tree_skeleton_simplex_iterator<SimplexTree>,
382 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
401 if (st ==
nullptr || st->
root() ==
nullptr || st->
root()->members().empty()) {
404 sh_ = st->
root()->members().begin();
406 while (st->
has_children(sh_) && curr_dim_ < dim_skel_) {
407 sib_ = sh_->second.children();
408 sh_ = sib_->members().begin();
414 friend class boost::iterator_core_access;
418 if (other.st_ ==
nullptr) {
419 return (st_ ==
nullptr);
421 if (st_ ==
nullptr) {
424 return (&(sh_->second) == &(other.sh_->second));
427 Simplex_handle
const& dereference()
const {
434 if (sh_ == sib_->members().end()) {
435 if (sib_->oncles() ==
nullptr) {
439 sh_ = sib_->oncles()->members().find(sib_->parent());
440 sib_ = sib_->oncles();
444 while (st_->
has_children(sh_) && curr_dim_ < dim_skel_) {
445 sib_ = sh_->second.children();
446 sh_ = sib_->members().begin();
Iterator over the simplices of the boundary of a simplex and their opposite vertices.
Definition: Simplex_tree_iterators.h:193
Iterator over the simplices of the boundary of a simplex.
Definition: Simplex_tree_iterators.h:81
Iterator over the simplices of a simplicial complex.
Definition: Simplex_tree_iterators.h:308
Iterator over the vertices of a simplex in a SimplexTree.
Definition: Simplex_tree_iterators.h:36
Iterator over the simplices of the skeleton of a given dimension of the simplicial complex.
Definition: Simplex_tree_iterators.h:382
Simplex Tree data structure for representing simplicial complexes.
Definition: Simplex_tree.h:98
Siblings const * self_siblings(SimplexHandle sh) const
Definition: Simplex_tree.h:1154
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:773
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:874
Dictionary::const_iterator Simplex_handle
Handle type to a simplex contained in the simplicial complex represented by the simplex tree.
Definition: Simplex_tree.h:192
Simplex_tree_siblings< Simplex_tree, Dictionary > Siblings
Set of nodes sharing a same parent in the simplex tree.
Definition: Simplex_tree.h:136
Options::Vertex_handle Vertex_handle
Type for the vertex handle.
Definition: Simplex_tree.h:119
Siblings * root()
Definition: Simplex_tree.h:1171
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:748
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:41
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:37
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15