diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-04-14 07:17:44 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-04-14 07:17:44 +0000 |
commit | 4e784aca4df90d3fca9146bfd9e3feda98ce5f4c (patch) | |
tree | 89182d71a1cfe45b70410af70500e3e90f7aca52 /src/common/example/CGAL_points_off_reader.cpp | |
parent | c829c36217c003b2068750aa8f23b6082636e6e1 (diff) | |
parent | baf1b5b39be90694b512fff9c79438bf362916f3 (diff) |
Merge last trunk modifications (version 1.3.0)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/ST_cythonize@1113 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 608c3cb733a7723c865f82a4de9408c984227f1a
Diffstat (limited to 'src/common/example/CGAL_points_off_reader.cpp')
-rw-r--r-- | src/common/example/CGAL_points_off_reader.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/common/example/CGAL_points_off_reader.cpp b/src/common/example/CGAL_points_off_reader.cpp new file mode 100644 index 00000000..45e9f1e6 --- /dev/null +++ b/src/common/example/CGAL_points_off_reader.cpp @@ -0,0 +1,44 @@ +#include <gudhi/Points_off_io.h> + +// For CGAL points type in dimension d +// cf. http://doc.cgal.org/latest/Kernel_d/classCGAL_1_1Point__d.html +#include <CGAL/Epick_d.h> + +#include <iostream> +#include <string> +#include <vector> + +typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Kernel; +typedef typename Kernel::Point_d Point_d; + +void usage(int argc, char * const progName) { + std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl; + std::cerr << "Usage: " << progName << " inputFile.off" << std::endl; + exit(-1); +} + +int main(int argc, char **argv) { + if (argc != 2) usage(argc, (argv[0] - 1)); + + std::string offInputFile(argv[1]); + // Read the OFF file (input file name given as parameter) and triangulate points + Gudhi::Points_off_reader<Point_d> off_reader(offInputFile); + // Check the read operation was correct + if (!off_reader.is_valid()) { + std::cerr << "Unable to read file " << offInputFile << std::endl; + exit(-1); + } + + // Retrieve the triangulation + std::vector<Point_d> point_cloud = off_reader.get_point_cloud(); + + int n = 0; + for (auto point : point_cloud) { + std::cout << "Point[" << n << "] = "; + for (int i = 0; i < point.dimension(); i++) + std::cout << point[i] << " "; + std::cout << "\n"; + ++n; + } + return 0; +} |