From fb22bc9ca84f5b3c55a598bf0c903a73c117e783 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 6 Apr 2016 11:08:33 +0000 Subject: 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 --- src/common/test/points_off_reader_unit_test.cpp | 78 +++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/common/test/points_off_reader_unit_test.cpp (limited to 'src/common/test/points_off_reader_unit_test.cpp') 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 . + */ + +#include + +// For CGAL points type in dimension d +// cf. http://doc.cgal.org/latest/Kernel_d/classCGAL_1_1Point__d.html +#include + +#include +#include +#include + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "points_off_read_write" +#include + +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 off_reader("alphacomplexdoc.off"); + // Check the read operation was correct + BOOST_CHECK(off_reader.is_valid()); + + // Retrieve the triangulation + std::vector point_cloud = off_reader.get_point_cloud(); + BOOST_CHECK(point_cloud.size() == 7); + + std::vector expected_points; + std::vector 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 off_reader("some_impossible_weird_file_name.off"); + // Check the read operation was correct + BOOST_CHECK(!off_reader.is_valid()); + + std::vector point_cloud = off_reader.get_point_cloud(); + BOOST_CHECK(point_cloud.size() == 0); +} -- cgit v1.2.3