summaryrefslogtreecommitdiff
path: root/src/Alpha_complex/example/Alpha_complex_from_off.cpp
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-02-02 15:24:51 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-02-02 15:24:51 +0000
commit74dcaacda1c887b008ea8c95b28962de1c02a2d0 (patch)
tree0eb1ab5c08fca08f0dccf65a0ad58bd6349adbcb /src/Alpha_complex/example/Alpha_complex_from_off.cpp
parentcbf1f4c98c9e6d7ba3b7c552e43c7c98ed349954 (diff)
alpha off reader test strategy modification
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@995 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: aa4ba97eecefb03e01a53ae1e2b50248a0857043
Diffstat (limited to 'src/Alpha_complex/example/Alpha_complex_from_off.cpp')
-rw-r--r--src/Alpha_complex/example/Alpha_complex_from_off.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/Alpha_complex/example/Alpha_complex_from_off.cpp b/src/Alpha_complex/example/Alpha_complex_from_off.cpp
index 780f904b..80445a22 100644
--- a/src/Alpha_complex/example/Alpha_complex_from_off.cpp
+++ b/src/Alpha_complex/example/Alpha_complex_from_off.cpp
@@ -5,14 +5,14 @@
#include <string>
void usage(char * const progName) {
- std::cerr << "Usage: " << progName << " filename.off alpha_square_max_value" << std::endl;
- std::cerr << " i.e.: " << progName << " ../../data/points/alphacomplexdoc.off 60.0" << std::endl;
+ std::cerr << "Usage: " << progName << " filename.off alpha_square_max_value [ouput_file.txt]\n";
+ std::cerr << " i.e.: " << progName << " ../../data/points/alphacomplexdoc.off 60.0\n";
exit(-1); // ----- >>
}
int main(int argc, char **argv) {
- if (argc != 3) {
- std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl;
+ if ((argc != 3) && (argc != 4)) {
+ std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n";
usage(argv[0]);
}
@@ -25,21 +25,34 @@ int main(int argc, char **argv) {
typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Kernel;
Gudhi::alphacomplex::Alpha_complex<Kernel> alpha_complex_from_file(off_file_name, alpha_square_max_value);
+ std::streambuf* streambufffer;
+ std::ofstream ouput_file_stream;
+
+ if (argc == 4) {
+ ouput_file_stream.open(std::string(argv[3]));
+ streambufffer = ouput_file_stream.rdbuf();
+ } else {
+ streambufffer = std::cout.rdbuf();
+ }
+
+ std::ostream output_stream(streambufffer);
+
// ----------------------------------------------------------------------------
// Display information about the alpha complex
// ----------------------------------------------------------------------------
- std::cout << "Alpha complex is of dimension " << alpha_complex_from_file.dimension() <<
+ output_stream << "Alpha complex is of dimension " << alpha_complex_from_file.dimension() <<
" - " << alpha_complex_from_file.num_simplices() << " simplices - " <<
alpha_complex_from_file.num_vertices() << " vertices." << std::endl;
- std::cout << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl;
+ output_stream << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl;
for (auto f_simplex : alpha_complex_from_file.filtration_simplex_range()) {
- std::cout << " ( ";
+ output_stream << " ( ";
for (auto vertex : alpha_complex_from_file.simplex_vertex_range(f_simplex)) {
- std::cout << vertex << " ";
+ output_stream << vertex << " ";
}
- std::cout << ") -> " << "[" << alpha_complex_from_file.filtration(f_simplex) << "] ";
- std::cout << std::endl;
+ output_stream << ") -> " << "[" << alpha_complex_from_file.filtration(f_simplex) << "] ";
+ output_stream << std::endl;
}
+ ouput_file_stream.close();
return 0;
}