summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/include/gudhi/Simplex_tree
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-01-12 16:54:37 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-01-12 16:54:37 +0000
commitd944e35af84a59c9dc88f7027b04c9528cc1bf9b (patch)
tree449420f406a63fc0df73fcfd4201e35f98678407 /src/Simplex_tree/include/gudhi/Simplex_tree
parent178f37684b9f3bebf95534568b5ef54c15e11c63 (diff)
parent9aa92aa2b504d9530125a6a164f76c11f45d8bb5 (diff)
Backmerge of last trunk modifications
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@959 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a5c6ef0ae2ee1e18fff88b98131ff4d14a252152
Diffstat (limited to 'src/Simplex_tree/include/gudhi/Simplex_tree')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h81
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h2
2 files changed, 51 insertions, 32 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
index 372ef329..936b7a1f 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
@@ -54,7 +54,7 @@ class Simplex_tree_simplex_vertex_iterator : public boost::iterator_facade<
explicit Simplex_tree_simplex_vertex_iterator(SimplexTree * st)
: // any end() iterator
- sib_(NULL),
+ sib_(nullptr),
v_(st->null_vertex()) {
}
@@ -99,21 +99,22 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
// any end() iterator
explicit Simplex_tree_boundary_simplex_iterator(SimplexTree * st)
- : last_(st->null_vertex()),
- sib_(NULL) {
+ : sib_(nullptr),
+ sh_(st->null_simplex()),
+ st_(st) {
}
Simplex_tree_boundary_simplex_iterator(SimplexTree * st, Simplex_handle sh)
- : suffix_(),
+ : last_(sh->first),
+ sib_(nullptr),
st_(st) {
- last_ = sh->first;
Siblings * sib = st->self_siblings(sh);
next_ = sib->parent();
- sib_ = sib->oncles(); /* \todo check if NULL*/
- if (sib_ != NULL) {
+ sib_ = sib->oncles();
+ if (sib_ != nullptr) {
sh_ = sib_->find(next_);
} else {
- last_ = st->null_vertex();
+ sh_ = st->null_simplex();
} // vertex: == end()
}
@@ -121,28 +122,40 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
friend class boost::iterator_core_access;
// valid when iterating along the SAME boundary.
bool equal(Simplex_tree_boundary_simplex_iterator const& other) const {
- return (sib_ == other.sib_ && last_ == other.last_);
+ return sh_ == other.sh_;
}
Simplex_handle const& dereference() const {
+ assert(sh_ != st_->null_simplex());
return sh_;
}
void increment() {
- if (sib_ == NULL) {
- last_ = st_->null_vertex();
+ if (sib_ == nullptr) {
+ sh_ = st_->null_simplex();
return;
}
Siblings * for_sib = sib_;
- for (auto rit = suffix_.rbegin(); rit != suffix_.rend(); ++rit) {
+ Siblings * new_sib = sib_->oncles();
+ auto rit = suffix_.rbegin();
+ if (SimplexTree::Options::contiguous_vertices && new_sib == nullptr && rit != suffix_.rend()) {
+ // We reached the root, use a short-cut to find a vertex. We could also
+ // optimize finding the second vertex of a segment, but people are
+ // expected to call endpoints().
+ assert(st_->contiguous_vertices());
+ sh_ = for_sib->members_.begin()+*rit;
+ for_sib = sh_->second.children();
+ ++rit;
+ }
+ for (; rit != suffix_.rend(); ++rit) {
sh_ = for_sib->find(*rit);
for_sib = sh_->second.children();
}
sh_ = for_sib->find(last_); // sh_ points to the right simplex now
suffix_.push_back(next_);
next_ = sib_->parent();
- sib_ = sib_->oncles();
+ sib_ = new_sib;
}
// Most of the storage should be moved to the range, iterators should be light.
@@ -176,13 +189,15 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade<
// any end() iterator
Simplex_tree_complex_simplex_iterator()
- : st_(NULL) {
+ : sib_(nullptr),
+ st_(nullptr) {
}
explicit Simplex_tree_complex_simplex_iterator(SimplexTree * st)
- : st_(st) {
- if (st == NULL || st->root() == NULL || st->root()->members().empty()) {
- st_ = NULL;
+ : sib_(nullptr),
+ st_(st) {
+ if (st == nullptr || st->root() == nullptr || st->root()->members().empty()) {
+ st_ = nullptr;
} else {
sh_ = st->root()->members().begin();
sib_ = st->root();
@@ -197,10 +212,10 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade<
// valid when iterating along the SAME boundary.
bool equal(Simplex_tree_complex_simplex_iterator const& other) const {
- if (other.st_ == NULL) {
- return (st_ == NULL);
+ if (other.st_ == nullptr) {
+ return (st_ == nullptr);
}
- if (st_ == NULL) {
+ if (st_ == nullptr) {
return false;
}
return (&(sh_->second) == &(other.sh_->second));
@@ -214,8 +229,8 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade<
void increment() {
++sh_;
if (sh_ == sib_->members().end()) {
- if (sib_->oncles() == NULL) {
- st_ = NULL;
+ if (sib_->oncles() == nullptr) {
+ st_ = nullptr;
return;
} // reach the end
sh_ = sib_->oncles()->members().find(sib_->parent());
@@ -248,15 +263,19 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade<
// any end() iterator
Simplex_tree_skeleton_simplex_iterator()
- : st_(NULL) {
+ : sib_(nullptr),
+ st_(nullptr),
+ dim_skel_(0),
+ curr_dim_(0) {
}
Simplex_tree_skeleton_simplex_iterator(SimplexTree * st, int dim_skel)
- : st_(st),
+ : sib_(nullptr),
+ st_(st),
dim_skel_(dim_skel),
curr_dim_(0) {
- if (st == NULL || st->root() == NULL || st->root()->members().empty()) {
- st_ = NULL;
+ if (st == nullptr || st->root() == nullptr || st->root()->members().empty()) {
+ st_ = nullptr;
} else {
sh_ = st->root()->members().begin();
sib_ = st->root();
@@ -272,10 +291,10 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade<
// valid when iterating along the SAME boundary.
bool equal(Simplex_tree_skeleton_simplex_iterator const& other) const {
- if (other.st_ == NULL) {
- return (st_ == NULL);
+ if (other.st_ == nullptr) {
+ return (st_ == nullptr);
}
- if (st_ == NULL) {
+ if (st_ == nullptr) {
return false;
}
return (&(sh_->second) == &(other.sh_->second));
@@ -289,8 +308,8 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade<
void increment() {
++sh_;
if (sh_ == sib_->members().end()) {
- if (sib_->oncles() == NULL) {
- st_ = NULL;
+ if (sib_->oncles() == nullptr) {
+ st_ = nullptr;
return;
} // reach the end
sh_ = sib_->oncles()->members().find(sib_->parent());
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h
index c1ff8bf2..8942d92c 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h
@@ -57,7 +57,7 @@ class Simplex_tree_siblings {
/* Default constructor.*/
Simplex_tree_siblings()
- : oncles_(NULL),
+ : oncles_(nullptr),
parent_(-1),
members_() {
}