diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-04-14 12:49:09 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-04-14 12:49:09 +0000 |
commit | 437ccdf9616d91534af91cd8a0090b6f32d6e65b (patch) | |
tree | 39177c3c8a1ce2f74af6aa9434cd92afcf6854af /src/common/example/CGAL_3D_points_off_reader.cpp | |
parent | 8bcb704e4772e9dda428d4de27a30e74eca7ff6a (diff) |
Add of src/common/include/gudhi/Points_3D_off_io.h to read specific 3D OFF Files for CGAL Point_3
Add an example to read 3D OFF Files for CGAL Point_3
Modify alpha_complex_3d_persistence.cpp to read OFF files
Add periodic_alpha_complex_3d_persistence.cpp in Persistent_cohomology examples
Add info about new examples in README
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/periodic_alpha_complex_3d@1116 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 6b423b598869a0f4f9c62d93c93b69efd93c0161
Diffstat (limited to 'src/common/example/CGAL_3D_points_off_reader.cpp')
-rw-r--r-- | src/common/example/CGAL_3D_points_off_reader.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/common/example/CGAL_3D_points_off_reader.cpp b/src/common/example/CGAL_3D_points_off_reader.cpp new file mode 100644 index 00000000..d48bb17d --- /dev/null +++ b/src/common/example/CGAL_3D_points_off_reader.cpp @@ -0,0 +1,41 @@ +#include <gudhi/Points_3D_off_io.h> + +#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> + +#include <iostream> +#include <string> +#include <vector> + +using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; +using Point_3 = Kernel::Point_3; + +void usage(char * const progName) { + std::cerr << "Usage: " << progName << " inputFile.off" << std::endl; + exit(-1); +} + +int main(int argc, char **argv) { + if (argc != 2) { + std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl; + usage(argv[0]); + } + + std::string offInputFile(argv[1]); + // Read the OFF file (input file name given as parameter) and triangulate points + Gudhi::Points_3D_off_reader<Point_3> off_reader(offInputFile); + // Check the read operation was correct + if (!off_reader.is_valid()) { + std::cerr << "Unable to read file " << offInputFile << std::endl; + usage(argv[0]); + } + + // Retrieve the triangulation + std::vector<Point_3> point_cloud = off_reader.get_point_cloud(); + + int n {0}; + for (auto point : point_cloud) { + ++n; + std::cout << "Point[" << n << "] = (" << point[0] << ", " << point[1] << ", " << point[2] << ")\n"; + } + return 0; +} |