summaryrefslogtreecommitdiff
path: root/src/common/test
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/test
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/test')
-rw-r--r--src/common/test/CMakeLists.txt14
-rw-r--r--src/common/test/dtoffrw_alphashapedoc_result.off22
-rw-r--r--src/common/test/dtoffrw_unit_test.cpp90
-rw-r--r--src/common/test/points_off_reader_unit_test.cpp78
4 files changed, 89 insertions, 115 deletions
diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt
index 12eecda8..6205f0e4 100644
--- a/src/common/test/CMakeLists.txt
+++ b/src/common/test/CMakeLists.txt
@@ -18,22 +18,16 @@ if(CGAL_FOUND)
message(STATUS "Eigen3 version: ${EIGEN3_VERSION}.")
include( ${EIGEN3_USE_FILE} )
- add_executable ( dtoffrw_UT dtoffrw_unit_test.cpp )
- target_link_libraries(dtoffrw_UT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+ add_executable ( poffreader_UT points_off_reader_unit_test.cpp )
+ target_link_libraries(poffreader_UT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
# Do not forget to copy test files in current binary dir
file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
# Unitary tests
- add_test(dtoffrw_UT ${CMAKE_CURRENT_BINARY_DIR}/dtoffrw_UT
+ add_test(poffreader_UT ${CMAKE_CURRENT_BINARY_DIR}/poffreader_UT
# XML format for Jenkins xUnit plugin
- --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/dtoffrw_UT.xml --log_level=test_suite --report_level=no)
-
- if (DIFF_PATH)
- # Do not forget to copy test result files in current binary dir
- file(COPY "dtoffrw_alphashapedoc_result.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
- add_test(dtoffrw_diff_files_UT ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/UT.off ${CMAKE_CURRENT_BINARY_DIR}/dtoffrw_alphashapedoc_result.off)
- endif()
+ --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/poffreader_UT.xml --log_level=test_suite --report_level=no)
else()
message(WARNING "Eigen3 not found. Version 3.1.0 is required for Alpha shapes feature.")
diff --git a/src/common/test/dtoffrw_alphashapedoc_result.off b/src/common/test/dtoffrw_alphashapedoc_result.off
index d1839a43..1deb8dbd 100644
--- a/src/common/test/dtoffrw_alphashapedoc_result.off
+++ b/src/common/test/dtoffrw_alphashapedoc_result.off
@@ -1,15 +1,7 @@
-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
+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/test/dtoffrw_unit_test.cpp b/src/common/test/dtoffrw_unit_test.cpp
deleted file mode 100644
index f682df1a..00000000
--- a/src/common/test/dtoffrw_unit_test.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Vincent Rouvreau
- *
- * Copyright (C) 2015 INRIA Saclay (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// 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 <stdlib.h>
-
-#include <iostream>
-#include <string>
-
-#define BOOST_TEST_DYN_LINK
-#define BOOST_TEST_MODULE "delaunay_triangulation_off_read_write"
-#include <boost/test/unit_test.hpp>
-
-// 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;
-
-BOOST_AUTO_TEST_CASE( Delaunay_triangulation_doc_test )
-{
- // Read the OFF file (input file name given as parameter) and triangulates points
- Gudhi::Delaunay_triangulation_off_reader<T> off_reader("alphacomplexdoc.off");
- // Check the read operation was correct
- BOOST_CHECK(off_reader.is_valid());
-
- // Retrieve the triangulation
- T* triangulation = off_reader.get_complex();
- BOOST_CHECK(triangulation != nullptr);
- // Operations on triangulation
- BOOST_CHECK(triangulation->number_of_vertices() == 7);
- BOOST_CHECK(triangulation->number_of_finite_full_cells() == 6);
-
- // 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("UT.off", triangulation);
-
- // Check the write operation was correct
- BOOST_CHECK(off_writer.is_valid());
-
- delete triangulation;
-}
-
-BOOST_AUTO_TEST_CASE( Delaunay_triangulation_unexisting_file_read_test )
-{
- Gudhi::Delaunay_triangulation_off_reader<T> off_reader("some_impossible_weird_file_name.off");
- // Check the read operation was correct
- BOOST_CHECK(!off_reader.is_valid());
- T* triangulation = off_reader.get_complex();
- BOOST_CHECK(triangulation == nullptr);
-}
-
-BOOST_AUTO_TEST_CASE( Delaunay_triangulation_unexisting_file_write_test )
-{
- // Read the OFF file (input file name given as parameter) and triangulates points
- Gudhi::Delaunay_triangulation_off_reader<T> off_reader("alphacomplexdoc.off");
-
- // Retrieve the triangulation
- T* triangulation = off_reader.get_complex();
-
- // 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("/some_impossible_weird_directory_name/another_weird_directory_name/some_impossible_weird_file_name.off", triangulation);
-
- // Check the write operation was correct
- BOOST_CHECK(!off_writer.is_valid());
-
- delete triangulation;
-}
-
diff --git a/src/common/test/points_off_reader_unit_test.cpp b/src/common/test/points_off_reader_unit_test.cpp
new file mode 100644
index 00000000..73e19cbc
--- /dev/null
+++ b/src/common/test/points_off_reader_unit_test.cpp
@@ -0,0 +1,78 @@
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Vincent Rouvreau
+ *
+ * Copyright (C) 2015 INRIA Saclay (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#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>
+
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE "points_off_read_write"
+#include <boost/test/unit_test.hpp>
+
+typedef CGAL::Epick_d< CGAL::Dynamic_dimension_tag > Kernel;
+typedef typename Kernel::Point_d Point_d;
+
+BOOST_AUTO_TEST_CASE( points_doc_test )
+{
+ // Read the OFF file (input file name given as parameter) and triangulates points
+ Gudhi::Points_off_reader<Point_d> off_reader("alphacomplexdoc.off");
+ // Check the read operation was correct
+ BOOST_CHECK(off_reader.is_valid());
+
+ // Retrieve the triangulation
+ std::vector<Point_d> point_cloud = off_reader.get_point_cloud();
+ BOOST_CHECK(point_cloud.size() == 7);
+
+ std::vector<Point_d> expected_points;
+ std::vector<double> point = {1.0, 1.0};
+ expected_points.push_back(Point_d(2, point.begin(), point.end()));
+ point = {7.0, 0.0};
+ expected_points.push_back(Point_d(2, point.begin(), point.end()));
+ point = {4.0, 6.0};
+ expected_points.push_back(Point_d(2, point.begin(), point.end()));
+ point = {9.0, 6.0};
+ expected_points.push_back(Point_d(2, point.begin(), point.end()));
+ point = {0.0, 14.0};
+ expected_points.push_back(Point_d(2, point.begin(), point.end()));
+ point = {2.0, 19.0};
+ expected_points.push_back(Point_d(2, point.begin(), point.end()));
+ point = {9.0, 17.0};
+ expected_points.push_back(Point_d(2, point.begin(), point.end()));
+
+ BOOST_CHECK(point_cloud == expected_points);
+}
+
+BOOST_AUTO_TEST_CASE( Delaunay_triangulation_unexisting_file_read_test )
+{
+ Gudhi::Points_off_reader<Point_d> off_reader("some_impossible_weird_file_name.off");
+ // Check the read operation was correct
+ BOOST_CHECK(!off_reader.is_valid());
+
+ std::vector<Point_d> point_cloud = off_reader.get_point_cloud();
+ BOOST_CHECK(point_cloud.size() == 0);
+}