summaryrefslogtreecommitdiff
path: root/src/common/test
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-06-18 14:21:31 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-06-18 14:21:31 +0000
commit56e89b6b7666dec86a70f6a30f08ef8b7960eb21 (patch)
treea43dd7705fcf7435df726e5bc5123662abc8ea4d /src/common/test
parent77b57ae69fa2042b652d91d8015c1d9533176090 (diff)
Moved alphashapedoc.off in data/points
Moved Delaunay triangulation OFF files read and write in src/common Delaunay triangulation OFF files read and write documentation, examples and tests git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@623 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: e03902736a79436e97dbf77a88504f3faa8bd9c6
Diffstat (limited to 'src/common/test')
-rw-r--r--src/common/test/CMakeLists.txt44
-rw-r--r--src/common/test/README14
-rw-r--r--src/common/test/dtoffrw_alphashapedoc_result.off15
-rw-r--r--src/common/test/dtoffrw_alphashapedoc_result.txt3
-rw-r--r--src/common/test/dtoffrw_unit_test.cpp91
5 files changed, 167 insertions, 0 deletions
diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt
new file mode 100644
index 00000000..22783caf
--- /dev/null
+++ b/src/common/test/CMakeLists.txt
@@ -0,0 +1,44 @@
+cmake_minimum_required(VERSION 2.6)
+project(GUDHIDelaunayTriangulationOffFileReadWriteUT)
+
+if(NOT MSVC)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} --coverage")
+endif()
+
+# need CGAL 4.6
+if(CGAL_FOUND)
+ if (NOT CGAL_VERSION VERSION_LESS 4.6.0)
+ message(STATUS "CGAL version: ${CGAL_VERSION}.")
+
+ include( ${CGAL_USE_FILE} )
+
+ find_package(Eigen3 3.1.0)
+ if (EIGEN3_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})
+
+ # Unitary tests
+ add_test(dtoffrw_UT ${CMAKE_CURRENT_BINARY_DIR}/dtoffrw_UT)
+
+ if (DIFF_PATH)
+ add_test(diff_files_UT ${DIFF_PATH} ${CMAKE_CURRENT_BINARY_DIR}/UT.off ${CMAKE_CURRENT_BINARY_DIR}/dtoffrw_alphashapedoc_result.off)
+ endif()
+
+ else()
+ message(WARNING "Eigen3 not found. Version 3.1.0 is required for Alpha shapes feature.")
+ endif()
+ else()
+ message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile Alpha shapes feature. Version 4.6.0 is required.")
+ endif ()
+endif()
+
+
+
+
+
+cpplint_add_tests("${CMAKE_SOURCE_DIR}/src/common/include/gudhi")
diff --git a/src/common/test/README b/src/common/test/README
new file mode 100644
index 00000000..f2a7eb5a
--- /dev/null
+++ b/src/common/test/README
@@ -0,0 +1,14 @@
+To compile:
+***********
+
+cmake .
+make
+
+To launch with details:
+***********************
+
+./dtoffrw_UT --report_level=detailed --log_level=all
+
+ ==> echo $? returns 0 in case of success (non-zero otherwise)
+
+
diff --git a/src/common/test/dtoffrw_alphashapedoc_result.off b/src/common/test/dtoffrw_alphashapedoc_result.off
new file mode 100644
index 00000000..13c255c6
--- /dev/null
+++ b/src/common/test/dtoffrw_alphashapedoc_result.off
@@ -0,0 +1,15 @@
+nOFF
+2 7 6 0
+1 1
+7 0
+4 6
+9 6
+0 14
+2 19
+9 17
+3 1 2 3
+3 4 3 2
+3 5 1 3
+3 5 3 7
+3 7 3 4
+3 6 5 7
diff --git a/src/common/test/dtoffrw_alphashapedoc_result.txt b/src/common/test/dtoffrw_alphashapedoc_result.txt
new file mode 100644
index 00000000..57761d14
--- /dev/null
+++ b/src/common/test/dtoffrw_alphashapedoc_result.txt
@@ -0,0 +1,3 @@
+Number of vertices= 7
+Number of finite full cells= 6
+
diff --git a/src/common/test/dtoffrw_unit_test.cpp b/src/common/test/dtoffrw_unit_test.cpp
new file mode 100644
index 00000000..4905d845
--- /dev/null
+++ b/src/common/test/dtoffrw_unit_test.cpp
@@ -0,0 +1,91 @@
+/* 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/>.
+ */
+
+#define BOOST_TEST_MODULE DelaunayTriangulationOffFileReadWrite test
+
+// 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 <stdio.h>
+#include <stdlib.h>
+#include <string>
+
+#include <boost/test/included/unit_test.hpp>
+#include <boost/system/error_code.hpp>
+//#include <boost/chrono/thread_clock.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("../../../data/points/alphashapedoc.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("pouetpouet_tralala.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("../../../data/points/alphashapedoc.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("/pouetpouet_tralala/pouetpouet_tralala/pouetpouet_tralala.off", triangulation);
+
+ // Check the write operation was correct
+ BOOST_CHECK(!off_writer.is_valid());
+
+ delete triangulation;
+}
+