summaryrefslogtreecommitdiff
path: root/example/common
diff options
context:
space:
mode:
Diffstat (limited to 'example/common')
-rw-r--r--example/common/CMakeLists.txt27
-rw-r--r--example/common/example_CGAL_3D_points_off_reader.cpp (renamed from example/common/CGAL_3D_points_off_reader.cpp)2
-rw-r--r--example/common/example_CGAL_points_off_reader.cpp (renamed from example/common/CGAL_points_off_reader.cpp)4
-rw-r--r--example/common/example_vector_double_points_off_reader.cpp41
4 files changed, 60 insertions, 14 deletions
diff --git a/example/common/CMakeLists.txt b/example/common/CMakeLists.txt
index 0da3dcc0..d5311b18 100644
--- a/example/common/CMakeLists.txt
+++ b/example/common/CMakeLists.txt
@@ -1,17 +1,22 @@
cmake_minimum_required(VERSION 2.6)
project(Common_examples)
-# need CGAL 4.7
+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(NAME Common_example_vector_double_off_reader COMMAND $<TARGET_FILE:vector_double_off_reader>
+ "${CMAKE_SOURCE_DIR}/data/points/SO3_10000.off")
+
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)
+ 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(NAME Common_example_vector_cgal_3D_off_reader COMMAND $<TARGET_FILE:cgal_3D_off_reader>
+ "${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)
+ # need CGAL 4.7and Eigen3
+ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
+ add_executable ( cgal_off_reader example_CGAL_points_off_reader.cpp )
+ target_link_libraries(cgal_off_reader ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
+ add_test(NAME Common_example_vector_cgal_off_reader COMMAND $<TARGET_FILE:cgal_off_reader>
+ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off")
+ endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0)
endif()
diff --git a/example/common/CGAL_3D_points_off_reader.cpp b/example/common/example_CGAL_3D_points_off_reader.cpp
index d48bb17d..665b7a29 100644
--- a/example/common/CGAL_3D_points_off_reader.cpp
+++ b/example/common/example_CGAL_3D_points_off_reader.cpp
@@ -32,7 +32,7 @@ int main(int argc, char **argv) {
// Retrieve the triangulation
std::vector<Point_3> point_cloud = off_reader.get_point_cloud();
- int n {0};
+ int n {};
for (auto point : point_cloud) {
++n;
std::cout << "Point[" << n << "] = (" << point[0] << ", " << point[1] << ", " << point[2] << ")\n";
diff --git a/example/common/CGAL_points_off_reader.cpp b/example/common/example_CGAL_points_off_reader.cpp
index d1ca166d..8c6a6b54 100644
--- a/example/common/CGAL_points_off_reader.cpp
+++ b/example/common/example_CGAL_points_off_reader.cpp
@@ -34,10 +34,10 @@ int main(int argc, char **argv) {
// Retrieve the triangulation
std::vector<Point_d> point_cloud = off_reader.get_point_cloud();
- int n {0};
+ int n {};
for (auto point : point_cloud) {
std::cout << "Point[" << n << "] = ";
- for (int i {0}; i < point.dimension(); i++)
+ for (std::size_t i {0}; i < point.size(); i++)
std::cout << point[i] << " ";
std::cout << "\n";
++n;
diff --git a/example/common/example_vector_double_points_off_reader.cpp b/example/common/example_vector_double_points_off_reader.cpp
new file mode 100644
index 00000000..8aecb26e
--- /dev/null
+++ b/example/common/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;
+}