From c89ae478ea5d6685c862533fac1aea973e9cda02 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 31 Jul 2018 14:33:49 +0000 Subject: Add unitary tests and documentation Fix debug exception mechanism git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3712 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 43f66f3843981ab9cd74c117c2b1c6bb9b94810b --- src/Alpha_complex/doc/Intro_alpha_complex.h | 23 + src/Alpha_complex/example/CMakeLists.txt | 10 + .../Weighted_alpha_complex_3d_from_points.cpp | 71 +++ src/Alpha_complex/example/traits_test.cpp | 354 ----------- .../example/weightedalpha3dfrompoints_for_doc.txt | 31 + src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 10 +- .../test/Alpha_complex_3d_unit_test.cpp | 663 +++++++++++++++++++++ src/Alpha_complex/test/CMakeLists.txt | 7 + .../utilities/alpha_complex_3d_persistence.cpp | 29 +- src/Alpha_complex/utilities/alphacomplex.md | 44 +- 10 files changed, 829 insertions(+), 413 deletions(-) create mode 100644 src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp delete mode 100644 src/Alpha_complex/example/traits_test.cpp create mode 100644 src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt create mode 100644 src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h index 7a375c9f..82aee275 100644 --- a/src/Alpha_complex/doc/Intro_alpha_complex.h +++ b/src/Alpha_complex/doc/Intro_alpha_complex.h @@ -165,6 +165,29 @@ namespace alpha_complex { * * \include Alpha_complex/alphaoffreader_for_doc_32.txt * + * + * \section weighted3dexample 3d specific example + * + * A specific module for Alpha complex is available in 3d (cf. Alpha_complex_3d) and allows to construct default, exact, + * weighted, periodic or weighted and periodic versions of alpha complexes + * + * This example builds the CGAL 3d weighted alpha shapes from a small molecule, and initializes the alpha complex with + * it. This example is taken from CGAL 3d + * weighted alpha shapes. + * + * Then, it is asked to display information about the alpha complex. + * + * \include Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp + * + * When launching: + * + * \code $> ./Alpha_complex_example_weighted_3d_from_points + * \endcode + * + * the program output is: + * + * \include Alpha_complex/weightedalpha3dfrompoints_for_doc.txt + * */ /** @} */ // end defgroup alpha_complex diff --git a/src/Alpha_complex/example/CMakeLists.txt b/src/Alpha_complex/example/CMakeLists.txt index af4bfd74..4a1cd26d 100644 --- a/src/Alpha_complex/example/CMakeLists.txt +++ b/src/Alpha_complex/example/CMakeLists.txt @@ -30,4 +30,14 @@ if(CGAL_FOUND) ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_result_32.txt ${CMAKE_CURRENT_BINARY_DIR}/alphaoffreader_for_doc_32.txt) endif() endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) + if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) + add_executable ( Alpha_complex_example_weighted_3d_from_points Weighted_alpha_complex_3d_from_points.cpp ) + target_link_libraries(Alpha_complex_example_weighted_3d_from_points ${CGAL_LIBRARY}) + if (TBB_FOUND) + target_link_libraries(Alpha_complex_example_weighted_3d_from_points ${TBB_LIBRARIES}) + endif() + add_test(NAME Alpha_complex_example_weighted_3d_from_points + COMMAND $) + + endif(NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.11.0) endif() \ No newline at end of file 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 new file mode 100644 index 00000000..abb73427 --- /dev/null +++ b/src/Alpha_complex/example/Weighted_alpha_complex_3d_from_points.cpp @@ -0,0 +1,71 @@ +#include +#include +// to construct a simplex_tree from alpha complex +#include + +#include +#include +#include +#include // for numeric limits + +using Weighted_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_alpha_shapes_3d; +using Weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Point = Gudhi::alpha_complex::Weighted_alpha_shapes_3d::Point_3 ; +using Vector_of_points = std::vector; +using Vector_of_weights = std::vector; + +void usage(int nbArgs, char * const progName) { + std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; + std::cerr << "Usage: " << progName << " \n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { + if (argc != 1) { + std::cerr << "Error: Number of arguments (" << argc << ") is not correct\n"; + std::cerr << "Usage: " << (argv[0] - 1) << " \n"; + exit(-1); // ----- >> + } + + // ---------------------------------------------------------------------------- + // 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.); + + // ---------------------------------------------------------------------------- + // Init of an alpha complex from the list of points + // ---------------------------------------------------------------------------- + Weighted_alpha_complex_3d alpha_complex_from_points(points, weights); + + Gudhi::Simplex_tree<> simplex; + if (alpha_complex_from_points.create_complex(simplex)) { + // ---------------------------------------------------------------------------- + // Display information about the alpha complex + // ---------------------------------------------------------------------------- + std::cout << "Alpha complex is of dimension " << simplex.dimension() << + " - " << simplex.num_simplices() << " simplices - " << + simplex.num_vertices() << " vertices." << std::endl; + + std::cout << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << std::endl; + for (auto f_simplex : simplex.filtration_simplex_range()) { + std::cout << " ( "; + for (auto vertex : simplex.simplex_vertex_range(f_simplex)) { + std::cout << vertex << " "; + } + std::cout << ") -> " << "[" << simplex.filtration(f_simplex) << "] "; + std::cout << std::endl; + } + } + return 0; +} diff --git a/src/Alpha_complex/example/traits_test.cpp b/src/Alpha_complex/example/traits_test.cpp deleted file mode 100644 index 1dd062de..00000000 --- a/src/Alpha_complex/example/traits_test.cpp +++ /dev/null @@ -1,354 +0,0 @@ -#include -#include - -#include -#include -#include -#include // for numeric limits -#include - -void usage(int nbArgs, char * const progName) { - std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " [alpha_square_max_value]\n"; - std::cerr << " i.e.: " << progName << " 60.0\n"; - exit(-1); // ----- >> -} - -int main(int argc, char **argv) { - //if ((argc != 1) && (argc != 2)) usage(argc, (argv[0] - 1)); - - std::cout << "Alpha complex 3d" << std::endl; - using Alpha_shapes_3d = Gudhi::alpha_complex::Alpha_shapes_3d; - std::vector points; - points.push_back(Alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); - points.push_back(Alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); - points.push_back(Alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); - points.push_back(Alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); - points.push_back(Alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); - points.push_back(Alpha_shapes_3d::Point_3(0.2, 0.8, 0.6)); - - Gudhi::alpha_complex::Alpha_complex_3d alpha_complex(points); - - Gudhi::Simplex_tree<> stree; - alpha_complex.create_complex(stree); - - std::cout << "Exact alpha complex 3d" << std::endl; - using Exact_alpha_shapes_3d = Gudhi::alpha_complex::Exact_alpha_shapes_3d; - std::vector e_points; - e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); - e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); - e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); - e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); - e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); - e_points.push_back(Exact_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6)); - - Gudhi::alpha_complex::Alpha_complex_3d exact_alpha_complex(e_points); - - Gudhi::Simplex_tree exact_stree; - exact_alpha_complex.create_complex(exact_stree); - - std::cout << "Weighted alpha complex 3d" << std::endl; - using Weighted_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_alpha_shapes_3d; - std::vector w_points; - w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); - w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); - w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); - w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); - w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); - w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6)); - - std::vector weights = {0.01, 0.005, 0.006, 0.01, 0.009, 0.001}; - - Gudhi::alpha_complex::Alpha_complex_3d weighted_alpha_complex(w_points, weights); - - Gudhi::Simplex_tree<> w_stree; - weighted_alpha_complex.create_complex(w_stree); - - std::cout << "Periodic alpha complex 3d" << std::endl; - using Periodic_alpha_shapes_3d = Gudhi::alpha_complex::Periodic_alpha_shapes_3d; - std::vector p_points; - - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.1, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.6)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.8)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.0)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.4)); - p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.6)); - - Gudhi::alpha_complex::Alpha_complex_3d periodic_alpha_complex(p_points, - 0., 0., 0., - 1., 1., 1.); - - Gudhi::Simplex_tree<> p_stree; - periodic_alpha_complex.create_complex(p_stree); - - std::cout << "Weighted periodic alpha complex 3d" << std::endl; - using Weighted_periodic_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_periodic_alpha_shapes_3d; - std::vector wp_points; - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.1, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.6)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.8)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.0)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.4)); - wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.6)); - - std::vector p_weights; - - std::random_device rd; - std::mt19937 mt(rd()); - // Weights must be in range [0, <1/64] - std::uniform_real_distribution dist(0.0, 0.0156245); - - for (std::size_t i = 0; i < wp_points.size(); ++i) { - double value = dist(mt); - std::cout << value << std::endl; - p_weights.push_back(value); - } - - Gudhi::alpha_complex::Alpha_complex_3d - weighted_periodic_alpha_complex(wp_points, p_weights, - 0., 0., 0., - 1., 1., 1.); - Gudhi::Simplex_tree<> wp_stree; - weighted_periodic_alpha_complex.create_complex(wp_stree); - - return 0; -} diff --git a/src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt b/src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt new file mode 100644 index 00000000..7a09998d --- /dev/null +++ b/src/Alpha_complex/example/weightedalpha3dfrompoints_for_doc.txt @@ -0,0 +1,31 @@ +Alpha complex is of dimension 3 - 29 simplices - 5 vertices. +Iterator on alpha complex simplices in the filtration order, with [filtration value]: + ( 0 ) -> [-4] + ( 1 ) -> [-4] + ( 2 ) -> [-4] + ( 3 ) -> [-4] + ( 1 0 ) -> [-2] + ( 2 0 ) -> [-2] + ( 2 1 ) -> [-2] + ( 3 0 ) -> [-2] + ( 3 1 ) -> [-2] + ( 3 2 ) -> [-2] + ( 2 1 0 ) -> [-1.33333] + ( 3 1 0 ) -> [-1.33333] + ( 3 2 0 ) -> [-1.33333] + ( 3 2 1 ) -> [-1.33333] + ( 3 2 1 0 ) -> [-1] + ( 4 ) -> [-1] + ( 4 2 ) -> [-1] + ( 4 0 ) -> [23] + ( 4 1 ) -> [23] + ( 4 2 0 ) -> [23] + ( 4 2 1 ) -> [23] + ( 4 3 ) -> [23] + ( 4 3 2 ) -> [23] + ( 4 1 0 ) -> [95] + ( 4 2 1 0 ) -> [95] + ( 4 3 0 ) -> [95] + ( 4 3 1 ) -> [95] + ( 4 3 2 0 ) -> [95] + ( 4 3 2 1 ) -> [95] diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index f37c0816..15acd7bd 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -216,8 +216,8 @@ public: static_assert(AlphaComplex3dOptions::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. - GUDHI_CHECK((x_max - x_min == y_max - y_min) || - (x_max - x_min == z_max - z_min) || + GUDHI_CHECK((x_max - x_min == y_max - y_min) && + (x_max - x_min == z_max - z_min) && (z_max - z_min == y_max - y_min), std::invalid_argument("The size of the cuboid in every directions is not the same.")); @@ -295,8 +295,8 @@ public: GUDHI_CHECK((weights.size() == points.size()), std::invalid_argument("Points number in range different from weights range number")); // Checking if the cuboid is the same in x,y and z direction. If not, CGAL will not process it. - GUDHI_CHECK((x_max - x_min == y_max - y_min) || - (x_max - x_min == z_max - z_min) || + GUDHI_CHECK((x_max - x_min == y_max - y_min) && + (x_max - x_min == z_max - z_min) && (z_max - z_min == y_max - y_min), std::invalid_argument("The size of the cuboid in every directions is not the same.")); @@ -312,7 +312,7 @@ public: #endif while ((index < weights.size()) && (index < points.size())) { - GUDHI_CHECK((weights[index] < maximal_possible_weight) || (weights[index] >= 0), + GUDHI_CHECK((weights[index] < maximal_possible_weight) && (weights[index] >= 0), std::invalid_argument("Invalid weight at line" + 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.")); diff --git a/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp new file mode 100644 index 00000000..7873deca --- /dev/null +++ b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp @@ -0,0 +1,663 @@ +/* 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) 2015 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 . + */ + +#define BOOST_TEST_DYN_LINK +#define BOOST_TEST_MODULE "alpha_complex_3d" +#include +#include + +#include // float comparison +#include +#include +#include +#include + +#include +#include +// to construct a simplex_tree from Delaunay_triangulation +#include +#include +#include +#include + +using Alpha_shapes_3d = Gudhi::alpha_complex::Alpha_shapes_3d; +using Exact_alpha_shapes_3d = Gudhi::alpha_complex::Exact_alpha_shapes_3d; +using Weighted_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_alpha_shapes_3d; +using Periodic_alpha_shapes_3d = Gudhi::alpha_complex::Periodic_alpha_shapes_3d; +using Weighted_periodic_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_periodic_alpha_shapes_3d; + +BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) { + // ----------------- + // Non exact version + // ----------------- + std::cout << "Alpha complex 3d" << std::endl; + std::vector points; + points.push_back(Alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); + points.push_back(Alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); + points.push_back(Alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); + points.push_back(Alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); + points.push_back(Alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); + points.push_back(Alpha_shapes_3d::Point_3(0.2, 0.8, 0.6)); + + Gudhi::alpha_complex::Alpha_complex_3d alpha_complex(points); + + Gudhi::Simplex_tree<> stree; + alpha_complex.create_complex(stree); + + // ----------------- + // Exact version + // ----------------- + std::cout << "Exact alpha complex 3d" << std::endl; + using Exact_alpha_shapes_3d = Gudhi::alpha_complex::Exact_alpha_shapes_3d; + + Gudhi::alpha_complex::Alpha_complex_3d exact_alpha_complex(points); + + Gudhi::Simplex_tree<> exact_stree; + exact_alpha_complex.create_complex(exact_stree); + + // --------------------- + // Compare both versions + // --------------------- + std::cout << "Exact 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 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 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()); + + auto sh = stree.filtration_simplex_range().begin(); + auto sh_exact = exact_stree.filtration_simplex_range().begin(); + while(sh != stree.filtration_simplex_range().end() && sh_exact != exact_stree.filtration_simplex_range().end()) { + std::vector simplex; + std::vector exact_simplex; + std::cout << "Non-exact ( "; + for (auto vertex : stree.simplex_vertex_range(*sh)) { + simplex.push_back(vertex); + std::cout << vertex << " "; + } + std::cout << ") -> " << "[" << stree.filtration(*sh) << "] "; + std::cout << std::endl; + std::cout << "Exact ( "; + for (auto vertex : exact_stree.simplex_vertex_range(*sh_exact)) { + exact_simplex.push_back(vertex); + std::cout << vertex << " "; + } + std::cout << ") -> " << "[" << exact_stree.filtration(*sh_exact) << "] "; + std::cout << std::endl; + BOOST_CHECK(exact_simplex == 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)); + ++sh; + ++sh_exact; + } +} + +#ifdef GUDHI_DEBUG +BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_throw) { + std::vector w_points; + w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); + w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); + w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); + // w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); + // w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); + // w_points.push_back(Weighted_alpha_shapes_3d::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}; + + std::cout << "Check exception throw in debug mode" << std::endl; + BOOST_CHECK_THROW (Gudhi::alpha_complex::Alpha_complex_3d wac(w_points, weights), + std::invalid_argument); +} +#endif + +BOOST_AUTO_TEST_CASE(Alpha_complex_weighted) { + std::cout << "Weighted alpha complex 3d" << std::endl; + using Weighted_alpha_shapes_3d = Gudhi::alpha_complex::Weighted_alpha_shapes_3d; + std::vector w_points; + w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); + w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); + w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); + w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); + w_points.push_back(Weighted_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); + w_points.push_back(Weighted_alpha_shapes_3d::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}; + + Gudhi::alpha_complex::Alpha_complex_3d weighted_alpha_complex(w_points, weights); + Gudhi::Simplex_tree<> w_stree; + weighted_alpha_complex.create_complex(w_stree); + + std::cout << "Weighted Alpha complex 3d is of dimension " << w_stree.dimension() << std::endl; + BOOST_CHECK(w_stree.dimension() == 3); + std::cout << " num_simplices " << w_stree.num_simplices() << std::endl; + BOOST_CHECK(w_stree.num_simplices() == 35); + std::cout << " num_vertices " << w_stree.num_vertices() << std::endl; + BOOST_CHECK(w_stree.num_vertices() == 6); +} + +#ifdef GUDHI_DEBUG +BOOST_AUTO_TEST_CASE(Alpha_complex_periodic_throw) { + std::cout << "Periodic alpha complex 3d exception throw" << std::endl; + std::vector p_points; + + // Not important, this is not what we want to check + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); + + std::cout << "Check exception throw in debug mode" << std::endl; + using Periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + // Check it throws an exception when the cuboid is not iso + BOOST_CHECK_THROW (Periodic_alpha_complex_3d periodic_alpha_complex(p_points, 0., 0., 0., 0.9, 1., 1.), + std::invalid_argument); + BOOST_CHECK_THROW (Periodic_alpha_complex_3d periodic_alpha_complex(p_points, 0., 0., 0., 1., 0.9, 1.), + std::invalid_argument); + BOOST_CHECK_THROW (Periodic_alpha_complex_3d periodic_alpha_complex(p_points, 0., 0., 0., 1., 1., 0.9), + std::invalid_argument); + +} +#endif + +BOOST_AUTO_TEST_CASE(Alpha_complex_periodic) { + std::cout << "Periodic alpha complex 3d" << std::endl; + std::vector p_points; + + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.1, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.6)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.8)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.0)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.4)); + p_points.push_back(Periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.6)); + + Gudhi::alpha_complex::Alpha_complex_3d periodic_alpha_complex(p_points, + 0., 0., 0., + 1., 1., 1.); + + Gudhi::Simplex_tree<> p_stree; + periodic_alpha_complex.create_complex(p_stree); + + std::cout << "Periodic Alpha complex 3d is of dimension " << p_stree.dimension() << std::endl; + BOOST_CHECK(p_stree.dimension() == 3); + std::cout << " num_simplices " << p_stree.num_simplices() << std::endl; + BOOST_CHECK(p_stree.num_simplices() == 3266); + std::cout << " num_vertices " << p_stree.num_vertices() << std::endl; + BOOST_CHECK(p_stree.num_vertices() == 125); + +} + +#ifdef GUDHI_DEBUG +BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_periodic_throw) { + std::cout << "Weighted periodic alpha complex 3d exception throw" << std::endl; + + std::vector wp_points; + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.1, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.6)); + + std::vector p_weights; + + std::random_device rd; + std::mt19937 mt(rd()); + // Weights must be in range [0, <1/64] + std::uniform_real_distribution dist(0.0, 0.0156245); + + for (std::size_t i = 0; i < wp_points.size(); ++i) { + double value = dist(mt); + p_weights.push_back(value); + } + + std::cout << "Cuboid is not iso exception" << std::endl; + using Weighted_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + // Check it throws an exception when the cuboid is not iso + BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 0.9, 1., 1.), + std::invalid_argument); + BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 0.9, 1.), + std::invalid_argument); + BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 0.9), + std::invalid_argument); + + std::cout << "0 <= point.weight() < 1/64 * domain_size * domain_size exception" << std::endl; + // Weights must be in range [0, <1/64] + p_weights[25] = 1.0; + BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.), + std::invalid_argument); + // Weights must be in range [0, <1/64] + p_weights[25] = 0.012; + p_weights[14] = -0.012; + BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.), + std::invalid_argument); + p_weights[14] = 0.005; + + std::cout << "wp_points and p_weights size exception" << std::endl; + // Weights and points must have the same size + // + 1 + p_weights.push_back(0.007); + BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.), + std::invalid_argument); + // - 1 + p_weights.pop_back(); + p_weights.pop_back(); + BOOST_CHECK_THROW (Weighted_periodic_alpha_complex_3d periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.), + std::invalid_argument); +} +#endif + +BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_periodic) { + std::cout << "Weighted periodic alpha complex 3d" << std::endl; + + std::vector wp_points; + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.0, 0.8, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.2, 0.8, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.4, 0.8, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.1, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.6, 0.8, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.0, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.2, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.4, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.6)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.6, 0.8)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.0)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.2)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.4)); + wp_points.push_back(Weighted_periodic_alpha_shapes_3d::Point_3(0.8, 0.8, 0.6)); + + std::vector p_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) { + double value = dist(mt); + p_weights.push_back(value); + } + + using Weighted_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + Weighted_periodic_alpha_complex_3d weighted_periodic_alpha_complex(wp_points, p_weights, 0., 0., 0., 1., 1., 1.); + + Gudhi::Simplex_tree<> wp_stree; + weighted_periodic_alpha_complex.create_complex(wp_stree); + + std::cout << "Weighted periodic Alpha complex 3d is of dimension " << wp_stree.dimension() << std::endl; + BOOST_CHECK(wp_stree.dimension() == 3); + std::cout << " num_simplices " << wp_stree.num_simplices() << std::endl; + BOOST_CHECK(wp_stree.num_simplices() >= 3100); + std::cout << " num_vertices " << wp_stree.num_vertices() << std::endl; + BOOST_CHECK(wp_stree.num_vertices() == 125); +} diff --git a/src/Alpha_complex/test/CMakeLists.txt b/src/Alpha_complex/test/CMakeLists.txt index 9255d3db..7b6de748 100644 --- a/src/Alpha_complex/test/CMakeLists.txt +++ b/src/Alpha_complex/test/CMakeLists.txt @@ -9,10 +9,17 @@ if (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) target_link_libraries(Alpha_complex_test_unit ${TBB_LIBRARIES}) endif() + add_executable ( Alpha_complex_3d_test_unit Alpha_complex_3d_unit_test.cpp ) + target_link_libraries(Alpha_complex_3d_test_unit ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) + if (TBB_FOUND) + target_link_libraries(Alpha_complex_3d_test_unit ${TBB_LIBRARIES}) + endif() + # Do not forget to copy test files in current binary dir file(COPY "${CMAKE_SOURCE_DIR}/data/points/alphacomplexdoc.off" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) gudhi_add_coverage_test(Alpha_complex_test_unit) + gudhi_add_coverage_test(Alpha_complex_3d_test_unit) endif (NOT CGAL_WITH_EIGEN3_VERSION VERSION_LESS 4.7.0) diff --git a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp index 00ede9ce..536de444 100644 --- a/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp +++ b/src/Alpha_complex/utilities/alpha_complex_3d_persistence.cpp @@ -45,12 +45,13 @@ using Persistent_cohomology = Gudhi::persistent_cohomology::Persistent_cohomology; 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, int &coeff_field_characteristic, - Filtration_value &min_persistence); + std::string &cuboid_file, std::string &output_file_diag, Filtration_value &alpha_square_max_value, + int &coeff_field_characteristic, Filtration_value &min_persistence); template -bool create_complex(AlphaComplex3d& alpha_complex, Simplex_tree& simplex_tree) { - return alpha_complex.create_complex(simplex_tree); +bool create_complex(AlphaComplex3d& alpha_complex, Simplex_tree& simplex_tree, + Filtration_value alpha_square_max_value) { + return alpha_complex.create_complex(simplex_tree, alpha_square_max_value); } bool read_weight_file(const std::string& weight_file, std::vector& weights) { @@ -87,6 +88,7 @@ int main(int argc, char **argv) { std::string weight_file; std::string cuboid_file; std::string output_file_diag; + Filtration_value alpha_square_max_value = 0.; int coeff_field_characteristic = 0; Filtration_value min_persistence = 0.; bool exact_version = false; @@ -94,7 +96,7 @@ int main(int argc, char **argv) { bool periodic_version = false; program_options(argc, argv, off_file_points, exact_version, weight_file, cuboid_file, output_file_diag, - coeff_field_characteristic, min_persistence); + alpha_square_max_value, coeff_field_characteristic, min_persistence); // Read the OFF file (input file name given as parameter) and triangulate points Gudhi::Points_3D_off_reader off_reader(off_file_points); @@ -131,25 +133,25 @@ int main(int argc, char **argv) { exit(-1); } else { Exact_alpha_complex_3d alpha_complex(off_reader.get_point_cloud()); - create_complex(alpha_complex, simplex_tree); + 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); + 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); + 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); + 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); + create_complex(alpha_complex, simplex_tree, alpha_square_max_value); } } } @@ -179,8 +181,8 @@ int main(int argc, char **argv) { } 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, int &coeff_field_characteristic, - Filtration_value &min_persistence) { + std::string &cuboid_file, std::string &output_file_diag, Filtration_value &alpha_square_max_value, + int &coeff_field_characteristic, Filtration_value &min_persistence) { namespace po = boost::program_options; po::options_description hidden("Hidden options"); hidden.add_options()("input-file", po::value(&off_file_points), @@ -196,6 +198,9 @@ void program_options(int argc, char *argv[], std::string &off_file_points, bool& "Name of file describing the periodic domain. Format is:\n min_hx min_hy min_hz\n max_hx max_hy max_hz")( "output-file,o", po::value(&output_file_diag)->default_value(std::string()), "Name of file in which the persistence diagram is written. Default print in std::cout")( + "max-alpha-square-value,r", po::value(&alpha_square_max_value) + ->default_value(std::numeric_limits::infinity()), + "Maximal alpha square value for the Alpha complex construction.")( "field-charac,p", po::value(&coeff_field_characteristic)->default_value(11), "Characteristic p of the coefficient field Z/pZ for computing homology.")( "min-persistence,m", po::value(&min_persistence), diff --git a/src/Alpha_complex/utilities/alphacomplex.md b/src/Alpha_complex/utilities/alphacomplex.md index 7ae5f913..7fc6cc0c 100644 --- a/src/Alpha_complex/utilities/alphacomplex.md +++ b/src/Alpha_complex/utilities/alphacomplex.md @@ -94,6 +94,8 @@ where `` is the path to the input point cloud in * `-h [ --help ]` Produce help message * `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. +* `-r [ --max-alpha-square-value ]` (default = inf) Maximal alpha square value +for the Alpha complex construction. * `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. * `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature @@ -120,45 +122,3 @@ N.B.: [Alpha shape](https://doc.cgal.org/latest/Alpha_shapes_3/index.html#title0) and [Regular triangulation](https://doc.cgal.org/latest/Triangulation_3/index.html#Triangulation3secclassRegulartriangulation) documentation. - - - - - - - - -## periodic_alpha_complex_3d_persistence ## -Same as `alpha_complex_3d_persistence`, but using periodic alpha shape 3d. -Refer to the [CGAL's 3D Periodic Triangulations User Manual](https://doc.cgal.org/latest/Periodic_3_triangulation_3/index.html) for more details. - -**Usage** - -``` - periodic_alpha_complex_3d_persistence [options] -``` - -where - -* `` is the path to the input point cloud in [nOFF ASCII format](http://www.geomview.org/docs/html/OFF.html). -* `` is the path to the file describing the periodic domain. It must be in the format described -[here](/doc/latest/fileformats.html#FileFormatsIsoCuboid). - -**Allowed options** - -* `-h [ --help ]` Produce help message -* `-o [ --output-file ]` Name of file in which the persistence diagram is written. Default print in standard output. -* `-p [ --field-charac ]` (default=11) Characteristic p of the coefficient field Z/pZ for computing homology. -* `-m [ --min-persistence ]` (default = 0) Minimal lifetime of homology feature to be recorded. Enter a negative value to see zero length intervals - - -**Example** - -``` -periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off ../../data/points/iso_cuboid_3_in_0_1.txt -p 3 -m 1.0 -``` - -N.B.: - -* Cuboid file must be in the format described [here](/doc/latest/fileformats.html#FileFormatsIsoCuboid). -* Filtration values are alpha square values. -- cgit v1.2.3