From 0973c016220d689fcb429021a86d9e5833034800 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 24 Apr 2017 12:24:54 +0000 Subject: Make compilation and tests out of source git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@2376 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0bc362b7321ed22af0c20f020eafc98efecbac46 --- .../example/Bitmap_cubical_complex.cpp | 24 ++++++++++++++-------- ...ubical_complex_periodic_boundary_conditions.cpp | 21 ++++++++++++------- 2 files changed, 30 insertions(+), 15 deletions(-) (limited to 'src/Bitmap_cubical_complex') diff --git a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp index e6bc6648..67735ba1 100644 --- a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp +++ b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex.cpp @@ -27,8 +27,9 @@ // standard stuff #include -#include +#include #include +#include int main(int argc, char** argv) { std::cout << "This program computes persistent homology, by using bitmap_cubical_complex class, of cubical " << @@ -38,9 +39,6 @@ int main(int argc, char** argv) { "filtrations of top dimensional cells. We assume that the cells are in the lexicographical order. See " << "CubicalOneSphere.txt or CubicalTwoSphere.txt for example.\n" << std::endl; - int p = 2; - double min_persistence = 0; - if (argc != 2) { std::cerr << "Wrong number of parameters. Please provide the name of a file with a Perseus style bitmap at " << "the input. The program will now terminate.\n"; @@ -56,16 +54,26 @@ int main(int argc, char** argv) { // Compute the persistence diagram of the complex Persistent_cohomology pcoh(b); + int p = 2; + double min_persistence = 0; + pcoh.init_coefficients(p); // initializes the coefficient field for homology pcoh.compute_persistent_cohomology(min_persistence); - std::stringstream ss; - ss << argv[1] << "_persistence"; - std::ofstream out(ss.str().c_str()); + std::string output_file_name(argv[1]); + output_file_name += "_persistence"; + + std::size_t last_in_path = output_file_name.find_last_of("/\\"); + + if (last_in_path != std::string::npos) { + output_file_name = output_file_name.substr(last_in_path+1); + } + + std::ofstream out(output_file_name.c_str()); pcoh.output_diagram(out); out.close(); - std::cout << "Result in file: " << ss.str().c_str() << "\n"; + std::cout << "Result in file: " << output_file_name << "\n"; return 0; } diff --git a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp index 839a4c89..f8754345 100644 --- a/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp +++ b/src/Bitmap_cubical_complex/example/Bitmap_cubical_complex_periodic_boundary_conditions.cpp @@ -40,9 +40,6 @@ int main(int argc, char** argv) { "assume that the cells are in the lexicographical order. See CubicalOneSphere.txt or CubicalTwoSphere.txt for" << " example.\n" << std::endl; - int p = 2; - double min_persistence = 0; - if (argc != 2) { std::cerr << "Wrong number of parameters. Please provide the name of a file with a Perseus style bitmap at " << "the input. The program will now terminate.\n"; @@ -58,16 +55,26 @@ int main(int argc, char** argv) { typedef Gudhi::persistent_cohomology::Persistent_cohomology Persistent_cohomology; // Compute the persistence diagram of the complex Persistent_cohomology pcoh(b, true); + + int p = 2; + double min_persistence = 0; pcoh.init_coefficients(p); // initializes the coefficient field for homology pcoh.compute_persistent_cohomology(min_persistence); - std::stringstream ss; - ss << argv[1] << "_persistence"; - std::ofstream out(ss.str().c_str()); + std::string output_file_name(argv[1]); + output_file_name += "_persistence"; + + std::size_t last_in_path = output_file_name.find_last_of("/\\"); + + if (last_in_path != std::string::npos) { + output_file_name = output_file_name.substr(last_in_path+1); + } + + std::ofstream out(output_file_name.c_str()); pcoh.output_diagram(out); out.close(); - std::cout << "Result in file: " << ss.str().c_str() << "\n"; + std::cout << "Result in file: " << output_file_name << "\n"; return 0; } -- cgit v1.2.3