From 9b8bb34ff06b08119b8fa1e78c260886287c5a92 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 3 Jul 2018 16:08:32 +0000 Subject: Documentation for Alpha complex 3d git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3664 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c6d824cdab7ac5ea79ce458dac666d35a9a21ab7 --- src/common/doc/examples.h | 4 ---- src/common/doc/installation.h | 20 ++------------------ src/common/doc/main_page.h | 2 +- 3 files changed, 3 insertions(+), 23 deletions(-) (limited to 'src/common') diff --git a/src/common/doc/examples.h b/src/common/doc/examples.h index 40f202c7..7c2a8f69 100644 --- a/src/common/doc/examples.h +++ b/src/common/doc/examples.h @@ -53,10 +53,6 @@ * @example Spatial_searching/example_spatial_searching.cpp * @example Alpha_complex/alpha_complex_3d_persistence.cpp * @example Alpha_complex/alpha_complex_persistence.cpp - * @example Alpha_complex/weighted_periodic_alpha_complex_3d_persistence.cpp - * @example Alpha_complex/weighted_alpha_complex_3d_persistence.cpp - * @example Alpha_complex/periodic_alpha_complex_3d_persistence.cpp - * @example Alpha_complex/exact_alpha_complex_3d_persistence.cpp * @example Bottleneck_distance/bottleneck_distance.cpp * @example Witness_complex/weak_witness_persistence.cpp * @example Witness_complex/strong_witness_persistence.cpp diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index 12407c18..8f91e9c1 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -58,10 +58,6 @@ make doxygen * Library (CGAL \cite cgal:eb-15b) and will not be built if CGAL is not installed: * \li * Alpha_complex/alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/exact_alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp * \li * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp * @@ -84,8 +80,6 @@ make doxygen * Alpha_complex/Alpha_complex_from_points.cpp * \li * Alpha_complex/alpha_complex_persistence.cpp - * \li - * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp * \li * Persistent_cohomology/custom_persistence_sort.cpp * @@ -132,8 +126,8 @@ make doxygen * Alpha_complex/Alpha_complex_from_points.cpp * \li * Alpha_complex/alpha_complex_persistence.cpp - * \li - * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp + * \li + * Alpha_complex/alpha_complex_3d_persistence.cpp * \li * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp * \li @@ -179,12 +173,6 @@ make doxygen * Alpha_complex/alpha_complex_3d_persistence.cpp * \li * Alpha_complex/alpha_complex_persistence.cpp - * \li - * Alpha_complex/exact_alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/periodic_alpha_complex_3d_persistence.cpp - * \li - * Alpha_complex/weighted_alpha_complex_3d_persistence.cpp * \li * Bitmap_cubical_complex/cubical_complex_persistence.cpp * \li @@ -223,10 +211,6 @@ make doxygen * Persistent_cohomology/rips_multifield_persistence.cpp * \li * Persistent_cohomology/rips_persistence_step_by_step.cpp - * \li - * Persistent_cohomology/exact_alpha_complex_3d_persistence.cpp - * \li - * Persistent_cohomology/weighted_alpha_complex_3d_persistence.cpp * \li * Persistent_cohomology/custom_persistence_sort.cpp * \li diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index db1e80ce..35b84d2e 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -29,7 +29,7 @@ Author: Vincent Rouvreau
Introduced in: GUDHI 1.3.0
Copyright: GPL v3
- Requires: \ref cgal ≥ 4.7.0 and \ref eigen3 + Requires: \ref cgal ≥ 4.11.0 and \ref eigen3 Alpha_complex is a simplicial complex constructed from the finite cells of a Delaunay Triangulation.
-- cgit v1.2.3 From a114ccb40558615139eeb23dfc05e3ceeb909d7f Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 31 Jul 2018 15:47:22 +0000 Subject: Fix documentation for CGAL version required by 3d version Remove duplicated example (cf. the one in the Simplex tree) Add the example for documentation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3713 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 204f77982c61bc30a6ad3218c82b98f8bb49d711 --- .../example/alpha_complex_3d_step_by_step.cpp | 309 --------------------- src/common/doc/examples.h | 1 + src/common/doc/installation.h | 10 +- 3 files changed, 9 insertions(+), 311 deletions(-) delete mode 100644 src/Alpha_complex/example/alpha_complex_3d_step_by_step.cpp (limited to 'src/common') diff --git a/src/Alpha_complex/example/alpha_complex_3d_step_by_step.cpp b/src/Alpha_complex/example/alpha_complex_3d_step_by_step.cpp deleted file mode 100644 index d76402e5..00000000 --- a/src/Alpha_complex/example/alpha_complex_3d_step_by_step.cpp +++ /dev/null @@ -1,309 +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) 2014 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 . - */ - -#include -#include -#include - -#if BOOST_VERSION >= 105400 -#include -#endif - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -template -Vertex_list from_cell(const Cell_handle& ch) { - Vertex_list the_list; - for (auto i = 0; i < 4; i++) { -#ifdef DEBUG_TRACES - std::cout << "from cell[" << i << "]=" << ch->vertex(i)->point() << std::endl; -#endif // DEBUG_TRACES - the_list.push_back(ch->vertex(i)); - } - return the_list; -} - -template -Vertex_list from_facet(const Facet& fct) { - Vertex_list the_list; - for (auto i = 0; i < 4; i++) { - if (fct.second != i) { -#ifdef DEBUG_TRACES - std::cout << "from facet=[" << i << "]" << fct.first->vertex(i)->point() << std::endl; -#endif // DEBUG_TRACES - the_list.push_back(fct.first->vertex(i)); - } - } - return the_list; -} - -template -Vertex_list from_edge(const Edge_3& edg) { - Vertex_list the_list; - for (auto i : {edg.second, edg.third}) { -#ifdef DEBUG_TRACES - std::cout << "from edge[" << i << "]=" << edg.first->vertex(i)->point() << std::endl; -#endif // DEBUG_TRACES - the_list.push_back(edg.first->vertex(i)); - } - return the_list; -} - -template -Vertex_list from_vertex(const Vertex_handle& vh) { - Vertex_list the_list; -#ifdef DEBUG_TRACES - std::cout << "from vertex=" << vh->point() << std::endl; -#endif // DEBUG_TRACES - the_list.push_back(vh); - return the_list; -} - -// Alpha_shape_3 templates type definitions -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; -using Alpha_shape_3 = CGAL::Alpha_shape_3; - -// From file type definition -using Point_3 = Kernel::Point_3; - -// filtration with alpha values needed type definition -using Alpha_value_type = Alpha_shape_3::FT; -using Object = CGAL::Object; -using Dispatch = - CGAL::Dispatch_output_iterator, - CGAL::cpp11::tuple >, - std::back_insert_iterator > > >; -using Cell_handle = Alpha_shape_3::Cell_handle; -using Facet = Alpha_shape_3::Facet; -using Edge_3 = Alpha_shape_3::Edge; -using Vertex_handle = Alpha_shape_3::Vertex_handle; - -#if BOOST_VERSION >= 105400 -using Vertex_list = boost::container::static_vector; -#else -using Vertex_list = std::vector; -#endif - -// gudhi type definition -using ST = Gudhi::Simplex_tree; -using Filtration_value = ST::Filtration_value; -using Simplex_tree_vertex = ST::Vertex_handle; -using Alpha_shape_simplex_tree_map = std::map; -using Simplex_tree_vector_vertex = std::vector; - -void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag); - -int main(int argc, char **argv) { - std::string off_file_points; - std::string output_file_diag; - - program_options(argc, argv, off_file_points, output_file_diag); - - // 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 - if (!off_reader.is_valid()) { - std::cerr << "Unable to read file " << off_file_points << std::endl; - exit(-1); - } - - // Retrieve the points - std::vector lp = off_reader.get_point_cloud(); - - // alpha shape construction from points. CGAL has a strange behavior in REGULARIZED mode. - Alpha_shape_3 as(lp.begin(), lp.end(), 0, Alpha_shape_3::GENERAL); -#ifdef DEBUG_TRACES - std::cout << "Alpha shape computed in GENERAL mode" << std::endl; -#endif // DEBUG_TRACES - - // filtration with alpha values from alpha shape - std::vector the_objects; - std::vector the_alpha_values; - - Dispatch disp = CGAL::dispatch_output(std::back_inserter(the_objects), - std::back_inserter(the_alpha_values)); - - as.filtration_with_alpha_values(disp); -#ifdef DEBUG_TRACES - std::cout << "filtration_with_alpha_values returns : " << the_objects.size() << " objects" << std::endl; -#endif // DEBUG_TRACES - - Alpha_shape_3::size_type count_vertices = 0; - Alpha_shape_3::size_type count_edges = 0; - Alpha_shape_3::size_type count_facets = 0; - Alpha_shape_3::size_type count_cells = 0; - - // Loop on objects vector - Vertex_list vertex_list; - ST simplex_tree; - Alpha_shape_simplex_tree_map map_cgal_simplex_tree; - std::vector::iterator the_alpha_value_iterator = the_alpha_values.begin(); - for (auto object_iterator : the_objects) { - // Retrieve Alpha shape vertex list from object - if (const Cell_handle *cell = CGAL::object_cast(&object_iterator)) { - vertex_list = from_cell(*cell); - count_cells++; - } else if (const Facet *facet = CGAL::object_cast(&object_iterator)) { - vertex_list = from_facet(*facet); - count_facets++; - } else if (const Edge_3 *edge = CGAL::object_cast(&object_iterator)) { - vertex_list = from_edge(*edge); - count_edges++; - } else if (const Vertex_handle *vertex = CGAL::object_cast(&object_iterator)) { - count_vertices++; - vertex_list = from_vertex(*vertex); - } - // Construction of the vector of simplex_tree vertex from list of alpha_shapes vertex - Simplex_tree_vector_vertex the_simplex; - for (auto the_alpha_shape_vertex : vertex_list) { - Alpha_shape_simplex_tree_map::iterator the_map_iterator = map_cgal_simplex_tree.find(the_alpha_shape_vertex); - if (the_map_iterator == map_cgal_simplex_tree.end()) { - // alpha shape not found - Simplex_tree_vertex vertex = map_cgal_simplex_tree.size(); -#ifdef DEBUG_TRACES - std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] not found - insert " << vertex << std::endl; -#endif // DEBUG_TRACES - the_simplex.push_back(vertex); - map_cgal_simplex_tree.emplace(the_alpha_shape_vertex, vertex); - } else { - // alpha shape found - Simplex_tree_vertex vertex = the_map_iterator->second; -#ifdef DEBUG_TRACES - std::cout << "vertex [" << the_alpha_shape_vertex->point() << "] found in " << vertex << std::endl; -#endif // DEBUG_TRACES - the_simplex.push_back(vertex); - } - } - // Construction of the simplex_tree - Filtration_value filtr = /*std::sqrt*/ (*the_alpha_value_iterator); -#ifdef DEBUG_TRACES - std::cout << "filtration = " << filtr << std::endl; -#endif // DEBUG_TRACES - simplex_tree.insert_simplex(the_simplex, filtr); - GUDHI_CHECK(the_alpha_value_iterator != the_alpha_values.end(), "CGAL provided more simplices than values"); - ++the_alpha_value_iterator; - } - -#ifdef DEBUG_TRACES - std::cout << "vertices \t\t" << count_vertices << std::endl; - std::cout << "edges \t\t" << count_edges << std::endl; - std::cout << "facets \t\t" << count_facets << std::endl; - std::cout << "cells \t\t" << count_cells << std::endl; - - std::cout << "Information of the Simplex Tree: " << std::endl; - std::cout << " Number of vertices = " << simplex_tree.num_vertices() << " "; - std::cout << " Number of simplices = " << simplex_tree.num_simplices() << std::endl << std::endl; - std::cout << " Dimension = " << simplex_tree.dimension() << " "; -#endif // DEBUG_TRACES - -#ifdef DEBUG_TRACES - std::cout << "Iterator on vertices: " << std::endl; - for (auto vertex : simplex_tree.complex_vertex_range()) { - std::cout << vertex << " "; - } -#endif // DEBUG_TRACES - - // Sort the simplices in the order of the filtration - simplex_tree.initialize_filtration(); - - std::streambuf* streambufffer; - std::ofstream ouput_file_stream; - if (output_file_diag != std::string()) { - ouput_file_stream.open(output_file_diag); - streambufffer = ouput_file_stream.rdbuf(); - } else { - streambufffer = std::cout.rdbuf(); - } - - std::ostream output_stream(streambufffer); - - // ---------------------------------------------------------------------------- - // Display information about the alpha complex - // ---------------------------------------------------------------------------- - output_stream << "Alpha complex is of dimension " << simplex_tree.dimension() << - " - " << simplex_tree.num_simplices() << " simplices - " << - simplex_tree.num_vertices() << " vertices." << std::endl; - - output_stream << "Iterator on alpha complex simplices in the filtration order, with [filtration value]:" << - std::endl; - for (auto f_simplex : simplex_tree.filtration_simplex_range()) { - output_stream << " ( "; - for (auto vertex : simplex_tree.simplex_vertex_range(f_simplex)) { - output_stream << vertex << " "; - } - output_stream << ") -> " << "[" << simplex_tree.filtration(f_simplex) << "] "; - output_stream << std::endl; - } - - return 0; -} - -void program_options(int argc, char *argv[], std::string &off_file_points, std::string &output_file_diag) { - namespace po = boost::program_options; - po::options_description hidden("Hidden options"); - hidden.add_options()("input-file", po::value(&off_file_points), - "Name of file containing a point set. Format is one point per line: X1 ... Xd "); - - po::options_description visible("Allowed options", 100); - visible.add_options()("help,h", "produce help message")( - "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"); - - po::positional_options_description pos; - pos.add("input-file", 1); - - po::options_description all; - all.add(visible).add(hidden); - - po::variables_map vm; - po::store(po::command_line_parser(argc, argv).options(all).positional(pos).run(), vm); - po::notify(vm); - - if (vm.count("help") || !vm.count("input-file")) { - std::cout << std::endl; - std::cout << "Compute and displays the 3D Alpha complex defined on a set of input points.\n \n"; - std::cout << "Usage: " << argv[0] << " [options] input-file" << std::endl << std::endl; - std::cout << visible << std::endl; - exit(-1); - } -} diff --git a/src/common/doc/examples.h b/src/common/doc/examples.h index 7c2a8f69..c19b3444 100644 --- a/src/common/doc/examples.h +++ b/src/common/doc/examples.h @@ -53,6 +53,7 @@ * @example Spatial_searching/example_spatial_searching.cpp * @example Alpha_complex/alpha_complex_3d_persistence.cpp * @example Alpha_complex/alpha_complex_persistence.cpp + * @example Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp * @example Bottleneck_distance/bottleneck_distance.cpp * @example Witness_complex/weak_witness_persistence.cpp * @example Witness_complex/strong_witness_persistence.cpp diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index 8f91e9c1..d36a216f 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -56,8 +56,6 @@ make doxygen * * The following examples/utilities require the Computational Geometry Algorithms * Library (CGAL \cite cgal:eb-15b) and will not be built if CGAL is not installed: - * \li - * Alpha_complex/alpha_complex_3d_persistence.cpp * \li * Simplex_tree/example_alpha_shapes_3_simplex_tree_from_off_file.cpp * @@ -113,6 +111,12 @@ make doxygen * \li * Tangential_complex/example_with_perturb.cpp * + * The following example requires CGAL version ≥ 4.11.0: + * \li + * Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp + * \li + * Alpha_complex/alpha_complex_3d_persistence.cpp + * * \subsection eigen3 Eigen3 * The \ref alpha_complex data structure and few examples requires * Eigen3 is a C++ template library for linear algebra: @@ -128,6 +132,8 @@ make doxygen * Alpha_complex/alpha_complex_persistence.cpp * \li * Alpha_complex/alpha_complex_3d_persistence.cpp + * \li + * Alpha_complex/Weighted_alpha_complex_3d_from_points.cpp * \li * Bottleneck_distance/alpha_rips_persistence_bottleneck_distance.cpp.cpp * \li -- cgit v1.2.3 From 5b76e5b635e04e4c9a92b6be4a719cfee51b5fa9 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 29 Aug 2018 10:54:26 +0000 Subject: weighted/non-weighted and periodic/non-periodic with fast/exact are working well (test suites and examples) Still utilities to rewrite Modify GUDHI_TEST_FLOAT_EQUALITY_CHECK as one test was reaching exactly std::numeric_limits::epsilon() git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@3842 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: bbd17f90644b4b8444d480ca95da0909e8fe5048 --- src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 44 +- .../test/Alpha_complex_3d_unit_test.cpp | 625 ++++++++++++++------- src/common/include/gudhi/Unitary_tests_utils.h | 2 +- 3 files changed, 453 insertions(+), 218 deletions(-) (limited to 'src/common') diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index ed58c1c0..7e2454e5 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -108,20 +108,38 @@ class Alpha_complex_3d { using Vb = CGAL::Alpha_shape_vertex_base_3; + using TdsCb = typename std::conditional, + CGAL::Triangulation_ds_cell_base_3<>>::type; + using Tcb = typename std::conditional, - CGAL::Triangulation_cell_base_3>::type; + CGAL::Regular_triangulation_cell_base_3, + CGAL::Triangulation_cell_base_3>::type; using Cb = CGAL::Alpha_shape_cell_base_3; using Tds = CGAL::Triangulation_data_structure_3; - using Pre_triangulation_3 = typename std::conditional, - CGAL::Delaunay_triangulation_3>::type; - - using Triangulation_3 = typename std::conditional<(Weighted && Periodic), - CGAL::Periodic_3_regular_triangulation_3, - Pre_triangulation_3>::type; + // The other way to do a conditional type. Here there 4 possibilities, cannot use std::conditional + template struct Triangulation {}; + + template < typename Kernel, typename Tds > + struct Triangulation { + using Triangulation_3 = CGAL::Delaunay_triangulation_3; + }; + template < typename Kernel, typename Tds > + struct Triangulation { + using Triangulation_3 = CGAL::Regular_triangulation_3; + }; + template < typename Kernel, typename Tds > + struct Triangulation { + using Triangulation_3 = CGAL::Periodic_3_Delaunay_triangulation_3; + }; + template < typename Kernel, typename Tds > + struct Triangulation { + using Triangulation_3 = CGAL::Periodic_3_regular_triangulation_3; + }; + + using Triangulation_3 = typename Triangulation::Triangulation_3; public: using Alpha_shape_3 = CGAL::Alpha_shape_3; @@ -255,7 +273,7 @@ public: * 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. */ - /*template + 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) { @@ -269,10 +287,8 @@ public: (z_max - z_min == y_max - y_min), std::invalid_argument("The size of the cuboid in every directions is not the same.")); - using Periodic_delaunay_triangulation_3 = typename AlphaComplex3dOptions::Periodic_delaunay_triangulation_3; - using Iso_cuboid_3 = typename AlphaComplex3dOptions::Iso_cuboid_3; // Define the periodic cube - Periodic_delaunay_triangulation_3 pdt(Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max)); + Triangulation_3 pdt(typename Kernel::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max)); // Heuristic for inserting large point sets (if pts is reasonably large) pdt.insert(std::begin(points), std::end(points), true); // As pdt won't be modified anymore switch to 1-sheeted cover if possible @@ -294,7 +310,7 @@ public: std::cout << "filtration_with_alpha_values returns : " << objects_.size() << " objects" << std::endl; #endif // DEBUG_TRACES - }*/ + } /** \brief Alpha_complex constructor from a list of points, associated weights and an iso-cuboid coordinates. * 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 7873deca..2ebe090e 100644 --- a/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp @@ -33,32 +33,38 @@ #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 Fast_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 Exact_weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Fast_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +using Exact_periodic_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; +/*using Fast_alpha_complex_3d = Gudhi::alpha_complex::Fast_alpha_complex_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; +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 + // Fast 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)); + std::cout << "Fast alpha complex 3d" << std::endl; + std::vector points; + points.push_back(Fast_alpha_complex_3d::Point_3(0.0, 0.0, 0.0)); + points.push_back(Fast_alpha_complex_3d::Point_3(0.0, 0.0, 0.2)); + points.push_back(Fast_alpha_complex_3d::Point_3(0.2, 0.0, 0.2)); + points.push_back(Fast_alpha_complex_3d::Point_3(0.6, 0.6, 0.0)); + points.push_back(Fast_alpha_complex_3d::Point_3(0.8, 0.8, 0.2)); + points.push_back(Fast_alpha_complex_3d::Point_3(0.2, 0.8, 0.6)); - Gudhi::alpha_complex::Alpha_complex_3d alpha_complex(points); + Fast_alpha_complex_3d alpha_complex(points); Gudhi::Simplex_tree<> stree; alpha_complex.create_complex(stree); @@ -67,9 +73,8 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) { // 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); + Exact_alpha_complex_3d exact_alpha_complex(points); Gudhi::Simplex_tree<> exact_stree; exact_alpha_complex.create_complex(exact_stree); @@ -88,8 +93,7 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) { 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()) { + while(sh != stree.filtration_simplex_range().end()) { std::vector simplex; std::vector exact_simplex; std::cout << "Non-exact ( "; @@ -99,77 +103,125 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_3d_from_points) { } 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); + + // Find it in the exact structure + auto sh_exact = exact_stree.find(simplex); + BOOST_CHECK(sh_exact != exact_stree.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(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)); +typedef boost::mpl::list weighted_variants_type_list; + +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; + 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}; 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); + BOOST_CHECK_THROW (Weighted_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)); + // --------------------- + // 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)); // 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); + Fast_weighted_alpha_complex_3d weighted_alpha_complex(w_points, weights); + Gudhi::Simplex_tree<> stree; + weighted_alpha_complex.create_complex(stree); + + // ---------------------- + // Exact weighted version + // ---------------------- + std::cout << "Exact weighted alpha complex 3d" << std::endl; + + 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); + + Gudhi::Simplex_tree<> exact_stree; + exact_alpha_complex.create_complex(exact_stree); + + // --------------------- + // 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()); + + 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 ( "; + for (auto vertex : stree.simplex_vertex_range(*sh)) { + simplex.push_back(vertex); + std::cout << vertex << " "; + } + std::cout << ") -> " << "[" << stree.filtration(*sh) << "] "; + 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()); + + // 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; + } - 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) { +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; - std::vector p_points; + using Point_3 = typename Periodic_alpha_complex_3d::Point_3; + 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)); + p_points.push_back(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); @@ -177,157 +229,323 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_periodic_throw) { 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); + // --------------------- + // Fast periodic version + // --------------------- + std::cout << "Fast periodic alpha complex 3d" << std::endl; + std::vector p_points; + + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.1, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.6)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.8)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.0)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.2)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.4)); + p_points.push_back(Fast_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.6)); + + Fast_periodic_alpha_complex_3d periodic_alpha_complex(p_points, 0., 0., 0., 1., 1., 1.); + + Gudhi::Simplex_tree<> stree; + periodic_alpha_complex.create_complex(stree); + + // ---------------------- + // Exact periodic version + // ---------------------- + std::cout << "Exact periodic alpha complex 3d" << std::endl; + + std::vector e_p_points; + + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.0, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.2, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.4, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.6, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.0, 0.8, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.0, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.2, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.4, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.6, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.2, 0.8, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.0, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.2, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.4, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.6, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.4, 0.8, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.0, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.1, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.2, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.4, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.6, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.6, 0.8, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.0, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.2, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.4, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.6)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.6, 0.8)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.0)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.2)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.4)); + e_p_points.push_back(Exact_periodic_alpha_complex_3d::Point_3(0.8, 0.8, 0.6)); + + Exact_periodic_alpha_complex_3d exact_alpha_complex(e_p_points, 0., 0., 0., 1., 1., 1.); + + Gudhi::Simplex_tree<> exact_stree; + exact_alpha_complex.create_complex(exact_stree); + + // --------------------- + // 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; + 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()); + + 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 ( "; + for (auto vertex : stree.simplex_vertex_range(*sh)) { + simplex.push_back(vertex); + std::cout << vertex << " "; + } + std::cout << ") -> " << "[" << stree.filtration(*sh) << "] "; + 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()); + + // 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)); + ++sh; + } + } -#ifdef GUDHI_DEBUG +/*#ifdef GUDHI_DEBUG BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_periodic_throw) { std::cout << "Weighted periodic alpha complex 3d exception throw" << std::endl; @@ -661,3 +879,4 @@ BOOST_AUTO_TEST_CASE(Alpha_complex_weighted_periodic) { std::cout << " num_vertices " << wp_stree.num_vertices() << std::endl; BOOST_CHECK(wp_stree.num_vertices() == 125); } +*/ \ No newline at end of file diff --git a/src/common/include/gudhi/Unitary_tests_utils.h b/src/common/include/gudhi/Unitary_tests_utils.h index e07c8d42..22f00212 100644 --- a/src/common/include/gudhi/Unitary_tests_utils.h +++ b/src/common/include/gudhi/Unitary_tests_utils.h @@ -34,7 +34,7 @@ void GUDHI_TEST_FLOAT_EQUALITY_CHECK(FloatingType a, FloatingType b, std::cout << "GUDHI_TEST_FLOAT_EQUALITY_CHECK - " << a << " versus " << b << " | diff = " << std::fabs(a - b) << " - epsilon = " << epsilon << std::endl; #endif - BOOST_CHECK(std::fabs(a - b) < epsilon); + BOOST_CHECK(std::fabs(a - b) <= epsilon); } #endif // UNITARY_TESTS_UTILS_H_ -- cgit v1.2.3 From a3b3e527f75ea05a7840ecf73f613f56c3c52273 Mon Sep 17 00:00:00 2001 From: pdlotko Date: Thu, 20 Sep 2018 09:56:33 +0000 Subject: The same comment in the file format description... git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cubical_complex_small_fix@3900 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 656bfe12681707838a564d886b803b6b8f3f90de --- src/common/doc/file_formats.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/common') diff --git a/src/common/doc/file_formats.h b/src/common/doc/file_formats.h index 523153b8..3a236087 100644 --- a/src/common/doc/file_formats.h +++ b/src/common/doc/file_formats.h @@ -118,6 +118,9 @@ namespace Gudhi { Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y. Other sample files can be found in the `data/bitmap` folder. + + Please note that unlike in Perseus format the filtration on the maximal cubes can be any double precision number. + Consequently one cannot mark the cubes that are not present with -1's. To do that please set their filtration value to +Inf. */ } // namespace Gudhi -- cgit v1.2.3 From e8401b6fd2f9ff533824a6773f592b448d0863ed Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 31 Oct 2018 11:48:04 +0000 Subject: Make dependency with boost 1.56 instead of 1.48 git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/boost_1.56_vincent@3967 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: a5941b8c4f65ec8e6f62117aceb5f22e0142f255 --- src/cmake/modules/GUDHI_third_party_libraries.cmake | 2 +- src/common/doc/installation.h | 2 +- src/cython/doc/installation.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/cmake/modules/GUDHI_third_party_libraries.cmake b/src/cmake/modules/GUDHI_third_party_libraries.cmake index b020ebfc..cde3725c 100644 --- a/src/cmake/modules/GUDHI_third_party_libraries.cmake +++ b/src/cmake/modules/GUDHI_third_party_libraries.cmake @@ -1,6 +1,6 @@ # This files manage third party libraries required by GUDHI -find_package(Boost 1.48.0 REQUIRED COMPONENTS system filesystem unit_test_framework program_options thread) +find_package(Boost 1.56.0 REQUIRED COMPONENTS system filesystem unit_test_framework program_options thread) if(NOT Boost_FOUND) message(FATAL_ERROR "NOTICE: This program requires Boost and will not be compiled.") diff --git a/src/common/doc/installation.h b/src/common/doc/installation.h index df7eed37..bf2d0a87 100644 --- a/src/common/doc/installation.h +++ b/src/common/doc/installation.h @@ -5,7 +5,7 @@ * Examples of GUDHI headers inclusion can be found in \ref utilities. * * \section compiling Compiling - * The library uses c++11 and requires Boost ≥ 1.48.0 + * The library uses c++11 and requires Boost ≥ 1.56.0 * and CMake ≥ 3.1. * It is a multi-platform library and compiles on Linux, Mac OSX and Visual Studio 2015. * diff --git a/src/cython/doc/installation.rst b/src/cython/doc/installation.rst index ef2f7af2..040f6b4a 100644 --- a/src/cython/doc/installation.rst +++ b/src/cython/doc/installation.rst @@ -7,7 +7,7 @@ Installation Compiling ********* -The library uses c++11 and requires `Boost `_ ≥ 1.48.0 +The library uses c++11 and requires `Boost `_ ≥ 1.56.0 and `CMake `_ ≥ 3.1. It is a multi-platform library and compiles on Linux, Mac OSX and Visual Studio 2015. -- cgit v1.2.3 From eef89bb492169faeb57dfdc65222b6a0483cb7c8 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Wed, 21 Nov 2018 08:49:55 +0000 Subject: Code review : Use # error instead of static_assert(false, ...) for CGAL version detection Doc review : Better document CGAL types (FT, Weighted_point_3, Point_3, ...) Weighted alpha complex 3d example simplification git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@4009 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 187d7a08468c96192b3cb82c93a2df5b425290f9 --- .../benchmark/Alpha_complex_3d_benchmark.cpp | 4 +- .../Weighted_alpha_complex_3d_from_points.cpp | 12 +- src/Alpha_complex/include/gudhi/Alpha_complex_3d.h | 129 ++++++++++++++------- .../test/Alpha_complex_3d_unit_test.cpp | 2 +- src/common/doc/main_page.h | 7 +- 5 files changed, 94 insertions(+), 60 deletions(-) (limited to 'src/common') diff --git a/src/Alpha_complex/benchmark/Alpha_complex_3d_benchmark.cpp b/src/Alpha_complex/benchmark/Alpha_complex_3d_benchmark.cpp index 96a4baf3..005a712a 100644 --- a/src/Alpha_complex/benchmark/Alpha_complex_3d_benchmark.cpp +++ b/src/Alpha_complex/benchmark/Alpha_complex_3d_benchmark.cpp @@ -116,7 +116,7 @@ void benchmark_weighted_points_on_torus_3D(const std::string& msg) { std::vector points_on_torus = Gudhi::generate_points_on_torus_3D(nb_points, 1.0, 0.5); using Point = typename Weighted_alpha_complex_3d::Point_3; - using Weighted_point = typename Weighted_alpha_complex_3d::Triangulation_3::Weighted_point; + using Weighted_point = typename Weighted_alpha_complex_3d::Weighted_point_3; std::vector points; @@ -207,7 +207,7 @@ void benchmark_weighted_periodic_points(const std::string& msg) { << std::endl; using Point = typename Weighted_periodic_alpha_complex_3d::Point_3; - using Weighted_point = typename Weighted_periodic_alpha_complex_3d::Triangulation_3::Weighted_point; + using Weighted_point = typename Weighted_periodic_alpha_complex_3d::Weighted_point_3; std::vector points; for (double i = 0; i < nb_points; i++) { 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 3a69623f..734b4f37 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 @@ -11,21 +11,13 @@ using Weighted_alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; 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; +using Weighted_point = Weighted_alpha_complex_3d::Weighted_point_3; 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_weighted_points weighted_points; + std::vector 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.)); diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h index ca3c5fc3..c33b9cf8 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex_3d.h @@ -58,7 +58,7 @@ #if CGAL_VERSION_NR < 1041101000 // Make compilation fail - required for external projects - https://gitlab.inria.fr/GUDHI/gudhi-devel/issues/10 -static_assert(false, "Alpha_complex_3d is only available for CGAL >= 4.11"); +# error Alpha_complex_3d is only available for CGAL >= 4.11 #endif namespace Gudhi { @@ -153,7 +153,7 @@ template ::Kernel; - using Exact_tag = typename std::conditional<(Complexity == complexity::FAST), CGAL::Tag_false, CGAL::Tag_true>::type; + using Exact_alpha_comparison_tag = typename std::conditional<(Complexity == complexity::FAST), CGAL::Tag_false, CGAL::Tag_true>::type; using TdsVb = typename std::conditional, CGAL::Triangulation_ds_vertex_base_3<>>::type; @@ -196,7 +196,7 @@ class Alpha_complex_3d { using Tvb = typename std::conditional, CGAL::Triangulation_vertex_base_3>::type; - using Vb = CGAL::Alpha_shape_vertex_base_3; + using Vb = CGAL::Alpha_shape_vertex_base_3; using TdsCb = typename std::conditional, CGAL::Triangulation_ds_cell_base_3<>>::type; @@ -204,43 +204,84 @@ class Alpha_complex_3d { using Tcb = typename std::conditional, CGAL::Triangulation_cell_base_3>::type; - using Cb = CGAL::Alpha_shape_cell_base_3; + using Cb = CGAL::Alpha_shape_cell_base_3; using Tds = CGAL::Triangulation_data_structure_3; // The other way to do a conditional type. Here there 4 possibilities, cannot use std::conditional template - struct Triangulation {}; + struct Triangulation_3 {}; template - struct Triangulation { - using Triangulation_3 = CGAL::Delaunay_triangulation_3; + struct Triangulation_3 { + using Dt = CGAL::Delaunay_triangulation_3; + using Weighted_point_3 = void; }; template - struct Triangulation { - using Triangulation_3 = CGAL::Regular_triangulation_3; + struct Triangulation_3 { + using Dt = CGAL::Regular_triangulation_3; + using Weighted_point_3 = typename Dt::Weighted_point; }; template - struct Triangulation { - using Triangulation_3 = CGAL::Periodic_3_Delaunay_triangulation_3; + struct Triangulation_3 { + using Dt = CGAL::Periodic_3_Delaunay_triangulation_3; + using Weighted_point_3 = void; }; template - struct Triangulation { - using Triangulation_3 = CGAL::Periodic_3_regular_triangulation_3; + struct Triangulation_3 { + using Dt = CGAL::Periodic_3_regular_triangulation_3; + using Weighted_point_3 = typename Dt::Weighted_point; }; - public: - using Triangulation_3 = typename Triangulation::Triangulation_3; - - using Alpha_shape_3 = CGAL::Alpha_shape_3; + /** \brief Is either Delaunay_triangulation_3 (Weighted = false and Periodic = false), + * Regular_triangulation_3 (Weighted = true and Periodic = false), + * Periodic_3_Delaunay_triangulation_3 (Weighted = false and Periodic = true) + * or Periodic_3_regular_triangulation_3 (Weighted = true and Periodic = true). + * + * This type is required by `Gudhi::alpha_complex::Alpha_complex_3d::Alpha_shape_3`. + * */ + using Dt = typename Triangulation_3::Dt; +public: + /** \brief The CGAL 3D Alpha + * Shapes type. + * + * The `Gudhi::alpha_complex::Alpha_complex_3d` is a wrapper on top of this class to ease the standard, weighted + * and/or periodic build of the Alpha complex 3d.*/ + using Alpha_shape_3 = CGAL::Alpha_shape_3; + + /** \brief The alpha values type. + * Must be compatible with double. */ + using FT = typename Alpha_shape_3::FT; + + /** \brief Gives public access to the Point_3 type. Here is a Point_3 constructor example: +\code{.cpp} +using Alpha_complex_3d = Gudhi::alpha_complex::Alpha_complex_3d; + +// x0 = 1., y0 = -1.1, z0 = -1.. +Alpha_complex_3d::Point_3 p0(1., -1.1, -1.); +\endcode + * */ using Point_3 = typename Kernel::Point_3; - private: - using Alpha_value_type = typename Alpha_shape_3::FT; + /** \brief Gives public access to the Weighted_point_3 type. A Weighted point can be constructed as follows: +\code{.cpp} +using Weighted_alpha_complex_3d = + Gudhi::alpha_complex::Alpha_complex_3d; + +// x0 = 1., y0 = -1.1, z0 = -1., weight = 4. +Weighted_alpha_complex_3d::Weighted_point_3 wp0(Weighted_alpha_complex_3d::Point_3(1., -1.1, -1.), 4.); +\endcode + * + * Note: This type is defined to void if Alpha complex is not weighted. + * + * */ + using Weighted_point_3 = typename Triangulation_3::Weighted_point_3; + +private: using Dispatch = - CGAL::Dispatch_output_iterator, + CGAL::Dispatch_output_iterator, CGAL::cpp11::tuple>, - std::back_insert_iterator>>>; + std::back_insert_iterator>>>; using Cell_handle = typename Alpha_shape_3::Cell_handle; using Facet = typename Alpha_shape_3::Facet; @@ -252,12 +293,12 @@ class Alpha_complex_3d { /** \brief Alpha_complex constructor from a list of points. * * @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`. + * `Alpha_complex_3d::Weighted_point_3`. * * @pre Available if Alpha_complex_3d is not Periodic. * * 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`. + * `Alpha_complex_3d::Point_3` or a `Alpha_complex_3d::Weighted_point_3`. */ template Alpha_complex_3d(const InputPointRange& points) { @@ -271,15 +312,15 @@ class Alpha_complex_3d { * * @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 `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] 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 double. * * @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 `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 `Alpha_complex_3d::Alpha_shape_3::FT`. + * std::end return an input iterator on a double. */ template Alpha_complex_3d(const InputPointRange& points, WeightRange weights) { @@ -288,7 +329,6 @@ class Alpha_complex_3d { GUDHI_CHECK((weights.size() == points.size()), std::invalid_argument("Points number in range different from weights range number")); - using Weighted_point_3 = typename Triangulation_3::Weighted_point; std::vector weighted_points_3; std::size_t index = 0; @@ -307,7 +347,7 @@ class Alpha_complex_3d { * @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 `Alpha_complex_3d::Point_3` or - * `Alpha_complex_3d::Triangulation_3::Weighted_point`. + * `Alpha_complex_3d::Weighted_point_3`. * @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. @@ -318,14 +358,14 @@ class Alpha_complex_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 - * `Alpha_complex_3d::Point_3` or a `Alpha_complex_3d::Triangulation_3::Weighted_point`. + * `Alpha_complex_3d::Point_3` or a `Alpha_complex_3d::Weighted_point_3`. * * @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) { + Alpha_complex_3d(const InputPointRange& points, FT x_min, FT y_min, + FT z_min, FT x_max, FT y_max, FT z_max) { 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. GUDHI_CHECK( @@ -333,7 +373,7 @@ class Alpha_complex_3d { std::invalid_argument("The size of the cuboid in every directions is not the same.")); // Define the periodic cube - Triangulation_3 pdt(typename Kernel::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max)); + Dt pdt(typename Kernel::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max)); // Heuristic for inserting large point sets (if pts is reasonably large) pdt.insert(std::begin(points), std::end(points), true); // As pdt won't be modified anymore switch to 1-sheeted cover if possible @@ -354,8 +394,8 @@ class Alpha_complex_3d { * @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 `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] 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 double. * @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. @@ -368,12 +408,12 @@ class Alpha_complex_3d { * The type InputPointRange must be a range for which std::begin and * 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 `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`. + * std::end return an input iterator on a double. + * The type of x_min, y_min, z_min, x_max, y_max and z_max must be a double. */ template - Alpha_complex_3d(const InputPointRange& points, WeightRange weights, 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) { + Alpha_complex_3d(const InputPointRange& points, WeightRange weights, FT x_min, FT y_min, + FT z_min, FT x_max, FT y_max, FT z_max) { static_assert(Weighted, "This constructor is not available for non-weighted versions of Alpha_complex_3d"); static_assert(Periodic, "This constructor is not available for non-periodic versions of Alpha_complex_3d"); GUDHI_CHECK((weights.size() == points.size()), @@ -383,7 +423,6 @@ class Alpha_complex_3d { (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.")); - using Weighted_point_3 = typename Triangulation_3::Weighted_point; std::vector weighted_points_3; std::size_t index = 0; @@ -391,7 +430,7 @@ class Alpha_complex_3d { #ifdef GUDHI_DEBUG // Defined in GUDHI_DEBUG to avoid unused variable warning for GUDHI_CHECK - Alpha_value_type maximal_possible_weight = 0.015625 * (x_max - x_min) * (x_max - x_min); + FT maximal_possible_weight = 0.015625 * (x_max - x_min) * (x_max - x_min); #endif while ((index < weights.size()) && (index < points.size())) { @@ -404,7 +443,7 @@ class Alpha_complex_3d { } // Define the periodic cube - Triangulation_3 pdt(typename Kernel::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max)); + Dt pdt(typename Kernel::Iso_cuboid_3(x_min, y_min, z_min, x_max, y_max, z_max)); // Heuristic for inserting large point sets (if pts is reasonably large) pdt.insert(std::begin(weighted_points_3), std::end(weighted_points_3), true); // As pdt won't be modified anymore switch to 1-sheeted cover if possible @@ -453,9 +492,9 @@ class Alpha_complex_3d { std::size_t count_cells = 0; #endif // DEBUG_TRACES std::vector objects; - std::vector alpha_values; + std::vector alpha_values; - Dispatch dispatcher = CGAL::dispatch_output(std::back_inserter(objects), + Dispatch dispatcher = CGAL::dispatch_output(std::back_inserter(objects), std::back_inserter(alpha_values)); alpha_shape_3_ptr_->filtration_with_alpha_values(dispatcher); @@ -464,7 +503,7 @@ class Alpha_complex_3d { #endif // DEBUG_TRACES Alpha_shape_simplex_tree_map map_cgal_simplex_tree; - using Alpha_value_iterator = typename std::vector::const_iterator; + using Alpha_value_iterator = typename std::vector::const_iterator; Alpha_value_iterator alpha_value_iterator = alpha_values.begin(); for (auto object_iterator : objects) { Vertex_list vertex_list; 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 b818fb2e..e4a45791 100644 --- a/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp +++ b/src/Alpha_complex/test/Alpha_complex_3d_unit_test.cpp @@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(Alpha_complex_weighted, Weighted_alpha_complex_3d, alpha_complex_p_a_w.create_complex(stree); std::cout << "Weighted alpha complex 3d from weighted points" << std::endl; - using Weighted_point_3 = typename Weighted_alpha_complex_3d::Triangulation_3::Weighted_point; + using Weighted_point_3 = typename Weighted_alpha_complex_3d::Weighted_point_3; std::vector weighted_points; diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 35b84d2e..b33a95a1 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -29,7 +29,9 @@ Author: Vincent Rouvreau
Introduced in: GUDHI 1.3.0
Copyright: GPL v3
- Requires: \ref cgal ≥ 4.11.0 and \ref eigen3 + Requires: \ref eigen3 and
+ \ref cgal ≥ 4.7.0 for Alpha_complex
+ \ref cgal ≥ 4.11.0 for Alpha_complex_3d Alpha_complex is a simplicial complex constructed from the finite cells of a Delaunay Triangulation.
@@ -38,7 +40,8 @@ values of the codimension 1 cofaces that make it not Gabriel otherwise. All simplices that have a filtration value strictly greater than a given alpha squared value are not inserted into the complex.
- User manual: \ref alpha_complex - Reference manual: Gudhi::alpha_complex::Alpha_complex + User manual: \ref alpha_complex - Reference manual: Gudhi::alpha_complex::Alpha_complex and + Gudhi::alpha_complex::Alpha_complex_3d -- cgit v1.2.3 From 13b6be9e73f4ac5105f8344dcf37a7007e9ef904 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 17 Jan 2019 15:26:17 +0000 Subject: adjacency lists can be directed, undirected or bidirectional for Simplex tree insert_graph method Use of directed adjacency lists to fasten computation and use less memory git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/adjacency_list_direction_improvement@4061 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 839fabc15398ce590d09806bd783cd656029f3c1 --- src/Rips_complex/include/gudhi/Rips_complex.h | 2 +- .../include/gudhi/Sparse_rips_complex.h | 2 +- .../example/cech_complex_cgal_mini_sphere_3d.cpp | 2 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 19 +++++---- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 47 +++++++++++++++------- .../include/gudhi/graph_simplicial_complex.h | 2 +- 6 files changed, 47 insertions(+), 27 deletions(-) (limited to 'src/common') diff --git a/src/Rips_complex/include/gudhi/Rips_complex.h b/src/Rips_complex/include/gudhi/Rips_complex.h index f0fe57f4..e902e52c 100644 --- a/src/Rips_complex/include/gudhi/Rips_complex.h +++ b/src/Rips_complex/include/gudhi/Rips_complex.h @@ -59,7 +59,7 @@ class Rips_complex { /** * \brief Type of the one skeleton graph stored inside the Rips complex structure. */ - typedef typename boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS + typedef typename boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS , boost::property < vertex_filtration_t, Filtration_value > , boost::property < edge_filtration_t, Filtration_value >> OneSkeletonGraph; diff --git a/src/Rips_complex/include/gudhi/Sparse_rips_complex.h b/src/Rips_complex/include/gudhi/Sparse_rips_complex.h index 4dcc08ed..00da148f 100644 --- a/src/Rips_complex/include/gudhi/Sparse_rips_complex.h +++ b/src/Rips_complex/include/gudhi/Sparse_rips_complex.h @@ -55,7 +55,7 @@ template class Sparse_rips_complex { private: // TODO(MG): use a different graph where we know we can safely insert in parallel. - typedef typename boost::adjacency_list, boost::property> Graph; diff --git a/src/Simplex_tree/example/cech_complex_cgal_mini_sphere_3d.cpp b/src/Simplex_tree/example/cech_complex_cgal_mini_sphere_3d.cpp index 34092ef6..6bab8adb 100644 --- a/src/Simplex_tree/example/cech_complex_cgal_mini_sphere_3d.cpp +++ b/src/Simplex_tree/example/cech_complex_cgal_mini_sphere_3d.cpp @@ -50,7 +50,7 @@ using Vertex_handle = Simplex_tree::Vertex_handle; using Simplex_handle = Simplex_tree::Simplex_handle; using Filtration_value = Simplex_tree::Filtration_value; using Siblings = Simplex_tree::Siblings; -using Graph_t = boost::adjacency_list, boost::property >; using Edge_t = std::pair; diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 78697ea2..4b18651c 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1049,7 +1049,8 @@ class Simplex_tree { * boost::graph_traits::vertex_descriptor * must be Vertex_handle. * boost::graph_traits::directed_category - * must be undirected_tag. + * can be directed_tag (the fastest, the least RAM use), undirected_tag or even + * bidirected_tag. * * If an edge appears with multiplicity, the function will arbitrarily pick * one representative to read the filtration value. */ @@ -1077,12 +1078,14 @@ class Simplex_tree { root_.members_.end(), *v_it, Node(&root_, boost::get(vertex_filtration_t(), skel_graph, *v_it))); } - typename boost::graph_traits::edge_iterator e_it, - e_it_end; - for (std::tie(e_it, e_it_end) = boost::edges(skel_graph); e_it != e_it_end; - ++e_it) { - auto u = source(*e_it, skel_graph); - auto v = target(*e_it, skel_graph); + std::pair::edge_iterator, + typename boost::graph_traits::edge_iterator> boost_edges = boost::edges(skel_graph); + // boost_edges.first is the equivalent to boost_edges.begin() + // boost_edges.second is the equivalent to boost_edges.end() + for (; boost_edges.first != boost_edges.second; boost_edges.first++) { + auto edge = *(boost_edges.first); + auto u = source(edge, skel_graph); + auto v = target(edge, skel_graph); if (u == v) throw "Self-loops are not simplicial"; // We cannot skip edges with the wrong orientation and expect them to // come a second time with the right orientation, that does not always @@ -1098,7 +1101,7 @@ class Simplex_tree { } sh->second.children()->members().emplace(v, - Node(sh->second.children(), boost::get(edge_filtration_t(), skel_graph, *e_it))); + Node(sh->second.children(), boost::get(edge_filtration_t(), skel_graph, edge))); } } diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index f63ea080..0ae073ca 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -864,34 +864,51 @@ BOOST_AUTO_TEST_CASE(make_filtration_non_decreasing) { } -BOOST_AUTO_TEST_CASE(insert_graph) { + +typedef boost::mpl::list, + boost::property>, + boost::adjacency_list, + boost::property>, + boost::adjacency_list, + boost::property>> list_of_graph_variants; + +BOOST_AUTO_TEST_CASE_TEMPLATE(simplex_tree_insert_graph, Graph, list_of_graph_variants) { std::cout << "********************************************************************" << std::endl; std::cout << "INSERT GRAPH" << std::endl; - typedef typename boost::adjacency_list, - boost::property> Graph; + Graph g(3); // filtration value 0 everywhere put(Gudhi::vertex_filtration_t(), g, 0, 0); put(Gudhi::vertex_filtration_t(), g, 1, 0); put(Gudhi::vertex_filtration_t(), g, 2, 0); // vertices don't always occur in sorted order - add_edge(0, 1, 0, g); - add_edge(2, 1, 0, g); - add_edge(2, 0, 0, g); + add_edge(0, 1, 1.1, g); + add_edge(2, 0, 2.2, g); + add_edge(2, 1, 3.3, g); - typedef Simplex_tree<> typeST; - typeST st1; + Simplex_tree<> st1; st1.insert_graph(g); BOOST_CHECK(st1.num_simplices() == 6); // edges can have multiplicity in the graph unless we replace the first vecS with (hash_)setS - add_edge(1, 0, 0, g); - add_edge(1, 2, 0, g); - add_edge(0, 2, 0, g); - add_edge(0, 2, 0, g); - typeST st2; + add_edge(1, 0, 1.1, g); + add_edge(1, 2, 3.3, g); + add_edge(0, 2, 2.2, g); + add_edge(0, 1, 1.1, g); + add_edge(2, 1, 3.3, g); + add_edge(2, 0, 2.2, g); + Simplex_tree<> st2; st2.insert_graph(g); BOOST_CHECK(st2.num_simplices() == 6); + + std::cout << "st1 is" << std::endl; + std::cout << st1 << std::endl; + + std::cout << "st2 is" << std::endl; + std::cout << st2 << std::endl; + + BOOST_CHECK(st1 == st2); } diff --git a/src/common/include/gudhi/graph_simplicial_complex.h b/src/common/include/gudhi/graph_simplicial_complex.h index 49fe56cc..0d81ca71 100644 --- a/src/common/include/gudhi/graph_simplicial_complex.h +++ b/src/common/include/gudhi/graph_simplicial_complex.h @@ -49,7 +49,7 @@ struct vertex_filtration_t { * */ template -using Proximity_graph = typename boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS +using Proximity_graph = typename boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS , boost::property < vertex_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value > , boost::property < edge_filtration_t, typename SimplicialComplexForProximityGraph::Filtration_value >>; -- cgit v1.2.3 From e1b61dcdae35e0f968846fdd919d43b84f29fe4e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 17 Jan 2019 16:19:05 +0000 Subject: Fix cpplint git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cubical_complex_small_fix@4063 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7186509b0d722fc7a4264eeaf504cef1c1be3a2a --- src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h | 9 +++++---- src/common/doc/file_formats.h | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/common') diff --git a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h index 0c70c6e0..9e14455e 100644 --- a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h +++ b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h @@ -91,10 +91,11 @@ namespace cubical_complex { * filtration to all cubes. There are a number of constructors that can be used to construct cubical complex by users * who want to use the code directly. They can be found in the \a Bitmap_cubical_complex class. * Currently one input from a text file is used. It uses a format nspired from the Perseus software - * (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda. Note however an important difference: while Perseus assume - * the filtration of all maximal cubes to be non-negative, over here we do not enforce this and we allow any filtration values. - * As a consequence one cannot use -1's to indicate missing cubes. If you have missing cubes in your complex, please set - * their filtration to +Inf. The file format is described in details in here: \ref FileFormatsPerseus. + * (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda. Note however an important difference: while Perseus + * assume the filtration of all maximal cubes to be non-negative, over here we do not enforce this and we allow any + * filtration values. + * As a consequence one cannot use -1's to indicate missing cubes. If you have missing cubes in your complex, please + * set their filtration to +Inf. The file format is described in details in here: \ref FileFormatsPerseus. * * \section PeriodicBoundaryConditions Periodic boundary conditions * Often one would like to impose periodic boundary conditions to the cubical complex. Let \f$ I_1\times ... \times diff --git a/src/common/doc/file_formats.h b/src/common/doc/file_formats.h index 3a236087..d38d90e0 100644 --- a/src/common/doc/file_formats.h +++ b/src/common/doc/file_formats.h @@ -119,8 +119,9 @@ namespace Gudhi { Other sample files can be found in the `data/bitmap` folder. - Please note that unlike in Perseus format the filtration on the maximal cubes can be any double precision number. - Consequently one cannot mark the cubes that are not present with -1's. To do that please set their filtration value to +Inf. + Please note that unlike in Perseus format the filtration on the maximal cubes can be any double precision number. + Consequently one cannot mark the cubes that are not present with -1's. To do that please set their filtration value to + +Inf. */ } // namespace Gudhi -- cgit v1.2.3 From 453fc857c70a5168eed639545faa903f48e84c9c Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 18 Jan 2019 14:50:07 +0000 Subject: Add boost graph adjacency benchmark git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/adjacency_list_direction_improvement@4068 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6970242e9449e0cab0c03819cd4373335a50c697 --- src/common/benchmark/CMakeLists.txt | 3 + .../Graph_simplicial_complex_benchmark.cpp | 150 +++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 src/common/benchmark/CMakeLists.txt create mode 100644 src/common/benchmark/Graph_simplicial_complex_benchmark.cpp (limited to 'src/common') diff --git a/src/common/benchmark/CMakeLists.txt b/src/common/benchmark/CMakeLists.txt new file mode 100644 index 00000000..a3787d6e --- /dev/null +++ b/src/common/benchmark/CMakeLists.txt @@ -0,0 +1,3 @@ +project(common_benchmark) + +add_executable(Graph_simplicial_complex_benchmark Graph_simplicial_complex_benchmark.cpp) diff --git a/src/common/benchmark/Graph_simplicial_complex_benchmark.cpp b/src/common/benchmark/Graph_simplicial_complex_benchmark.cpp new file mode 100644 index 00000000..825d6cb5 --- /dev/null +++ b/src/common/benchmark/Graph_simplicial_complex_benchmark.cpp @@ -0,0 +1,150 @@ +/* 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 . + */ + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include // for numeric limits +#include +#include + + +std::ofstream results_csv("results.csv"); + +template< typename Adjacency_list, typename ForwardPointRange, typename Distance > +Adjacency_list proximity_graph_computation(const ForwardPointRange& points, double threshold, Distance distance) { + std::vector> edges; + std::vector< double > edges_fil; + std::map< int, double > vertices; + + int idx_u, idx_v; + double fil; + idx_u = 0; + for (auto it_u = points.begin(); it_u != points.end(); ++it_u) { + idx_v = idx_u + 1; + for (auto it_v = it_u + 1; it_v != points.end(); ++it_v, ++idx_v) { + fil = distance(*it_u, *it_v); + if (fil <= threshold) { + edges.emplace_back(idx_u, idx_v); + edges_fil.push_back(fil); + } + } + ++idx_u; + } + + // Points are labeled from 0 to idx_u-1 + Adjacency_list skel_graph(edges.begin(), edges.end(), edges_fil.begin(), idx_u); + + auto vertex_prop = boost::get(Gudhi::vertex_filtration_t(), skel_graph); + + typename boost::graph_traits::vertex_iterator vi, vi_end; + for (std::tie(vi, vi_end) = boost::vertices(skel_graph); + vi != vi_end; ++vi) { + boost::put(vertex_prop, *vi, 0.); + } + + return skel_graph; +} + +template +void benchmark_proximity_graph(const std::string& msg, const std::string& off_file_name) { + Gudhi::Points_off_reader> off_reader(off_file_name); + assert(off_reader.is_valid()); + + std::cout << "+ " << msg << std::endl; + + results_csv << "\"nb_points\";" + << "\"nb_simplices\";" + << "\"compute proximity graph(sec.)\";" + << "\"complex_creation_time(sec.)\";" + << "\"" << msg << "\";" << std::endl; + + Gudhi::Clock pg_compute_proximity_graph(" benchmark_proximity_graph - compute proximity graph"); + pg_compute_proximity_graph.begin(); + // benchmark begin + Adjacency_list proximity_graph = proximity_graph_computation(off_reader.get_point_cloud(), + std::numeric_limits::infinity(), + Gudhi::Euclidean_distance()); + // benchmark end + pg_compute_proximity_graph.end(); + std::cout << pg_compute_proximity_graph; + + Gudhi::Simplex_tree<> complex; + Gudhi::Clock st_create_clock(" benchmark_proximity_graph - complex creation"); + st_create_clock.begin(); + // benchmark begin + complex.insert_graph(proximity_graph); + // benchmark end + st_create_clock.end(); + std::cout << st_create_clock; + + results_csv << off_reader.get_point_cloud().size() << ";" << complex.num_simplices() << ";" + << pg_compute_proximity_graph.num_seconds() << ";" + << st_create_clock.num_seconds() << ";" << std::endl; + + std::cout << " benchmark_proximity_graph - nb simplices = " << complex.num_simplices() << std::endl; +} + +int main(int argc, char * const argv[]) { + std::string off_file_name(argv[1]); + + // The fastest, the less memory used + using vecSdirectedS = boost::adjacency_list, + boost::property>; + benchmark_proximity_graph("vecSdirectedS", off_file_name); + + using vecSundirectedS = boost::adjacency_list, + boost::property>; + benchmark_proximity_graph("vecSundirectedS", off_file_name); + + using vecSbidirectionalS = boost::adjacency_list, + boost::property>; + benchmark_proximity_graph("vecSbidirectionalS", off_file_name); + + using setSdirectedS = boost::adjacency_list, + boost::property>; + benchmark_proximity_graph("setSdirectedS", off_file_name); + + using setSundirectedS = boost::adjacency_list, + boost::property>; + benchmark_proximity_graph("setSundirectedS", off_file_name); + + using setSbidirectionalS = boost::adjacency_list, + boost::property>; + benchmark_proximity_graph("setSbidirectionalS", off_file_name); + + return 0; +} -- cgit v1.2.3 From 32bde4c643a8af5195d4e30450f29c3ed422af8f Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 24 Jan 2019 13:45:02 +0000 Subject: Fix persistence_from_file example when the file is not conform. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@4075 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9a1b15f6d0b02084babd70ce8001cd90b6c35c85 --- src/Persistent_cohomology/example/persistence_from_file.cpp | 1 - src/common/include/gudhi/reader_utils.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/Persistent_cohomology/example/persistence_from_file.cpp b/src/Persistent_cohomology/example/persistence_from_file.cpp index 53456919..0a05c193 100644 --- a/src/Persistent_cohomology/example/persistence_from_file.cpp +++ b/src/Persistent_cohomology/example/persistence_from_file.cpp @@ -33,7 +33,6 @@ using namespace Gudhi; using namespace Gudhi::persistent_cohomology; -typedef int Vertex_handle; typedef double Filtration_value; void program_options(int argc, char * argv[] diff --git a/src/common/include/gudhi/reader_utils.h b/src/common/include/gudhi/reader_utils.h index 26eeb76d..0ee7649d 100644 --- a/src/common/include/gudhi/reader_utils.h +++ b/src/common/include/gudhi/reader_utils.h @@ -172,10 +172,10 @@ bool read_simplex(std::istream& in_, std::vector& simplex, Filtra if (!(in_ >> dim)) return false; Vertex_handle v; for (int i = 0; i < dim + 1; ++i) { - in_ >> v; + if (!(in_ >> v)) return false; simplex.push_back(v); } - in_ >> fil; + if (!(in_ >> fil)) return false; in_.ignore((std::numeric_limits::max)(), '\n'); // ignore until the carriage return return true; } -- cgit v1.2.3 From f29a6e9a03dca95dc0a070b604fb11e18897a6f6 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Tue, 12 Feb 2019 14:08:56 +0000 Subject: Fix doc for C++ and Python. Fix some warnings on Nerve GIC sphinx doc generation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cubical_complex_small_fix@4101 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 57eacb8c4108be212e61796c65e3b45bb9c13644 --- src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h | 13 +++++++------ src/common/doc/file_formats.h | 8 ++++---- src/cython/doc/cubical_complex_user.rst | 10 ++++++++-- src/cython/doc/fileformats.rst | 10 +++++++++- src/cython/doc/nerve_gic_complex_ref.rst | 4 ++++ src/cython/doc/nerve_gic_complex_user.rst | 4 ++++ 6 files changed, 36 insertions(+), 13 deletions(-) (limited to 'src/common') diff --git a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h index e1e5885e..5fa02a5e 100644 --- a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h +++ b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h @@ -87,15 +87,16 @@ namespace cubical_complex { * * \section inputformat Input Format * - * In the current implantation, filtration is given at the maximal cubes, and it is then extended by the lower star + * In the current implementation, filtration is given at the maximal cubes, and it is then extended by the lower star * filtration to all cubes. There are a number of constructors that can be used to construct cubical complex by users * who want to use the code directly. They can be found in the \a Bitmap_cubical_complex class. * Currently one input from a text file is used. It uses a format inspired from the Perseus software - * (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda. Note however an important difference: while Perseus - * assume the filtration of all maximal cubes to be non-negative, over here we do not enforce this and we allow any - * filtration values. - * As a consequence one cannot use -1's to indicate missing cubes. If you have missing cubes in your complex, please - * set their filtration to +Inf. The file format is described in details in here: \ref FileFormatsPerseus. + * (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda. + * \note While Perseus assume the filtration of all maximal cubes to be non-negative, over here we do not enforce this + * and we allow any filtration values. As a consequence one cannot use `-1`'s to indicate missing cubes. If you have + * missing cubes in your complex, please set their filtration to \f$+\infty\f$ (aka. `inf` in the file). + * + * The file format is described in details in \ref FileFormatsPerseus file format section. * * \section PeriodicBoundaryConditions Periodic boundary conditions * Often one would like to impose periodic boundary conditions to the cubical complex. Let \f$ I_1\times ... \times diff --git a/src/common/doc/file_formats.h b/src/common/doc/file_formats.h index d38d90e0..23214e25 100644 --- a/src/common/doc/file_formats.h +++ b/src/common/doc/file_formats.h @@ -72,7 +72,7 @@ namespace Gudhi { \section FileFormatsPerseus Perseus - This file format is the format used by the Perseus software + This file format is a format inspired from the Perseus software (http://www.sas.upenn.edu/~vnanda/perseus/) by Vidit Nanda. The first line contains a number d begin the dimension of the bitmap (2 in the example below). Next d lines are the numbers of top dimensional cubes in each dimensions (3 and 3 @@ -119,9 +119,9 @@ namespace Gudhi { Other sample files can be found in the `data/bitmap` folder. - Please note that unlike in Perseus format the filtration on the maximal cubes can be any double precision number. - Consequently one cannot mark the cubes that are not present with -1's. To do that please set their filtration value to - +Inf. + \note Unlike in Perseus format the filtration on the maximal cubes can be any double precision number. + Consequently one cannot mark the cubes that are not present with `-1`'s. To do that please set their filtration value + to \f$+\infty\f$ (aka. `inf` in the file). */ } // namespace Gudhi diff --git a/src/cython/doc/cubical_complex_user.rst b/src/cython/doc/cubical_complex_user.rst index 320bd79b..19120360 100644 --- a/src/cython/doc/cubical_complex_user.rst +++ b/src/cython/doc/cubical_complex_user.rst @@ -83,9 +83,15 @@ Input Format. In the current implantation, filtration is given at the maximal cubes, and it is then extended by the lower star filtration to all cubes. There are a number of constructors that can be used to construct cubical complex by users who want to use the code directly. They can be found in the :doc:`cubical_complex_ref`. -Currently one input from a text file is used. It uses a format used already in +Currently one input from a text file is used. It uses a format inspired from the Perseus software `Perseus software `_ by Vidit Nanda. -The file format is described here: :doc:`Perseus `. + +.. note:: + While Perseus assume the filtration of all maximal cubes to be non-negative, over here we do not enforce this and + we allow any filtration values. As a consequence one cannot use ``-1``'s to indicate missing cubes. If you have + missing cubes in your complex, please set their filtration to :math:`+\infty` (aka. ``inf`` in the file). + +The file format is described in details in :ref:`Perseus file format` file format section. .. testcode:: diff --git a/src/cython/doc/fileformats.rst b/src/cython/doc/fileformats.rst index ff20f26e..e205cc8b 100644 --- a/src/cython/doc/fileformats.rst +++ b/src/cython/doc/fileformats.rst @@ -51,10 +51,12 @@ Here is a simple sample file in the 3D case:: 1. 1. 1. +.. _Perseus file format: + Perseus ******* -This file format is the format used by the +This file format is a format inspired from the `Perseus software `_ by Vidit Nanda. The first line contains a number d begin the dimension of the bitmap (2 in the example below). Next d lines are the numbers of top dimensional cubes in each @@ -88,3 +90,9 @@ Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y. Other sample files can be found in the `data/bitmap` folder. + +.. note:: + Unlike in Perseus format the filtration on the maximal cubes can be any + double precision number. Consequently one cannot mark the cubes that are + not present with ``-1``'s. To do that please set their filtration value to + :math:`+\infty` (aka. ``inf`` in the file). \ No newline at end of file diff --git a/src/cython/doc/nerve_gic_complex_ref.rst b/src/cython/doc/nerve_gic_complex_ref.rst index e24e01fc..abde2e8c 100644 --- a/src/cython/doc/nerve_gic_complex_ref.rst +++ b/src/cython/doc/nerve_gic_complex_ref.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + ================================ Cover complexes reference manual ================================ diff --git a/src/cython/doc/nerve_gic_complex_user.rst b/src/cython/doc/nerve_gic_complex_user.rst index d774827e..44f30e1a 100644 --- a/src/cython/doc/nerve_gic_complex_user.rst +++ b/src/cython/doc/nerve_gic_complex_user.rst @@ -1,3 +1,7 @@ +:orphan: + +.. To get rid of WARNING: document isn't included in any toctree + Cover complexes user manual =========================== Definition -- cgit v1.2.3