From 3d5bf7ed64b155894787cb356aead439977643e4 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 22 Sep 2016 14:38:46 +0000 Subject: New template function create_complex for Alpha_complex to create the simplicial complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_create_complex@1540 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 24e53dc58d158166b976dd09760ad0e2acaf8e36 --- src/Alpha_complex/doc/Intro_alpha_complex.h | 36 ++-- src/Alpha_complex/doc/alpha_complex_doc.ipe | 315 +--------------------------- src/Alpha_complex/doc/alpha_complex_doc.png | Bin 25554 -> 18720 bytes 3 files changed, 29 insertions(+), 322 deletions(-) (limited to 'src/Alpha_complex/doc') diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h index f3126169..4ca3271b 100644 --- a/src/Alpha_complex/doc/Intro_alpha_complex.h +++ b/src/Alpha_complex/doc/Intro_alpha_complex.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2015 INRIA Saclay (France) + * Copyright (C) 2015 INRIA * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,7 +39,8 @@ namespace alpha_complex { * Alpha_complex is a simplicial complex * constructed from the finite cells of a Delaunay Triangulation. * - * The filtration value of each simplex is computed as the square of the circumradius of the simplex if the circumsphere is empty (the simplex is then said to be Gabriel), and as the minimum of the filtration + * The filtration value of each simplex is computed as the square of the circumradius of the simplex if the + * circumsphere is empty (the simplex is then said to be Gabriel), and as the minimum of the filtration * 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 @@ -47,23 +48,24 @@ namespace alpha_complex { * * \image html "alpha_complex_representation.png" "Alpha-complex representation" * - * Alpha_complex is constructing a `Simplex_tree` using Delaunay Triangulation * \cite cgal:hdj-t-15b from CGAL (the Computational Geometry - * Algorithms Library \cite cgal:eb-15b). + * Algorithms Library \cite cgal:eb-15b) and is able to create a `Simplicial_complex_for_alpha`. * * The complex is a template class requiring an Epick_d dD Geometry Kernel * \cite cgal:s-gkd-15b from CGAL as template parameter. * - * \remark When Alpha_complex is constructed with an infinite value of alpha, the complex is a Delaunay complex. + * \remark When the simplicial complex is constructed with an infinite value of alpha, the complex is a Delaunay + * complex. * * \section pointsexample Example from points * - * This example builds the Delaunay triangulation from the given points in a 2D static kernel, and initializes the - * alpha complex with it. + * This example builds the Delaunay triangulation from the given points in a 2D static kernel, and creates a + * `Simplex_tree` with it. * - * Then, it is asked to display information about the alpha complex. + * Then, it is asked to display information about the simplicial complex. * * \include Alpha_complex/Alpha_complex_from_points.cpp * @@ -76,13 +78,15 @@ namespace alpha_complex { * * \include Alpha_complex/alphaoffreader_for_doc_60.txt * - * \section algorithm Algorithm + * \section createcomplexalgorithm Create complex algorithm * * \subsection datastructure Data structure * - * In order to build the alpha complex, first, a Simplex tree is built from the cells of a Delaunay Triangulation. - * (The filtration value is set to NaN, which stands for unknown value): - * \image html "alpha_complex_doc.png" "Simplex tree structure construction example" + * In order to create the simplicial complex, first, it is built from the cells of the Delaunay Triangulation. + * The filtration values are set to NaN, which stands for unknown value. + * + * In example, : + * \image html "alpha_complex_doc.png" "Simplicial complex structure construction example" * * \subsection filtrationcomputation Filtration value computation algorithm * @@ -129,12 +133,14 @@ namespace alpha_complex { * * \subsubsection nondecreasing Non decreasing filtration values * - * As the squared radii computed by CGAL are an approximation, it might happen that these alpha squared values do not quite define a proper filtration (i.e. non-decreasing with respect to inclusion). - * We fix that up by calling `Simplex_tree::make_filtration_non_decreasing()`. + * As the squared radii computed by CGAL are an approximation, it might happen that these alpha squared values do not + * quite define a proper filtration (i.e. non-decreasing with respect to inclusion). + * We fix that up by calling `Simplicial_complex_for_alpha::make_filtration_non_decreasing()`. * * \subsubsection pruneabove Prune above given filtration value * - * The simplex tree is pruned from the given maximum alpha squared value (cf. `Simplex_tree::prune_above_filtration()`). + * The simplex tree is pruned from the given maximum alpha squared value (cf. + * `Simplicial_complex_for_alpha::prune_above_filtration()`). * In the following example, the value is given by the user as argument of the program. * * diff --git a/src/Alpha_complex/doc/alpha_complex_doc.ipe b/src/Alpha_complex/doc/alpha_complex_doc.ipe index baf0d26a..71e5ce6c 100644 --- a/src/Alpha_complex/doc/alpha_complex_doc.ipe +++ b/src/Alpha_complex/doc/alpha_complex_doc.ipe @@ -1,7 +1,7 @@ - + @@ -278,35 +278,7 @@ h 320 580 l 280 660 l - -4 0 0 4 320 704 e - - -322.919 706.788 m -317.189 701.058 l -317.189 701.203 l - - -317.551 706.934 m -322.629 701.058 l - - -240 620 m -220 600 l - - -240 620 m -220 640 l - -Simplex tree structure - -280 630 m -170 630 l - - -280 610 m -170 610 l - +Simplicial complex data structure : @@ -314,282 +286,11 @@ h -2 - -300 688 m -300 676 l -312 676 l -312 688 l -h - -2 - -300 688 m -300 676 l -312 676 l -312 688 l -h - - -300 688 m -300 676 l -312 676 l -312 688 l -h - -4 -1 - -300 688 m -300 676 l -312 676 l -312 688 l -h - - -300 688 m -300 676 l -312 676 l -312 688 l -h - -4 -3 - -300 688 m -300 676 l -312 676 l -312 688 l -h - -2 - -300 688 m -300 676 l -312 676 l -312 688 l -h - - -300 688 m -300 676 l -312 676 l -312 688 l -h - -3 -6 - -300 688 m -300 676 l -312 676 l -312 688 l -h - -4 - -300 688 m -300 676 l -312 676 l -312 688 l -h - - -300 688 m -300 676 l -312 676 l -312 688 l -h - -6 -6 - -300 688 m -300 676 l -312 676 l -312 688 l -h - -5 - -300 688 m -300 676 l -312 676 l -312 688 l -h - - -300 688 m -300 676 l -312 676 l -312 688 l -h - -6 - -300 688 m -300 676 l -312 676 l -312 688 l -h - -6 - -292 716 m -292 728 l -316 728 l -316 716 l -h - - -316 716 m -316 728 l -340 728 l -340 716 l -h - - -340 716 m -340 728 l -364 728 l -364 716 l -h - - -364 716 m -364 728 l -388 728 l -388 716 l -h - - -388 716 m -388 728 l -412 728 l -412 716 l -h - - -412 716 m -412 728 l -436 728 l -436 716 l -h - - -436 716 m -436 728 l -460 728 l -460 716 l -h - -0 -1 -2 -3 -4 -5 -6 - -436 708 m -436 716 l - - -364 708 m -364 716 l - - -364 688 m -364 696 l - - -320 688 m -320 696 l - - -296 708 m -308 716 l -308 716 l - - -264 688 m -268 696 l - - -292 688 m -292 696 l - - -388 736 m -388 728 l - - -372 612 m -376 620 l - - -448 612 m -448 620 l - -3 - -300 688 m -300 676 l -312 676 l -312 688 l -h - - -300 688 m -300 676 l -312 676 l -312 688 l -h - -6 - -364 688 m -364 696 l - - -300 688 m -300 676 l -312 676 l -312 688 l -h - -6 - -300 688 m -300 676 l -312 676 l -312 688 l -h - -6 - -436 708 m -436 716 l - - -300 688 m -300 676 l -312 676 l -312 688 l -h - -6 - -300 688 m -300 676 l -312 676 l -312 688 l -h - -6 - -436 708 m -436 716 l - +insert simplex and subfaces [0,1,2] +insert simplex and subfaces [1,2,3] +insert simplex and subfaces [0,2,4] +insert simplex and subfaces [2,3,6] +insert simplex and subfaces [2,4,6] +insert simplex and subfaces [4,5,6] diff --git a/src/Alpha_complex/doc/alpha_complex_doc.png b/src/Alpha_complex/doc/alpha_complex_doc.png index 0b6201da..170bae80 100644 Binary files a/src/Alpha_complex/doc/alpha_complex_doc.png and b/src/Alpha_complex/doc/alpha_complex_doc.png differ -- cgit v1.2.3 From 6b1843bc5f19800433eedd288f2d966a985bcc16 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 23 Sep 2016 07:26:41 +0000 Subject: Modify the Alpha complex doc wit a concept to create a simplicial complex from alpha complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_create_complex@1546 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d8083c3b0e03e1cf0033e5c7c1ba6f95618efdc1 --- .../concept/Simplicial_complex_for_alpha.h | 98 ++++++++++++++++++++++ src/Alpha_complex/doc/Intro_alpha_complex.h | 6 +- src/Alpha_complex/include/gudhi/Alpha_complex.h | 31 +++---- 3 files changed, 117 insertions(+), 18 deletions(-) create mode 100644 src/Alpha_complex/concept/Simplicial_complex_for_alpha.h (limited to 'src/Alpha_complex/doc') diff --git a/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h new file mode 100644 index 00000000..2fd5dc03 --- /dev/null +++ b/src/Alpha_complex/concept/Simplicial_complex_for_alpha.h @@ -0,0 +1,98 @@ +/* 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) 2016 INRIA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ +#define CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ + +namespace Gudhi { + +namespace alpha_complex { + +/** \brief The concept SimplicialComplexForAlpha describes the requirements for a type to implement a simplicial + * complex, that can be created from a `Alpha_complex`. + */ +struct SimplicialComplexForAlpha { + /** Handle to specify a simplex. */ + typedef unspecified Simplex_handle; + /** Handle to specify a vertex. Must be a non-negative integer. */ + typedef unspecified Vertex_handle; + /** Handle to specify the simplex filtration value. */ + typedef unspecified Filtration_value; + + /** Returns the number of vertices in the simplicial complex. */ + std::size_t num_vertices(); + + /** Gets the simplicial complex dimension. */ + int dimension(); + + /** Sets the simplicial complex dimension. */ + void set_dimension(int dimension); + + /** Gets the 'simplex' dimension. */ + int dimension(Simplex_handle simplex); + + /** Assigns the 'simplex' with the given 'filtration' value. */ + int assign_filtration(Simplex_handle simplex, Filtration_value filtration); + + /** \brief Inserts a simplex with vertices from a given range 'vertex_range' in the simplicial complex with the given + * 'filtration' value. */ + template< typedef Input_vertex_range > + Insertion_result_type insert_simplex_and_subfaces(Input_vertex_range const & vertex_range, + Filtration_value filtration); + + /** Browses the simplicial complex to make the filtration non-decreasing. */ + void make_filtration_non_decreasing(); + + /** Prune the simplicial complex above 'filtration' value given as parameter. */ + void prune_above_filtration(Filtration_value filtration); + + /** Sorts the filtration values in the simplicial complex. */ + void initialize_filtration(); + + /** \brief Iterator over vertices of a simplex. + * + * 'value type' must be 'Vertex_handle'.*/ + typedef unspecified Simplex_vertex_range; + + /** \brief Returns a range over vertices of a given + * simplex. */ + Simplex_vertex_range simplex_vertex_range(Simplex_handle const & simplex); + + /** \brief Iterator over the boundaries of the complex, in an arbitrary order. + * + * 'value_type' must be 'Simplex_handle'.*/ + typedef unspecified Boundary_simplex_range; + + /** \brief Returns a range over boundaries of a given simplex. */ + Boundary_simplex_range boundary_simplex_range(Simplex_handle const & simplex); + + /** \brief Return type of an insertion of a simplex + */ + typedef unspecified Insertion_result_type; + +}; + +} // namespace alpha_complex + +} // namespace Gudhi + +#endif // CONCEPT_ALPHA_COMPLEX_SIMPLICIAL_COMPLEX_FOR_ALPHA_H_ diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h index 4ca3271b..3ffdae7f 100644 --- a/src/Alpha_complex/doc/Intro_alpha_complex.h +++ b/src/Alpha_complex/doc/Intro_alpha_complex.h @@ -51,7 +51,7 @@ namespace alpha_complex { * Alpha_complex is constructing a Delaunay Triangulation * \cite cgal:hdj-t-15b from CGAL (the Computational Geometry - * Algorithms Library \cite cgal:eb-15b) and is able to create a `Simplicial_complex_for_alpha`. + * Algorithms Library \cite cgal:eb-15b) and is able to create a `SimplicialComplexForAlpha`. * * The complex is a template class requiring an Epick_d dD Geometry Kernel @@ -135,12 +135,12 @@ namespace alpha_complex { * * As the squared radii computed by CGAL are an approximation, it might happen that these alpha squared values do not * quite define a proper filtration (i.e. non-decreasing with respect to inclusion). - * We fix that up by calling `Simplicial_complex_for_alpha::make_filtration_non_decreasing()`. + * We fix that up by calling `SimplicialComplexForAlpha::make_filtration_non_decreasing()`. * * \subsubsection pruneabove Prune above given filtration value * * The simplex tree is pruned from the given maximum alpha squared value (cf. - * `Simplicial_complex_for_alpha::prune_above_filtration()`). + * `SimplicialComplexForAlpha::prune_above_filtration()`). * In the following example, the value is given by the user as argument of the program. * * diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 66a55ac7..ab96531f 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -206,17 +206,17 @@ class Alpha_complex { } public: - template - bool create_complex(Simplicial_complex& complex) { - typedef typename Simplicial_complex::Filtration_value Filtration_value; + template + bool create_complex(SimplicialComplexForAlpha& complex) { + typedef typename SimplicialComplexForAlpha::Filtration_value Filtration_value; return create_complex(complex, std::numeric_limits::infinity()); } /** \brief Initialize the simplicial complex from the Delaunay triangulation. * - * \tparam Simplicial_complex must meet Simplicial_complex_for_alpha concept. + * \tparam SimplicialComplexForAlpha must meet `SimplicialComplexForAlpha` concept. * - * @param[in] complex Simplicial_complex to be created. + * @param[in] complex SimplicialComplexForAlpha to be created. * @param[in] max_alpha_square maximum for alpha square value. Default value is +\f$\infty\f$. * * @return true if creation succeeds, false otherwise. @@ -226,10 +226,11 @@ class Alpha_complex { * * Initialization can be launched once. */ - template - bool create_complex(Simplicial_complex& complex, Filtration_value max_alpha_square) { - // From Simplicial_complex type required to insert into a simplicial complex (with or without subfaces). - typedef typename Simplicial_complex::Vertex_handle Vertex_handle; + template + bool create_complex(SimplicialComplexForAlpha& complex, Filtration_value max_alpha_square) { + // From SimplicialComplexForAlpha type required to insert into a simplicial complex (with or without subfaces). + typedef typename SimplicialComplexForAlpha::Vertex_handle Vertex_handle; + typedef typename SimplicialComplexForAlpha::Simplex_handle Simplex_handle; typedef std::vector Vector_vertex; if (triangulation_ == nullptr) { @@ -294,7 +295,7 @@ class Alpha_complex { // ### For i : d -> 0 for (int decr_dim = complex.dimension(); decr_dim >= 0; decr_dim--) { // ### Foreach Sigma of dim i - for (auto f_simplex : complex.skeleton_simplex_range(decr_dim)) { + for (Simplex_handle f_simplex : complex.skeleton_simplex_range(decr_dim)) { int f_simplex_dim = complex.dimension(f_simplex); if (decr_dim == f_simplex_dim) { pointVector.clear(); @@ -345,12 +346,12 @@ class Alpha_complex { } private: - template - void propagate_alpha_filtration(Simplicial_complex& complex, Simplex_handle f_simplex, int decr_dim) { - // From Simplicial_complex type required to assign filtration values. - typedef typename Simplicial_complex::Filtration_value Filtration_value; + template + void propagate_alpha_filtration(SimplicialComplexForAlpha& complex, Simplex_handle f_simplex, int decr_dim) { + // From SimplicialComplexForAlpha type required to assign filtration values. + typedef typename SimplicialComplexForAlpha::Filtration_value Filtration_value; #ifdef DEBUG_TRACES - typedef typename Simplicial_complex::Vertex_handle Vertex_handle; + typedef typename SimplicialComplexForAlpha::Vertex_handle Vertex_handle; #endif // DEBUG_TRACES // ### Foreach Tau face of Sigma -- cgit v1.2.3