summaryrefslogtreecommitdiff
path: root/src/common/example
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-04-06 11:08:33 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-04-06 11:08:33 +0000
commitfb22bc9ca84f5b3c55a598bf0c903a73c117e783 (patch)
treee066a8a8fa5a07e2d0faf0be096cb542295def52 /src/common/example
parent3d592b82f837219ee9ecd8e33120563edb4e76ab (diff)
Replace Delaunay_triangulation_off_io.h and Delaunay_triangulation_off_rw.cpp with
Points_off_io.h and CGAL_points_off_reader.cpp Adapt UT and examples for this Adapt Alpha complex for it Alpha complex is now inserting points in a faster way (after a spatial_sort). Remove Alpha complex construction from a pointer on Delaunay triangulation (no more needed). Adapt documentation to all these modifications Forbid copy/move constructor/assignment operator on Alpha complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@1098 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 08a673b66451b5cb03fbdf482d696d93b35d220f
Diffstat (limited to 'src/common/example')
-rw-r--r--src/common/example/CGAL_points_off_reader.cpp43
-rw-r--r--src/common/example/CMakeLists.txt12
-rw-r--r--src/common/example/Delaunay_triangulation_off_rw.cpp54
-rw-r--r--src/common/example/cgaloffreader_result.txt7
-rw-r--r--src/common/example/dtoffrw_alphashapedoc_result.off15
-rw-r--r--src/common/example/dtoffrw_alphashapedoc_result.txt2
6 files changed, 53 insertions, 80 deletions
diff --git a/src/common/example/CGAL_points_off_reader.cpp b/src/common/example/CGAL_points_off_reader.cpp
new file mode 100644
index 00000000..076afd5b
--- /dev/null
+++ b/src/common/example/CGAL_points_off_reader.cpp
@@ -0,0 +1,43 @@
+#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>
+
+typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Kernel;
+typedef typename Kernel::Point_d Point_d;
+
+void usage(int argc, char * const progName) {
+ std::cerr << "Error: Number of arguments (" << argc << ") is not correct" << std::endl;
+ std::cerr << "Usage: " << progName << " inputFile.off" << std::endl;
+ exit(-1);
+}
+
+int main(int argc, char **argv) {
+ if (argc != 2) usage(argc, (argv[0] - 1));
+
+ 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;
+ exit(-1);
+ }
+
+ // 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/src/common/example/CMakeLists.txt b/src/common/example/CMakeLists.txt
index 91e78ea2..2914756e 100644
--- a/src/common/example/CMakeLists.txt
+++ b/src/common/example/CMakeLists.txt
@@ -9,15 +9,9 @@ if(CGAL_FOUND)
message(STATUS "Eigen3 version: ${EIGEN3_VERSION}.")
include( ${EIGEN3_USE_FILE} )
- add_executable ( dtoffrw Delaunay_triangulation_off_rw.cpp )
- target_link_libraries(dtoffrw ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
- add_test(dtoffrw ${CMAKE_CURRENT_BINARY_DIR}/dtoffrw ${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off ${CMAKE_CURRENT_BINARY_DIR}/result.off)
-
- if (DIFF_PATH)
- # Do not forget to copy test results files in current binary dir
- file(COPY "dtoffrw_alphashapedoc_result.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
- add_test(dtoffrw_result_off_diff_files ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/dtoffrw_alphashapedoc_result.off ${CMAKE_CURRENT_BINARY_DIR}/result.off)
- endif()
+ 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)
else()
message(WARNING "Eigen3 not found. Version 3.1.0 is required for Alpha shapes feature.")
diff --git a/src/common/example/Delaunay_triangulation_off_rw.cpp b/src/common/example/Delaunay_triangulation_off_rw.cpp
deleted file mode 100644
index 4c7a9aaf..00000000
--- a/src/common/example/Delaunay_triangulation_off_rw.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-// to construct a Delaunay_triangulation from a OFF file
-#include <gudhi/Delaunay_triangulation_off_io.h>
-
-#include <CGAL/Delaunay_triangulation.h>
-#include <CGAL/Epick_d.h>
-
-#include <iostream>
-#include <string>
-
-// Use dynamic_dimension_tag for the user to be able to set dimension
-typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > K;
-typedef CGAL::Delaunay_triangulation<K> T;
-// The triangulation uses the default instantiation of the
-// TriangulationDataStructure template parameter
-
-void usage(char * const progName) {
- std::cerr << "Usage: " << progName << " inputFile.off outputFile.off" << std::endl;
- exit(-1);
-}
-
-int main(int argc, char **argv) {
- if (argc != 3) {
- 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 triangulates points
- Gudhi::Delaunay_triangulation_off_reader<T> off_reader(offInputFile);
- // Check the read operation was correct
- if (!off_reader.is_valid()) {
- std::cerr << "Unable to read file " << offInputFile << std::endl;
- exit(-1);
- }
-
- // Retrieve the triangulation
- T* triangulation = off_reader.get_complex();
- // Operations on triangulation
- std::cout << "Number of vertices= " << triangulation->number_of_vertices() << std::endl;
- std::cout << "Number of finite full cells= " << triangulation->number_of_finite_full_cells() << std::endl;
-
- std::string outFileName(argv[2]);
- std::string offOutputFile(outFileName);
- // Write the OFF file (output file name given as parameter) with the points and triangulated cells as faces
- Gudhi::Delaunay_triangulation_off_writer<T> off_writer(offOutputFile, triangulation);
-
- // Check the write operation was correct
- if (!off_writer.is_valid()) {
- std::cerr << "Unable to write file " << offOutputFile << std::endl;
- exit(-1);
- }
-
- return 0;
-}
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/dtoffrw_alphashapedoc_result.off b/src/common/example/dtoffrw_alphashapedoc_result.off
deleted file mode 100644
index d1839a43..00000000
--- a/src/common/example/dtoffrw_alphashapedoc_result.off
+++ /dev/null
@@ -1,15 +0,0 @@
-nOFF
-2 7 6 0
-9 17
-0 14
-1 1
-2 19
-4 6
-9 6
-7 0
-3 5 0 4
-3 0 1 4
-3 3 1 0
-3 4 1 2
-3 5 4 6
-3 6 4 2
diff --git a/src/common/example/dtoffrw_alphashapedoc_result.txt b/src/common/example/dtoffrw_alphashapedoc_result.txt
deleted file mode 100644
index 8e659740..00000000
--- a/src/common/example/dtoffrw_alphashapedoc_result.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Number of vertices= 7
-Number of finite full cells= 6