diff options
author | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-04-02 12:28:46 +0000 |
---|---|---|
committer | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-04-02 12:28:46 +0000 |
commit | b76ee21ac17dbfc630bb16d66fec4b1c2ee4013a (patch) | |
tree | c2ec99f3090d37a2fce0b02b221d00c788048be6 /src/Witness_complex | |
parent | 42ef28d73a05b84ad02193e4f3bf76b416ba9a02 (diff) |
Added writing to file functions
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@538 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 429568c33608ad8f49508513379e33cd6a73b006
Diffstat (limited to 'src/Witness_complex')
-rw-r--r-- | src/Witness_complex/include/gudhi/Witness_complex.h | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index bcfe0f38..1b50ca95 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -208,7 +208,7 @@ namespace Gudhi { } k++; } - print_sc(root()); std::cout << std::endl; + //print_sc(root()); std::cout << std::endl; } /** \brief Construction of witness complex from points given explicitly @@ -254,6 +254,44 @@ private: std::cout << ")"; } + public: + /** \brief Print functions + */ + + void st_to_file(std::ofstream& out_file) + { + sc_to_file(out_file, root()); + } + + private: + void sc_to_file(std::ofstream& out_file, Siblings * sibl) + { + if (sibl == NULL) + out_file << "&"; + else + children_to_file(out_file, sibl->members_); + } + + void children_to_file(std::ofstream& out_file, Dictionary map) + { + out_file << "("; + if (!map.empty()) + { + out_file << map.begin()->first; + if (has_children(map.begin())) + sc_to_file(out_file, map.begin()->second.children()); + typename Dictionary::iterator it; + for (it = map.begin()+1; it != map.end(); ++it) + { + out_file << "," << it->first; + if (has_children(it)) + sc_to_file(out_file, it->second.children()); + } + } + out_file << ")"; + } + + /** \brief Check if the facets of the k-dimensional simplex witnessed * by witness witness_id are already in the complex. * inserted_vertex is the handle of the (k+1)-th vertex witnessed by witness_id |