From 91b0ff839b8058d3f5767e6ed80b93c23be2c98a Mon Sep 17 00:00:00 2001 From: Hind-M Date: Mon, 9 Aug 2021 16:21:24 +0200 Subject: First version of cech enhancement --- src/Cech_complex/test/test_cech_complex.cpp | 86 ++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 26 deletions(-) (limited to 'src/Cech_complex/test') diff --git a/src/Cech_complex/test/test_cech_complex.cpp b/src/Cech_complex/test/test_cech_complex.cpp index 6e00d7b5..81efd6ae 100644 --- a/src/Cech_complex/test/test_cech_complex.cpp +++ b/src/Cech_complex/test/test_cech_complex.cpp @@ -26,17 +26,24 @@ #include #include +#include // For EXACT or SAFE version + + // Type definitions using Simplex_tree = Gudhi::Simplex_tree<>; using Filtration_value = Simplex_tree::Filtration_value; -using Point = std::vector; +//using Point = std::vector; +using Kernel = CGAL::Epeck_d; +using FT = typename Kernel::FT; +using Point = typename Kernel::Point_d; + using Point_cloud = std::vector; using Points_off_reader = Gudhi::Points_off_reader; -using Cech_complex = Gudhi::cech_complex::Cech_complex; +using Cech_complex = Gudhi::cech_complex::Cech_complex; -using Point_iterator = Point_cloud::const_iterator; -using Coordinate_iterator = Point::const_iterator; -using Min_sphere = Gudhi::Miniball::Miniball>; +// using Point_iterator = Point_cloud::const_iterator; +// using Coordinate_iterator = Point::const_iterator; +// using Min_sphere = Gudhi::Miniball::Miniball>; BOOST_AUTO_TEST_CASE(Cech_complex_for_documentation) { // ---------------------------------------------------------------------------- @@ -45,17 +52,41 @@ BOOST_AUTO_TEST_CASE(Cech_complex_for_documentation) { // // ---------------------------------------------------------------------------- Point_cloud points; - points.push_back({1., 0.}); // 0 - points.push_back({0., 1.}); // 1 - points.push_back({2., 1.}); // 2 - points.push_back({3., 2.}); // 3 - points.push_back({0., 3.}); // 4 - points.push_back({3. + std::sqrt(3.), 3.}); // 5 - points.push_back({1., 4.}); // 6 - points.push_back({3., 4.}); // 7 - points.push_back({2., 4. + std::sqrt(3.)}); // 8 - points.push_back({0., 4.}); // 9 - points.push_back({-0.5, 2.}); // 10 +// points.push_back({1., 0.}); // 0 +// points.push_back({0., 1.}); // 1 +// points.push_back({2., 1.}); // 2 +// points.push_back({3., 2.}); // 3 +// points.push_back({0., 3.}); // 4 +// points.push_back({3. + std::sqrt(3.), 3.}); // 5 +// points.push_back({1., 4.}); // 6 +// points.push_back({3., 4.}); // 7 +// points.push_back({2., 4. + std::sqrt(3.)}); // 8 +// points.push_back({0., 4.}); // 9 +// points.push_back({-0.5, 2.}); // 10 + + + std::vector point0({1., 0.}); + points.emplace_back(point0.begin(), point0.end()); + std::vector point1({0., 1.}); + points.emplace_back(point1.begin(), point1.end()); + std::vector point2({2., 1.}); + points.emplace_back(point2.begin(), point2.end()); + std::vector point3({3., 2.}); + points.emplace_back(point3.begin(), point3.end()); + std::vector point4({0., 3.}); + points.emplace_back(point4.begin(), point4.end()); + std::vector point5({3. + std::sqrt(3.), 3.}); + points.emplace_back(point5.begin(), point5.end()); + std::vector point6({1., 4.}); + points.emplace_back(point6.begin(), point6.end()); + std::vector point7({3., 4.}); + points.emplace_back(point7.begin(), point7.end()); + std::vector point8({2., 4. + std::sqrt(3.)}); + points.emplace_back(point8.begin(), point8.end()); + std::vector point9({0., 4.}); + points.emplace_back(point9.begin(), point9.end()); + std::vector point10({-0.5, 2.}); + points.emplace_back(point10.begin(), point10.end()); Filtration_value max_radius = 1.0; std::clog << "========== NUMBER OF POINTS = " << points.size() << " - Cech max_radius = " << max_radius @@ -125,35 +156,38 @@ BOOST_AUTO_TEST_CASE(Cech_complex_for_documentation) { for (std::size_t vertex = 0; vertex <= 2; vertex++) { points012.push_back(cech_complex_for_doc.get_point(vertex)); } - std::size_t dimension = points[0].end() - points[0].begin(); - Min_sphere ms012(dimension, points012.begin(), points012.end()); +// std::size_t dimension = points[0].end() - points[0].begin(); +// Min_sphere ms012(dimension, points012.begin(), points012.end()); + Kernel kern; Simplex_tree::Filtration_value f012 = st2.filtration(st2.find({0, 1, 2})); - std::clog << "f012= " << f012 << " | ms012_radius= " << std::sqrt(ms012.squared_radius()) << std::endl; + CGAL::NT_converter cast_to_double; + std::clog << "f012= " << f012 << " | points012_radius= " << std::sqrt(cast_to_double(kern.compute_squared_radius_d_object()(points012.begin(), points012.end()))) << std::endl; + - GUDHI_TEST_FLOAT_EQUALITY_CHECK(f012, std::sqrt(ms012.squared_radius())); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f012, std::sqrt(cast_to_double(kern.compute_squared_radius_d_object()(points012.begin(), points012.end())))); Point_cloud points1410; points1410.push_back(cech_complex_for_doc.get_point(1)); points1410.push_back(cech_complex_for_doc.get_point(4)); points1410.push_back(cech_complex_for_doc.get_point(10)); - Min_sphere ms1410(dimension, points1410.begin(), points1410.end()); +// Min_sphere ms1410(dimension, points1410.begin(), points1410.end()); Simplex_tree::Filtration_value f1410 = st2.filtration(st2.find({1, 4, 10})); - std::clog << "f1410= " << f1410 << " | ms1410_radius= " << std::sqrt(ms1410.squared_radius()) << std::endl; + std::clog << "f1410= " << f1410 << " | points1410_radius= " << std::sqrt(cast_to_double(kern.compute_squared_radius_d_object()(points1410.begin(), points1410.end()))) << std::endl; - GUDHI_TEST_FLOAT_EQUALITY_CHECK(f1410, std::sqrt(ms1410.squared_radius())); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f1410, std::sqrt(cast_to_double(kern.compute_squared_radius_d_object()(points1410.begin(), points1410.end())))); Point_cloud points469; points469.push_back(cech_complex_for_doc.get_point(4)); points469.push_back(cech_complex_for_doc.get_point(6)); points469.push_back(cech_complex_for_doc.get_point(9)); - Min_sphere ms469(dimension, points469.begin(), points469.end()); +// Min_sphere ms469(dimension, points469.begin(), points469.end()); Simplex_tree::Filtration_value f469 = st2.filtration(st2.find({4, 6, 9})); - std::clog << "f469= " << f469 << " | ms469_radius= " << std::sqrt(ms469.squared_radius()) << std::endl; + std::clog << "f469= " << f469 << " | points469_radius= " << std::sqrt(cast_to_double(kern.compute_squared_radius_d_object()(points469.begin(), points469.end()))) << std::endl; - GUDHI_TEST_FLOAT_EQUALITY_CHECK(f469, std::sqrt(ms469.squared_radius())); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(f469, std::sqrt(cast_to_double(kern.compute_squared_radius_d_object()(points469.begin(), points469.end())))); BOOST_CHECK((st2.find({6, 7, 8}) == st2.null_simplex())); BOOST_CHECK((st2.find({3, 5, 7}) == st2.null_simplex())); -- cgit v1.2.3