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 Simplex_tree_boundary_simplex_iterator()
95 explicit Simplex_tree_boundary_simplex_iterator(SimplexTree
const* st)
103 template<
class SimplexHandle>
104 Simplex_tree_boundary_simplex_iterator(SimplexTree
const* st, SimplexHandle sh)
111 if constexpr (SimplexTree::Options::contiguous_vertices)
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) {
117 if constexpr (SimplexTree::Options::contiguous_vertices &&
118 !SimplexTree::Options::stable_simplex_handles)
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;
133 bool equal(Simplex_tree_boundary_simplex_iterator
const& other)
const {
134 return sh_ == other.sh_;
137 Simplex_handle
const& dereference()
const {
138 assert(sh_ != st_->null_simplex());
143 if (sib_ ==
nullptr) {
144 sh_ = st_->null_simplex();
148 Siblings
const* for_sib = sib_;
149 Siblings
const* new_sib = sib_->oncles();
150 auto rit = suffix_.rbegin();
151 if constexpr (SimplexTree::Options::contiguous_vertices && !SimplexTree::Options::stable_simplex_handles) {
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_;
184 SimplexTree
const* st_;
191class Simplex_tree_boundary_opposite_vertex_simplex_iterator :
public boost::iterator_facade<
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;
202 Simplex_tree_boundary_opposite_vertex_simplex_iterator()
208 explicit Simplex_tree_boundary_opposite_vertex_simplex_iterator(SimplexTree
const* st)
216 template<
class SimplexHandle>
217 Simplex_tree_boundary_opposite_vertex_simplex_iterator(SimplexTree
const* st, SimplexHandle sh)
224 if constexpr (SimplexTree::Options::contiguous_vertices)
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) {
230 if constexpr (SimplexTree::Options::contiguous_vertices &&
231 !SimplexTree::Options::stable_simplex_handles) {
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;
247 bool equal(Simplex_tree_boundary_opposite_vertex_simplex_iterator
const& other)
const {
248 return (baov_.first == other.baov_.first);
251 std::pair<Simplex_handle, Vertex_handle>
const& dereference()
const {
256 if (sib_ ==
nullptr) {
257 baov_.first = st_->null_simplex();
260 Siblings
const* for_sib = sib_;
261 Siblings
const* new_sib = sib_->oncles();
262 auto rit = suffix_.rbegin();
263 if constexpr (SimplexTree::Options::contiguous_vertices && !SimplexTree::Options::stable_simplex_handles) {
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_;
298 SimplexTree
const* st_;
306class Simplex_tree_complex_simplex_iterator :
public boost::iterator_facade<
307 Simplex_tree_complex_simplex_iterator<SimplexTree>,
308 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
315 Simplex_tree_complex_simplex_iterator()
320 explicit Simplex_tree_complex_simplex_iterator(SimplexTree
const* st)
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;
338 bool equal(Simplex_tree_complex_simplex_iterator
const& other)
const {
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();
364 while (st_->has_children(sh_)) {
365 sib_ = sh_->second.children();
366 sh_ = sib_->members().begin();
371 Siblings
const* sib_;
372 SimplexTree
const* st_;
380class Simplex_tree_skeleton_simplex_iterator :
public boost::iterator_facade<
381 Simplex_tree_skeleton_simplex_iterator<SimplexTree>,
382 typename SimplexTree::Simplex_handle const, boost::forward_traversal_tag> {
389 Simplex_tree_skeleton_simplex_iterator()
396 Simplex_tree_skeleton_simplex_iterator(SimplexTree
const* st,
int dim_skel)
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;
417 bool equal(Simplex_tree_skeleton_simplex_iterator
const& other)
const {
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();
452 Siblings
const* sib_;
453 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: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
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