From 884d91ed81876af1a3d986843253acaaff443834 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 16 May 2017 14:26:11 +0000 Subject: 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 --- .../example/bottleneck_read_file_example.cpp | 31 +++------------------- 1 file changed, 4 insertions(+), 27 deletions(-) (limited to 'src') 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 +#include #include #include #include // for pair @@ -30,39 +32,14 @@ #include #include -std::vector< std::pair > read_diagram_from_file(const char* filename) { - std::ifstream in; - in.open(filename); - std::vector< std::pair > 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]); -- cgit v1.2.3