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> 
   18#include <boost/container/static_vector.hpp> 
   34template<
class SimplexTree>
 
   36    Simplex_tree_simplex_vertex_iterator<SimplexTree>,
 
   37    typename SimplexTree::Vertex_handle const, boost::forward_traversal_tag,
 
   38    typename SimplexTree::Vertex_handle const> {
 
   56  friend class boost::iterator_core_access;
 
   59    return sib_ == other.sib_ && v_ == other.v_;
 
   68    sib_ = sib_->oncles();
 
   80template<
class SimplexTree>
 
   82    Simplex_tree_boundary_simplex_iterator<SimplexTree>,
 
   83    typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
 
  104  template<
class SimplexHandle>
 
  112    if (SimplexTree::Options::contiguous_vertices)
 
  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) {
 
  118      if (SimplexTree::Options::contiguous_vertices && sib_->oncles() == 
nullptr)
 
  120        sh_ = sib_->members_.begin()+next_;
 
  122        sh_ = sib_->find(next_);
 
  127  friend class boost::iterator_core_access;
 
  130    return sh_ == other.sh_;
 
  133  Simplex_handle 
const& dereference()
 const {
 
  139    if (sib_ == 
nullptr) {
 
  145    Siblings * new_sib = sib_->oncles();
 
  146    auto rit = suffix_.rbegin();
 
  147    if (SimplexTree::Options::contiguous_vertices && new_sib == 
nullptr) {
 
  149      if (rit == suffix_.rend()) {
 
  151        sh_ = for_sib->members_.begin()+last_;
 
  156        sh_ = for_sib->members_.begin()+*rit;
 
  157        for_sib = sh_->second.children();
 
  161    for (; rit != suffix_.rend(); ++rit) {
 
  162      sh_ = for_sib->find(*rit);
 
  163      for_sib = sh_->second.children();
 
  165    sh_ = for_sib->find(last_);  
 
  166    suffix_.push_back(next_);
 
  167    next_ = sib_->parent();
 
  176  boost::container::static_vector<Vertex_handle, 40> suffix_;
 
  187template<
class SimplexTree>
 
  189    Simplex_tree_boundary_opposite_vertex_simplex_iterator<SimplexTree>,
 
  190    std::pair<typename SimplexTree::Simplex_handle, typename SimplexTree::Vertex_handle> const, boost::forward_traversal_tag> {
 
  212  template<
class SimplexHandle>
 
  220    if (SimplexTree::Options::contiguous_vertices)
 
  221      GUDHI_CHECK(st_->contiguous_vertices(), 
"The set of vertices is not { 0, ..., n } without holes");
 
  223    next_ = sib->parent();
 
  224    sib_ = sib->oncles();
 
  225    if (sib_ != 
nullptr) {
 
  226      if (SimplexTree::Options::contiguous_vertices && sib_->oncles() == 
nullptr)
 
  228        baov_.first = sib_->members_.begin()+next_;
 
  230        baov_.first = sib_->find(next_);
 
  235  friend class boost::iterator_core_access;
 
  239    return (baov_.first == other.baov_.first);
 
  242  std::pair<Simplex_handle, Vertex_handle> 
const& dereference()
 const {
 
  247    if (sib_ == 
nullptr) {
 
  251    Siblings * for_sib = sib_;
 
  252    Siblings * new_sib = sib_->oncles();
 
  253    auto rit = suffix_.rbegin();
 
  254    if (SimplexTree::Options::contiguous_vertices && new_sib == 
nullptr) {
 
  256      if (rit == suffix_.rend()) {
 
  257        baov_.second = baov_.first->first;
 
  259        baov_.first = for_sib->members_.begin()+last_;
 
  264        baov_.first = for_sib->members_.begin()+*rit;
 
  265        for_sib = baov_.first->second.children();
 
  269    for (; rit != suffix_.rend(); ++rit) {
 
  270      baov_.first = for_sib->find(*rit);
 
  271      for_sib = baov_.first->second.children();
 
  273    baov_.first = for_sib->find(last_);  
 
  274    suffix_.push_back(next_);
 
  275    next_ = sib_->parent();
 
  277    baov_.second = suffix_.back();
 
  285  boost::container::static_vector<Vertex_handle, 40> suffix_;
 
  289  std::pair<Simplex_handle, Vertex_handle> baov_;  
 
  297template<
class SimplexTree>
 
  299    Simplex_tree_complex_simplex_iterator<SimplexTree>,
 
  300    typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
 
  315    if (st == 
nullptr || st->
root() == 
nullptr || st->
root()->members().empty()) {
 
  318      sh_ = st->
root()->members().begin();
 
  321        sib_ = sh_->second.children();
 
  322        sh_ = sib_->members().begin();
 
  327  friend class boost::iterator_core_access;
 
  331    if (other.st_ == 
nullptr) {
 
  332      return (st_ == 
nullptr);
 
  334    if (st_ == 
nullptr) {
 
  337    return (&(sh_->second) == &(other.sh_->second));
 
  340  Simplex_handle 
const& dereference()
 const {
 
  347    if (sh_ == sib_->members().end()) {
 
  348      if (sib_->oncles() == 
nullptr) {
 
  352      sh_ = sib_->oncles()->members().find(sib_->parent());
 
  353      sib_ = sib_->oncles();
 
  357      sib_ = sh_->second.children();
 
  358      sh_ = sib_->members().begin();
 
  371template<
class SimplexTree>
 
  373    Simplex_tree_skeleton_simplex_iterator<SimplexTree>,
 
  374    typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
 
  393    if (st == 
nullptr || st->
root() == 
nullptr || st->
root()->members().empty()) {
 
  396      sh_ = st->
root()->members().begin();
 
  398      while (st->
has_children(sh_) && curr_dim_ < dim_skel_) {
 
  399        sib_ = sh_->second.children();
 
  400        sh_ = sib_->members().begin();
 
  406  friend class boost::iterator_core_access;
 
  410    if (other.st_ == 
nullptr) {
 
  411      return (st_ == 
nullptr);
 
  413    if (st_ == 
nullptr) {
 
  416    return (&(sh_->second) == &(other.sh_->second));
 
  419  Simplex_handle 
const& dereference()
 const {
 
  426    if (sh_ == sib_->members().end()) {
 
  427      if (sib_->oncles() == 
nullptr) {
 
  431      sh_ = sib_->oncles()->members().find(sib_->parent());
 
  432      sib_ = sib_->oncles();
 
  436    while (st_->
has_children(sh_) && curr_dim_ < dim_skel_) {
 
  437      sib_ = sh_->second.children();
 
  438      sh_ = sib_->members().begin();
 
Iterator over the simplices of the boundary of a simplex and their opposite vertices.
Definition: Simplex_tree_iterators.h:190
 
Iterator over the simplices of the boundary of a simplex.
Definition: Simplex_tree_iterators.h:83
 
Iterator over the simplices of a simplicial complex.
Definition: Simplex_tree_iterators.h:300
 
Iterator over the vertices of a simplex in a SimplexTree.
Definition: Simplex_tree_iterators.h:38
 
Iterator over the simplices of the skeleton of a given dimension of the simplicial complex.
Definition: Simplex_tree_iterators.h:374
 
Simplex Tree data structure for representing simplicial complexes.
Definition: Simplex_tree.h:83
 
static Siblings * self_siblings(SimplexHandle sh)
Definition: Simplex_tree.h:893
 
Dictionary::iterator Simplex_handle
Handle type to a simplex contained in the simplicial complex represented by the simplex tree.
Definition: Simplex_tree.h:156
 
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:571
 
bool has_children(SimplexHandle sh) const
Returns true if the node in the simplex tree pointed by sh has children.
Definition: Simplex_tree.h:637
 
Simplex_tree_siblings< Simplex_tree, Dictionary > Siblings
Set of nodes sharing a same parent in the simplex tree.
Definition: Simplex_tree.h:109
 
Options::Vertex_handle Vertex_handle
Type for the vertex handle.
Definition: Simplex_tree.h:98
 
Siblings * root()
Definition: Simplex_tree.h:902
 
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:560
 
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15