From db938dbd74460e7a0fd705be8628984052f71dc0 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 4 Sep 2020 17:23:16 +0200 Subject: Alpha_kernel_d, its tests and Alpha complex to use it --- .../include/gudhi/Alpha_complex/Alpha_kernel_d.h | 137 +++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h new file mode 100644 index 00000000..87604ec4 --- /dev/null +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -0,0 +1,137 @@ +/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + * Author(s): Vincent Rouvreau + * + * Copyright (C) 2020 Inria + * + * Modification(s): + * - YYYY/MM Author: Description of the modification + */ + +#ifndef ALPHA_COMPLEX_ALPHA_KERNEL_D_H_ +#define ALPHA_COMPLEX_ALPHA_KERNEL_D_H_ + +#include // For EXACT or SAFE version +#include // For FAST version +#include // for CGAL_VERSION_NR + +#include // for EIGEN_VERSION_AT_LEAST + +#include // for std::make_pair + +// Make compilation fail - required for external projects - https://github.com/GUDHI/gudhi-devel/issues/10 +#if CGAL_VERSION_NR < 1041101000 +# error Alpha_complex is only available for CGAL >= 4.11 +#endif + +#if !EIGEN_VERSION_AT_LEAST(3,1,0) +# error Alpha_complex is only available for Eigen3 >= 3.1.0 installed with CGAL +#endif + +namespace Gudhi { + +namespace alpha_complex { + +template < typename Kernel, bool Weighted = false > +class Alpha_kernel_d { +}; + +// Unweighted Kernel_d version +template < typename Kernel > +class Alpha_kernel_d { + private: + // Kernel for functions access. + Kernel kernel_; + public: + // Fake type for compilation to succeed (cf. std::conditional in Alpha_complex.h) + using Weighted_point_d = void; + using Point_d = typename Kernel::Point_d; + // Numeric type of coordinates in the kernel + using FT = typename Kernel::FT; + // Sphere is a pair of point and squared radius. + using Sphere = typename std::pair; + + int get_dimension(const Point_d& p0) const { + return kernel_.point_dimension_d_object()(p0); + } + + template + Sphere get_sphere(PointIterator begin, PointIterator end) const { + Point_d c = kernel_.construct_circumcenter_d_object()(begin, end); + FT r = kernel_.squared_distance_d_object()(c, *begin); + return std::make_pair(std::move(c), std::move(r)); + } + + template + FT get_squared_radius(PointIterator begin, PointIterator end) const { + return kernel_.compute_squared_radius_d_object()(begin, end); + } + + FT get_squared_radius(const Sphere& sph) const { + return sph.second; + } + + template + Point get_circumcenter(const Sphere& sph) const { + return sph.first; + } + + template + FT get_squared_distance(const Point& first, const Point& second) const { + return kernel_.squared_distance_d_object()(first, second); + } +}; + +// Weighted Kernel_d version +template < typename Kernel > +class Alpha_kernel_d { + private: + // Kernel for functions access. + Kernel kernel_; + public: + // Fake type for compilation to succeed (cf. std::conditional in Alpha_complex.h) + using Point_d = void; + using Weighted_point_d = typename Kernel::Weighted_point_d; + using Bare_point_d = typename Kernel::Point_d; + // Numeric type of coordinates in the kernel + using FT = typename Kernel::FT; + // Sphere is a weighted point (point + weight [= squared radius]). + using Sphere = Weighted_point_d; + + int get_dimension(const Weighted_point_d& p0) const { + return kernel_.point_dimension_d_object()(p0.point()); + } + + template + Sphere get_sphere(PointIterator begin, PointIterator end) const { + return kernel_.power_center_d_object()(begin, end); + } + + template + FT get_squared_radius(PointIterator begin, PointIterator end) const { + Sphere sph = get_sphere(begin, end); + return sph.weight(); + } + + FT get_squared_radius(const Sphere& sph) const { + return sph.weight(); + } + + template + Point get_circumcenter(const Sphere& sph) const { + return sph.point(); + } + + template + FT get_squared_distance(const Point& first, const Point& second) const { + return kernel_.power_distance_d_object()(first, second); + } +}; + +} // namespace alpha_complex + +namespace alphacomplex = alpha_complex; + +} // namespace Gudhi + +#endif // ALPHA_COMPLEX_ALPHA_KERNEL_D_H_ \ No newline at end of file -- cgit v1.2.3 From 9922407fe6f5d8872522157555c3573e95930ac3 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 7 Sep 2020 10:31:11 +0200 Subject: Fix compilation error and test with 0. weights --- src/Alpha_complex/example/CMakeLists.txt | 4 +++- .../example/Weighted_alpha_complex_from_points.cpp | 14 +++++++------- .../include/gudhi/Alpha_complex/Alpha_kernel_d.h | 11 ++++------- 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt index 08eb979e..17dc896c 100644 --- a/src/Alpha_complex/example/CMakeLists.txt +++ b/src/Alpha_complex/example/CMakeLists.txt @@ -28,6 +28,8 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) add_test(NAME Alpha_complex_example_fast_from_off_32 COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "32.0" "${CMAKE_CURRENT_BINARY_DIR}/fastalphaoffreader_result_32.txt") + add_test(NAME Weighted_alpha_complex_example_from_points COMMAND $) + if (DIFF_PATH) # Do not forget to copy test results files in current binary dir file(COPY "alphaoffreader_for_doc_32.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) @@ -47,7 +49,7 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) ${CMAKE_CURRENT_BINARY_DIR}/fastalphaoffreader_result_32.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_32.txt) set_tests_properties(Alpha_complex_example_fast_from_off_32_diff_files PROPERTIES DEPENDS Alpha_complex_example_fast_from_off_32) endif() - endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) +endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) if (NOT CGAL_VERSION VERSION_LESS 4.11.0) add_executable ( Alpha_complex_example_weighted_3d_from_points Weighted_alpha_complex_3d_from_points.cpp ) diff --git a/src/Alpha_complex/example/Weighted_alpha_complex_from_points.cpp b/src/Alpha_complex/example/Weighted_alpha_complex_from_points.cpp index 19a04282..05858084 100644 --- a/src/Alpha_complex/example/Weighted_alpha_complex_from_points.cpp +++ b/src/Alpha_complex/example/Weighted_alpha_complex_from_points.cpp @@ -18,13 +18,13 @@ int main() { // Init of a list of points // ---------------------------------------------------------------------------- Vector_of_points points; - points.push_back(Weighted_point(Bare_point(1.0, 1.0) , 1.)); - points.push_back(Weighted_point(Bare_point(7.0, 0.0) , 1.)); - points.push_back(Weighted_point(Bare_point(4.0, 6.0) , 1.)); - points.push_back(Weighted_point(Bare_point(9.0, 6.0) , 1.)); - points.push_back(Weighted_point(Bare_point(0.0, 14.0), 1.)); - points.push_back(Weighted_point(Bare_point(2.0, 19.0), 1.)); - points.push_back(Weighted_point(Bare_point(9.0, 17.0), 1.)); + points.push_back(Weighted_point(Bare_point(1.0, 1.0) , 0.)); + points.push_back(Weighted_point(Bare_point(7.0, 0.0) , 0.)); + points.push_back(Weighted_point(Bare_point(4.0, 6.0) , 0.)); + points.push_back(Weighted_point(Bare_point(9.0, 6.0) , 0.)); + points.push_back(Weighted_point(Bare_point(0.0, 14.0), 0.)); + points.push_back(Weighted_point(Bare_point(2.0, 19.0), 0.)); + points.push_back(Weighted_point(Bare_point(9.0, 17.0), 0.)); // ---------------------------------------------------------------------------- // Init of an alpha complex from the list of points diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h index 87604ec4..a3e3845a 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -71,8 +71,7 @@ class Alpha_kernel_d { return sph.second; } - template - Point get_circumcenter(const Sphere& sph) const { + auto get_circumcenter(const Sphere& sph) const { return sph.first; } @@ -117,13 +116,11 @@ class Alpha_kernel_d { return sph.weight(); } - template - Point get_circumcenter(const Sphere& sph) const { - return sph.point(); + auto get_circumcenter(const Sphere& sph) const { + return sph; } - template - FT get_squared_distance(const Point& first, const Point& second) const { + FT get_squared_distance(const Weighted_point_d& first, const Weighted_point_d& second) const { return kernel_.power_distance_d_object()(first, second); } }; -- cgit v1.2.3 From 171ddab9b7a50f0303d7201fa547dbfb445f9698 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 11 Sep 2020 11:55:55 +0200 Subject: Requires CGAL >= 5.1. Fix is_gabriel computation --- src/Alpha_complex/example/CMakeLists.txt | 14 +++++++++----- .../example/Weighted_alpha_complex_from_points.cpp | 14 +++++++------- src/Alpha_complex/include/gudhi/Alpha_complex.h | 8 ++++++-- .../include/gudhi/Alpha_complex/Alpha_kernel_d.h | 17 ++++------------- src/Alpha_complex/test/CMakeLists.txt | 13 +++++++++---- 5 files changed, 35 insertions(+), 31 deletions(-) (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt index 17dc896c..1fc2330a 100644 --- a/src/Alpha_complex/example/CMakeLists.txt +++ b/src/Alpha_complex/example/CMakeLists.txt @@ -7,13 +7,10 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) target_link_libraries(Alpha_complex_example_from_off ${CGAL_LIBRARY}) add_executable ( Alpha_complex_example_fast_from_off Fast_alpha_complex_from_off.cpp ) target_link_libraries(Alpha_complex_example_fast_from_off ${CGAL_LIBRARY}) - add_executable ( Weighted_alpha_complex_example_from_points Weighted_alpha_complex_from_points.cpp ) - target_link_libraries(Weighted_alpha_complex_example_from_points ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Alpha_complex_example_from_points ${TBB_LIBRARIES}) target_link_libraries(Alpha_complex_example_from_off ${TBB_LIBRARIES}) target_link_libraries(Alpha_complex_example_fast_from_off ${TBB_LIBRARIES}) - target_link_libraries(Weighted_alpha_complex_example_from_points ${TBB_LIBRARIES}) endif() add_test(NAME Alpha_complex_example_from_points COMMAND $) @@ -28,8 +25,6 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) add_test(NAME Alpha_complex_example_fast_from_off_32 COMMAND $ "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" "32.0" "${CMAKE_CURRENT_BINARY_DIR}/fastalphaoffreader_result_32.txt") - add_test(NAME Weighted_alpha_complex_example_from_points COMMAND $) - if (DIFF_PATH) # Do not forget to copy test results files in current binary dir file(COPY "alphaoffreader_for_doc_32.txt" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) @@ -69,3 +64,12 @@ if (NOT CGAL_VERSION VERSION_LESS 4.11.0) COMMAND $) endif(NOT CGAL_VERSION VERSION_LESS 4.11.0) + +if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 5.1.0) + add_executable ( Weighted_alpha_complex_example_from_points Weighted_alpha_complex_from_points.cpp ) + target_link_libraries(Weighted_alpha_complex_example_from_points ${CGAL_LIBRARY}) + if (TBB_FOUND) + target_link_libraries(Weighted_alpha_complex_example_from_points ${TBB_LIBRARIES}) + endif() + add_test(NAME Weighted_alpha_complex_example_from_points COMMAND $) +endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 5.1.0) diff --git a/src/Alpha_complex/example/Weighted_alpha_complex_from_points.cpp b/src/Alpha_complex/example/Weighted_alpha_complex_from_points.cpp index 05858084..19a04282 100644 --- a/src/Alpha_complex/example/Weighted_alpha_complex_from_points.cpp +++ b/src/Alpha_complex/example/Weighted_alpha_complex_from_points.cpp @@ -18,13 +18,13 @@ int main() { // Init of a list of points // ---------------------------------------------------------------------------- Vector_of_points points; - points.push_back(Weighted_point(Bare_point(1.0, 1.0) , 0.)); - points.push_back(Weighted_point(Bare_point(7.0, 0.0) , 0.)); - points.push_back(Weighted_point(Bare_point(4.0, 6.0) , 0.)); - points.push_back(Weighted_point(Bare_point(9.0, 6.0) , 0.)); - points.push_back(Weighted_point(Bare_point(0.0, 14.0), 0.)); - points.push_back(Weighted_point(Bare_point(2.0, 19.0), 0.)); - points.push_back(Weighted_point(Bare_point(9.0, 17.0), 0.)); + points.push_back(Weighted_point(Bare_point(1.0, 1.0) , 1.)); + points.push_back(Weighted_point(Bare_point(7.0, 0.0) , 1.)); + points.push_back(Weighted_point(Bare_point(4.0, 6.0) , 1.)); + points.push_back(Weighted_point(Bare_point(9.0, 6.0) , 1.)); + points.push_back(Weighted_point(Bare_point(0.0, 14.0), 1.)); + points.push_back(Weighted_point(Bare_point(2.0, 19.0), 1.)); + points.push_back(Weighted_point(Bare_point(9.0, 17.0), 1.)); // ---------------------------------------------------------------------------- // Init of an alpha complex from the list of points diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 8e9fe773..4316d9bc 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -210,6 +210,11 @@ class Alpha_complex { << std::endl; #endif +#if CGAL_VERSION_NR < 1050101000 + // Make compilation fail if weighted and CGAL < 5.1 + static_assert(!Weighted, "Weighted Alpha_complex is only available for CGAL >= 5.1"); +#endif + auto first = std::begin(points); auto last = std::end(points); @@ -457,8 +462,7 @@ class Alpha_complex { while(shortiter != enditer && *longiter == *shortiter) { ++longiter; ++shortiter; } Vertex_handle extra = *longiter; auto const& cache=get_cache(complex, f_boundary); - bool is_gab = kernel_.get_squared_distance(kernel_.get_circumcenter(cache), get_point_(extra)) >= - kernel_.get_squared_radius(cache); + bool is_gab = kernel_.is_gabriel(cache, get_point_(extra)); #ifdef DEBUG_TRACES std::clog << " | Tau is_gabriel(Sigma)=" << is_gab << " - vertexForGabriel=" << extra << std::endl; #endif // DEBUG_TRACES diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h index a3e3845a..b64e4f59 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -71,13 +71,8 @@ class Alpha_kernel_d { return sph.second; } - auto get_circumcenter(const Sphere& sph) const { - return sph.first; - } - - template - FT get_squared_distance(const Point& first, const Point& second) const { - return kernel_.squared_distance_d_object()(first, second); + bool is_gabriel(const Sphere& circumcenter, const Point_d& point) { + return kernel_.squared_distance_d_object()(circumcenter.first, point) >= circumcenter.second; } }; @@ -116,12 +111,8 @@ class Alpha_kernel_d { return sph.weight(); } - auto get_circumcenter(const Sphere& sph) const { - return sph; - } - - FT get_squared_distance(const Weighted_point_d& first, const Weighted_point_d& second) const { - return kernel_.power_distance_d_object()(first, second); + bool is_gabriel(const Sphere& circumcenter, const Weighted_point_d& point) { + return kernel_.power_distance_d_object()(circumcenter, point) >= 0; } }; diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt index 71e4ea7c..837d2948 100644 --- a/src/Alpha_complex/test/CMakeLists.txt +++ b/src/Alpha_complex/test/CMakeLists.txt @@ -10,17 +10,13 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) target_link_libraries(Alpha_complex_test_unit ${CGAL_LIBRARY}) add_executable ( Delaunay_complex_test_unit Delaunay_complex_unit_test.cpp ) target_link_libraries(Delaunay_complex_test_unit ${CGAL_LIBRARY}) - add_executable ( Alpha_kernel_d_test_unit Alpha_kernel_d_unit_test.cpp ) - target_link_libraries(Alpha_kernel_d_test_unit ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Alpha_complex_test_unit ${TBB_LIBRARIES}) target_link_libraries(Delaunay_complex_test_unit ${TBB_LIBRARIES}) - target_link_libraries(Alpha_kernel_d_test_unit ${TBB_LIBRARIES}) endif() gudhi_add_boost_test(Alpha_complex_test_unit) gudhi_add_boost_test(Delaunay_complex_test_unit) - gudhi_add_boost_test(Alpha_kernel_d_test_unit) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) @@ -47,3 +43,12 @@ if (NOT CGAL_VERSION VERSION_LESS 4.11.0) gudhi_add_boost_test(Weighted_periodic_alpha_complex_3d_test_unit) endif (NOT CGAL_VERSION VERSION_LESS 4.11.0) + +if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 5.1.0) + add_executable ( Alpha_kernel_d_test_unit Alpha_kernel_d_unit_test.cpp ) + target_link_libraries(Alpha_kernel_d_test_unit ${CGAL_LIBRARY}) + if (TBB_FOUND) + target_link_libraries(Alpha_kernel_d_test_unit ${TBB_LIBRARIES}) + endif() + gudhi_add_boost_test(Alpha_kernel_d_test_unit) +endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 5.1.0) \ No newline at end of file -- cgit v1.2.3 From d299e943d6fd07a58a270fe685dac7b5d5d23964 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 11 Sep 2020 14:35:39 +0200 Subject: fonction was renamed between 5.1 and 5.2 --- .../include/gudhi/Alpha_complex/Alpha_kernel_d.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h index b64e4f59..a4824207 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -82,6 +82,7 @@ class Alpha_kernel_d { private: // Kernel for functions access. Kernel kernel_; + public: // Fake type for compilation to succeed (cf. std::conditional in Alpha_complex.h) using Point_d = void; @@ -98,7 +99,13 @@ class Alpha_kernel_d { template Sphere get_sphere(PointIterator begin, PointIterator end) const { + // power_center_d_object has been renamed between CGAL 5.1 and 5.2 +#if defined CGAL_VERSION_NR >= 1050101000 && defined CGAL_VERSION_NR < 1050201000 return kernel_.power_center_d_object()(begin, end); +#endif +#if CGAL_VERSION_NR >= 1050201000 + return kernel_.construct_power_sphere_d_object()(begin, end); +#endif } template @@ -112,7 +119,13 @@ class Alpha_kernel_d { } bool is_gabriel(const Sphere& circumcenter, const Weighted_point_d& point) { + // power_center_d_object has been renamed between CGAL 5.1 and 5.2 +#if defined CGAL_VERSION_NR >= 1050101000 && defined CGAL_VERSION_NR < 1050201000 return kernel_.power_distance_d_object()(circumcenter, point) >= 0; +#endif +#if CGAL_VERSION_NR >= 1050201000 + return kernel_.compute_power_product_d_object()(circumcenter, point) >= 0; +#endif } }; -- cgit v1.2.3 From 837ffddda60d3f389184fe167710f74ad8adf36b Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Thu, 17 Sep 2020 09:37:25 +0200 Subject: Some documentation for weighted version --- src/Alpha_complex/include/gudhi/Alpha_complex.h | 7 ++++--- src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index b66ec20d..1d395bd8 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -132,17 +132,18 @@ class Alpha_complex { using Triangulation = typename std::conditional, CGAL::Delaunay_triangulation>::type; + /** \brief CGAL kernel container for computations in function of the weighted or not characteristics.*/ using A_kernel_d = Alpha_kernel_d; // Numeric type of coordinates in the kernel using FT = typename A_kernel_d::FT; - /** \brief If Weighted, the weighted point is cached (point + weight [= squared radius]), - * else a pair of point and squared radius is cached. + /** \brief Sphere is a std::pair (aka. circurmcenter and squared radius). + * If Weighted, Sphere is a Kernel::Weighted_point_d (aka. circurmcenter and the weight value is the squared radius). */ using Sphere = typename A_kernel_d::Sphere; - /** \brief A point in Euclidean space.*/ + /** \brief A point, or a weighted point in Euclidean space.*/ using Point_d = typename std::conditional::type; diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h index a4824207..e3567a6d 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -32,6 +32,14 @@ namespace Gudhi { namespace alpha_complex { +/** + * \class Alpha_kernel_d + * \brief Alpha complex kernel container. + * + * \details + * The Alpha complex kernel container stores CGAL Kernel and dispatch basics computations in function of the weighted + * or not version of the Alpha complex. + */ template < typename Kernel, bool Weighted = false > class Alpha_kernel_d { }; -- cgit v1.2.3 From 8afdbebe27effb0a9c184a153b645dd85aa0415b Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Fri, 18 Sep 2020 13:08:37 +0200 Subject: Fix #if cgal_version --- .../include/gudhi/Alpha_complex/Alpha_kernel_d.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h index e3567a6d..a6760645 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -108,18 +108,16 @@ class Alpha_kernel_d { template Sphere get_sphere(PointIterator begin, PointIterator end) const { // power_center_d_object has been renamed between CGAL 5.1 and 5.2 -#if defined CGAL_VERSION_NR >= 1050101000 && defined CGAL_VERSION_NR < 1050201000 +#if CGAL_VERSION_NR < 1050201000 return kernel_.power_center_d_object()(begin, end); -#endif -#if CGAL_VERSION_NR >= 1050201000 +#else return kernel_.construct_power_sphere_d_object()(begin, end); #endif } template FT get_squared_radius(PointIterator begin, PointIterator end) const { - Sphere sph = get_sphere(begin, end); - return sph.weight(); + return get_sphere(begin, end).weight(); } FT get_squared_radius(const Sphere& sph) const { @@ -128,10 +126,9 @@ class Alpha_kernel_d { bool is_gabriel(const Sphere& circumcenter, const Weighted_point_d& point) { // power_center_d_object has been renamed between CGAL 5.1 and 5.2 -#if defined CGAL_VERSION_NR >= 1050101000 && defined CGAL_VERSION_NR < 1050201000 +#if CGAL_VERSION_NR < 1050201000 return kernel_.power_distance_d_object()(circumcenter, point) >= 0; -#endif -#if CGAL_VERSION_NR >= 1050201000 +#else return kernel_.compute_power_product_d_object()(circumcenter, point) >= 0; #endif } -- cgit v1.2.3 From f7faba86fced9c75c530c86665ca3c73429d8f12 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 5 Oct 2020 13:19:52 +0200 Subject: code review: include what you use --- src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h index a6760645..7c49bb14 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -11,8 +11,6 @@ #ifndef ALPHA_COMPLEX_ALPHA_KERNEL_D_H_ #define ALPHA_COMPLEX_ALPHA_KERNEL_D_H_ -#include // For EXACT or SAFE version -#include // For FAST version #include // for CGAL_VERSION_NR #include // for EIGEN_VERSION_AT_LEAST -- cgit v1.2.3 From 2d80f0e7f3e09167760338c15596b052050ddb55 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 5 Oct 2020 14:00:51 +0200 Subject: code review: roll back include epick --- src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h index 7c49bb14..d4dbd68b 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -12,6 +12,8 @@ #define ALPHA_COMPLEX_ALPHA_KERNEL_D_H_ #include // for CGAL_VERSION_NR +#include // For EXACT or SAFE version +#include // For FAST version #include // for EIGEN_VERSION_AT_LEAST -- cgit v1.2.3 From d6ca67fee4f9c2a97b64710a5b70ed66dd307372 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 5 Oct 2020 14:50:57 +0200 Subject: code review: fix include what you use and compute_squared_radius_smallest_orthogonal_sphere_d_object use --- src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h index d4dbd68b..fbb931d4 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -12,10 +12,8 @@ #define ALPHA_COMPLEX_ALPHA_KERNEL_D_H_ #include // for CGAL_VERSION_NR -#include // For EXACT or SAFE version -#include // For FAST version -#include // for EIGEN_VERSION_AT_LEAST +#include // for EIGEN_VERSION_AT_LEAST #include // for std::make_pair @@ -117,7 +115,7 @@ class Alpha_kernel_d { template FT get_squared_radius(PointIterator begin, PointIterator end) const { - return get_sphere(begin, end).weight(); + return kernel_.compute_squared_radius_smallest_orthogonal_sphere_d_object()(begin, end); } FT get_squared_radius(const Sphere& sph) const { -- cgit v1.2.3 From afafd56fdb4a53b66ca3354fc20f787f12340fa4 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent Date: Mon, 26 Oct 2020 10:56:25 +0100 Subject: for CGAL 5.2 pre-release to work --- src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h index fbb931d4..28d6d7a9 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex/Alpha_kernel_d.h @@ -106,7 +106,7 @@ class Alpha_kernel_d { template Sphere get_sphere(PointIterator begin, PointIterator end) const { // power_center_d_object has been renamed between CGAL 5.1 and 5.2 -#if CGAL_VERSION_NR < 1050201000 +#if CGAL_VERSION_NR < 1050200000 return kernel_.power_center_d_object()(begin, end); #else return kernel_.construct_power_sphere_d_object()(begin, end); @@ -124,7 +124,7 @@ class Alpha_kernel_d { bool is_gabriel(const Sphere& circumcenter, const Weighted_point_d& point) { // power_center_d_object has been renamed between CGAL 5.1 and 5.2 -#if CGAL_VERSION_NR < 1050201000 +#if CGAL_VERSION_NR < 1050200000 return kernel_.power_distance_d_object()(circumcenter, point) >= 0; #else return kernel_.compute_power_product_d_object()(circumcenter, point) >= 0; -- cgit v1.2.3