From 2ca2d175f0b49ff267d9a99e5a4c0a5f03e0d30c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 18 Aug 2015 12:45:13 +0000 Subject: exception throw on get_point not found git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alphashapes@740 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: fd2efc725a140f978d2624fe7879dc32f5566ab0 --- src/Alpha_complex/include/gudhi/Alpha_complex.h | 13 +++++-------- src/Alpha_complex/test/Alpha_complex_unit_test.cpp | 20 ++++++-------------- 2 files changed, 11 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 71d34229..213436e0 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -166,17 +166,14 @@ class Alpha_complex : public Simplex_tree<> { * * @param[in] vertex Vertex handle of the point to retrieve. * @return The founded point. + * @warning Exception std::out_of_range is thrown in case vertex is not in the map vertex_handle_to_iterator_. */ Point_d get_point(Vertex_handle vertex) { - Point_d point(dimension()); - try { - if (vertex_handle_to_iterator_[vertex] != nullptr) { - point = vertex_handle_to_iterator_[vertex]->point(); - } - } catch (...) { - std::cerr << "Alpha_complex - getPoint not found on vertex " << vertex << std::endl; + if (vertex_handle_to_iterator_[vertex] != nullptr) { + return vertex_handle_to_iterator_[vertex]->point(); + } else { + throw std::out_of_range("Vertex out of vector range"); } - return point; } private: diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp index aa9500e7..c15f07e1 100644 --- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp @@ -92,11 +92,11 @@ BOOST_AUTO_TEST_CASE(S4_100_OFF_file_filtered) { std::cout << "alpha_complex_from_file.dimension()=" << alpha_complex_from_file.dimension() << std::endl; BOOST_CHECK(alpha_complex_from_file.dimension() == DIMENSION); - const int NUMBER_OF_VERTICES = 13; // Versus 100, because of filtered alpha value + const int NUMBER_OF_VERTICES = 100; std::cout << "alpha_complex_from_file.num_vertices()=" << alpha_complex_from_file.num_vertices() << std::endl; BOOST_CHECK(alpha_complex_from_file.num_vertices() == NUMBER_OF_VERTICES); - const int NUMBER_OF_SIMPLICES = 90; // Versus 6879, because of filtered alpha value + const int NUMBER_OF_SIMPLICES = 5966; // Versus 6879, because of filtered alpha value std::cout << "alpha_complex_from_file.num_simplices()=" << alpha_complex_from_file.num_simplices() << std::endl; // TODO(VR) : BOOST_CHECK(alpha_complex_from_file.num_simplices() == NUMBER_OF_SIMPLICES); @@ -166,7 +166,7 @@ BOOST_AUTO_TEST_CASE(S8_10_OFF_file_filtered) { std::cout << "alpha_complex_from_file.num_vertices()=" << alpha_complex_from_file.num_vertices() << std::endl; BOOST_CHECK(alpha_complex_from_file.num_vertices() == NUMBER_OF_VERTICES); - const int NUMBER_OF_SIMPLICES = 895; // Versus 1007, because of filtered alpha value + const int NUMBER_OF_SIMPLICES = 1004; // Versus 1007, because of filtered alpha value std::cout << "alpha_complex_from_file.num_simplices()=" << alpha_complex_from_file.num_simplices() << std::endl; // TODO(VR) : BOOST_CHECK(alpha_complex_from_file.num_simplices() == NUMBER_OF_SIMPLICES); @@ -283,15 +283,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { BOOST_CHECK(4 == p4.dimension()); BOOST_CHECK(is_point_in_list(points, p4)); - Point p5 = alpha_complex_from_points.get_point(5); - std::cout << "alpha_complex_from_points.get_point(5)=" << p5 << std::endl; - BOOST_CHECK(!is_point_in_list(points, p5)); - - Point p0 = alpha_complex_from_points.get_point(0); - std::cout << "alpha_complex_from_points.get_point(0)=" << p0 << std::endl; - BOOST_CHECK(!is_point_in_list(points, p0)); - - Point p1234 = alpha_complex_from_points.get_point(1234); - std::cout << "alpha_complex_from_points.get_point(1234)=" << p1234.dimension() << std::endl; - BOOST_CHECK(!is_point_in_list(points, p1234)); + BOOST_CHECK_THROW (alpha_complex_from_points.get_point(5), std::out_of_range); + BOOST_CHECK_THROW (alpha_complex_from_points.get_point(0), std::out_of_range); + BOOST_CHECK_THROW (alpha_complex_from_points.get_point(1234), std::out_of_range); } -- cgit v1.2.3