summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-01-14 14:31:08 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-01-14 14:31:08 +0000
commit22a90cae3ce7ca63ca712a74281410e61e829dd2 (patch)
treed2667612b539a0a650aed0abff88a08c6e71f814 /src
parent765c9698fc77cb7d4347a1de035d52c8a44b23f0 (diff)
AddressSanitizer bug fixes on Simplex tree copy constructor.
debug_tree function git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_insert_with_subfaces_fix@967 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: dd4b15dc8f2a4795d3a0b6fdcf4938aff152906b
Diffstat (limited to 'src')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index 708cdef9..0a406076 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -325,11 +325,10 @@ class Simplex_tree {
Simplex_tree(const Simplex_tree& simplex_source)
: null_vertex_(simplex_source.null_vertex_),
threshold_(simplex_source.threshold_),
+ root_(nullptr, null_vertex_ , simplex_source.root_.members_),
filtration_vect_(),
dimension_(simplex_source.dimension_) {
auto root_source = simplex_source.root_;
- auto memb_source = root_source.members();
- root_ = Siblings(nullptr, null_vertex_, memb_source);
rec_copy(&root_, &root_source);
}
@@ -341,7 +340,7 @@ class Simplex_tree {
Siblings * newsib = new Siblings(sib, sh_source->first);
newsib->members_.reserve(sh_source->second.children()->members().size());
for (auto & child : sh_source->second.children()->members())
- newsib->members_.emplace_hint(newsib->members_.end(), child.first, Node(sib, child.second.filtration()));
+ newsib->members_.emplace_hint(newsib->members_.end(), child.first, Node(newsib, child.second.filtration()));
rec_copy(newsib, sh_source->second.children());
sh->second.assign_children(newsib);
}
@@ -1105,6 +1104,43 @@ class Simplex_tree {
os << filtration(sh) << " \n";
}
}
+/***************************************************************************************************************/
+ public:
+ /** \brief Prints the simplex_tree hierarchically.
+ * Since it prints the vertices recursively, one can watch its tree shape.
+ */
+ void debug_tree() {
+ std::cout << "{" << &root_ << "} -------------------------------------------------------------------" << std::endl;
+ for (auto sh = root_.members().begin(); sh != root_.members().end(); ++sh) {
+ std::cout << sh->first << " [" << sh->second.filtration() << "] ";
+ if (has_children(sh)) {
+ rec_debug_tree(sh->second.children());
+ } else {
+ std::cout << " {- " << sh->second.children() << "} ";
+ }
+ std::cout << std::endl;
+ }
+ std::cout << "--------------------------------------------------------------------------------------" << std::endl;
+ }
+
+
+ /** \brief Recursively prints the simplex_tree, using depth first search. */
+ private:
+ void rec_debug_tree(Siblings * sib) {
+ std::cout << " {" << sib << "} (";
+ for (auto sh = sib->members().begin(); sh != sib->members().end(); ++sh) {
+ std::cout << " " << sh->first << " [" << sh->second.filtration() << "] ";
+ if (has_children(sh)) {
+ rec_debug_tree(sh->second.children());
+ } else {
+ std::cout << " {- " << sh->second.children() << "} ";
+ }
+ }
+ std::cout << ")";
+ }
+
+/*****************************************************************************************************************/
+
private:
Vertex_handle null_vertex_;