From 437ccdf9616d91534af91cd8a0090b6f32d6e65b Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 14 Apr 2016 12:49:09 +0000 Subject: 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 --- src/common/example/CGAL_3D_points_off_reader.cpp | 41 ++++++++++++++++++++++++ src/common/example/CGAL_points_off_reader.cpp | 18 ++++++----- src/common/example/CMakeLists.txt | 4 +++ 3 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 src/common/example/CGAL_3D_points_off_reader.cpp (limited to 'src/common/example') 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 + +#include + +#include +#include +#include + +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 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_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; +} diff --git a/src/common/example/CGAL_points_off_reader.cpp b/src/common/example/CGAL_points_off_reader.cpp index 45e9f1e6..997b47c1 100644 --- a/src/common/example/CGAL_points_off_reader.cpp +++ b/src/common/example/CGAL_points_off_reader.cpp @@ -8,17 +8,19 @@ #include #include -typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Kernel; -typedef typename Kernel::Point_d Point_d; +using Kernel = CGAL::Epick_d< CGAL::Dynamic_dimension_tag >; +using Point_d = typename Kernel::Point_d; -void usage(int argc, char * const progName) { - std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl; +void usage(char * const progName) { std::cerr << "Usage: " << progName << " inputFile.off" << std::endl; exit(-1); } int main(int argc, char **argv) { - if (argc != 2) usage(argc, (argv[0] - 1)); + 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 @@ -26,16 +28,16 @@ int main(int argc, char **argv) { // Check the read operation was correct if (!off_reader.is_valid()) { std::cerr << "Unable to read file " << offInputFile << std::endl; - exit(-1); + usage(argv[0]); } // Retrieve the triangulation std::vector point_cloud = off_reader.get_point_cloud(); - int n = 0; + int n {0}; for (auto point : point_cloud) { std::cout << "Point[" << n << "] = "; - for (int i = 0; i < point.dimension(); i++) + for (int i {0}; i < point.dimension(); i++) std::cout << point[i] << " "; std::cout << "\n"; ++n; diff --git a/src/common/example/CMakeLists.txt b/src/common/example/CMakeLists.txt index 5aeaa8c6..ee6c9058 100644 --- a/src/common/example/CMakeLists.txt +++ b/src/common/example/CMakeLists.txt @@ -3,6 +3,10 @@ project(GUDHIDelaunayTriangulationOffFileReadWrite) # need CGAL 4.7 if(CGAL_FOUND) + add_executable ( cgal3Doffreader CGAL_3D_points_off_reader.cpp ) + target_link_libraries(cgal3Doffreader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + add_test(cgal3Doffreader ${CMAKE_CURRENT_BINARY_DIR}/cgaloffreader ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off) + if (NOT CGAL_VERSION VERSION_LESS 4.7.0) find_package(Eigen3 3.1.0) if (EIGEN3_FOUND) -- cgit v1.2.3