diff options
Diffstat (limited to 'src/common/example')
-rw-r--r-- | src/common/example/CMakeLists.txt | 21 | ||||
-rw-r--r-- | src/common/example/cgal3Doffreader_result.txt | 8 | ||||
-rw-r--r-- | src/common/example/cgaloffreader_result.txt | 7 | ||||
-rw-r--r-- | src/common/example/example_CGAL_3D_points_off_reader.cpp | 41 | ||||
-rw-r--r-- | src/common/example/example_CGAL_points_off_reader.cpp | 46 | ||||
-rw-r--r-- | src/common/example/example_vector_double_points_off_reader.cpp | 41 |
6 files changed, 164 insertions, 0 deletions
diff --git a/src/common/example/CMakeLists.txt b/src/common/example/CMakeLists.txt new file mode 100644 index 00000000..b0c6d69a --- /dev/null +++ b/src/common/example/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 2.6) +project(Common_examples) + +add_executable ( vector_double_off_reader example_vector_double_points_off_reader.cpp ) +target_link_libraries(vector_double_off_reader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) +add_test(vector_double_off_reader ${CMAKE_CURRENT_BINARY_DIR}/vector_double_off_reader ${CMAKE_SOURCE_DIR}/data/points/SO3_10000.off) + +if(CGAL_FOUND) + add_executable ( cgal_3D_off_reader example_CGAL_3D_points_off_reader.cpp ) + target_link_libraries(cgal_3D_off_reader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + add_test(cgal_3D_off_reader ${CMAKE_CURRENT_BINARY_DIR}/cgal_3D_off_reader ${CMAKE_SOURCE_DIR}/data/points/tore3D_300.off) + + # need CGAL 4.7 + if (NOT CGAL_VERSION VERSION_LESS 4.7.0) + if (EIGEN3_FOUND) + add_executable ( cgal_off_reader example_CGAL_points_off_reader.cpp ) + target_link_libraries(cgal_off_reader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + add_test(cgal_off_reader ${CMAKE_CURRENT_BINARY_DIR}/cgal_off_reader ${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off) + endif(EIGEN3_FOUND) + endif (NOT CGAL_VERSION VERSION_LESS 4.7.0) +endif() diff --git a/src/common/example/cgal3Doffreader_result.txt b/src/common/example/cgal3Doffreader_result.txt new file mode 100644 index 00000000..f992c8e3 --- /dev/null +++ b/src/common/example/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/src/common/example/cgaloffreader_result.txt b/src/common/example/cgaloffreader_result.txt new file mode 100644 index 00000000..1deb8dbd --- /dev/null +++ b/src/common/example/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 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; +} 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..4522174a --- /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 (std::size_t i {0}; i < point.size(); i++) + std::cout << point[i] << " "; + std::cout << "\n"; + ++n; + } + return 0; +} diff --git a/src/common/example/example_vector_double_points_off_reader.cpp b/src/common/example/example_vector_double_points_off_reader.cpp new file mode 100644 index 00000000..8aecb26e --- /dev/null +++ b/src/common/example/example_vector_double_points_off_reader.cpp @@ -0,0 +1,41 @@ +#include <gudhi/Points_off_io.h> + +#include <iostream> +#include <string> +#include <vector> + +using Point_d = std::vector<double>; + +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 (std::size_t i {0}; i < point.size(); i++) + std::cout << point[i] << " "; + std::cout << "\n"; + ++n; + } + return 0; +} |