diff options
author | cjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-05-16 14:26:11 +0000 |
---|---|---|
committer | cjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2017-05-16 14:26:11 +0000 |
commit | 884d91ed81876af1a3d986843253acaaff443834 (patch) | |
tree | e377974e6c1119fb6c61755a2160e0ab63afacd5 /src/Bottleneck_distance | |
parent | e7162cf121d5e1619ca4b7b54b9cef4d9ff1c9f7 (diff) |
Use read_persistence_diagram_from_file in this example
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/read_persistence_from_file@2440 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: cb5cbba3f968c6cd16025250076bbe1df4f2e11a
Diffstat (limited to 'src/Bottleneck_distance')
-rw-r--r-- | src/Bottleneck_distance/example/bottleneck_read_file_example.cpp | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp index bde05825..e50a243d 100644 --- a/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp +++ b/src/Bottleneck_distance/example/bottleneck_read_file_example.cpp @@ -21,8 +21,10 @@ */ #define CGAL_HAS_THREADS +#define DEBUG_TRACES #include <gudhi/Bottleneck.h> +#include <gudhi/reader_utils.h> #include <iostream> #include <vector> #include <utility> // for pair @@ -30,39 +32,14 @@ #include <sstream> #include <string> -std::vector< std::pair<double, double> > read_diagram_from_file(const char* filename) { - std::ifstream in; - in.open(filename); - std::vector< std::pair<double, double> > result; - if (!in.is_open()) { - std::cerr << "File : " << filename << " do not exist. The program will now terminate \n"; - throw "File do not exist \n"; - } - - std::string line; - while (!in.eof()) { - getline(in, line); - if (line.length() != 0) { - std::stringstream lineSS; - lineSS << line; - double beginn, endd; - lineSS >> beginn; - lineSS >> endd; - result.push_back(std::make_pair(beginn, endd)); - } - } - in.close(); - return result; -} // read_diagram_from_file - int main(int argc, char** argv) { if (argc < 3) { std::cout << "To run this program please provide as an input two files with persistence diagrams. Each file " << "should contain a birth-death pair per line. Third, optional parameter is an error bound on a bottleneck" << " distance (set by default to zero). The program will now terminate \n"; } - std::vector< std::pair< double, double > > diag1 = read_diagram_from_file(argv[1]); - std::vector< std::pair< double, double > > diag2 = read_diagram_from_file(argv[2]); + std::vector< std::pair< double, double > > diag1 = read_persistence_diagram_from_file(argv[1]); + std::vector< std::pair< double, double > > diag2 = read_persistence_diagram_from_file(argv[2]); double tolerance = 0.; if (argc == 4) { tolerance = atof(argv[3]); |