diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Alpha_complex/include/gudhi/Alpha_complex.h | 29 | ||||
-rw-r--r-- | src/Alpha_complex/test/Alpha_complex_unit_test.cpp | 43 |
2 files changed, 65 insertions, 7 deletions
diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 138270ff..16781563 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -50,8 +50,6 @@ namespace Gudhi { namespace alphacomplex { -#define Kinit(f) =k.f() - /** * \brief Alpha complex data structure. * @@ -99,6 +97,8 @@ class Alpha_complex : public Simplex_tree<> { Bimap_vertex cgal_simplextree; /** \brief Pointer on the CGAL Delaunay triangulation.*/ Delaunay_triangulation* triangulation; + /** \brief Kernel for triangulation functions access.*/ + Kernel kernel; public: /** \brief Alpha_complex constructor from an OFF file name. @@ -156,6 +156,22 @@ class Alpha_complex : public Simplex_tree<> { delete triangulation; } + /** \brief get_point returns the point corresponding to the vertex given as parameter. + * + * @param[in] vertex Vertex handle of the point to retrieve. + * @return The founded point. + */ + Kernel::Point_d get_point(Vertex_handle vertex) { + Kernel::Point_d point; + try { + point = cgal_simplextree.right.at(vertex)->point(); + } + catch(...) { + std::cerr << "Alpha_complex - getPoint not found on vertex " << vertex << std::endl; + } + return point; + } + private: /** \brief Initialize the Alpha_complex from the Delaunay triangulation. * @@ -248,9 +264,8 @@ class Alpha_complex : public Simplex_tree<> { // No need to compute squared_radius on a single point - alpha is 0.0 if (f_simplex_dim > 0) { // squared_radius function initialization - Kernel k; - Squared_Radius squared_radius Kinit(compute_squared_radius_d_object); - + Squared_Radius squared_radius = kernel.compute_squared_radius_d_object(); + alpha_complex_filtration = squared_radius(pointVector.begin(), pointVector.end()); } assign_filtration(f_simplex, alpha_complex_filtration); @@ -315,8 +330,7 @@ class Alpha_complex : public Simplex_tree<> { } } // is_gabriel function initialization - Kernel k; - Is_Gabriel is_gabriel Kinit(side_of_bounded_sphere_d_object); + Is_Gabriel is_gabriel = kernel.side_of_bounded_sphere_d_object(); #ifdef DEBUG_TRACES bool is_gab = is_gabriel(pointVector.begin(), pointVector.end(), (cgal_simplextree.right.at(vertexForGabriel))->point()) != CGAL::ON_BOUNDED_SIDE; @@ -337,6 +351,7 @@ class Alpha_complex : public Simplex_tree<> { } } } + }; } // namespace alphacomplex diff --git a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp index 9530314c..b55b5e2e 100644 --- a/src/Alpha_complex/test/Alpha_complex_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_unit_test.cpp @@ -93,6 +93,14 @@ bool are_almost_the_same(float a, float b) { return std::fabs(a - b) < std::numeric_limits<float>::epsilon(); } +bool is_point_in_list(Vector_of_points points_list, Point point) { + for (auto& point_in_list : points_list) { + if (point_in_list == point) { + return true; // point found + } + } + return false; // point not found +} BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { // ---------------------------------------------------------------------------- @@ -159,5 +167,40 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_from_points) { break; } } + + Point p1 = alpha_complex_from_points.get_point(1); + std::cout << "alpha_complex_from_points.get_point(1)=" << p1 << std::endl; + BOOST_CHECK(4 == p1.dimension()); + BOOST_CHECK(is_point_in_list(points, p1)); + + Point p2 = alpha_complex_from_points.get_point(2); + std::cout << "alpha_complex_from_points.get_point(2)=" << p2 << std::endl; + BOOST_CHECK(4 == p2.dimension()); + BOOST_CHECK(is_point_in_list(points, p2)); + + Point p3 = alpha_complex_from_points.get_point(3); + std::cout << "alpha_complex_from_points.get_point(3)=" << p3 << std::endl; + BOOST_CHECK(4 == p3.dimension()); + BOOST_CHECK(is_point_in_list(points, p3)); + + Point p4 = alpha_complex_from_points.get_point(4); + std::cout << "alpha_complex_from_points.get_point(4)=" << p4 << std::endl; + 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(0 == p5.dimension()); + 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(0 == p0.dimension()); + 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(0 == p1234.dimension()); + BOOST_CHECK(!is_point_in_list(points, p1234)); } |