diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-11-19 22:00:44 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-11-19 22:00:44 +0000 |
commit | c9f8f4b0fbe1e603015e324c980ad81213b428e2 (patch) | |
tree | bc551962fcff0ecd12d476b6102b9184141eb0c6 | |
parent | ff9818929e33aaf95c407ae6b7539051ca55ad88 (diff) | |
parent | 2ead33fd01bbe97e3b88070d169647c68c3db359 (diff) |
Merge last trunk modifications
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/alpha_complex_3d_module_vincent@4003 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 94bbb0a5588ceee1ecf73d0503892e2f6c78274f
-rw-r--r-- | src/Alpha_complex/doc/Intro_alpha_complex.h | 2 | ||||
-rw-r--r-- | src/Alpha_complex/example/Alpha_complex_from_points.cpp | 20 | ||||
-rw-r--r-- | src/Alpha_complex/include/gudhi/Alpha_complex.h | 82 | ||||
-rw-r--r-- | src/Simplex_tree/include/gudhi/Simplex_tree.h | 6 |
4 files changed, 45 insertions, 65 deletions
diff --git a/src/Alpha_complex/doc/Intro_alpha_complex.h b/src/Alpha_complex/doc/Intro_alpha_complex.h index fddab003..ab7c4794 100644 --- a/src/Alpha_complex/doc/Intro_alpha_complex.h +++ b/src/Alpha_complex/doc/Intro_alpha_complex.h @@ -106,7 +106,7 @@ namespace alpha_complex { * \quad\quad\quad\quad \text{filtration(} \tau \text{) = min( filtration(} \tau \text{), filtration(} \sigma * \text{) )}\\ * \quad\quad\quad \textbf{else}\\ - * \quad\quad\quad\quad \textbf{if } \textbf{if } \tau \text{ is not Gabriel for } \sigma \textbf{ then}\\ + * \quad\quad\quad\quad \textbf{if } \tau \text{ is not Gabriel for } \sigma \textbf{ then}\\ * \quad\quad\quad\quad\quad \text{filtration(} \tau \text{) = filtration(} \sigma \text{)}\\ * \quad\quad\quad\quad \textbf{end if}\\ * \quad\quad\quad \textbf{end if}\\ diff --git a/src/Alpha_complex/example/Alpha_complex_from_points.cpp b/src/Alpha_complex/example/Alpha_complex_from_points.cpp index c19f7cc8..981aa470 100644 --- a/src/Alpha_complex/example/Alpha_complex_from_points.cpp +++ b/src/Alpha_complex/example/Alpha_complex_from_points.cpp @@ -5,29 +5,13 @@ #include <CGAL/Epick_d.h> #include <iostream> -#include <string> #include <vector> -#include <limits> // for numeric limits using Kernel = CGAL::Epick_d< CGAL::Dimension_tag<2> >; using Point = Kernel::Point_d; using Vector_of_points = std::vector<Point>; -void usage(int nbArgs, char * const progName) { - std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; - std::cerr << "Usage: " << progName << " [alpha_square_max_value]\n"; - std::cerr << " i.e.: " << progName << " 60.0\n"; - exit(-1); // ----- >> -} - -int main(int argc, char **argv) { - if ((argc != 1) && (argc != 2)) usage(argc, (argv[0] - 1)); - - // Delaunay complex if alpha_square_max_value is not given by the user. - double alpha_square_max_value {std::numeric_limits<double>::infinity()}; - if (argc == 2) - alpha_square_max_value = atof(argv[1]); - +int main() { // ---------------------------------------------------------------------------- // Init of a list of points // ---------------------------------------------------------------------------- @@ -46,7 +30,7 @@ int main(int argc, char **argv) { Gudhi::alpha_complex::Alpha_complex<Kernel> alpha_complex_from_points(points); Gudhi::Simplex_tree<> simplex; - if (alpha_complex_from_points.create_complex(simplex, alpha_square_max_value)) { + if (alpha_complex_from_points.create_complex(simplex)) { // ---------------------------------------------------------------------------- // Display information about the alpha complex // ---------------------------------------------------------------------------- diff --git a/src/Alpha_complex/include/gudhi/Alpha_complex.h b/src/Alpha_complex/include/gudhi/Alpha_complex.h index 5c577c29..53216e2f 100644 --- a/src/Alpha_complex/include/gudhi/Alpha_complex.h +++ b/src/Alpha_complex/include/gudhi/Alpha_complex.h @@ -228,11 +228,6 @@ class Alpha_complex { } public: - template <typename SimplicialComplexForAlpha> - bool create_complex(SimplicialComplexForAlpha& complex) { - typedef typename SimplicialComplexForAlpha::Filtration_value Filtration_value; - return create_complex(complex, std::numeric_limits<Filtration_value>::infinity()); - } /** \brief Inserts all Delaunay triangulation into the simplicial complex. * It also computes the filtration values accordingly to the \ref createcomplexalgorithm @@ -240,7 +235,8 @@ class Alpha_complex { * \tparam SimplicialComplexForAlpha must meet `SimplicialComplexForAlpha` concept. * * @param[in] complex SimplicialComplexForAlpha to be created. - * @param[in] max_alpha_square maximum for alpha square value. Default value is +\f$\infty\f$. + * @param[in] max_alpha_square maximum for alpha square value. Default value is +\f$\infty\f$, and there is very + * little point using anything else since it does not save time. * * @return true if creation succeeds, false otherwise. * @@ -252,8 +248,10 @@ class Alpha_complex { * * Initialization can be launched once. */ - template <typename SimplicialComplexForAlpha, typename Filtration_value> - bool create_complex(SimplicialComplexForAlpha& complex, Filtration_value max_alpha_square) { + template <typename SimplicialComplexForAlpha, + typename Filtration_value = typename SimplicialComplexForAlpha::Filtration_value> + bool create_complex(SimplicialComplexForAlpha& complex, + Filtration_value max_alpha_square = std::numeric_limits<Filtration_value>::infinity()) { // 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; @@ -275,7 +273,9 @@ class Alpha_complex { // -------------------------------------------------------------------------------------------- // Simplex_tree construction from loop on triangulation finite full cells list if (triangulation_->number_of_vertices() > 0) { - for (auto cit = triangulation_->finite_full_cells_begin(); cit != triangulation_->finite_full_cells_end(); ++cit) { + for (auto cit = triangulation_->finite_full_cells_begin(); + cit != triangulation_->finite_full_cells_end(); + ++cit) { Vector_vertex vertexVector; #ifdef DEBUG_TRACES std::cout << "Simplex_tree insertion "; @@ -336,7 +336,9 @@ class Alpha_complex { std::cout << "filt(Sigma) is NaN : filt(Sigma) =" << complex.filtration(f_simplex) << std::endl; #endif // DEBUG_TRACES } - propagate_alpha_filtration(complex, f_simplex, decr_dim); + // No need to propagate further, unweighted points all have value 0 + if (decr_dim > 1) + propagate_alpha_filtration(complex, f_simplex); } } } @@ -353,7 +355,7 @@ class Alpha_complex { private: template <typename SimplicialComplexForAlpha, typename Simplex_handle> - void propagate_alpha_filtration(SimplicialComplexForAlpha& complex, Simplex_handle f_simplex, int decr_dim) { + void propagate_alpha_filtration(SimplicialComplexForAlpha& complex, Simplex_handle f_simplex) { // From SimplicialComplexForAlpha type required to assign filtration values. typedef typename SimplicialComplexForAlpha::Filtration_value Filtration_value; #ifdef DEBUG_TRACES @@ -382,46 +384,42 @@ class Alpha_complex { #endif // DEBUG_TRACES // ### Else } else { - // No need to compute is_gabriel for dimension <= 2 - // i.e. : Sigma = (3,1) => Tau = 1 - if (decr_dim > 1) { - // insert the Tau points in a vector for is_gabriel function - Vector_of_CGAL_points pointVector; + // insert the Tau points in a vector for is_gabriel function + Vector_of_CGAL_points pointVector; #ifdef DEBUG_TRACES - Vertex_handle vertexForGabriel = Vertex_handle(); + Vertex_handle vertexForGabriel = Vertex_handle(); #endif // DEBUG_TRACES - for (auto vertex : complex.simplex_vertex_range(f_boundary)) { - pointVector.push_back(get_point(vertex)); - } - // Retrieve the Sigma point that is not part of Tau - parameter for is_gabriel function - Point_d point_for_gabriel; - for (auto vertex : complex.simplex_vertex_range(f_simplex)) { - point_for_gabriel = get_point(vertex); - if (std::find(pointVector.begin(), pointVector.end(), point_for_gabriel) == pointVector.end()) { + for (auto vertex : complex.simplex_vertex_range(f_boundary)) { + pointVector.push_back(get_point(vertex)); + } + // Retrieve the Sigma point that is not part of Tau - parameter for is_gabriel function + Point_d point_for_gabriel; + for (auto vertex : complex.simplex_vertex_range(f_simplex)) { + point_for_gabriel = get_point(vertex); + if (std::find(pointVector.begin(), pointVector.end(), point_for_gabriel) == pointVector.end()) { #ifdef DEBUG_TRACES - // vertex is not found in Tau - vertexForGabriel = vertex; + // vertex is not found in Tau + vertexForGabriel = vertex; #endif // DEBUG_TRACES - // No need to continue loop - break; - } + // No need to continue loop + break; } - // is_gabriel function initialization - Is_Gabriel is_gabriel = kernel_.side_of_bounded_sphere_d_object(); - bool is_gab = is_gabriel(pointVector.begin(), pointVector.end(), point_for_gabriel) - != CGAL::ON_BOUNDED_SIDE; + } + // is_gabriel function initialization + Is_Gabriel is_gabriel = kernel_.side_of_bounded_sphere_d_object(); + bool is_gab = is_gabriel(pointVector.begin(), pointVector.end(), point_for_gabriel) + != CGAL::ON_BOUNDED_SIDE; #ifdef DEBUG_TRACES - std::cout << " | Tau is_gabriel(Sigma)=" << is_gab << " - vertexForGabriel=" << vertexForGabriel << std::endl; + std::cout << " | Tau is_gabriel(Sigma)=" << is_gab << " - vertexForGabriel=" << vertexForGabriel << std::endl; #endif // DEBUG_TRACES - // ### If Tau is not Gabriel of Sigma - if (false == is_gab) { - // ### filt(Tau) = filt(Sigma) - Filtration_value alpha_complex_filtration = complex.filtration(f_simplex); - complex.assign_filtration(f_boundary, alpha_complex_filtration); + // ### If Tau is not Gabriel of Sigma + if (false == is_gab) { + // ### filt(Tau) = filt(Sigma) + Filtration_value alpha_complex_filtration = complex.filtration(f_simplex); + complex.assign_filtration(f_boundary, alpha_complex_filtration); #ifdef DEBUG_TRACES - std::cout << " | filt(Tau) = filt(Sigma) = " << complex.filtration(f_boundary) << std::endl; + std::cout << " | filt(Tau) = filt(Sigma) = " << complex.filtration(f_boundary) << std::endl; #endif // DEBUG_TRACES - } } } } diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 13d7372c..78697ea2 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -323,8 +323,7 @@ class Simplex_tree { } /** \brief User-defined copy assignment reproduces the whole tree structure. */ - Simplex_tree& operator= (const Simplex_tree& complex_source) - { + Simplex_tree& operator= (const Simplex_tree& complex_source) { #ifdef DEBUG_TRACES std::cout << "Simplex_tree copy assignment" << std::endl; #endif // DEBUG_TRACES @@ -341,8 +340,7 @@ class Simplex_tree { /** \brief User-defined move assignment relocates the whole tree structure. * \exception std::invalid_argument In debug mode, if the complex_source is invalid. */ - Simplex_tree& operator=(Simplex_tree&& complex_source) - { + Simplex_tree& operator=(Simplex_tree&& complex_source) { #ifdef DEBUG_TRACES std::cout << "Simplex_tree move assignment" << std::endl; #endif // DEBUG_TRACES |