diff options
author | cjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-09-21 09:23:34 +0000 |
---|---|---|
committer | cjamin <cjamin@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-09-21 09:23:34 +0000 |
commit | 35444924982074475df87b126a51cf4b16949a8a (patch) | |
tree | fa53714d321965d72b5252e31e3f466e7e0a2721 /src/common/example/example_CGAL_3D_points_off_reader.cpp | |
parent | 227f58f39835ea33381ddb28f05ce43fcfa058b2 (diff) | |
parent | d04f3f02858044180471fc7e38948ff73e330162 (diff) |
Merge from trunk
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1520 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 477d84d9b29057de29afbb77d830d9d46a8f54be
Diffstat (limited to 'src/common/example/example_CGAL_3D_points_off_reader.cpp')
-rw-r--r-- | src/common/example/example_CGAL_3D_points_off_reader.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/common/example/example_CGAL_3D_points_off_reader.cpp b/src/common/example/example_CGAL_3D_points_off_reader.cpp new file mode 100644 index 00000000..d48bb17d --- /dev/null +++ b/src/common/example/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; +} |