diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-09-19 17:27:24 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-09-19 17:27:24 +0000 |
commit | e54574c7290b28543b9c1e7d1b9a16f42825ae26 (patch) | |
tree | 6dfe7dab377095a49833fd6e13fa5dea72ba5cf7 /src/common/example/example_CGAL_points_off_reader.cpp | |
parent | 21eb395a9571d4b6df64b4972f6727b235369836 (diff) |
Rename off file reader as stands in convention.
Add an example with a vector of double for point type.
Fix SO3 OFF files accordingly to OFF file standard.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1510 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: ff61bed1f1895bc5bf1af4ae946e2a84a692c390
Diffstat (limited to 'src/common/example/example_CGAL_points_off_reader.cpp')
-rw-r--r-- | src/common/example/example_CGAL_points_off_reader.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/common/example/example_CGAL_points_off_reader.cpp b/src/common/example/example_CGAL_points_off_reader.cpp new file mode 100644 index 00000000..264231b2 --- /dev/null +++ b/src/common/example/example_CGAL_points_off_reader.cpp @@ -0,0 +1,46 @@ +#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> + +using Kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; +using Point_d = Kernel::Point_d; + +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_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; + usage(argv[0]); + } + + // 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.size(); i++) + std::cout << point[i] << " "; + std::cout << "\n"; + ++n; + } + return 0; +} |