diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-09-19 17:27:24 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-09-19 17:27:24 +0000 |
commit | e54574c7290b28543b9c1e7d1b9a16f42825ae26 (patch) | |
tree | 6dfe7dab377095a49833fd6e13fa5dea72ba5cf7 | |
parent | 21eb395a9571d4b6df64b4972f6727b235369836 (diff) |
Rename off file reader as stands in convention.
Add an example with a vector of double for point type.
Fix SO3 OFF files accordingly to OFF file standard.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1510 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: ff61bed1f1895bc5bf1af4ae946e2a84a692c390
-rw-r--r-- | data/points/SO3_10000.off | 4 | ||||
-rw-r--r-- | data/points/SO3_50000.off | 4 | ||||
-rw-r--r-- | src/common/example/CMakeLists.txt | 18 | ||||
-rw-r--r-- | src/common/example/example_CGAL_3D_points_off_reader.cpp (renamed from src/common/example/CGAL_3D_points_off_reader.cpp) | 0 | ||||
-rw-r--r-- | src/common/example/example_CGAL_points_off_reader.cpp (renamed from src/common/example/CGAL_points_off_reader.cpp) | 2 | ||||
-rw-r--r-- | src/common/example/example_vector_double_points_off_reader.cpp | 41 | ||||
-rw-r--r-- | src/common/include/gudhi/Points_off_io.h | 11 |
7 files changed, 62 insertions, 18 deletions
diff --git a/data/points/SO3_10000.off b/data/points/SO3_10000.off index fbf9b273..3f2a3cda 100644 --- a/data/points/SO3_10000.off +++ b/data/points/SO3_10000.off @@ -1,5 +1,5 @@ -OFF -10000 1 0 +nOFF +9 10000 1 0 2.08167e-17 0 -1 -0.500001 0.866026 0 0.866026 0.500001 -2.08167e-17 0 0 -1 0.500001 -0.866026 0 -0.866026 -0.500001 0 0 0 -1 -1 0 0 0 1 0 diff --git a/data/points/SO3_50000.off b/data/points/SO3_50000.off index 635e8988..9b23a78f 100644 --- a/data/points/SO3_50000.off +++ b/data/points/SO3_50000.off @@ -1,5 +1,5 @@ -OFF -50000 1 0 +nOFF +9 50000 1 0 2.08167e-17 0 -1 -0.500001 0.866026 0 0.866026 0.500001 -2.08167e-17 0 0 -1 0.500001 -0.866026 0 -0.866026 -0.500001 0 0 0 -1 -1 0 0 0 1 0 diff --git a/src/common/example/CMakeLists.txt b/src/common/example/CMakeLists.txt index 0da3dcc0..b0c6d69a 100644 --- a/src/common/example/CMakeLists.txt +++ b/src/common/example/CMakeLists.txt @@ -1,17 +1,21 @@ 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(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 ( 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(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 ( 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) + 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/CGAL_3D_points_off_reader.cpp b/src/common/example/example_CGAL_3D_points_off_reader.cpp index d48bb17d..d48bb17d 100644 --- a/src/common/example/CGAL_3D_points_off_reader.cpp +++ b/src/common/example/example_CGAL_3D_points_off_reader.cpp diff --git a/src/common/example/CGAL_points_off_reader.cpp b/src/common/example/example_CGAL_points_off_reader.cpp index d1ca166d..264231b2 100644 --- a/src/common/example/CGAL_points_off_reader.cpp +++ b/src/common/example/example_CGAL_points_off_reader.cpp @@ -37,7 +37,7 @@ int main(int argc, char **argv) { 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.size(); i++) std::cout << point[i] << " "; std::cout << "\n"; ++n; 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..f691db92 --- /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 (int i {0}; i < point.size(); i++) + std::cout << point[i] << " "; + std::cout << "\n"; + ++n; + } + return 0; +} diff --git a/src/common/include/gudhi/Points_off_io.h b/src/common/include/gudhi/Points_off_io.h index 74b49386..18b23e84 100644 --- a/src/common/include/gudhi/Points_off_io.h +++ b/src/common/include/gudhi/Points_off_io.h @@ -73,9 +73,8 @@ class Points_off_visitor_reader { * @details * Point_d must have a constructor with the following form: * - * @code template<class InputIterator > Point_d::Point_d(int d, InputIterator first, InputIterator last) @endcode + * @code template<class InputIterator > Point_d::Point_d(InputIterator first, InputIterator last) @endcode * - * where d is the point dimension. */ void point(const std::vector<double>& point) { #ifdef DEBUG_TRACES @@ -86,7 +85,7 @@ class Points_off_visitor_reader { std::cout << std::endl; #endif // DEBUG_TRACES // Fill the point cloud - point_cloud.push_back(Point_d(point.size(), point.begin(), point.end())); + point_cloud.push_back(Point_d(point.begin(), point.end())); } // Off_reader visitor maximal_face implementation - Only points are read @@ -117,14 +116,14 @@ class Points_off_visitor_reader { * * \section Example * - * This example loads points from an OFF file and builds a vector of CGAL points in dimension d. + * This example loads points from an OFF file and builds a vector of points (vector of double). * Then, it is asked to display the points. * - * \include common/CGAL_points_off_reader.cpp + * \include common/example_vector_double_points_off_reader.cpp * * When launching: * - * \code $> ./cgaloffreader ../../data/points/alphacomplexdoc.off + * \code $> ./vector_double_off_reader ../../data/points/alphacomplexdoc.off * \endcode * * the program output is: |