From 35fee4017481fd3f62fceb76a1b2bc8cd0f15b95 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 7 Sep 2018 14:17:13 +0000 Subject: Code review : rearrange documentation and examples according to making choices more orthogonal Rename Alpha_complex_3d_options.h Alpha_complex_options.h as it can be used by Alpha complex dD git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3875 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6c5b105248e4766a44438a187bb130a3722b310f --- .../Weighted_alpha_complex_3d_from_points.cpp | 26 +- src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 112 ++--- .../include/gudhi/Alpha_complex_3d_options.h | 179 ------- .../include/gudhi/Alpha_complex_options.h | 64 +++ .../test/Alpha_complex_3d_unit_test.cpp | 535 ++++++++------------- .../utilities/alpha_complex_3d_persistence.cpp | 120 +++-- 6 files changed, 415 insertions(+), 621 deletions(-) delete mode 100644 src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h create mode 100644 src/Alpha_complex/include/gudhi/Alpha_complex_options.h (limited to 'src/Alpha_complex') diff --git a/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp b/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp index 1b60ccd8..61ceab6d 100644 --- a/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp +++ b/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp @@ -1,5 +1,4 @@ #include -#include // to construct a simplex_tree from alpha complex #include @@ -9,8 +8,9 @@ #include // for numeric limits using Weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; -using Point = Weighted_alpha_complex_3d::Point_3 ; -using Vector_of_points = std::vector; +using Point = Weighted_alpha_complex_3d::Point_3; +using Weighted_point = Weighted_alpha_complex_3d::Triangulation_3::Weighted_point; +using Vector_of_weighted_points = std::vector; using Vector_of_weights = std::vector; int main(int argc, char **argv) { @@ -23,23 +23,17 @@ int main(int argc, char **argv) { // ---------------------------------------------------------------------------- // Init of a list of points and weights from a small molecule // ---------------------------------------------------------------------------- - Vector_of_points points; - Vector_of_weights weights; - points.push_back(Point(1, -1, -1)); - weights.push_back(4.); - points.push_back(Point(-1, 1, -1)); - weights.push_back(4.); - points.push_back(Point(-1, -1, 1)); - weights.push_back(4.); - points.push_back(Point(1, 1, 1)); - weights.push_back(4.); - points.push_back(Point(2, 2, 2)); - weights.push_back(1.); + Vector_of_weighted_points weighted_points; + weighted_points.push_back(Weighted_point(Point(1, -1, -1), 4.)); + weighted_points.push_back(Weighted_point(Point(-1, 1, -1), 4.)); + weighted_points.push_back(Weighted_point(Point(-1, -1, 1), 4.)); + weighted_points.push_back(Weighted_point(Point(1, 1, 1), 4.)); + weighted_points.push_back(Weighted_point(Point(2, 2, 2), 1.)); // ---------------------------------------------------------------------------- // Init of an alpha complex from the list of points // ---------------------------------------------------------------------------- - Weighted_alpha_complex_3d alpha_complex_from_points(points, weights); + Weighted_alpha_complex_3d alpha_complex_from_points(weighted_points); Gudhi::Simplex_tree<> simplex; if (alpha_complex_from_points.create_complex(simplex)) { diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index bbe13be2..bf1aaa99 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -31,7 +31,7 @@ #endif #include -#include +#include #include #include @@ -57,13 +57,6 @@ namespace Gudhi { namespace alpha_complex { -enum class complexity: char -{ - fast='f', - safe='s', - exact='e', -}; - /** * \class Alpha_complex_3d * \brief Alpha complex data structure for 3d specific case. @@ -73,15 +66,30 @@ enum class complexity: char * \details * The data structure is constructing a CGAL 3D Alpha * Shapes from a range of points (can be read from an OFF file, cf. Points_off_reader). + * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. + * + * \tparam Complexity shall be `Gudhi::alpha_complex::complexity`. Default value is + * `Gudhi::alpha_complex::complexity::fast`. + * + * \tparam Weighted Boolean used to set/unset the weighted version of Alpha_complex_3d. Default value is false. + * + * \tparam Periodic Boolean used to set/unset the periodic version of Alpha_complex_3d. Default value is false. * - * \tparam AlphaComplex3dOptions can be `Gudhi::alpha_complex::Alpha_shapes_3d`, - * `Gudhi::alpha_complex::Exact_alpha_shapes_3d`, `Gudhi::alpha_complex::Weighted_alpha_shapes_3d`, - * `Gudhi::alpha_complex::Periodic_alpha_shapes_3d` or `Gudhi::alpha_complex::Weighted_periodic_alpha_shapes_3d`. + * For the weighted version, weights values are explained on CGAL + * Alpha shapes 3d and + * Regular + * triangulation documentation. + * + * For the periodic version, refer to the + * CGAL’s 3D Periodic Triangulations User + * Manual for more details. + * The periodicity is defined by an iso-oriented cuboid with diagonal opposite vertices (x_min, y_min, z_min) and + * (x_max, y_max, z_max). * * Please refer to \ref alpha_complex for examples. * * \remark When Alpha_complex_3d is constructed with an infinite value of alpha (default value), the complex is a - * Delaunay complex. + * 3d Delaunay complex. * */ template @@ -157,9 +165,9 @@ class Alpha_complex_3d { using Triangulation_3 = CGAL::Periodic_3_regular_triangulation_3; }; +public: using Triangulation_3 = typename Triangulation::Triangulation_3; -public: using Alpha_shape_3 = CGAL::Alpha_shape_3; using Point_3 = typename Kernel::Point_3; @@ -184,20 +192,16 @@ private: public: /** \brief Alpha_complex constructor from a list of points. * - * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. + * @param[in] points Range of points to triangulate. Points must be in `Alpha_complex_3d::Point_3` or + * `Alpha_complex_3d::Triangulation_3::Weighted_point`. * - * @param[in] points Range of points to triangulate. Points must be in AlphaComplex3dOptions::Point_3 + * @pre Available if Alpha_complex_3d is not Periodic. * - * @pre Available if AlphaComplex3dOptions is `Gudhi::alpha_complex::Alpha_shapes_3d` or - * `Gudhi::alpha_complex::Exact_alpha_shapes_3d`. - * - * The type InputPointRange must be a range for which std::begin and - * std::end return input iterators on a AlphaComplex3dOptions::Point_3. + * The type InputPointRange must be a range for which std::begin and std::end return input iterators on a + * `Alpha_complex_3d::Point_3` or a `Alpha_complex_3d::Triangulation_3::Weighted_point`. */ template Alpha_complex_3d(const InputPointRange& points) { - static_assert(!Weighted, - "This constructor is not available for weighted versions of Alpha_complex_3d"); static_assert(!Periodic, "This constructor is not available for periodic versions of Alpha_complex_3d"); @@ -215,23 +219,17 @@ public: /** \brief Alpha_complex constructor from a list of points and associated weights. * - * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. - * Weights values are explained on CGAL Alpha - * shape and - * Regular - * triangulation documentation. - * * @exception std::invalid_argument In debug mode, if points and weights do not have the same size. * - * @param[in] points Range of points to triangulate. Points must be in AlphaComplex3dOptions::Point_3 - * @param[in] weights Range of weights on points. Points must be in AlphaComplex3dOptions::Point_3 + * @param[in] points Range of points to triangulate. Points must be in `Alpha_complex_3d::Point_3` + * @param[in] weights Range of weights on points. Weights shall be in `Alpha_complex_3d::Alpha_shape_3::FT` * - * @pre Available if AlphaComplex3dOptions is `Weighted_alpha_shapes_3d`. + * @pre Available if Alpha_complex_3d is Weighted and not Periodic. * * The type InputPointRange must be a range for which std::begin and - * std::end return input iterators on a AlphaComplex3dOptions::Point_3. + * std::end return input iterators on a `Alpha_complex_3d::Point_3`. * The type WeightRange must be a range for which std::begin and - * std::end return an input iterator on a AlphaComplex3dOptions::Alpha_shape_3::FT. + * std::end return an input iterator on a `Alpha_complex_3d::Alpha_shape_3::FT`. */ template Alpha_complex_3d(const InputPointRange& points, WeightRange weights) { @@ -268,16 +266,10 @@ public: /** \brief Alpha_complex constructor from a list of points and an iso-cuboid coordinates. * - * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. - * - * Refer to the CGAL’s 3D Periodic - * Triangulations User Manual for more details. - * The periodicity is defined by an iso-oriented cuboid with diagonal opposite vertices (x_min, y_min, z_min) and - * (x_max, y_max, z_max). - * * @exception std::invalid_argument In debug mode, if the size of the cuboid in every directions is not the same. * - * @param[in] points Range of points to triangulate. Points must be in AlphaComplex3dOptions::Point_3 + * @param[in] points Range of points to triangulate. Points must be in `Alpha_complex_3d::Point_3` or + * `Alpha_complex_3d::Triangulation_3::Weighted_point`. * @param[in] x_min Iso-oriented cuboid x_min. * @param[in] y_min Iso-oriented cuboid y_min. * @param[in] z_min Iso-oriented cuboid z_min. @@ -285,18 +277,18 @@ public: * @param[in] y_max Iso-oriented cuboid y_max. * @param[in] z_max Iso-oriented cuboid z_max. * - * @pre Available if AlphaComplex3dOptions is `Periodic_alpha_shapes_3d`. + * @pre Available if Alpha_complex_3d is Periodic. * - * The type InputPointRange must be a range for which std::begin and - * std::end return input iterators on a AlphaComplex3dOptions::Point_3. - * The type of x_min, y_min, z_min, x_max, y_max and z_max is AlphaComplex3dOptions::Alpha_shape_3::FT. + * The type InputPointRange must be a range for which std::begin and std::end return input iterators on a + * `Alpha_complex_3d::Point_3` or a `Alpha_complex_3d::Triangulation_3::Weighted_point`. + * + * @note In weighted version, please check weights are greater than zero, and lower than 1/64*cuboid length + * squared. */ template Alpha_complex_3d(const InputPointRange& points, Alpha_value_type x_min, Alpha_value_type y_min, Alpha_value_type z_min, Alpha_value_type x_max, Alpha_value_type y_max, Alpha_value_type z_max) { - static_assert(!Weighted, - "This constructor is not available for weighted versions of Alpha_complex_3d"); static_assert(Periodic, "This constructor is not available for non-periodic versions of Alpha_complex_3d"); // Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it. @@ -332,25 +324,13 @@ public: /** \brief Alpha_complex constructor from a list of points, associated weights and an iso-cuboid coordinates. * - * Duplicate points are inserted once in the Alpha_complex. This is the reason why the vertices may be not contiguous. - * - * Weights values are explained on CGAL Alpha - * shape and - * Regular - * triangulation documentation. - * - * Refer to the CGAL’s 3D Periodic - * Triangulations User Manual for more details. - * The periodicity is defined by an iso-oriented cuboid with diagonal opposite vertices (x_min, y_min, z_min) and - * (x_max, y_max, z_max). - * * @exception std::invalid_argument In debug mode, if points and weights do not have the same size. * @exception std::invalid_argument In debug mode, if the size of the cuboid in every directions is not the same. * @exception std::invalid_argument In debug mode, if a weight is negative, zero, or greater than 1/64*cuboid length * squared. * - * @param[in] points Range of points to triangulate. Points must be in AlphaComplex3dOptions::Point_3 - * @param[in] weights Range of weights on points. Points must be in AlphaComplex3dOptions::Point_3 + * @param[in] points Range of points to triangulate. Points must be in `Alpha_complex_3d::Point_3` + * @param[in] weights Range of weights on points. Weights shall be in `Alpha_complex_3d::Alpha_shape_3::FT` * @param[in] x_min Iso-oriented cuboid x_min. * @param[in] y_min Iso-oriented cuboid y_min. * @param[in] z_min Iso-oriented cuboid z_min. @@ -358,13 +338,13 @@ public: * @param[in] y_max Iso-oriented cuboid y_max. * @param[in] z_max Iso-oriented cuboid z_max. * - * @pre Available if AlphaComplex3dOptions is `Weighted_periodic_alpha_shapes_3d`. + * @pre Available if Alpha_complex_3d is Weighted and Periodic. * * The type InputPointRange must be a range for which std::begin and - * std::end return input iterators on a AlphaComplex3dOptions::Point_3. + * std::end return input iterators on a `Alpha_complex_3d::Point_3`. * The type WeightRange must be a range for which std::begin and - * std::end return an input iterator on a AlphaComplex3dOptions::Alpha_shape_3::FT. - * The type of x_min, y_min, z_min, x_max, y_max and z_max is AlphaComplex3dOptions::Alpha_shape_3::FT. + * std::end return an input iterator on a `Alpha_complex_3d::Alpha_shape_3::FT`. + * The type of x_min, y_min, z_min, x_max, y_max and z_max is `Alpha_complex_3d::Alpha_shape_3::FT`. */ template Alpha_complex_3d(const InputPointRange& points, WeightRange weights, @@ -395,7 +375,7 @@ public: while ((index < weights.size()) && (index < points.size())) { GUDHI_CHECK((weights[index] < maximal_possible_weight) && (weights[index] >= 0), - std::invalid_argument("Invalid weight at line" + std::to_string(index + 1) + + std::invalid_argument("Invalid weight at index " + std::to_string(index + 1) + ". Must be positive and less than maximal possible weight = 1/64*cuboid length " "squared, which is not an acceptable input.")); weighted_points_3.push_back(Weighted_point_3(points[index], weights[index])); diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h deleted file mode 100644 index 567b19cb..00000000 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d_options.h +++ /dev/null @@ -1,179 +0,0 @@ -/* 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) 2018 Inria - * - * 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 . - */ - -#ifndef ALPHA_COMPLEX_3D_OPTIONS_H_ -#define ALPHA_COMPLEX_3D_OPTIONS_H_ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace Gudhi { - -namespace alpha_complex { - -class Alpha_shapes_3d { -private: - using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; - using Vb = CGAL::Alpha_shape_vertex_base_3; - using Fb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - using Triangulation_3 = CGAL::Delaunay_triangulation_3; - -public: - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = Kernel::Point_3; - - static const bool weighted = false; - static const bool periodic = false; - - // Default value_from_iterator as Alpha_shape_3 is not exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ *avi; - } -}; - -class Exact_alpha_shapes_3d { -private: - // Alpha_shape_3 templates type definitions - using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; - using Exact_tag = CGAL::Tag_true; - using Vb = CGAL::Alpha_shape_vertex_base_3; - using Fb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - using Triangulation_3 = CGAL::Delaunay_triangulation_3; - -public: - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = Kernel::Point_3; - - static const bool weighted = false; - static const bool periodic = false; - - // value_from_iterator needs to compute filtration value as Alpha_shape_3 is exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ CGAL::to_double(avi->exact()); - } -}; - -class Weighted_alpha_shapes_3d { -private: - using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; - using Rvb = CGAL::Regular_triangulation_vertex_base_3; - using Vb = CGAL::Alpha_shape_vertex_base_3; - using Rcb = CGAL::Regular_triangulation_cell_base_3; - using Cb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - using Triangulation_3 = CGAL::Regular_triangulation_3; - - -public: - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = Triangulation_3::Bare_point; - using Weighted_point_3 = Triangulation_3::Weighted_point; - - static const bool weighted = true; - static const bool periodic = false; - - // Default value_from_iterator as Alpha_shape_3 is not exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ *avi; - } -}; - -class Periodic_alpha_shapes_3d { -private: - // Traits - using K = CGAL::Exact_predicates_inexact_constructions_kernel; - using PK = CGAL::Periodic_3_Delaunay_triangulation_traits_3; -// Vertex type - using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>; - using Vb = CGAL::Triangulation_vertex_base_3; - using AsVb = CGAL::Alpha_shape_vertex_base_3; -// Cell type - using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>; - using Cb = CGAL::Triangulation_cell_base_3; - using AsCb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - -public: - using Periodic_delaunay_triangulation_3 = CGAL::Periodic_3_Delaunay_triangulation_3; - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = PK::Point_3; - using Iso_cuboid_3 = PK::Iso_cuboid_3; - - static const bool weighted = false; - static const bool periodic = true; - - // Default value_from_iterator as Alpha_shape_3 is not exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ *avi; - } -}; - -class Weighted_periodic_alpha_shapes_3d { -private: - using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; - using Periodic_kernel = CGAL::Periodic_3_regular_triangulation_traits_3; - using DsVb = CGAL::Periodic_3_triangulation_ds_vertex_base_3<>; - using Vb = CGAL::Regular_triangulation_vertex_base_3; - using AsVb = CGAL::Alpha_shape_vertex_base_3; - using DsCb = CGAL::Periodic_3_triangulation_ds_cell_base_3<>; - using Cb = CGAL::Regular_triangulation_cell_base_3; - using AsCb = CGAL::Alpha_shape_cell_base_3; - using Tds = CGAL::Triangulation_data_structure_3; - -public: - using Periodic_delaunay_triangulation_3 = CGAL::Periodic_3_regular_triangulation_3; - using Alpha_shape_3 = CGAL::Alpha_shape_3; - using Point_3 = Periodic_delaunay_triangulation_3::Bare_point; - using Weighted_point_3 = Periodic_delaunay_triangulation_3::Weighted_point; - using Iso_cuboid_3 = Periodic_kernel::Iso_cuboid_3; - - static const bool weighted = true; - static const bool periodic = true; - - // Default value_from_iterator as Alpha_shape_3 is not exact - template - static Filtration_value value_from_iterator(const Alpha_value_iterator avi) { - return /*std::sqrt*/ *avi; - } -}; - -} // namespace alpha_complex - -} // namespace Gudhi - -#endif // ALPHA_COMPLEX_3D_OPTIONS_H_ diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_options.h b/src/Alpha_complex/include/gudhi/Alpha_complex_options.h new file mode 100644 index 00000000..32980fa7 --- /dev/null +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_options.h @@ -0,0 +1,64 @@ +/* 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) 2018 Inria + * + * 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 . + */ + +#ifndef ALPHA_COMPLEX_OPTIONS_H_ +#define ALPHA_COMPLEX_OPTIONS_H_ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace Gudhi { + +namespace alpha_complex { + + +/** + * \class complexity + * \brief Alpha complex complexity template parameter possible values. + * + * \ingroup alpha_complex + */ +enum class complexity: char +{ + /** \brief Fast version.*/ + fast='f', + /** \brief Safe version.*/ + safe='s', + /** \brief Exact version.*/ + exact='e', +}; + +} // namespace alpha_complex + +} // namespace Gudhi + +#endif // ALPHA_COMPLEX_OPTIONS_H_ diff --git a/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp index 7cc21475..2bd925d3 100644 --- a/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp @@ -30,9 +30,9 @@ #include #include #include +#include // for std::size_t #include -#include #include #include #include @@ -111,9 +111,9 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) { } } -#ifdef GUDHI_DEBUG typedef boost::mpl::list weighted_variants_type_list; +#ifdef GUDHI_DEBUG BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_weighted_throw, Weighted_alpha_complex_3d, weighted_variants_type_list) { using Point_3 = typename Weighted_alpha_complex_3d::Point_3; std::vector w_points; @@ -132,61 +132,55 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_weighted_throw, Weighted_alpha_compl } #endif -BOOST_AUTO_TEST_CASE(Alpha_complex_weighted) { - // --------------------- - // Fast weighted version - // --------------------- - std::cout << "Fast weighted alpha complex 3d" << std::endl; - std::vector w_points; - w_points.push_back(Fast_weighted_alpha_complex_3d::Point_3(0.0, 0.0, 0.0)); - w_points.push_back(Fast_weighted_alpha_complex_3d::Point_3(0.0, 0.0, 0.2)); - w_points.push_back(Fast_weighted_alpha_complex_3d::Point_3(0.2, 0.0, 0.2)); - w_points.push_back(Fast_weighted_alpha_complex_3d::Point_3(0.6, 0.6, 0.0)); - w_points.push_back(Fast_weighted_alpha_complex_3d::Point_3(0.8, 0.8, 0.2)); - w_points.push_back(Fast_weighted_alpha_complex_3d::Point_3(0.2, 0.8, 0.6)); +BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_weighted, Weighted_alpha_complex_3d, weighted_variants_type_list) { + std::cout << "Weighted alpha complex 3d from points and weights" << std::endl; + using Point_3 = typename Weighted_alpha_complex_3d::Point_3; + std::vector w_points; + w_points.push_back(Point_3(0.0, 0.0, 0.0)); + w_points.push_back(Point_3(0.0, 0.0, 0.2)); + w_points.push_back(Point_3(0.2, 0.0, 0.2)); + w_points.push_back(Point_3(0.6, 0.6, 0.0)); + w_points.push_back(Point_3(0.8, 0.8, 0.2)); + w_points.push_back(Point_3(0.2, 0.8, 0.6)); // weights size is different from w_points size to make weighted Alpha_complex_3d throw in debug mode std::vector weights = {0.01, 0.005, 0.006, 0.01, 0.009, 0.001}; - Fast_weighted_alpha_complex_3d weighted_alpha_complex(w_points, weights); + Weighted_alpha_complex_3d alpha_complex_p_a_w(w_points, weights); Gudhi::Simplex_tree<> stree; - weighted_alpha_complex.create_complex(stree); + alpha_complex_p_a_w.create_complex(stree); - // ---------------------- - // Exact weighted version - // ---------------------- - std::cout << "Exact weighted alpha complex 3d" << std::endl; + std::cout << "Weighted alpha complex 3d from weighted points" << std::endl; + using Weighted_point_3 = typename Weighted_alpha_complex_3d::Triangulation_3::Weighted_point; - std::vector e_w_points; - e_w_points.push_back(Exact_weighted_alpha_complex_3d::Point_3(0.0, 0.0, 0.0)); - e_w_points.push_back(Exact_weighted_alpha_complex_3d::Point_3(0.0, 0.0, 0.2)); - e_w_points.push_back(Exact_weighted_alpha_complex_3d::Point_3(0.2, 0.0, 0.2)); - e_w_points.push_back(Exact_weighted_alpha_complex_3d::Point_3(0.6, 0.6, 0.0)); - e_w_points.push_back(Exact_weighted_alpha_complex_3d::Point_3(0.8, 0.8, 0.2)); - e_w_points.push_back(Exact_weighted_alpha_complex_3d::Point_3(0.2, 0.8, 0.6)); - Exact_weighted_alpha_complex_3d exact_alpha_complex(e_w_points, weights); + std::vector weighted_points; - Gudhi::Simplex_tree<> exact_stree; - exact_alpha_complex.create_complex(exact_stree); + for (std::size_t i=0; i < w_points.size(); i++) { + weighted_points.push_back(Weighted_point_3(w_points[i], weights[i])); + } + Weighted_alpha_complex_3d alpha_complex_w_p(weighted_points); + + Gudhi::Simplex_tree<> stree_bis; + alpha_complex_w_p.create_complex(stree_bis); // --------------------- // Compare both versions // --------------------- - std::cout << "Exact weighted alpha complex 3d is of dimension " << exact_stree.dimension() - << " - Non exact is " << stree.dimension() << std::endl; - BOOST_CHECK(exact_stree.dimension() == stree.dimension()); - std::cout << "Exact weighted alpha complex 3d num_simplices " << exact_stree.num_simplices() - << " - Non exact is " << stree.num_simplices() << std::endl; - BOOST_CHECK(exact_stree.num_simplices() == stree.num_simplices()); - std::cout << "Exact weighted alpha complex 3d num_vertices " << exact_stree.num_vertices() - << " - Non exact is " << stree.num_vertices() << std::endl; - BOOST_CHECK(exact_stree.num_vertices() == stree.num_vertices()); + std::cout << "Weighted alpha complex 3d is of dimension " << stree_bis.dimension() + << " - versus " << stree.dimension() << std::endl; + BOOST_CHECK(stree_bis.dimension() == stree.dimension()); + std::cout << "Weighted alpha complex 3d num_simplices " << stree_bis.num_simplices() + << " - versus " << stree.num_simplices() << std::endl; + BOOST_CHECK(stree_bis.num_simplices() == stree.num_simplices()); + std::cout << "Weighted alpha complex 3d num_vertices " << stree_bis.num_vertices() + << " - versus " << stree.num_vertices() << std::endl; + BOOST_CHECK(stree_bis.num_vertices() == stree.num_vertices()); auto sh = stree.filtration_simplex_range().begin(); while(sh != stree.filtration_simplex_range().end()) { std::vector simplex; std::vector exact_simplex; - std::cout << "Non-exact ( "; + std::cout << " ( "; for (auto vertex : stree.simplex_vertex_range(*sh)) { simplex.push_back(vertex); std::cout << vertex << " "; @@ -195,11 +189,11 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_weighted) { std::cout << std::endl; // Find it in the exact structure - auto sh_exact = exact_stree.find(simplex); - BOOST_CHECK(sh_exact != exact_stree.null_simplex()); + auto sh_exact = stree_bis.find(simplex); + BOOST_CHECK(sh_exact != stree_bis.null_simplex()); // Exact and non-exact version is not exactly the same due to float comparison - GUDHI_TEST_FLOAT_EQUALITY_CHECK(exact_stree.filtration(sh_exact), stree.filtration(*sh)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(stree_bis.filtration(sh_exact), stree.filtration(*sh)); ++sh; } @@ -207,7 +201,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_weighted) { } #ifdef GUDHI_DEBUG -typedef boost::mpl::list periodic_variants_type_list; +typedef boost::mpl::list periodic_variants_type_list; BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_periodic_throw, Periodic_alpha_complex_3d, periodic_variants_type_list) { std::cout << "Periodic alpha complex 3d exception throw" << std::endl; @@ -541,10 +535,11 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_periodic) { } -#ifdef GUDHI_DEBUG -typedef boost::mpl::list wp_variants_type_list; +typedef boost::mpl::list wp_variants_type_list; -BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_weighted_periodic_throw, Weighted_periodic_alpha_complex_3d, wp_variants_type_list) { +#ifdef GUDHI_DEBUG +BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_weighted_periodic_throw, Weighted_periodic_alpha_complex_3d, + wp_variants_type_list) { std::cout << "Weighted periodic alpha complex 3d exception throw" << std::endl; using Point_3 = typename Weighted_periodic_alpha_complex_3d::Point_3; @@ -722,311 +717,186 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_weighted_periodic_throw, Weighted_pe } #endif -BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_periodic) { - // ------------------------------ - // Fast weighted periodic version - // ------------------------------ - std::cout << "Fast weighted periodic alpha complex 3d" << std::endl; - - std::vector wp_points; - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.1, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.6)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.8)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.0)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.2)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.4)); - wp_points.push_back(Fast_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.6)); - - std::vector p_weights; +BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_weighted_periodic, Weighted_periodic_alpha_complex_3d, + wp_variants_type_list) { + std::cout << "Weighted Periodic alpha complex 3d from points and weights" << std::endl; + using Point_3 = typename Weighted_periodic_alpha_complex_3d::Point_3; + std::vector points; + + points.push_back(Point_3(0.0, 0.0, 0.2)); + points.push_back(Point_3(0.0, 0.0, 0.4)); + points.push_back(Point_3(0.0, 0.0, 0.6)); + points.push_back(Point_3(0.0, 0.0, 0.8)); + points.push_back(Point_3(0.0, 0.2, 0.0)); + points.push_back(Point_3(0.0, 0.2, 0.2)); + points.push_back(Point_3(0.0, 0.2, 0.4)); + points.push_back(Point_3(0.0, 0.2, 0.6)); + points.push_back(Point_3(0.0, 0.2, 0.8)); + points.push_back(Point_3(0.0, 0.4, 0.0)); + points.push_back(Point_3(0.0, 0.4, 0.2)); + points.push_back(Point_3(0.0, 0.4, 0.4)); + points.push_back(Point_3(0.0, 0.4, 0.6)); + points.push_back(Point_3(0.0, 0.4, 0.8)); + points.push_back(Point_3(0.0, 0.6, 0.0)); + points.push_back(Point_3(0.0, 0.6, 0.2)); + points.push_back(Point_3(0.0, 0.6, 0.4)); + points.push_back(Point_3(0.0, 0.6, 0.6)); + points.push_back(Point_3(0.0, 0.6, 0.8)); + points.push_back(Point_3(0.0, 0.8, 0.0)); + points.push_back(Point_3(0.0, 0.8, 0.2)); + points.push_back(Point_3(0.0, 0.8, 0.4)); + points.push_back(Point_3(0.0, 0.8, 0.6)); + points.push_back(Point_3(0.0, 0.8, 0.8)); + points.push_back(Point_3(0.2, 0.0, 0.0)); + points.push_back(Point_3(0.2, 0.0, 0.2)); + points.push_back(Point_3(0.2, 0.0, 0.4)); + points.push_back(Point_3(0.2, 0.0, 0.6)); + points.push_back(Point_3(0.2, 0.0, 0.8)); + points.push_back(Point_3(0.2, 0.2, 0.0)); + points.push_back(Point_3(0.2, 0.2, 0.2)); + points.push_back(Point_3(0.2, 0.2, 0.4)); + points.push_back(Point_3(0.2, 0.2, 0.6)); + points.push_back(Point_3(0.2, 0.2, 0.8)); + points.push_back(Point_3(0.2, 0.4, 0.0)); + points.push_back(Point_3(0.2, 0.4, 0.2)); + points.push_back(Point_3(0.2, 0.4, 0.4)); + points.push_back(Point_3(0.2, 0.4, 0.6)); + points.push_back(Point_3(0.2, 0.4, 0.8)); + points.push_back(Point_3(0.2, 0.6, 0.0)); + points.push_back(Point_3(0.2, 0.6, 0.2)); + points.push_back(Point_3(0.2, 0.6, 0.4)); + points.push_back(Point_3(0.2, 0.6, 0.6)); + points.push_back(Point_3(0.2, 0.6, 0.8)); + points.push_back(Point_3(0.0, 0.0, 0.0)); + points.push_back(Point_3(0.2, 0.8, 0.0)); + points.push_back(Point_3(0.2, 0.8, 0.2)); + points.push_back(Point_3(0.2, 0.8, 0.4)); + points.push_back(Point_3(0.2, 0.8, 0.6)); + points.push_back(Point_3(0.2, 0.8, 0.8)); + points.push_back(Point_3(0.4, 0.0, 0.0)); + points.push_back(Point_3(0.4, 0.0, 0.2)); + points.push_back(Point_3(0.4, 0.0, 0.4)); + points.push_back(Point_3(0.4, 0.0, 0.6)); + points.push_back(Point_3(0.4, 0.0, 0.8)); + points.push_back(Point_3(0.4, 0.2, 0.0)); + points.push_back(Point_3(0.4, 0.2, 0.2)); + points.push_back(Point_3(0.4, 0.2, 0.4)); + points.push_back(Point_3(0.4, 0.2, 0.6)); + points.push_back(Point_3(0.4, 0.2, 0.8)); + points.push_back(Point_3(0.4, 0.4, 0.0)); + points.push_back(Point_3(0.4, 0.4, 0.2)); + points.push_back(Point_3(0.4, 0.4, 0.4)); + points.push_back(Point_3(0.4, 0.4, 0.6)); + points.push_back(Point_3(0.4, 0.4, 0.8)); + points.push_back(Point_3(0.4, 0.6, 0.0)); + points.push_back(Point_3(0.4, 0.6, 0.2)); + points.push_back(Point_3(0.4, 0.6, 0.4)); + points.push_back(Point_3(0.4, 0.6, 0.6)); + points.push_back(Point_3(0.4, 0.6, 0.8)); + points.push_back(Point_3(0.4, 0.8, 0.0)); + points.push_back(Point_3(0.4, 0.8, 0.2)); + points.push_back(Point_3(0.4, 0.8, 0.4)); + points.push_back(Point_3(0.4, 0.8, 0.6)); + points.push_back(Point_3(0.4, 0.8, 0.8)); + points.push_back(Point_3(0.6, 0.0, 0.0)); + points.push_back(Point_3(0.6, 0.0, 0.2)); + points.push_back(Point_3(0.6, 0.0, 0.4)); + points.push_back(Point_3(0.6, 0.0, 0.6)); + points.push_back(Point_3(0.6, 0.0, 0.8)); + points.push_back(Point_3(0.6, 0.1, 0.0)); + points.push_back(Point_3(0.6, 0.2, 0.0)); + points.push_back(Point_3(0.6, 0.2, 0.2)); + points.push_back(Point_3(0.6, 0.2, 0.4)); + points.push_back(Point_3(0.6, 0.2, 0.6)); + points.push_back(Point_3(0.6, 0.2, 0.8)); + points.push_back(Point_3(0.6, 0.4, 0.0)); + points.push_back(Point_3(0.6, 0.4, 0.2)); + points.push_back(Point_3(0.6, 0.4, 0.4)); + points.push_back(Point_3(0.6, 0.4, 0.6)); + points.push_back(Point_3(0.6, 0.4, 0.8)); + points.push_back(Point_3(0.6, 0.6, 0.0)); + points.push_back(Point_3(0.6, 0.6, 0.2)); + points.push_back(Point_3(0.6, 0.6, 0.4)); + points.push_back(Point_3(0.6, 0.6, 0.6)); + points.push_back(Point_3(0.6, 0.6, 0.8)); + points.push_back(Point_3(0.6, 0.8, 0.0)); + points.push_back(Point_3(0.6, 0.8, 0.2)); + points.push_back(Point_3(0.6, 0.8, 0.4)); + points.push_back(Point_3(0.6, 0.8, 0.6)); + points.push_back(Point_3(0.6, 0.8, 0.8)); + points.push_back(Point_3(0.8, 0.0, 0.0)); + points.push_back(Point_3(0.8, 0.0, 0.2)); + points.push_back(Point_3(0.8, 0.0, 0.4)); + points.push_back(Point_3(0.8, 0.0, 0.6)); + points.push_back(Point_3(0.8, 0.0, 0.8)); + points.push_back(Point_3(0.8, 0.2, 0.0)); + points.push_back(Point_3(0.8, 0.2, 0.2)); + points.push_back(Point_3(0.8, 0.2, 0.4)); + points.push_back(Point_3(0.8, 0.2, 0.6)); + points.push_back(Point_3(0.8, 0.2, 0.8)); + points.push_back(Point_3(0.8, 0.4, 0.0)); + points.push_back(Point_3(0.8, 0.4, 0.2)); + points.push_back(Point_3(0.8, 0.4, 0.4)); + points.push_back(Point_3(0.8, 0.4, 0.6)); + points.push_back(Point_3(0.8, 0.4, 0.8)); + points.push_back(Point_3(0.8, 0.6, 0.0)); + points.push_back(Point_3(0.8, 0.6, 0.2)); + points.push_back(Point_3(0.8, 0.6, 0.4)); + points.push_back(Point_3(0.8, 0.6, 0.6)); + points.push_back(Point_3(0.8, 0.6, 0.8)); + points.push_back(Point_3(0.8, 0.8, 0.0)); + points.push_back(Point_3(0.8, 0.8, 0.2)); + points.push_back(Point_3(0.8, 0.8, 0.4)); + points.push_back(Point_3(0.8, 0.8, 0.6)); + + std::vector weights; std::random_device rd; std::mt19937 mt(rd()); // Weights must be in range [0, <1/64] std::uniform_real_distribution dist(0.01, 0.0156245); - for (std::size_t i = 0; i < wp_points.size(); ++i) { + for (std::size_t i = 0; i < points.size(); ++i) { double value = dist(mt); - p_weights.push_back(value); + weights.push_back(value); } - Fast_weighted_periodic_alpha_complex_3d weighted_periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.); + Weighted_periodic_alpha_complex_3d weighted_periodic_alpha_complex(points, weights, 0., 0., 0., 1., 1., 1.); Gudhi::Simplex_tree<> stree; weighted_periodic_alpha_complex.create_complex(stree); - // ------------------------------- - // Exact weighted periodic version - // ------------------------------- - std::cout << "Exact weighted periodic alpha complex 3d" << std::endl; - - std::vector e_wp_points; - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.1, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.6)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.8)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.0)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.2)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.4)); - e_wp_points.push_back(Exact_weighted_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.6)); - - Exact_weighted_periodic_alpha_complex_3d e_weighted_periodic_alpha_complex(e_wp_points, p_weights, 0., 0., 0., 1., 1., 1.); + std::cout << "Weighted periodic alpha complex 3d from weighted points" << std::endl; + using Weighted_point_3 = typename Weighted_periodic_alpha_complex_3d::Triangulation_3::Weighted_point; - Gudhi::Simplex_tree<> exact_stree; - e_weighted_periodic_alpha_complex.create_complex(exact_stree); + std::vector weighted_points; + + for (std::size_t i=0; i < points.size(); i++) { + weighted_points.push_back(Weighted_point_3(points[i], weights[i])); + } + Weighted_periodic_alpha_complex_3d alpha_complex_w_p(weighted_points, 0., 0., 0., 1., 1., 1.); + + Gudhi::Simplex_tree<> stree_bis; + alpha_complex_w_p.create_complex(stree_bis); // --------------------- // Compare both versions // --------------------- - std::cout << "Exact periodic alpha complex 3d is of dimension " << exact_stree.dimension() - << " - Non exact is " << stree.dimension() << std::endl; - BOOST_CHECK(exact_stree.dimension() == stree.dimension()); - std::cout << "Exact periodic alpha complex 3d num_simplices " << exact_stree.num_simplices() - << " - Non exact is " << stree.num_simplices() << std::endl; - // TODO(VR): BOOST_CHECK(exact_stree.num_simplices() == stree.num_simplices()); - std::cout << "Exact periodic alpha complex 3d num_vertices " << exact_stree.num_vertices() - << " - Non exact is " << stree.num_vertices() << std::endl; - BOOST_CHECK(exact_stree.num_vertices() == stree.num_vertices()); + std::cout << "Weighted periodic alpha complex 3d is of dimension " << stree_bis.dimension() + << " - versus " << stree.dimension() << std::endl; + BOOST_CHECK(stree_bis.dimension() == stree.dimension()); + std::cout << "Weighted periodic alpha complex 3d num_simplices " << stree_bis.num_simplices() + << " - versus " << stree.num_simplices() << std::endl; + BOOST_CHECK(stree_bis.num_simplices() == stree.num_simplices()); + std::cout << "Weighted periodic alpha complex 3d num_vertices " << stree_bis.num_vertices() + << " - versus " << stree.num_vertices() << std::endl; + BOOST_CHECK(stree_bis.num_vertices() == stree.num_vertices()); auto sh = stree.filtration_simplex_range().begin(); while(sh != stree.filtration_simplex_range().end()) { std::vector simplex; std::vector exact_simplex; - std::cout << "Non-exact ( "; + std::cout << " ( "; for (auto vertex : stree.simplex_vertex_range(*sh)) { simplex.push_back(vertex); std::cout << vertex << " "; @@ -1035,11 +905,12 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_periodic) { std::cout << std::endl; // Find it in the exact structure - auto sh_exact = exact_stree.find(simplex); - // TODO(VR): BOOST_CHECK(sh_exact != exact_stree.null_simplex()); + auto sh_exact = stree_bis.find(simplex); + BOOST_CHECK(sh_exact != stree_bis.null_simplex()); // Exact and non-exact version is not exactly the same due to float comparison - // TODO(VR): GUDHI_TEST_FLOAT_EQUALITY_CHECK(exact_stree.filtration(sh_exact), stree.filtration(*sh)); + GUDHI_TEST_FLOAT_EQUALITY_CHECK(stree_bis.filtration(sh_exact), stree.filtration(*sh)); + ++sh; } diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp index 536de444..1a152541 100644 --- a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -34,16 +33,24 @@ #include // gudhi type definition -using Weighted_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; -using Periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; -using Weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; -using Exact_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; -using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; using Simplex_tree = Gudhi::Simplex_tree; using Filtration_value = Simplex_tree::Filtration_value; using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; +using Fast_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Safe_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Exact_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Fast_weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Safe_weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Exact_weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Fast_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Safe_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Exact_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Fast_weighted_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Safe_weighted_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Exact_weighted_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + void program_options(int argc, char *argv[], std::string &off_file_points, bool& exact, std::string &weight_file, std::string &cuboid_file, std::string &output_file_diag, Filtration_value &alpha_square_max_value, int &coeff_field_characteristic, Filtration_value &min_persistence); @@ -98,6 +105,72 @@ int main(int argc, char **argv) { program_options(argc, argv, off_file_points, exact_version, weight_file, cuboid_file, output_file_diag, alpha_square_max_value, coeff_field_characteristic, min_persistence); + Gudhi::alpha_complex::complexity complexity = Gudhi::alpha_complex::complexity::fast; + if (exact_version) { + complexity = Gudhi::alpha_complex::complexity::exact; + } + + switch(complexity) { + case Gudhi::alpha_complex::complexity::fast: + if (weighted_version) { + if (periodic_version) { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } else { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } + } else { + if (periodic_version) { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } else { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } + } + break; + case Gudhi::alpha_complex::complexity::exact: + if (weighted_version) { + if (periodic_version) { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } else { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } + } else { + if (periodic_version) { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } else { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } + } + break; + case Gudhi::alpha_complex::complexity::safe: + if (weighted_version) { + if (periodic_version) { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } else { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } + } else { + if (periodic_version) { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } else { + using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + } + } + break; + } + + /*const Gudhi::alpha_complex::complexity complexity_(complexity); // Read the OFF file (input file name given as parameter) and triangulate points Gudhi::Points_3D_off_reader off_reader(off_file_points); // Check the read operation was correct @@ -127,35 +200,26 @@ int main(int argc, char **argv) { Simplex_tree simplex_tree; - if (exact_version) { - if ((weighted_version) || (periodic_version)) { - std::cerr << "Unable to compute exact version of a weighted and/or periodic alpha shape" << std::endl; - exit(-1); + if (weighted_version) { + if (periodic_version) { + Alpha_complex_3d alpha_complex(off_reader.get_point_cloud(), weights, + x_min, y_min, z_min, x_max, y_max, z_max); + create_complex(alpha_complex, simplex_tree, alpha_square_max_value); } else { - Exact_alpha_complex_3d alpha_complex(off_reader.get_point_cloud()); + Alpha_complex_3d alpha_complex(off_reader.get_point_cloud(), weights); create_complex(alpha_complex, simplex_tree, alpha_square_max_value); } } else { - if (weighted_version) { - if (periodic_version) { - Weighted_periodic_alpha_complex_3d alpha_complex(off_reader.get_point_cloud(), weights, - x_min, y_min, z_min, x_max, y_max, z_max); - create_complex(alpha_complex, simplex_tree, alpha_square_max_value); - } else { - Weighted_alpha_complex_3d alpha_complex(off_reader.get_point_cloud(), weights); - create_complex(alpha_complex, simplex_tree, alpha_square_max_value); - } + if (periodic_version) { + Alpha_complex_3d alpha_complex(off_reader.get_point_cloud(), x_min, y_min, z_min, x_max, y_max, z_max); + create_complex(alpha_complex, simplex_tree, alpha_square_max_value); } else { - if (periodic_version) { - Periodic_alpha_complex_3d alpha_complex(off_reader.get_point_cloud(), x_min, y_min, z_min, x_max, y_max, z_max); - create_complex(alpha_complex, simplex_tree, alpha_square_max_value); - } else { - Alpha_complex_3d alpha_complex(off_reader.get_point_cloud()); - create_complex(alpha_complex, simplex_tree, alpha_square_max_value); - } + Alpha_complex_3d alpha_complex(off_reader.get_point_cloud()); + create_complex(alpha_complex, simplex_tree, alpha_square_max_value); } } + // Sort the simplices in the order of the filtration simplex_tree.initialize_filtration(); @@ -175,7 +239,7 @@ int main(int argc, char **argv) { std::ofstream out(output_file_diag); pcoh.output_diagram(out); out.close(); - } + }*/ return 0; } -- cgit v1.2.3