diff options
Diffstat (limited to 'example/common')
-rw-r--r-- | example/common/CGAL_3D_points_off_reader.cpp | 41 | ||||
-rw-r--r-- | example/common/CGAL_points_off_reader.cpp | 46 | ||||
-rw-r--r-- | example/common/CMakeLists.txt | 17 | ||||
-rw-r--r-- | example/common/cgal3Doffreader_result.txt | 8 | ||||
-rw-r--r-- | example/common/cgaloffreader_result.txt | 7 |
5 files changed, 119 insertions, 0 deletions
diff --git a/example/common/CGAL_3D_points_off_reader.cpp b/example/common/CGAL_3D_points_off_reader.cpp new file mode 100644 index 00000000..d48bb17d --- /dev/null +++ b/example/common/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; +} diff --git a/example/common/CGAL_points_off_reader.cpp b/example/common/CGAL_points_off_reader.cpp new file mode 100644 index 00000000..d1ca166d --- /dev/null +++ b/example/common/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.dimension(); i++) + std::cout << point[i] << " "; + std::cout << "\n"; + ++n; + } + return 0; +} diff --git a/example/common/CMakeLists.txt b/example/common/CMakeLists.txt new file mode 100644 index 00000000..0da3dcc0 --- /dev/null +++ b/example/common/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 2.6) +project(Common_examples) + +# 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}/cgal3Doffreader ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off) + + if (NOT CGAL_VERSION VERSION_LESS 4.7.0) + if (EIGEN3_FOUND) + add_executable ( cgaloffreader CGAL_points_off_reader.cpp ) + target_link_libraries(cgaloffreader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + add_test(cgaloffreader ${CMAKE_CURRENT_BINARY_DIR}/cgaloffreader ${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off) + endif(EIGEN3_FOUND) + endif (NOT CGAL_VERSION VERSION_LESS 4.7.0) +endif() diff --git a/example/common/cgal3Doffreader_result.txt b/example/common/cgal3Doffreader_result.txt new file mode 100644 index 00000000..f992c8e3 --- /dev/null +++ b/example/common/cgal3Doffreader_result.txt @@ -0,0 +1,8 @@ +Point[1] = (0.959535, -0.418347, 0.302237) +Point[2] = (2.16795, 1.85348, -0.52312) +Point[3] = (-2.38753, -1.50911, -0.565889) +Point[4] = (-2.70428, -1.25688, 0.188394) +Point[5] = (-1.22932, -1.64337, -0.998632) +... +Point[300] = (-0.56244, 2.6018, -0.749591) + diff --git a/example/common/cgaloffreader_result.txt b/example/common/cgaloffreader_result.txt new file mode 100644 index 00000000..1deb8dbd --- /dev/null +++ b/example/common/cgaloffreader_result.txt @@ -0,0 +1,7 @@ +Point[0] = 1 1 +Point[1] = 7 0 +Point[2] = 4 6 +Point[3] = 9 6 +Point[4] = 0 14 +Point[5] = 2 19 +Point[6] = 9 17 |