33class Simplex_tree_simplex_vertex_iterator :
public boost::iterator_facade<
34 Simplex_tree_simplex_vertex_iterator<SimplexTree>,
35 typename SimplexTree::Vertex_handle const, boost::forward_traversal_tag,
36 typename SimplexTree::Vertex_handle const> {
42 explicit Simplex_tree_simplex_vertex_iterator(SimplexTree
const* st)
48 Simplex_tree_simplex_vertex_iterator(SimplexTree
const* st, Simplex_handle sh)
54 friend class boost::iterator_core_access;
56 bool equal(Simplex_tree_simplex_vertex_iterator
const &other)
const {
57 return sib_ == other.sib_ && v_ == other.v_;
60 Vertex_handle
const& dereference()
const {
66 sib_ = sib_->oncles();
79class Simplex_tree_boundary_simplex_iterator :
public boost::iterator_facade<
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;
89 explicit Simplex_tree_boundary_simplex_iterator(SimplexTree
const* st)
97 template<
class SimplexHandle>
98 Simplex_tree_boundary_simplex_iterator(SimplexTree
const* st, SimplexHandle sh)
105 if constexpr (SimplexTree::Options::contiguous_vertices)
106 GUDHI_CHECK(st_->contiguous_vertices(),
"The set of vertices is not { 0, ..., n } without holes");
108 next_ = sib->parent();
109 sib_ = sib->oncles();
110 if (sib_ !=
nullptr) {
111 if constexpr (SimplexTree::Options::contiguous_vertices &&
112 !SimplexTree::Options::stable_simplex_handles)
114 if (sib_->oncles() ==
nullptr)
115 sh_ = sib_->members_.begin() + next_;
117 sh_ = sib_->find(next_);
119 sh_ = sib_->find(next_);
125 friend class boost::iterator_core_access;
127 bool equal(Simplex_tree_boundary_simplex_iterator
const& other)
const {
128 return sh_ == other.sh_;
131 Simplex_handle
const& dereference()
const {
132 assert(sh_ != st_->null_simplex());
137 if (sib_ ==
nullptr) {
138 sh_ = st_->null_simplex();
142 Siblings
const* for_sib = sib_;
143 Siblings
const* new_sib = sib_->oncles();
144 auto rit = suffix_.rbegin();
145 if constexpr (SimplexTree::Options::contiguous_vertices && !SimplexTree::Options::stable_simplex_handles) {
146 if (new_sib ==
nullptr) {
148 if (rit == suffix_.rend()) {
150 sh_ = for_sib->members_.begin() + last_;
155 sh_ = for_sib->members_.begin() + *rit;
156 for_sib = sh_->second.children();
162 for (; rit != suffix_.rend(); ++rit) {
163 sh_ = for_sib->find(*rit);
164 for_sib = sh_->second.children();
166 sh_ = for_sib->find(last_);
167 suffix_.push_back(next_);
168 next_ = sib_->parent();
175 Static_vertex_vector suffix_;
176 Siblings
const* sib_;
178 SimplexTree
const* st_;
185class Simplex_tree_boundary_opposite_vertex_simplex_iterator :
public boost::iterator_facade<
186 Simplex_tree_boundary_opposite_vertex_simplex_iterator<SimplexTree>,
187 std::pair<typename SimplexTree::Simplex_handle, typename SimplexTree::Vertex_handle> const, boost::forward_traversal_tag> {
192 using Static_vertex_vector =
typename SimplexTree::Static_vertex_vector;
195 explicit Simplex_tree_boundary_opposite_vertex_simplex_iterator(SimplexTree
const* st)
203 template<
class SimplexHandle>
204 Simplex_tree_boundary_opposite_vertex_simplex_iterator(SimplexTree
const* st, SimplexHandle sh)
211 if constexpr (SimplexTree::Options::contiguous_vertices)
212 GUDHI_CHECK(st_->contiguous_vertices(),
"The set of vertices is not { 0, ..., n } without holes");
214 next_ = sib->parent();
215 sib_ = sib->oncles();
216 if (sib_ !=
nullptr) {
217 if constexpr (SimplexTree::Options::contiguous_vertices &&
218 !SimplexTree::Options::stable_simplex_handles) {
219 if (sib_->oncles() ==
nullptr)
221 baov_.first = sib_->members_.begin() + next_;
223 baov_.first = sib_->find(next_);
225 baov_.first = sib_->find(next_);
231 friend class boost::iterator_core_access;
234 bool equal(Simplex_tree_boundary_opposite_vertex_simplex_iterator
const& other)
const {
235 return (baov_.first == other.baov_.first);
238 std::pair<Simplex_handle, Vertex_handle>
const& dereference()
const {
243 if (sib_ ==
nullptr) {
244 baov_.first = st_->null_simplex();
247 Siblings
const* for_sib = sib_;
248 Siblings
const* new_sib = sib_->oncles();
249 auto rit = suffix_.rbegin();
250 if constexpr (SimplexTree::Options::contiguous_vertices && !SimplexTree::Options::stable_simplex_handles) {
251 if (new_sib ==
nullptr) {
253 if (rit == suffix_.rend()) {
254 baov_.second = baov_.first->first;
256 baov_.first = for_sib->members_.begin() + last_;
261 baov_.first = for_sib->members_.begin() + *rit;
262 for_sib = baov_.first->second.children();
268 for (; rit != suffix_.rend(); ++rit) {
269 baov_.first = for_sib->find(*rit);
270 for_sib = baov_.first->second.children();
272 baov_.first = for_sib->find(last_);
273 suffix_.push_back(next_);
274 next_ = sib_->parent();
276 baov_.second = suffix_.back();
282 Static_vertex_vector suffix_;
283 Siblings
const* sib_;
284 std::pair<Simplex_handle, Vertex_handle> baov_;
285 SimplexTree
const* st_;
293class Simplex_tree_complex_simplex_iterator :
public boost::iterator_facade<
294 Simplex_tree_complex_simplex_iterator<SimplexTree>,
295 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
302 Simplex_tree_complex_simplex_iterator()
307 explicit Simplex_tree_complex_simplex_iterator(SimplexTree
const* st)
310 if (st ==
nullptr || st->
root() ==
nullptr || st->
root()->members().empty()) {
313 sh_ = st->
root()->members().begin();
316 sib_ = sh_->second.children();
317 sh_ = sib_->members().begin();
322 friend class boost::iterator_core_access;
325 bool equal(Simplex_tree_complex_simplex_iterator
const& other)
const {
326 if (other.st_ ==
nullptr) {
327 return (st_ ==
nullptr);
329 if (st_ ==
nullptr) {
332 return (&(sh_->second) == &(other.sh_->second));
335 Simplex_handle
const& dereference()
const {
342 if (sh_ == sib_->members().end()) {
343 if (sib_->oncles() ==
nullptr) {
347 sh_ = sib_->oncles()->members().find(sib_->parent());
348 sib_ = sib_->oncles();
351 while (st_->has_children(sh_)) {
352 sib_ = sh_->second.children();
353 sh_ = sib_->members().begin();
358 Siblings
const* sib_;
359 SimplexTree
const* st_;
367class Simplex_tree_skeleton_simplex_iterator :
public boost::iterator_facade<
368 Simplex_tree_skeleton_simplex_iterator<SimplexTree>,
369 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
376 Simplex_tree_skeleton_simplex_iterator()
383 Simplex_tree_skeleton_simplex_iterator(SimplexTree
const* st,
int dim_skel)
388 if (st ==
nullptr || st->
root() ==
nullptr || st->
root()->members().empty()) {
391 sh_ = st->
root()->members().begin();
393 while (st->
has_children(sh_) && curr_dim_ < dim_skel_) {
394 sib_ = sh_->second.children();
395 sh_ = sib_->members().begin();
401 friend class boost::iterator_core_access;
404 bool equal(Simplex_tree_skeleton_simplex_iterator
const& other)
const {
405 if (other.st_ ==
nullptr) {
406 return (st_ ==
nullptr);
408 if (st_ ==
nullptr) {
411 return (&(sh_->second) == &(other.sh_->second));
414 Simplex_handle
const& dereference()
const {
421 if (sh_ == sib_->members().end()) {
422 if (sib_->oncles() ==
nullptr) {
426 sh_ = sib_->oncles()->members().find(sib_->parent());
427 sib_ = sib_->oncles();
431 while (st_->has_children(sh_) && curr_dim_ < dim_skel_) {
432 sib_ = sh_->second.children();
433 sh_ = sib_->members().begin();
439 Siblings
const* sib_;
440 SimplexTree
const* st_;
449class Simplex_tree_dimension_simplex_iterator :
public boost::iterator_facade<
450 Simplex_tree_dimension_simplex_iterator<SimplexTree>,
451 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
458 Simplex_tree_dimension_simplex_iterator()
465 Simplex_tree_dimension_simplex_iterator(SimplexTree
const* st,
int dim)
470 if (st ==
nullptr || st->
root() ==
nullptr || st->
root()->members().empty() ||
474 sh_ = st->
root()->members().begin();
478 if (curr_dim_ != dim_)
483 friend class boost::iterator_core_access;
486 bool equal(Simplex_tree_dimension_simplex_iterator
const& other)
const {
487 if (other.st_ ==
nullptr) {
488 return (st_ ==
nullptr);
490 if (st_ ==
nullptr) {
493 return (&(sh_->second) == &(other.sh_->second));
496 Simplex_handle
const& dereference()
const {
500 void until_leaf_or_dim() {
501 while (st_->has_children(sh_) && curr_dim_ != dim_) {
502 sib_ = sh_->second.children();
503 sh_ = sib_->members().begin();
507 std::clog <<
"Simplex_tree::dimension_simplex_range until_leaf_or_dim reached (";
508 for (
auto vertex : st_->simplex_vertex_range(sh_)) {
509 std::clog << vertex <<
",";
517 while (sh_ == sib_->members().end()) {
518 if (sib_->oncles() ==
nullptr) {
522 sh_ = sib_->oncles()->members().find(sib_->parent());
523 sib_ = sib_->oncles();
531 if (curr_dim_ != dim_)
536 Siblings
const* sib_;
537 SimplexTree
const* st_;
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:811
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:912
Dictionary::const_iterator Simplex_handle
Handle type to a simplex contained in the simplicial complex represented by the simplex tree.
Definition Simplex_tree.h:212
Simplex_tree_siblings< Simplex_tree, Dictionary > Siblings
Set of nodes sharing a same parent in the simplex tree.
Definition Simplex_tree.h:139
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:786