From 9b4c31ef855bf5c98718675a9caab52e8d8514e7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 5 Aug 2016 09:58:11 +0000 Subject: Fix the 3 billions of simplices limit Add some comment and documentation about the new limit (4 billions) Rephrase third party library installation documentation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/3billions_simplices_fix@1420 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 95b20677e455b61578da74aabbd3764b4a27816d --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 65ead001..91b27f28 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -48,6 +48,7 @@ #include // Inf #include #include // for std::max +#include // for std::uint32_t namespace Gudhi { /** \defgroup simplex_tree Filtered Complexes @@ -1297,25 +1298,31 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { return is; } -/// Model of SimplexTreeOptions. +/** Model of SimplexTreeOptions. + * + * Maximum number of simplices to compute persistence is std::numeric_limits::max()<\CODE> + * (about 4 billions of simplices). */ struct Simplex_tree_options_full_featured { typedef linear_indexing_tag Indexing_tag; typedef int Vertex_handle; typedef double Filtration_value; - typedef int Simplex_key; + typedef std::uint32_t Simplex_key; static const bool store_key = true; static const bool store_filtration = true; static const bool contiguous_vertices = false; }; -/** Model of SimplexTreeOptions, faster than - `Simplex_tree_options_full_featured` but note the unsafe - `contiguous_vertices` option. */ +/** Model of SimplexTreeOptions, faster than `Simplex_tree_options_full_featured` but note the unsafe + * `contiguous_vertices` option. + * + * Maximum number of simplices to compute persistence is std::numeric_limits::max()<\CODE> + * (about 4 billions of simplices). */ + struct Simplex_tree_options_fast_persistence { typedef linear_indexing_tag Indexing_tag; typedef int Vertex_handle; typedef float Filtration_value; - typedef int Simplex_key; + typedef std::uint32_t Simplex_key; static const bool store_key = true; static const bool store_filtration = true; static const bool contiguous_vertices = true; -- cgit v1.2.3 From 4f5809ac9e4989b6d7920c2fad45b16eea498d1d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 5 Aug 2016 12:45:40 +0000 Subject: bad tag termination for doxygen git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/3billions_simplices_fix@1421 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7665d06c502a1ed93d87d0393e630083e34bc846 --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 91b27f28..41db58e6 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1300,7 +1300,7 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { /** Model of SimplexTreeOptions. * - * Maximum number of simplices to compute persistence is std::numeric_limits::max()<\CODE> + * Maximum number of simplices to compute persistence is std::numeric_limits::max() * (about 4 billions of simplices). */ struct Simplex_tree_options_full_featured { typedef linear_indexing_tag Indexing_tag; @@ -1315,7 +1315,7 @@ struct Simplex_tree_options_full_featured { /** Model of SimplexTreeOptions, faster than `Simplex_tree_options_full_featured` but note the unsafe * `contiguous_vertices` option. * - * Maximum number of simplices to compute persistence is std::numeric_limits::max()<\CODE> + * Maximum number of simplices to compute persistence is std::numeric_limits::max() * (about 4 billions of simplices). */ struct Simplex_tree_options_fast_persistence { -- cgit v1.2.3 From d85e942e8ce71ec1f004ef527f219b67d640513a Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 25 Aug 2016 12:44:06 +0000 Subject: Modify SimpleyKey, SimplexTreeOptions concept and SimplexTree documentation about Simplex_key type (can be signed or unsigned). git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/3billions_simplices_fix@1454 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 562aadf6d7491ea7f7144a3394dc78bdabc9e9f1 --- src/Simplex_tree/concept/SimplexKey.h | 2 +- src/Simplex_tree/concept/SimplexTreeOptions.h | 2 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/concept/SimplexKey.h b/src/Simplex_tree/concept/SimplexKey.h index 7fdbdd84..9fbed401 100644 --- a/src/Simplex_tree/concept/SimplexKey.h +++ b/src/Simplex_tree/concept/SimplexKey.h @@ -22,7 +22,7 @@ /** \brief Key type used as simplex identifier. * - * Must be a signed integer type. + * Must be an integer type. */ struct SimplexKey {}; diff --git a/src/Simplex_tree/concept/SimplexTreeOptions.h b/src/Simplex_tree/concept/SimplexTreeOptions.h index d072cf34..89acdc18 100644 --- a/src/Simplex_tree/concept/SimplexTreeOptions.h +++ b/src/Simplex_tree/concept/SimplexTreeOptions.h @@ -31,7 +31,7 @@ struct SimplexTreeOptions { typedef VertexHandle Vertex_handle; /// Must be comparable with operator<. typedef FiltrationValue Filtration_value; - /// Must be a signed integer type. + /// Must be an integer type. typedef SimplexKey Simplex_key; /// If true, each simplex has extra storage for one `Simplex_key`. Necessary for `Persistent_cohomology`. static const bool store_key; diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 41db58e6..fa9c0800 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -110,7 +110,7 @@ class Simplex_tree { typedef typename Options::Filtration_value Filtration_value; /** \brief Key associated to each simplex. * - * Must be a signed integer type. */ + * Must be an integer type. */ typedef typename Options::Simplex_key Simplex_key; /** \brief Type for the vertex handle. * -- cgit v1.2.3 From ba76b65af98ad337e39b72fd4260baee17eb4f49 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 12 Sep 2016 12:47:01 +0000 Subject: Modify filtered complexes sections and examples. Modify persistence sections and examples git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1487 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 6b0bdc7199f7229ac152175c4cbc6ebd79c9bc67 --- .../doc/Intro_persistent_cohomology.h | 62 ++++++++++++++++++---- src/Simplex_tree/example/README | 4 +- src/Simplex_tree/include/gudhi/Simplex_tree.h | 32 ----------- src/common/doc/main_page.h | 10 ++-- 4 files changed, 61 insertions(+), 47 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h index c8081cac..0cba6361 100644 --- a/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h +++ b/src/Persistent_cohomology/doc/Intro_persistent_cohomology.h @@ -46,7 +46,7 @@ namespace persistent_cohomology { composed of three elements: topological spaces, their homology groups and an evolution scheme. -
Topological Spaces:
+ \section persistencetopolocalspaces Topological Spaces Topological spaces are represented by simplicial complexes. Let \f$V = \{1, \cdots ,|V|\}\f$ be a set of vertices. A simplex \f$\sigma\f$ is a subset of vertices @@ -84,7 +84,7 @@ namespace persistent_cohomology { Filtration_value filtration (Simplex_handle) that returns the value of the filtration on the simplex represented by the handle. -
Homology:
+ \section persistencehomology Homology For a ring \f$\mathcal{R}\f$, the group of n-chains, denoted \f$\mathbf{C}_n(\mathbf{K},\mathcal{R})\f$, of \f$\mathbf{K}\f$ is the group of formal sums of @@ -111,7 +111,7 @@ namespace persistent_cohomology { We refer to \cite Munkres-elementsalgtop1984 for an introduction to homology theory and to \cite DBLP:books/daglib/0025666 for an introduction to persistent homology. -
Indexing Scheme:
+ \section persistenceindexingscheme Indexing Scheme "Changing" a simplicial complex consists in applying a simplicial map. An indexing scheme is a directed graph together with a traversal order, such that two @@ -140,18 +140,62 @@ namespace persistent_cohomology { its subsimplices of same filtration value) provides an indexing scheme. \section Examples - We provide several example files: run these examples with -h for details on their use, and read the README file. -\li rips_persistence.cpp computes the Rips complex of a point cloud and its persistence diagram. +We provide several example files: run these examples with -h for details on their use, and read the README file. -\li rips_multifield_persistence.cpp computes the Rips complex of a point cloud and its persistence diagram -with a family of field coefficients. +\li +Persistent_cohomology/rips_persistence.cpp computes the Rips complex of a point cloud and its persistence diagram. -\li performance_rips_persistence.cpp provides timings for the construction of the Rips complex on a set of -points sampling a Klein bottle in \f$\mathbb{R}^5\f$ with a simplex tree, its conversion to a +\li +Persistent_cohomology/rips_multifield_persistence.cpp computes the Rips complex of a point cloud and its +persistence diagram with a family of field coefficients. + +\li +Persistent_cohomology/performance_rips_persistence.cpp provides timings for the construction of the Rips complex +on a set of points sampling a Klein bottle in \f$\mathbb{R}^5\f$ with a simplex tree, its conversion to a Hasse diagram and the computation of persistent homology and multi-field persistent homology for the different representations. +\li +Persistent_cohomology/alpha_complex_3d_persistence.cpp computes the persistent homology with +\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. +\code $> ./alpha_complex_3d_persistence ../../data/points/tore3D_300.off 2 0.45 \endcode +\code Simplex_tree dim: 3 +2 0 0 inf +2 1 0.0682162 1.0001 +2 1 0.0934117 1.00003 +2 2 0.56444 1.03938 \endcode + +\li +Persistent_cohomology/alpha_complex_persistence.cpp computes the persistent homology with +\f$\mathbb{Z}/p\mathbb{Z}\f$ coefficients of the alpha complex on points sampling from an OFF file. +\code $> ./alpha_complex_persistence -r 32 -p 2 -m 0.45 ../../data/points/tore3D_300.off \endcode +\code Alpha complex is of dimension 3 - 9273 simplices - 300 vertices. +Simplex_tree dim: 3 +2 0 0 inf +2 1 0.0682162 1.0001 +2 1 0.0934117 1.00003 +2 2 0.56444 1.03938 \endcode + +\li +Persistent_cohomology/periodic_alpha_complex_3d_persistence.cpp computes the persistent homology with +\f$\mathbb{Z}/2\mathbb{Z}\f$ coefficients of the periodic alpha complex on points sampling from an OFF file. +\code $> ./periodic_alpha_complex_3d_persistence ../../data/points/grid_10_10_10_in_0_1.off 3 1.0 \endcode +\code Periodic Delaunay computed. +Simplex_tree dim: 3 +3 0 0 inf +3 1 0.0025 inf +3 1 0.0025 inf +3 1 0.0025 inf +3 2 0.005 inf +3 2 0.005 inf +3 2 0.005 inf +3 3 0.0075 inf \endcode + +\li +Persistent_cohomology/plain_homology.cpp computes the plain homology of a simple simplicial complex without +filtration values. + \copyright GNU General Public License v3. */ diff --git a/src/Simplex_tree/example/README b/src/Simplex_tree/example/README index 03c759cb..e37af790 100644 --- a/src/Simplex_tree/example/README +++ b/src/Simplex_tree/example/README @@ -52,7 +52,7 @@ EXAMPLE OF SIMPLE INSERTION *** Simplex tree construction with Z/2Z coefficients on weighted graph Klein bottle file: -./simplex_tree_from_file ../../../data/points/Klein_bottle_complex.txt 2 +./simplex_tree_from_cliques_of_graph ../../../data/points/Klein_bottle_complex.txt 2 Insert the 1-skeleton in the simplex tree in 0 s. Expand the simplex tree in 0 s. Information of the Simplex Tree: @@ -60,7 +60,7 @@ Information of the Simplex Tree: with Z/3Z coefficients: -./simplex_tree_from_file ../../../data/points/Klein_bottle_complex.txt 3 +./simplex_tree_from_cliques_of_graph ../../../data/points/Klein_bottle_complex.txt 3 Insert the 1-skeleton in the simplex tree in 0 s. Expand the simplex tree in 0 s. diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index fa9c0800..63e3f0e5 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -51,38 +51,6 @@ #include // for std::uint32_t namespace Gudhi { -/** \defgroup simplex_tree Filtered Complexes - * \author Clément Maria - * - * A simplicial complex \f$\mathbf{K}\f$ - * on a set of vertices \f$V = \{1, \cdots ,|V|\}\f$ is a collection of simplices - * \f$\{\sigma\}\f$, - * \f$\sigma \subseteq V\f$ such that \f$\tau \subseteq \sigma \in \mathbf{K} \rightarrow \tau \in - * \mathbf{K}\f$. The - * dimension \f$n=|\sigma|-1\f$ of \f$\sigma\f$ is its number of elements minus \f$1\f$. - * - * A filtration of a simplicial complex is - * a function \f$f:\mathbf{K} \rightarrow \mathbb{R}\f$ satisfying \f$f(\tau)\leq f(\sigma)\f$ whenever - * \f$\tau \subseteq \sigma\f$. Ordering the simplices by increasing filtration values - * (breaking ties so as a simplex appears after its subsimplices of same filtration value) - * provides an indexing scheme. - * - -
Implementations:
- There are two implementation of complexes. The first on is the Simplex_tree data structure. - The simplex tree is an efficient and flexible - data structure for representing general (filtered) simplicial complexes. The data structure - is described in \cite boissonnatmariasimplextreealgorithmica - \image html "Simplex_tree_representation.png" "Simplex tree representation" - - The second one is the Hasse_complex. The Hasse complex is a data structure representing - explicitly all co-dimension 1 incidence relations in a complex. It is consequently faster - when accessing the boundary of a simplex, but is less compact and harder to construct from - scratch. - - * \copyright GNU General Public License v3. - * @{ - */ struct Simplex_tree_options_full_featured; diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 9146bed1..0983051d 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -13,8 +13,8 @@ * The current release of the GUDHI library includes: * * \li Data structures to represent, construct and manipulate simplicial complexes. - * \li Algorithms to compute persistent homology and multi-field persistent homology. - * \li Simplication of simplicial complexes by edge contraction. + * \li Simplification of simplicial complexes by edge contraction. + * \li Algorithms to compute persistent homology persistent homology. * * All data-structures are generic and several of their aspects can be parameterized via template classes. * We refer to \cite gudhilibrary_ICMS14 for a detailed description of the design of the library. @@ -266,8 +266,10 @@ make \endverbatim * Simplex_tree/simplex_tree_from_alpha_shapes_3.cpp * \li * Simplex_tree/simplex_tree_from_cliques_of_graph.cpp - * \li - * Persistent_cohomology/alpha_shapes_persistence.cpp + * \li + * Persistent_cohomology/alpha_complex_3d_persistence.cpp + * \li + * Persistent_cohomology/alpha_complex_persistence.cpp * \li * Persistent_cohomology/rips_persistence_via_boundary_matrix.cpp * \li -- cgit v1.2.3 From 7303b4098d4bd6ac6aa165a5ce666086809de768 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Mon, 12 Sep 2016 13:20:45 +0000 Subject: Intro_simplex_tree.h for filtered complexes module documentation git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@1488 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b9dfa3d056b4216efe02c8cb0323bdd8805b2756 --- src/Simplex_tree/doc/Intro_simplex_tree.h | 84 +++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/Simplex_tree/doc/Intro_simplex_tree.h (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/doc/Intro_simplex_tree.h b/src/Simplex_tree/doc/Intro_simplex_tree.h new file mode 100644 index 00000000..ddf9ad22 --- /dev/null +++ b/src/Simplex_tree/doc/Intro_simplex_tree.h @@ -0,0 +1,84 @@ +/* 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): Clément Maria + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * + * 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 DOC_SIMPLEX_TREE_INTRO_SIMPLEX_TREE_H_ +#define DOC_SIMPLEX_TREE_INTRO_SIMPLEX_TREE_H_ + +// needs namespace for Doxygen to link on classes +namespace Gudhi { + + +/** \defgroup simplex_tree Filtered Complexes + * \author Clément Maria + * + * A simplicial complex \f$\mathbf{K}\f$ on a set of vertices \f$V = \{1, \cdots ,|V|\}\f$ is a collection of + * implices \f$\{\sigma\}\f$, \f$\sigma \subseteq V\f$ such that + * \f$\tau \subseteq \sigma \in \mathbf{K} \rightarrow \tau \in \mathbf{K}\f$. The dimension \f$n=|\sigma|-1\f$ of + * \f$\sigma\f$ is its number of elements minus \f$1\f$. + * + * A filtration of a simplicial complex is a function \f$f:\mathbf{K} \rightarrow \mathbb{R}\f$ satisfying + * \f$f(\tau)\leq f(\sigma)\f$ whenever \f$\tau \subseteq \sigma\f$. Ordering the simplices by increasing filtration + * values (breaking ties so as a simplex appears after its subsimplices of same filtration value) provides an + * indexing scheme. + * + * \section filteredcomplexesimplementation Implementations + * \subsection filteredcomplexessimplextree Simplex tree + * There are two implementation of complexes. The first on is the Simplex_tree data structure. The simplex tree is an + * efficient and flexible data structure for representing general (filtered) simplicial complexes. The data structure + * is described in \cite boissonnatmariasimplextreealgorithmica + * \image html "Simplex_tree_representation.png" "Simplex tree representation" + * + * \subsubsection filteredcomplexessimplextreeexamples Examples + * + * Here is a list of simplex tree examples : + * \li + * Simplex_tree/simple_simplex_tree.cpp - Simple simplex tree construction and basic function use. + * + * \li + * Simplex_tree/simplex_tree_from_cliques_of_graph.cpp - Simplex tree construction from cliques of graph read in + * a file. + * + * Simplex tree construction with \f$\mathbb{Z}/3\mathbb{Z}\f$ coefficients on weighted graph Klein bottle file: + * \code $> ./simplex_tree_from_cliques_of_graph ../../data/points/Klein_bottle_complex.txt 3 \endcode + * \code Insert the 1-skeleton in the simplex tree in 0.000404 s. +max_dim = 3 +Expand the simplex tree in 3.8e-05 s. +Information of the Simplex Tree: +Number of vertices = 10 Number of simplices = 98 \endcode + * + * \li + * Simplex_tree/simplex_tree_from_alpha_shapes_3.cpp - Simplex tree is computed and displayed from a 3D alpha + * complex (Requires CGAL, GMP and GMPXX to be installed) + * + * + * \subsection filteredcomplexeshassecomplex Hasse complex + * The second one is the Hasse_complex. The Hasse complex is a data structure representing explicitly all co-dimension + * 1 incidence relations in a complex. It is consequently faster when accessing the boundary of a simplex, but is less + * compact and harder to construct from scratch. + * + * \copyright GNU General Public License v3. + * @{ + */ + +} // namespace Gudhi + +#endif // DOC_SIMPLEX_TREE_INTRO_SIMPLEX_TREE_H_ -- cgit v1.2.3 From bef66102e0ab999724dbb6c1ad9733ee2a5d6813 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 15 Sep 2016 14:00:35 +0000 Subject: Fix cpplint and warnings git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/warning_fix@1502 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: afc7d137b66225954ebfe37a823f1f0b6bcfe7a5 --- src/GudhUI/model/Model.h | 4 +- src/GudhUI/utils/Edge_contractor.h | 2 +- src/GudhUI/utils/Furthest_point_epsilon_net.h | 2 +- src/GudhUI/view/FirstCoordProjector.h | 6 +- src/Simplex_tree/test/simplex_tree_unit_test.cpp | 16 +- src/Skeleton_blocker/concept/SkeletonBlockerDS.h | 213 +++++++++++---------- .../concept/SkeletonBlockerGeometricDS.h | 113 ++++++----- .../example/Skeleton_blocker_from_simplices.cpp | 2 +- .../example/Skeleton_blocker_iteration.cpp | 2 +- .../example/Skeleton_blocker_link.cpp | 4 +- .../include/gudhi/Skeleton_blocker.h | 204 ++++++++++---------- .../Skeleton_blocker_complex_visitor.h | 53 ++--- .../Skeleton_blocker_link_superior.h | 14 +- .../Skeleton_blocker/Skeleton_blocker_off_io.h | 11 +- .../Skeleton_blocker_simple_geometric_traits.h | 13 +- .../Skeleton_blocker_simple_traits.h | 39 ++-- .../Skeleton_blocker/Skeleton_blocker_simplex.h | 12 +- .../Skeleton_blocker_sub_complex.h | 49 ++--- .../gudhi/Skeleton_blocker/internal/Top_faces.h | 5 +- .../include/gudhi/Skeleton_blocker/internal/Trie.h | 10 +- .../Skeleton_blockers_blockers_iterators.h | 5 +- .../iterators/Skeleton_blockers_edges_iterators.h | 3 +- .../iterators/Skeleton_blockers_iterators.h | 2 +- .../Skeleton_blockers_simplices_iterators.h | 34 ++-- .../Skeleton_blockers_triangles_iterators.h | 12 +- .../Skeleton_blockers_vertices_iterators.h | 12 +- .../include/gudhi/Skeleton_blocker_complex.h | 37 ++-- .../gudhi/Skeleton_blocker_geometric_complex.h | 3 +- .../include/gudhi/Skeleton_blocker_link_complex.h | 28 +-- .../gudhi/Skeleton_blocker_simplifiable_complex.h | 11 +- src/Skeleton_blocker/test/TestGeometricComplex.cpp | 2 +- src/Skeleton_blocker/test/TestSimplifiable.cpp | 10 +- .../test/TestSkeletonBlockerComplex.cpp | 9 +- 33 files changed, 474 insertions(+), 468 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/GudhUI/model/Model.h b/src/GudhUI/model/Model.h index 1c39c0d7..77e37b6c 100644 --- a/src/GudhUI/model/Model.h +++ b/src/GudhUI/model/Model.h @@ -72,8 +72,8 @@ class CGAL_geometric_flag_complex_wrapper { void maximal_face(std::vector vertices) { if (!load_only_points_) { // std::cout << "size:" << vertices.size() << std::endl; - for (int i = 0; i < vertices.size(); ++i) - for (int j = i + 1; j < vertices.size(); ++j) + for (std::size_t i = 0; i < vertices.size(); ++i) + for (std::size_t j = i + 1; j < vertices.size(); ++j) complex_.add_edge(Vertex_handle(vertices[i]), Vertex_handle(vertices[j])); } } diff --git a/src/GudhUI/utils/Edge_contractor.h b/src/GudhUI/utils/Edge_contractor.h index 45079a40..8a29ff4b 100644 --- a/src/GudhUI/utils/Edge_contractor.h +++ b/src/GudhUI/utils/Edge_contractor.h @@ -65,7 +65,7 @@ template class Edge_contractor { Placement_type operator()(const EdgeProfile& profile) const override { std::vector mid_coords(profile.p0().dimension(), 0); - for (size_t i = 0; i < profile.p0().dimension(); ++i) { + for (int i = 0; i < profile.p0().dimension(); ++i) { mid_coords[i] = (profile.p0()[i] + profile.p1()[i]) / 2.; } return Point(profile.p0().dimension(), mid_coords.begin(), mid_coords.end()); diff --git a/src/GudhUI/utils/Furthest_point_epsilon_net.h b/src/GudhUI/utils/Furthest_point_epsilon_net.h index f2a216f6..98346daa 100644 --- a/src/GudhUI/utils/Furthest_point_epsilon_net.h +++ b/src/GudhUI/utils/Furthest_point_epsilon_net.h @@ -73,7 +73,7 @@ template class Furthest_point_epsilon_net { complex_(complex) { if (!complex.empty()) { init_filtration(); - for (int k = 2; k < net_filtration_.size(); ++k) { + for (std::size_t k = 2; k < net_filtration_.size(); ++k) { update_radius_value(k); } } diff --git a/src/GudhUI/view/FirstCoordProjector.h b/src/GudhUI/view/FirstCoordProjector.h index a4027b7f..1333f5d3 100644 --- a/src/GudhUI/view/FirstCoordProjector.h +++ b/src/GudhUI/view/FirstCoordProjector.h @@ -33,9 +33,11 @@ class FirstCoordProjector3D : public Projector3D { Point_3 operator()(const Point& p) const { if (p.dimension() >= 3) - return Point_3(p.x(), p.y(), p.z()); + return Point_3(p.x(), p.y(), p.z()); else if (p.dimension() >= 2) - return Point_3(p.x(), p.y(), 0.0); + return Point_3(p.x(), p.y(), 0.0); + else + return Point_3(0.0, 0.0, 0.0); } }; diff --git a/src/Simplex_tree/test/simplex_tree_unit_test.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp index b1bb23b1..28bf202b 100644 --- a/src/Simplex_tree/test/simplex_tree_unit_test.cpp +++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp @@ -806,14 +806,14 @@ BOOST_AUTO_TEST_CASE(make_filtration_non_decreasing) { st.insert_simplex_and_subfaces({3, 0}, 2.0); st.insert_simplex_and_subfaces({3, 4, 5}, 2.0); - // Inserted simplex: - // 1 - // o - // /X\ - // o---o---o---o - // 2 0 3\X/4 - // o - // 5 + /* Inserted simplex: */ + /* 1 */ + /* o */ + /* /X\ */ + /* o---o---o---o */ + /* 2 0 3\X/4 */ + /* o */ + /* 5 */ std::cout << "Check default insertion ensures the filtration values are non decreasing" << std::endl; BOOST_CHECK(!st.make_filtration_non_decreasing()); diff --git a/src/Skeleton_blocker/concept/SkeletonBlockerDS.h b/src/Skeleton_blocker/concept/SkeletonBlockerDS.h index 3c650f99..d82425a0 100644 --- a/src/Skeleton_blocker/concept/SkeletonBlockerDS.h +++ b/src/Skeleton_blocker/concept/SkeletonBlockerDS.h @@ -1,128 +1,129 @@ -/* - * SkeletonBlockerDS.h +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Feb 20, 2014 - * Author: David Salinas - * Copyright 2013 INRIA. All rights reserved + * Author(s): David Salinas + * + * 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 . */ -#ifndef GUDHI_SKELETONBLOCKERDS_H_ -#define GUDHI_SKELETONBLOCKERDS_H_ - +#ifndef CONCEPT_SKELETON_BLOCKER_SKELETONBLOCKERDS_H_ +#define CONCEPT_SKELETON_BLOCKER_SKELETONBLOCKERDS_H_ namespace Gudhi { namespace skeleton_blocker { - - /** \brief Concept for the template class passed for Skeleton_blocker_complex. * Most importantly, it contains the nodes for vertices and edges * (Graph_vertex and Graph_edge) that are stored in the simplicial * complex. The user can redefine these classes to attach * additional information to vertices and edges. */ -struct SkeletonBlockerDS -{ - /** - * @brief index that allows to find the vertex in the boost graph - */ - typedef int boost_vertex_handle; - - - /** - * @brief Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor - * used in boost subgraphs - * and allow to localize a vertex of a subcomplex on its parent root complex. - * - * In gross, vertices are stored in a vector - * and the Root_vertex_handle and Vertex_handle store indices of a vertex in this vector. - * - * For the root simplicial complex, the Root_vertex_handle and Vertex_handle of a vertex - * are the same. - * - * - * For a subcomplex L of a simplicial complex K, the local descriptor, ie the Vertex_handle, of a - * vertex v (that belongs to L) is its position in the vector of vertices - * of the subcomplex L whereas its Root_vertex_handle (global descriptor) is the position of v in the vector of the - * vertices of the root simplicial complex K. - */ - struct Root_vertex_handle{ - - boost_vertex_handle vertex; - - friend ostream& operator << (ostream& o, const Root_vertex_handle & v); - }; - - /** - * A Vertex_handle must be Default Constructible, Assignable and Equality Comparable. - */ - struct Vertex_handle{ - boost_vertex_handle vertex; - - friend ostream& operator << (ostream& o, const Vertex_handle & v); - }; - - - /** - * \brief The type of vertices that are stored the boost graph. - * A Vertex must be Default Constructible and Equality Comparable. - * - */ - struct Graph_vertex{ - /** \brief Used to deactivate a vertex for example when contracting an edge. - * It allows in some cases to remove the vertex at low cost. - */ - void deactivate(); - - /** \brief Used to activate a vertex. - */ - void activate(); - - /** \brief Tells if the vertex is active. - */ - bool is_active() const; - - void set_id(Root_vertex_handle i); - Root_vertex_handle get_id() const; - virtual string to_string() const ; - friend ostream& operator << (ostream& o, const Graph_vertex & v); - }; - - - /** - * \brief The type of edges that are stored the boost graph. - * An Edge must be Default Constructible and Equality Comparable. - */ - struct Graph_edge{ - /** - * @brief Allows to modify vertices of the edge. - */ - void setId(Root_vertex_handle a,Root_vertex_handle b); - - /** - * @brief Returns the first vertex of the edge. - */ - Root_vertex_handle first() const ; - - /** - * @brief Returns the second vertex of the edge. - */ - Root_vertex_handle second() const ; - - friend ostream& operator << (ostream& o, const Simple_edge & v); - }; - - +struct SkeletonBlockerDS { + /** + * @brief index that allows to find the vertex in the boost graph + */ + typedef int boost_vertex_handle; + + /** + * @brief Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor + * used in boost subgraphs + * and allow to localize a vertex of a subcomplex on its parent root complex. + * + * In gross, vertices are stored in a vector + * and the Root_vertex_handle and Vertex_handle store indices of a vertex in this vector. + * + * For the root simplicial complex, the Root_vertex_handle and Vertex_handle of a vertex + * are the same. + * + * + * For a subcomplex L of a simplicial complex K, the local descriptor, ie the Vertex_handle, of a + * vertex v (that belongs to L) is its position in the vector of vertices + * of the subcomplex L whereas its Root_vertex_handle (global descriptor) is the position of v in the vector of the + * vertices of the root simplicial complex K. + */ + struct Root_vertex_handle { + boost_vertex_handle vertex; + + friend ostream& operator<<(ostream& o, const Root_vertex_handle & v); + }; + + /** + * A Vertex_handle must be Default Constructible, Assignable and Equality Comparable. + */ + struct Vertex_handle { + boost_vertex_handle vertex; + + friend ostream& operator<<(ostream& o, const Vertex_handle & v); + }; + + /** + * \brief The type of vertices that are stored the boost graph. + * A Vertex must be Default Constructible and Equality Comparable. + * + */ + struct Graph_vertex { + /** \brief Used to deactivate a vertex for example when contracting an edge. + * It allows in some cases to remove the vertex at low cost. + */ + void deactivate(); + + /** \brief Used to activate a vertex. + */ + void activate(); + + /** \brief Tells if the vertex is active. + */ + bool is_active() const; + + void set_id(Root_vertex_handle i); + Root_vertex_handle get_id() const; + virtual string to_string() const; + friend ostream& operator<<(ostream& o, const Graph_vertex & v); + }; + + /** + * \brief The type of edges that are stored the boost graph. + * An Edge must be Default Constructible and Equality Comparable. + */ + struct Graph_edge { + /** + * @brief Allows to modify vertices of the edge. + */ + void setId(Root_vertex_handle a, Root_vertex_handle b); + + /** + * @brief Returns the first vertex of the edge. + */ + Root_vertex_handle first() const; + + /** + * @brief Returns the second vertex of the edge. + */ + Root_vertex_handle second() const; + + friend ostream& operator<<(ostream& o, const Simple_edge & v); + }; }; - - } // namespace skeleton_blocker namespace skbl = skeleton_blocker; } // namespace Gudhi - -#endif /* GUDHI_SKELETONBLOCKERDS_H_ */ +#endif // CONCEPT_SKELETON_BLOCKER_SKELETONBLOCKERDS_H_ diff --git a/src/Skeleton_blocker/concept/SkeletonBlockerGeometricDS.h b/src/Skeleton_blocker/concept/SkeletonBlockerGeometricDS.h index c5d52800..6017df1a 100644 --- a/src/Skeleton_blocker/concept/SkeletonBlockerGeometricDS.h +++ b/src/Skeleton_blocker/concept/SkeletonBlockerGeometricDS.h @@ -1,13 +1,27 @@ -/* - * SkeletonBlockerGeometricDS.h +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Feb 20, 2014 - * Author: David Salinas - * Copyright 2013 INRIA. All rights reserved + * Author(s): David Salinas + * + * 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 . */ -#ifndef GUDHI_SKELETONBLOCKERGEOMETRICDS_H_ -#define GUDHI_SKELETONBLOCKERGEOMETRICDS_H_ +#ifndef CONCEPT_SKELETON_BLOCKER_SKELETONBLOCKERGEOMETRICDS_H_ +#define CONCEPT_SKELETON_BLOCKER_SKELETONBLOCKERGEOMETRICDS_H_ namespace Gudhi { namespace skeleton_blocker { @@ -20,52 +34,51 @@ namespace skeleton_blocker { * Graph_edge must specify how to access to an index. * */ - //todo the index is just for contraction, to remove -template -struct SkeletonBlockerGeometricDS : public SkeletonBlockerDS -{ +//todo the index is just for contraction, to remove - /** - * Geometry information. - */ - typedef GeometryTrait GT ; +template +struct SkeletonBlockerGeometricDS : public SkeletonBlockerDS { + /** + * Geometry information. + */ + typedef GeometryTrait GT; - /** - * Type of point (should be the same as GT::Point). - */ - typedef typename GeometryTrait::Point Point; + /** + * Type of point (should be the same as GT::Point). + */ + typedef typename GeometryTrait::Point Point; - /** - * @brief Vertex that stores a point. - */ - class Graph_vertex : public SkeletonBlockerDS::Graph_vertex{ - public: - /** - * @brief Access to the point. - */ - Point& point(); - /** - * @brief Access to the point. - */ - const Point& point(); - }; + /** + * @brief Vertex that stores a point. + */ + class Graph_vertex : public SkeletonBlockerDS::Graph_vertex { + public: + /** + * @brief Access to the point. + */ + Point& point(); + /** + * @brief Access to the point. + */ + const Point& point(); + }; - /** - * @brief Edge that allows to access to an index. - * The indices of the edges are used to store heap information - * in the edge contraction algorithm. - */ - class Graph_Edge : public SkeletonBlockerDS::Graph_edge{ - public: - /** - * @brief Access to the index. - */ - int& index(); - /** - * @brief Access to the index. - */ - int index(); - }; + /** + * @brief Edge that allows to access to an index. + * The indices of the edges are used to store heap information + * in the edge contraction algorithm. + */ + class Graph_Edge : public SkeletonBlockerDS::Graph_edge { + public: + /** + * @brief Access to the index. + */ + int& index(); + /** + * @brief Access to the index. + */ + int index(); + }; }; } // namespace skeleton_blocker @@ -74,4 +87,4 @@ namespace skbl = skeleton_blocker; } // namespace Gudhi -#endif /* GUDHI_SKELETONBLOCKERGEOMETRICDS_H_ */ +#endif // CONCEPT_SKELETON_BLOCKER_SKELETONBLOCKERGEOMETRICDS_H_ diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp index 171f35f2..5f89536b 100644 --- a/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp +++ b/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp index 8d9d1a67..7df0e3c9 100644 --- a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp +++ b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp index 1f937170..e2a04d75 100644 --- a/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp +++ b/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) { // For instance, to test if the link contains the vertex that was labeled i: for (int i = 0; i < 5; ++i) cout << "link.contains_vertex(Root_vertex_handle(" << i << ")):" << - link.contains_vertex(Root_vertex_handle(i)) << endl; + link.contains_vertex(Root_vertex_handle(i)) << endl; return EXIT_SUCCESS; } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h index 822282fd..85fada4f 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h @@ -1,24 +1,24 @@ - /* 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): David Salinas - * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) - * - * 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 . - */ +/* 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): David Salinas + * + * 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 . + */ #ifndef SKELETON_BLOCKER_H_ #define SKELETON_BLOCKER_H_ @@ -63,7 +63,7 @@ when \f$ \tau \neq \sigma\f$ we say that \f$ \tau\f$ is a proper-face of \f$ \si An abstract simplicial complex is a set of simplices that contains all the faces of its simplices. The 1-skeleton of a simplicial complex (or its graph) consists of its elements of dimension lower than 2. -*\image html "ds_representation.png" "Skeleton-blocker representation" width=20cm + *\image html "ds_representation.png" "Skeleton-blocker representation" width=20cm To encode, a simplicial complex, one can encodes all its simplices. @@ -85,7 +85,7 @@ in next figure. Storing the graph and blockers of such simplicial complexes is m their simplices. -*\image html "blockers_curve.png" "Number of blockers of random triangulations of 3-spheres" width=10cm + *\image html "blockers_curve.png" "Number of blockers of random triangulations of 3-spheres" width=10cm @@ -127,46 +127,46 @@ such as the Simplex Tree. The following example computes the Euler Characteristi of a simplicial complex. \code{.cpp} - typedef Skeleton_blocker_complex Complex; - typedef Complex::Vertex_handle Vertex_handle; - typedef Complex::Simplex Simplex; - - const int n = 15; - - // build a full complex with 10 vertices and 2^n-1 simplices - Complex complex; - for(int i=0;i Complex; + typedef Complex::Vertex_handle Vertex_handle; + typedef Complex::Simplex Simplex; + + const int n = 15; + + // build a full complex with 10 vertices and 2^n-1 simplices + Complex complex; + for(int i=0;i simplices; - - //add 4 triangles of a tetrahedron 0123 - simplices.push_back(Simplex(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2))); - simplices.push_back(Simplex(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3))); - simplices.push_back(Simplex(Vertex_handle(3),Vertex_handle(0),Vertex_handle(2))); - simplices.push_back(Simplex(Vertex_handle(3),Vertex_handle(0),Vertex_handle(1))); - - Complex complex; - //get complex from top faces - make_complex_from_top_faces(complex,simplices.begin(),simplices.end()); - - std::cout << "Simplices:"< simplices; + + //add 4 triangles of a tetrahedron 0123 + simplices.push_back(Simplex(Vertex_handle(0),Vertex_handle(1),Vertex_handle(2))); + simplices.push_back(Simplex(Vertex_handle(1),Vertex_handle(2),Vertex_handle(3))); + simplices.push_back(Simplex(Vertex_handle(3),Vertex_handle(0),Vertex_handle(2))); + simplices.push_back(Simplex(Vertex_handle(3),Vertex_handle(0),Vertex_handle(1))); + + Complex complex; + //get complex from top faces + make_complex_from_top_faces(complex,simplices.begin(),simplices.end()); + + std::cout << "Simplices:"<. */ + #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_COMPLEX_VISITOR_H_ #define SKELETON_BLOCKER_SKELETON_BLOCKER_COMPLEX_VISITOR_H_ @@ -27,7 +28,7 @@ namespace Gudhi { namespace skeleton_blocker { -// todo rajouter les const +// TODO(DS): to be constified /** *@class Skeleton_blocker_complex_visitor @@ -36,7 +37,7 @@ namespace skeleton_blocker { template class Skeleton_blocker_complex_visitor { public: - virtual ~Skeleton_blocker_complex_visitor() {} + virtual ~Skeleton_blocker_complex_visitor() { } virtual void on_add_vertex(Vertex_handle) = 0; virtual void on_remove_vertex(Vertex_handle) = 0; @@ -61,9 +62,9 @@ class Skeleton_blocker_complex_visitor { virtual void on_swaped_edge(Vertex_handle a, Vertex_handle b, Vertex_handle x) = 0; virtual void on_add_blocker( - const Skeleton_blocker_simplex&) = 0; + const Skeleton_blocker_simplex&) = 0; virtual void on_delete_blocker( - const Skeleton_blocker_simplex*) = 0; + const Skeleton_blocker_simplex*) = 0; }; /** @@ -73,24 +74,23 @@ class Skeleton_blocker_complex_visitor { */ template class Dummy_complex_visitor : public Skeleton_blocker_complex_visitor< - Vertex_handle> { +Vertex_handle> { public: - void on_add_vertex(Vertex_handle) { - } - void on_remove_vertex(Vertex_handle) { - } - void on_add_edge_without_blockers(Vertex_handle a, Vertex_handle b) { - } - void on_remove_edge(Vertex_handle a, Vertex_handle b) { - } - void on_changed_edge(Vertex_handle a, Vertex_handle b) { - } - void on_swaped_edge(Vertex_handle a, Vertex_handle b, Vertex_handle x) { - } - void on_add_blocker(const Skeleton_blocker_simplex&) { - } - void on_delete_blocker(const Skeleton_blocker_simplex*) { - } + void on_add_vertex(Vertex_handle) { } + + void on_remove_vertex(Vertex_handle) { } + + void on_add_edge_without_blockers(Vertex_handle a, Vertex_handle b) { } + + void on_remove_edge(Vertex_handle a, Vertex_handle b) { } + + void on_changed_edge(Vertex_handle a, Vertex_handle b) { } + + void on_swaped_edge(Vertex_handle a, Vertex_handle b, Vertex_handle x) { } + + void on_add_blocker(const Skeleton_blocker_simplex&) { } + + void on_delete_blocker(const Skeleton_blocker_simplex*) { } }; /** @@ -100,29 +100,36 @@ class Dummy_complex_visitor : public Skeleton_blocker_complex_visitor< */ template class Print_complex_visitor : public Skeleton_blocker_complex_visitor< - Vertex_handle> { +Vertex_handle> { public: void on_add_vertex(Vertex_handle v) { std::cerr << "on_add_vertex:" << v << std::endl; } + void on_remove_vertex(Vertex_handle v) { std::cerr << "on_remove_vertex:" << v << std::endl; } + void on_add_edge_without_blockers(Vertex_handle a, Vertex_handle b) { std::cerr << "on_add_edge_without_blockers:" << a << "," << b << std::endl; } + void on_remove_edge(Vertex_handle a, Vertex_handle b) { std::cerr << "on_remove_edge:" << a << "," << b << std::endl; } + void on_changed_edge(Vertex_handle a, Vertex_handle b) { std::cerr << "on_changed_edge:" << a << "," << b << std::endl; } + void on_swaped_edge(Vertex_handle a, Vertex_handle b, Vertex_handle x) { std::cerr << "on_swaped_edge:" << a << "," << b << "," << x << std::endl; } + void on_add_blocker(const Skeleton_blocker_simplex& b) { std::cerr << "on_add_blocker:" << b << std::endl; } + void on_delete_blocker(const Skeleton_blocker_simplex* b) { std::cerr << "on_delete_blocker:" << b << std::endl; } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h index 3bfb5d11..d4b60613 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_LINK_SUPERIOR_H_ #define SKELETON_BLOCKER_SKELETON_BLOCKER_LINK_SUPERIOR_H_ @@ -36,7 +37,7 @@ template class Skeleton_blocker_sub_complex; */ template class Skeleton_blocker_link_superior : public Skeleton_blocker_link_complex< - ComplexType> { +ComplexType> { typedef typename ComplexType::Edge_handle Edge_handle; typedef typename ComplexType::boost_vertex_handle boost_vertex_handle; @@ -54,20 +55,17 @@ class Skeleton_blocker_link_superior : public Skeleton_blocker_link_complex< typedef typename ComplexType::Root_simplex_handle::Simplex_vertex_const_iterator IdSimplexConstIterator; Skeleton_blocker_link_superior() - : Skeleton_blocker_link_complex(true) { - } + : Skeleton_blocker_link_complex(true) { } Skeleton_blocker_link_superior(const ComplexType & parent_complex, Simplex& alpha_parent_adress) : Skeleton_blocker_link_complex(parent_complex, - alpha_parent_adress, true) { - } + alpha_parent_adress, true) { } Skeleton_blocker_link_superior(const ComplexType & parent_complex, Vertex_handle a_parent_adress) : Skeleton_blocker_link_complex(parent_complex, - a_parent_adress, true) { - } + a_parent_adress, true) { } }; } // namespace skeleton_blocker diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h index ba46c49e..747e60f1 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_ #define SKELETON_BLOCKER_SKELETON_BLOCKER_OFF_IO_H_ @@ -49,8 +50,8 @@ class Skeleton_blocker_off_flag_visitor_reader { load_only_points_(load_only_points) { } void init(int dim, int num_vertices, int num_faces, int num_edges) { - // todo do an assert to check that this number are correctly read - // todo reserve size for vector points + // TODO(DS): do an assert to check that this number are correctly read + // TODO(DS): reserve size for vector points } void point(const std::vector& point) { @@ -108,7 +109,7 @@ class Skeleton_blocker_off_visitor_reader { void done() { complex_ = make_complex_from_top_faces(maximal_faces_.begin(), maximal_faces_.end(), - points_.begin(), points_.end() ); + points_.begin(), points_.end()); } }; @@ -140,7 +141,7 @@ class Skeleton_blocker_off_reader { } /** - * return true iff reading did not meet problems. + * return true if reading did not meet problems. */ bool is_valid() const { return valid_; diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h index fb4a1106..275376e6 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_geometric_traits.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_GEOMETRIC_TRAITS_H_ #define SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_GEOMETRIC_TRAITS_H_ @@ -39,7 +40,7 @@ namespace skeleton_blocker { */ template struct Skeleton_blocker_simple_geometric_traits : - public Skeleton_blocker_simple_traits { +public Skeleton_blocker_simple_traits { public: typedef GeometryTrait GT; typedef typename GT::Point Point; @@ -57,19 +58,20 @@ struct Skeleton_blocker_simple_geometric_traits : Point& point() { return point_; } + const Point& point() const { return point_; } }; class Simple_geometric_edge : - public Skeleton_blocker_simple_traits::Graph_edge { + public Skeleton_blocker_simple_traits::Graph_edge { int index_; public: Simple_geometric_edge() : Skeleton_blocker_simple_traits::Graph_edge(), - index_(-1) { - } + index_(-1) { } + /** * @brief Allows to modify the index of the edge. * The indices of the edge are used to store heap information @@ -78,6 +80,7 @@ struct Skeleton_blocker_simple_geometric_traits : int& index() { return index_; } + int index() const { return index_; } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h index 31bec3b6..469717ae 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_ #define SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_ @@ -48,9 +49,9 @@ struct Skeleton_blocker_simple_traits { */ struct Root_vertex_handle { typedef int boost_vertex_handle; + explicit Root_vertex_handle(boost_vertex_handle val = -1) - : vertex(val) { - } + : vertex(val) { } boost_vertex_handle vertex; bool operator!=(const Root_vertex_handle& other) const { @@ -65,8 +66,8 @@ struct Skeleton_blocker_simple_traits { return this->vertex < other.vertex; } - friend std::ostream& operator <<(std::ostream& o, - const Root_vertex_handle & v) { + friend std::ostream& operator<<(std::ostream& o, + const Root_vertex_handle & v) { o << v.vertex; return o; } @@ -74,11 +75,13 @@ struct Skeleton_blocker_simple_traits { struct Vertex_handle { typedef int boost_vertex_handle; + explicit Vertex_handle(boost_vertex_handle val = -1) - : vertex(val) { - } + : vertex(val) { } - operator int() const { return static_cast(vertex); } + operator int() const { + return static_cast (vertex); + } boost_vertex_handle vertex; @@ -94,7 +97,7 @@ struct Skeleton_blocker_simple_traits { return this->vertex < other.vertex; } - friend std::ostream& operator <<(std::ostream& o, const Vertex_handle & v) { + friend std::ostream& operator<<(std::ostream& o, const Vertex_handle & v) { o << v.vertex; return o; } @@ -105,21 +108,24 @@ struct Skeleton_blocker_simple_traits { Root_vertex_handle id_; public: - virtual ~Graph_vertex() { - } + virtual ~Graph_vertex() { } void activate() { is_active_ = true; } + void deactivate() { is_active_ = false; } + bool is_active() const { return is_active_; } + void set_id(Root_vertex_handle i) { id_ = i; } + Root_vertex_handle get_id() const { return id_; } @@ -130,7 +136,7 @@ struct Skeleton_blocker_simple_traits { return res.str(); } - friend std::ostream& operator <<(std::ostream& o, const Graph_vertex & v) { + friend std::ostream& operator<<(std::ostream& o, const Graph_vertex & v) { o << v.to_string(); return o; } @@ -142,15 +148,16 @@ struct Skeleton_blocker_simple_traits { int index_; public: + Graph_edge() : a_(-1), - b_(-1), - index_(-1) { - } + b_(-1), + index_(-1) { } int& index() { return index_; } + int index() const { return index_; } @@ -168,7 +175,7 @@ struct Skeleton_blocker_simple_traits { return b_; } - friend std::ostream& operator <<(std::ostream& o, const Graph_edge & v) { + friend std::ostream& operator<<(std::ostream& o, const Graph_edge & v) { o << "(" << v.a_ << "," << v.b_ << " - id = " << v.index(); return o; } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h index 3c7f1dd5..aa6f2215 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -63,7 +63,6 @@ class Skeleton_blocker_simplex { */ //@{ - // Skeleton_blocker_simplex():simplex_set() {} void clear() { simplex_set.clear(); } @@ -89,8 +88,7 @@ class Skeleton_blocker_simplex { add_vertex(v); } - void add_vertices() { - } + void add_vertices() { } /** * Initialize a simplex with a string such as {0,1,2} @@ -192,7 +190,6 @@ class Skeleton_blocker_simplex { return simplex_set.crend(); } - typename std::set::iterator begin() { return simplex_set.begin(); } @@ -236,6 +233,7 @@ class Skeleton_blocker_simplex { assert(!empty()); return *(simplex_set.rbegin()); } + /** * @return true iff the simplex contains the simplex a. */ @@ -351,8 +349,8 @@ class Skeleton_blocker_simplex { //@} - friend std::ostream& operator <<(std::ostream& o, - const Skeleton_blocker_simplex & sigma) { + friend std::ostream& operator<<(std::ostream& o, + const Skeleton_blocker_simplex & sigma) { bool first = true; o << "{"; for (auto i : sigma) { diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h index 196fe8c0..fadf6619 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_sub_complex.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -159,7 +159,7 @@ class Skeleton_blocker_sub_complex : public ComplexType { if (simplex.contains(*blocker)) { Root_simplex_handle blocker_root(parent_complex.get_id(*(blocker))); Simplex blocker_restr( - *(this->get_simplex_address(blocker_root))); + *(this->get_simplex_address(blocker_root))); this->add_blocker(new Simplex(blocker_restr)); } } @@ -190,14 +190,15 @@ class Skeleton_blocker_sub_complex : public ComplexType { // */ // boost::optional get_address(const Root_simplex_handle & s) const; -// private: + // private: /** * same as get_address except that it will return a simplex in any case. * The vertices that were not found are not added. */ // @remark should be private but problem with VS + std::vector > get_addresses( - const Root_simplex_handle & s) const { + const Root_simplex_handle & s) const { std::vector < boost::optional > res; for (auto i : s) { res.push_back(get_address(i)); @@ -214,14 +215,14 @@ class Skeleton_blocker_sub_complex : public ComplexType { */ template bool proper_face_in_union( - Skeleton_blocker_sub_complex & link, - std::vector > & addresses_sigma_in_link, - int vertex_to_be_ignored) { + Skeleton_blocker_sub_complex & link, + std::vector > & addresses_sigma_in_link, + std::size_t vertex_to_be_ignored) { // we test that all vertices of 'addresses_sigma_in_link' but 'vertex_to_be_ignored' // are in link1 if it is the case we construct the corresponding simplex bool vertices_sigma_are_in_link = true; typename ComplexType::Simplex sigma_in_link; - for (int i = 0; i < addresses_sigma_in_link.size(); ++i) { + for (std::size_t i = 0; i < addresses_sigma_in_link.size(); ++i) { if (i != vertex_to_be_ignored) { if (!addresses_sigma_in_link[i]) { vertices_sigma_are_in_link = false; @@ -236,43 +237,24 @@ bool proper_face_in_union( return vertices_sigma_are_in_link && link.contains(sigma_in_link); } -/* - template - bool - proper_faces_in_union(Skeleton_blocker_simplex & sigma, Skeleton_blocker_sub_complex & link1, Skeleton_blocker_sub_complex & link2) - { - typedef typename ComplexType::Vertex_handle Vertex_handle; - std::vector > addresses_sigma_in_link1 = link1.get_addresses(sigma); - std::vector > addresses_sigma_in_link2 = link2.get_addresses(sigma); - - for (int current_index = 0; current_index < addresses_sigma_in_link1.size(); ++current_index) - { - - if (!proper_face_in_union(link1, addresses_sigma_in_link1, current_index) - && !proper_face_in_union(link2, addresses_sigma_in_link2, current_index)){ - return false; - } - } - return true; - }*/ - // Remark: this function should be friend in order to leave get_adresses private // however doing so seemes currently not possible due to a visual studio bug c2668 // "the compiler does not support partial ordering of template functions as specified in the C++ Standard" // http://www.serkey.com/error-c2668-ambiguous-call-to-overloaded-function-bb45ft.html + template bool proper_faces_in_union( - Skeleton_blocker_simplex & sigma, - Skeleton_blocker_sub_complex & link1, - Skeleton_blocker_sub_complex & link2) { + Skeleton_blocker_simplex & sigma, + Skeleton_blocker_sub_complex & link1, + Skeleton_blocker_sub_complex & link2) { typedef typename ComplexType::Vertex_handle Vertex_handle; std::vector < boost::optional > addresses_sigma_in_link1 = link1.get_addresses(sigma); std::vector < boost::optional > addresses_sigma_in_link2 = link2.get_addresses(sigma); - for (int current_index = 0; current_index < addresses_sigma_in_link1.size(); - ++current_index) { + for (std::size_t current_index = 0; current_index < addresses_sigma_in_link1.size(); + ++current_index) { if (!proper_face_in_union(link1, addresses_sigma_in_link1, current_index) && !proper_face_in_union(link2, addresses_sigma_in_link2, current_index)) { @@ -289,4 +271,3 @@ namespace skbl = skeleton_blocker; } // namespace Gudhi #endif // SKELETON_BLOCKER_SKELETON_BLOCKER_SUB_COMPLEX_H_ - diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Top_faces.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Top_faces.h index 39d95661..2b681752 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Top_faces.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Top_faces.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_ #define SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_ @@ -69,4 +70,4 @@ namespace skbl = skeleton_blocker; } // namespace Gudhi -#endif // SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_ +#endif // SKELETON_BLOCKER_INTERNAL_TOP_FACES_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h index cdc47b8a..ccc7c36b 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * 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 @@ -21,7 +21,6 @@ * */ - #ifndef SKELETON_BLOCKER_INTERNAL_TRIE_H_ #define SKELETON_BLOCKER_INTERNAL_TRIE_H_ @@ -46,6 +45,7 @@ struct Trie { const Trie* parent_; public: + Trie() : parent_(0) { } Trie(Vertex_handle v_) : v(v_), parent_(0) { } @@ -80,6 +80,7 @@ struct Trie { private: // go down recursively in the tree while advancing the simplex iterator. // when it reaches a leaf, it inserts the remaining that is not present + void add_simplex_helper(Simplex_vertex_const_iterator s_it, Simplex_vertex_const_iterator s_end) { assert(*s_it == v); ++s_it; @@ -105,6 +106,7 @@ struct Trie { } public: + /** * adds the simplex to the trie */ @@ -240,7 +242,7 @@ struct Tries { std::vector next_dimension_simplices() const { std::vector res; - while (!to_see_.empty() && to_see_.front()->simplex().dimension() == current_dimension_) { + while (!(to_see_.empty()) && (to_see_.front()->simplex().dimension() == current_dimension_)) { res.emplace_back(to_see_.front()->simplex()); for (auto child : to_see_.front()->childs) to_see_.push_back(child.get()); @@ -257,7 +259,7 @@ struct Tries { private: mutable std::deque to_see_; - mutable unsigned current_dimension_ = 0; + mutable int current_dimension_ = 0; std::vector cofaces_; }; diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h index 4dbc9ed3..4049fb0b 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_ #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_BLOCKERS_ITERATORS_H_ @@ -46,6 +47,7 @@ ReturnType MapIteratorType end_of_map; public: + Blocker_iterator_internal() : current_position() { } Blocker_iterator_internal(MapIteratorType position, MapIteratorType end_of_map_) : @@ -64,6 +66,7 @@ ReturnType } private: + /** * Let the current pair be (v,sigma) where v is a vertex and sigma is a blocker. * If v is not the first vertex of sigma then we already have seen sigma as a blocker diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_edges_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_edges_iterators.h index 15618932..b90dcf34 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_edges_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_edges_iterators.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_EDGES_ITERATORS_H_ #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_EDGES_ITERATORS_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_iterators.h index cc3ed276..1351614f 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_iterators.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h index 3b941be5..c9482263 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_SIMPLICES_ITERATORS_H_ #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_SIMPLICES_ITERATORS_H_ @@ -68,10 +69,10 @@ public boost::iterator_facade < Simplex_around_vertex_iterator link_v; std::shared_ptr trie; - std::list nodes_to_be_seen; // todo deque + std::list nodes_to_be_seen; // todo deque public: - Simplex_around_vertex_iterator() : complex(0) {} + Simplex_around_vertex_iterator() : complex(0) { } Simplex_around_vertex_iterator(const Complex* complex_, Vertex_handle v_) : complex(complex_), @@ -81,15 +82,16 @@ public boost::iterator_facade < Simplex_around_vertex_iterator } private: - // todo return to private Simplex_iterator(const Complex* complex, bool end) : complex_(complex) { set_end(); @@ -306,7 +307,7 @@ public boost::iterator_facade < Simplex_iterator /** * Iterator through the maximal faces of the coboundary of a simplex. - */ + */ template class Simplex_coboundary_iterator : public boost::iterator_facade < Simplex_coboundary_iterator @@ -329,7 +330,7 @@ public boost::iterator_facade < Simplex_coboundary_iteratorconvert_handle_from_another_complex(*link, link_vh); } -public: + public: friend std::ostream& operator<<(std::ostream& stream, const Simplex_coboundary_iterator& sci) { return stream; } @@ -369,8 +370,8 @@ public: // assume that iterator points to the same complex and comes from the same simplex bool equal(const Simplex_coboundary_iterator& other) const { assert(complex == other.complex && sigma == other.sigma); - if(is_end()) return other.is_end(); - if(other.is_end()) return is_end(); + if (is_end()) return other.is_end(); + if (other.is_end()) return is_end(); return *current_vertex == *(other.current_vertex); } @@ -384,13 +385,12 @@ public: return res; } -private: + private: bool is_end() const { return !link || current_vertex == link_vertex_end; } }; - } // namespace skeleton_blocker namespace skbl = skeleton_blocker; diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h index b2dd9a21..4e0dbb74 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_TRIANGLES_ITERATORS_H_ @@ -135,7 +136,7 @@ typename SkeletonBlockerComplex::Simplex const Triangle_iterator(const SkeletonBlockerComplex* complex) : complex_(complex), current_vertex_(complex->vertex_range().begin()), - current_triangle_(complex, *current_vertex_), // xxx this line is problematic is the complex is empty + current_triangle_(complex, *current_vertex_), // xxx this line is problematic is the complex is empty is_end_(false) { assert(!complex->empty()); gotoFirstTriangle(); @@ -172,7 +173,8 @@ typename SkeletonBlockerComplex::Simplex const bool both_arent_finished = !is_finished() && !other.is_finished(); // if the two iterators are not finished, they must have the same state return (complex_ == other.complex_) && (both_are_finished || ((both_arent_finished) && - current_vertex_ == other.current_vertex_ && current_triangle_ == other.current_triangle_)); + current_vertex_ == other.current_vertex_ && + current_triangle_ == other.current_triangle_)); } Simplex dereference() const { @@ -183,8 +185,8 @@ typename SkeletonBlockerComplex::Simplex const // goto the next vertex that has a triangle pending or the // end vertex iterator if none exists void goto_next_vertex() { - assert(current_triangle_.finished()); // we mush have consume all triangles passing through the vertex - assert(!is_finished()); // we must not be done + assert(current_triangle_.finished()); // we mush have consume all triangles passing through the vertex + assert(!is_finished()); // we must not be done ++current_vertex_; diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h index f06cab71..9e9ae961 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ #define SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ @@ -103,7 +104,7 @@ class Vertex_iterator : public boost::iterator_facade< Vertex_iterator -class Neighbors_vertices_iterator: public boost::iterator_facade < Neighbors_vertices_iterator +class Neighbors_vertices_iterator : public boost::iterator_facade < Neighbors_vertices_iterator , typename SkeletonBlockerComplex::Vertex_handle const , boost::forward_traversal_tag , typename SkeletonBlockerComplex::Vertex_handle const> { @@ -122,9 +123,6 @@ class Neighbors_vertices_iterator: public boost::iterator_facade < Neighbors_ver boost_adjacency_iterator end_; public: - // boost_adjacency_iterator ai, ai_end; - // for (tie(ai, ai_end) = adjacent_vertices(v.vertex, skeleton); ai != ai_end; ++ai) { - Neighbors_vertices_iterator() : complex(NULL) { } Neighbors_vertices_iterator(const Complex* complex_, Vertex_handle v_) : @@ -157,7 +155,7 @@ class Neighbors_vertices_iterator: public boost::iterator_facade < Neighbors_ver } private: - // todo remove this ugly hack + // TODO(DS): remove this ugly hack void set_end() { current_ = end_; } @@ -170,5 +168,3 @@ namespace skbl = skeleton_blocker; } // namespace Gudhi #endif // SKELETON_BLOCKER_ITERATORS_SKELETON_BLOCKERS_VERTICES_ITERATORS_H_ - - diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h index 7a6d1d50..c1a0cf2d 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -104,8 +104,8 @@ class Skeleton_blocker_complex { typedef typename Simplex::Simplex_vertex_const_iterator Simplex_handle_iterator; protected: - typedef typename boost::adjacency_list Graph; // todo/remark : edges are not sorted, it heavily penalizes computation for SuperiorLink // (eg Link with greater vertices) @@ -211,7 +211,6 @@ class Skeleton_blocker_complex { add_edge_without_blockers(e.first, e.second); } - template void add_blockers(SimpleHandleOutputIterator simplices_begin, SimpleHandleOutputIterator simplices_end) { Tries tries(num_vertices(), simplices_begin, simplices_end); @@ -414,7 +413,8 @@ class Skeleton_blocker_complex { /** */ bool contains_vertex(Vertex_handle u) const { - if (u.vertex < 0 || u.vertex >= boost::num_vertices(skeleton)) + Vertex_handle num_vertices(boost::num_vertices(skeleton)); + if (u.vertex < 0 || u.vertex >= num_vertices) return false; return (*this)[u].is_active(); } @@ -441,11 +441,11 @@ class Skeleton_blocker_complex { * @brief Given an Id return the address of the vertex having this Id in the complex. * @remark For a simplicial complex, the address is the id but it may not be the case for a SubComplex. */ - virtual boost::optional get_address( - Root_vertex_handle id) const { + virtual boost::optional get_address(Root_vertex_handle id) const { boost::optional res; - if (id.vertex < boost::num_vertices(skeleton)) - res = Vertex_handle(id.vertex); // xxx + int num_vertices = boost::num_vertices(skeleton); + if (id.vertex < num_vertices) + res = Vertex_handle(id.vertex); // xxx return res; } @@ -560,7 +560,7 @@ class Skeleton_blocker_complex { return res; } - /** + /** * @brief Adds all edges of s in the complex. */ void add_edge(const Simplex& s) { @@ -591,7 +591,6 @@ class Skeleton_blocker_complex { return *edge_handle; } - /** * @brief Adds all edges of s in the complex without adding blockers. */ @@ -844,12 +843,13 @@ class Skeleton_blocker_complex { boost_adjacency_iterator ai, ai_end; for (tie(ai, ai_end) = adjacent_vertices(v.vertex, skeleton); ai != ai_end; ++ai) { + Vertex_handle value(*ai); if (keep_only_superior) { - if (*ai > v.vertex) { - n.add_vertex(Vertex_handle(*ai)); + if (value > v.vertex) { + n.add_vertex(value); } } else { - n.add_vertex(Vertex_handle(*ai)); + n.add_vertex(value); } } } @@ -929,7 +929,7 @@ class Skeleton_blocker_complex { // xxx rename get_address et place un using dans sub_complex boost::optional get_simplex_address( - const Root_simplex_handle& s) const { + const Root_simplex_handle& s) const { boost::optional res; Simplex s_address; @@ -1001,10 +1001,9 @@ class Skeleton_blocker_complex { return std::distance(triangles.begin(), triangles.end()); } - /* * @brief returns the number of simplices of a given dimension in the complex. - */ + */ size_t num_simplices() const { auto simplices = complex_simplex_range(); return std::distance(simplices.begin(), simplices.end()); @@ -1012,8 +1011,8 @@ class Skeleton_blocker_complex { /* * @brief returns the number of simplices of a given dimension in the complex. - */ - size_t num_simplices(unsigned dimension) const { + */ + size_t num_simplices(int dimension) const { // TODO(DS): iterator on k-simplices size_t res = 0; for (const auto& s : complex_simplex_range()) diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h index 1130ca9f..95331b7a 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_ #define SKELETON_BLOCKER_GEOMETRIC_COMPLEX_H_ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h index 1bd66289..906d3e86 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_LINK_COMPLEX_H_ #define SKELETON_BLOCKER_LINK_COMPLEX_H_ @@ -39,7 +40,7 @@ template class Skeleton_blocker_sub_complex; */ template class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex< - ComplexType> { +ComplexType> { template friend class Skeleton_blocker_link_superior; typedef typename ComplexType::Edge_handle Edge_handle; @@ -60,8 +61,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex< typedef typename ComplexType::Root_simplex_handle::Simplex_vertex_const_iterator Root_simplex_handle_iterator; explicit Skeleton_blocker_link_complex(bool only_superior_vertices = false) - : only_superior_vertices_(only_superior_vertices) { - } + : only_superior_vertices_(only_superior_vertices) { } /** * If the parameter only_superior_vertices is true, @@ -95,10 +95,10 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex< */ Skeleton_blocker_link_complex(const ComplexType & parent_complex, Edge_handle edge, bool only_superior_vertices = - false) + false) : only_superior_vertices_(only_superior_vertices) { Simplex alpha_simplex(parent_complex.first_vertex(edge), - parent_complex.second_vertex(edge)); + parent_complex.second_vertex(edge)); build_link(parent_complex, alpha_simplex); } @@ -151,7 +151,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex< bool only_superior_vertices) { // for a vertex we know exactly the number of vertices of the link (and the size of the corresponding vector this->skeleton.m_vertices.reserve( - parent_complex.degree(alpha_parent_adress)); + parent_complex.degree(alpha_parent_adress)); // For all vertex 'v' in this intersection, we go through all its adjacent blockers. // If one blocker minus 'v' is included in alpha then the vertex is not in the link complex. @@ -169,21 +169,21 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex< return; for (auto x_link = this->vertex_range().begin(); - x_link != this->vertex_range().end(); ++x_link) { + x_link != this->vertex_range().end(); ++x_link) { for (auto y_link = x_link; ++y_link != this->vertex_range().end();) { Vertex_handle x_parent = *parent_complex.get_address( - this->get_id(*x_link)); + this->get_id(*x_link)); Vertex_handle y_parent = *parent_complex.get_address( - this->get_id(*y_link)); + this->get_id(*y_link)); if (parent_complex.contains_edge(x_parent, y_parent)) { // we check that there is no blocker subset of alpha passing trough x and y bool new_edge = true; for (auto blocker_parent : parent_complex.const_blocker_range( - x_parent)) { + x_parent)) { if (!is_alpha_blocker || *blocker_parent != alpha_parent_adress) { if (blocker_parent->contains(y_parent)) { new_edge = !(alpha_parent_adress.contains_difference( - *blocker_parent, x_parent, y_parent)); + *blocker_parent, x_parent, y_parent)); if (!new_edge) break; } @@ -202,7 +202,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex< * It assumes that other_complex have a vertex 'this.get_id(address)' */ boost::optional give_equivalent_vertex( - const ComplexType & other_complex, Vertex_handle address) const { + const ComplexType & other_complex, Vertex_handle address) const { Root_vertex_handle id((*this)[address].get_id()); return other_complex.get_address(id); } @@ -269,7 +269,7 @@ class Skeleton_blocker_link_complex : public Skeleton_blocker_sub_complex< bool only_vertices = false) { assert(is_alpha_blocker || parent_complex.contains(alpha_parent_adress)); compute_link_vertices(parent_complex, alpha_parent_adress, only_superior_vertices_); - if(!only_vertices) { + if (!only_vertices) { compute_link_edges(parent_complex, alpha_parent_adress, is_alpha_blocker); compute_link_blockers(parent_complex, alpha_parent_adress, is_alpha_blocker); } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h index 171efd4b..fcb6bafe 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -19,6 +19,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + #ifndef SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ #define SKELETON_BLOCKER_SIMPLIFIABLE_COMPLEX_H_ @@ -33,7 +34,7 @@ namespace Gudhi { namespace skeleton_blocker { /** - * Returns true iff the blocker 'sigma' is popable. + * Returns true if the blocker 'sigma' is popable. * To define popable, let us call 'L' the complex that * consists in the current complex without the blocker 'sigma'. * A blocker 'sigma' is then "popable" if the link of 'sigma' @@ -146,7 +147,7 @@ void Skeleton_blocker_complex::remove_star(Vertex_handle v) { */ template void Skeleton_blocker_complex::update_blockers_after_remove_star_of_vertex_or_edge( - const Simplex& simplex_to_be_removed) { + const Simplex& simplex_to_be_removed) { std::list blockers_to_update; if (simplex_to_be_removed.empty()) return; @@ -224,8 +225,6 @@ void Skeleton_blocker_complex::add_simplex(const Simplex& sig add_blockers_after_simplex_insertion(sigma); } - - template void Skeleton_blocker_complex::add_blockers_after_simplex_insertion(Simplex sigma) { if (sigma.dimension() < 1) return; @@ -385,7 +384,7 @@ Skeleton_blocker_complex::contract_edge(Vertex_handle a, Vert template void Skeleton_blocker_complex::get_blockers_to_be_added_after_contraction(Vertex_handle a, - Vertex_handle b, std::set& blockers_to_add) { + Vertex_handle b, std::set& blockers_to_add) { blockers_to_add.clear(); typedef Skeleton_blocker_link_complex > LinkComplexType; diff --git a/src/Skeleton_blocker/test/TestGeometricComplex.cpp b/src/Skeleton_blocker/test/TestGeometricComplex.cpp index 9edb13fe..102162c5 100644 --- a/src/Skeleton_blocker/test/TestGeometricComplex.cpp +++ b/src/Skeleton_blocker/test/TestGeometricComplex.cpp @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 diff --git a/src/Skeleton_blocker/test/TestSimplifiable.cpp b/src/Skeleton_blocker/test/TestSimplifiable.cpp index 76736240..6646734d 100644 --- a/src/Skeleton_blocker/test/TestSimplifiable.cpp +++ b/src/Skeleton_blocker/test/TestSimplifiable.cpp @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -20,14 +20,12 @@ * along with this program. If not, see . */ - #include #include #include #include #include #include "gudhi/Test.h" -//#include "Skeleton_blocker/Simplex.h" #include "gudhi/Skeleton_blocker.h" @@ -406,11 +404,11 @@ int main(int argc, char *argv[]) { tests_simplifiable_complex.add("Test collapse 2", test_collapse2); tests_simplifiable_complex.add("Test collapse 3", test_collapse3); - tests_simplifiable_complex.add("Test add edge",test_add_edge); + tests_simplifiable_complex.add("Test add edge", test_add_edge); tests_simplifiable_complex.add("Test add simplex", test_add_simplex); tests_simplifiable_complex.add("Test add simplex2", test_add_simplex2); - tests_simplifiable_complex.add("Test add simplex3",test_add_simplex3); - tests_simplifiable_complex.add("Test add simplex4",test_add_simplex4); + tests_simplifiable_complex.add("Test add simplex3", test_add_simplex3); + tests_simplifiable_complex.add("Test add simplex4", test_add_simplex4); tests_simplifiable_complex.run(); diff --git a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp index 6e891483..f61cffac 100644 --- a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp +++ b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp @@ -4,7 +4,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * 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 @@ -27,10 +27,6 @@ #include "gudhi/Debug_utils.h" #include "gudhi/Test.h" #include "gudhi/Skeleton_blocker.h" -//#include "gudhi/Skeleton_blocker_link_complex.h" -//#include "gudhi/Skeleton_blocker/Skeleton_blocker_link_superior.h" -//#include "gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h" -//#include "gudhi/Skeleton_blocker/internal/Trie.h" using namespace std; @@ -946,7 +942,4 @@ int main(int argc, char *argv[]) { } else { return EXIT_FAILURE; } - - // test_iterator_simplices(); } - -- cgit v1.2.3 From 865b64d6b006d7ce8d6ac179ea4df3dbddb8d85f Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 15 Sep 2016 15:04:01 +0000 Subject: Fix cpplint warnings git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/warning_fix@1503 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b4e1ec1b6cc95a6a7207e68fb31e064c0e3bd065 --- src/Simplex_tree/doc/Intro_simplex_tree.h | 3 +- .../example/Skeleton_blocker_from_simplices.cpp | 9 +- .../example/Skeleton_blocker_iteration.cpp | 8 +- .../example/Skeleton_blocker_link.cpp | 20 ++-- .../include/gudhi/Skeleton_blocker.h | 11 +- .../Skeleton_blocker_simple_traits.h | 1 - .../include/gudhi/Skeleton_blocker/internal/Trie.h | 3 - .../Skeleton_blockers_blockers_iterators.h | 2 - .../Skeleton_blockers_simplices_iterators.h | 6 +- .../Skeleton_blockers_triangles_iterators.h | 8 +- .../include/gudhi/Skeleton_blocker_complex.h | 6 +- .../include/gudhi/Skeleton_blocker_link_complex.h | 4 +- .../gudhi/Skeleton_blocker_simplifiable_complex.h | 6 +- src/Skeleton_blocker/test/TestGeometricComplex.cpp | 26 ++--- src/Skeleton_blocker/test/TestSimplifiable.cpp | 111 ++++++++++----------- .../test/TestSkeletonBlockerComplex.cpp | 102 +++++++++---------- 16 files changed, 152 insertions(+), 174 deletions(-) (limited to 'src/Simplex_tree') diff --git a/src/Simplex_tree/doc/Intro_simplex_tree.h b/src/Simplex_tree/doc/Intro_simplex_tree.h index ddf9ad22..be061785 100644 --- a/src/Simplex_tree/doc/Intro_simplex_tree.h +++ b/src/Simplex_tree/doc/Intro_simplex_tree.h @@ -28,6 +28,7 @@ namespace Gudhi { /** \defgroup simplex_tree Filtered Complexes + * @{ * \author Clément Maria * * A simplicial complex \f$\mathbf{K}\f$ on a set of vertices \f$V = \{1, \cdots ,|V|\}\f$ is a collection of @@ -76,7 +77,7 @@ Number of vertices = 10 Number of simplices = 98 \endcode * compact and harder to construct from scratch. * * \copyright GNU General Public License v3. - * @{ + * @} */ } // namespace Gudhi diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp index 5f89536b..076c6a53 100644 --- a/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp +++ b/src/Skeleton_blocker/example/Skeleton_blocker_from_simplices.cpp @@ -29,11 +29,8 @@ #include #include -using namespace std; -using namespace Gudhi; -using namespace skeleton_blocker; - -typedef Skeleton_blocker_complex Complex; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_simple_traits Traits; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_complex Complex; typedef Complex::Vertex_handle Vertex_handle; typedef Complex::Simplex Simplex; @@ -47,7 +44,7 @@ int main(int argc, char *argv[]) { simplices.push_back(Simplex(Vertex_handle(3), Vertex_handle(0), Vertex_handle(1))); // get complex from top faces - Complex complex(make_complex_from_top_faces(simplices.begin(), simplices.end())); + Complex complex(Gudhi::skeleton_blocker::make_complex_from_top_faces(simplices.begin(), simplices.end())); std::cout << "Simplices:" << std::endl; diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp index 7df0e3c9..6a1bc480 100644 --- a/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp +++ b/src/Skeleton_blocker/example/Skeleton_blocker_iteration.cpp @@ -30,12 +30,8 @@ #include #include - -using namespace std; -using namespace Gudhi; -using namespace skeleton_blocker; - -typedef Skeleton_blocker_complex Complex; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_simple_traits Traits; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_complex Complex; typedef Complex::Vertex_handle Vertex_handle; typedef Complex::Simplex Simplex; diff --git a/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp b/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp index e2a04d75..58322038 100644 --- a/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp +++ b/src/Skeleton_blocker/example/Skeleton_blocker_link.cpp @@ -28,11 +28,8 @@ #include #include -using namespace std; -using namespace Gudhi; -using namespace skeleton_blocker; - -typedef Skeleton_blocker_complex Complex; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_simple_traits Traits; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_complex Complex; typedef Complex::Vertex_handle Vertex_handle; typedef Complex::Root_vertex_handle Root_vertex_handle; typedef Complex::Simplex Simplex; @@ -47,25 +44,26 @@ int main(int argc, char *argv[]) { Simplex tetrahedron(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)); complex.add_simplex(tetrahedron); - cout << "complex:" << complex.to_string() << endl; + std::cout << "complex:" << complex.to_string() << std::endl; // build the link of vertex 1, eg a triangle {0,2,3} auto link = complex.link(Vertex_handle(1)); - cout << "link:" << link.to_string() << endl; + std::cout << "link:" << link.to_string() << std::endl; // Internally link is a subcomplex of 'complex' and its vertices are stored in a vector. // They can be accessed via Vertex_handle(x) where x is an index of the vector. // In that example, link has three vertices and thus it contains only // Vertex_handle(0),Vertex_handle(1) and Vertex_handle(2) are). for (int i = 0; i < 5; ++i) - cout << "link.contains_vertex(Vertex_handle(" << i << ")):" << link.contains_vertex(Vertex_handle(i)) << endl; - cout << endl; + std::cout << "link.contains_vertex(Vertex_handle(" << i << ")):" << link.contains_vertex(Vertex_handle(i)) << + std::endl; + std::cout << std::endl; // To access to the initial vertices eg (0,1,2,3,4), Root_vertex_handle must be used. // For instance, to test if the link contains the vertex that was labeled i: for (int i = 0; i < 5; ++i) - cout << "link.contains_vertex(Root_vertex_handle(" << i << ")):" << - link.contains_vertex(Root_vertex_handle(i)) << endl; + std::cout << "link.contains_vertex(Root_vertex_handle(" << i << ")):" << + link.contains_vertex(Root_vertex_handle(i)) << std::endl; return EXIT_SUCCESS; } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h index 85fada4f..bd907131 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h @@ -37,7 +37,8 @@ namespace Gudhi { namespace skeleton_blocker { -/** \defgroup skbl Skeleton-Blocker +/** \defgroup skbl Skeleton-Blocker +@{ \author David Salinas @@ -236,12 +237,12 @@ The author wishes to thank Dominique Attali and André Lieutier for their collaboration to write the two initial papers \cite socg_blockers_2011,\cite blockers2012 about this data-structure - and also Dominique for leaving him use a prototype. + and also Dominique for leaving him use a prototype. -\copyright GNU General Public License v3. - */ -/** @} */ // end defgroup +\copyright GNU General Public License v3. + +@} */ } // namespace skeleton_blocker diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h index 469717ae..3835cf77 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_simple_traits.h @@ -148,7 +148,6 @@ struct Skeleton_blocker_simple_traits { int index_; public: - Graph_edge() : a_(-1), b_(-1), diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h index ccc7c36b..b0ee35f5 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/internal/Trie.h @@ -45,7 +45,6 @@ struct Trie { const Trie* parent_; public: - Trie() : parent_(0) { } Trie(Vertex_handle v_) : v(v_), parent_(0) { } @@ -80,7 +79,6 @@ struct Trie { private: // go down recursively in the tree while advancing the simplex iterator. // when it reaches a leaf, it inserts the remaining that is not present - void add_simplex_helper(Simplex_vertex_const_iterator s_it, Simplex_vertex_const_iterator s_end) { assert(*s_it == v); ++s_it; @@ -106,7 +104,6 @@ struct Trie { } public: - /** * adds the simplex to the trie */ diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h index 4049fb0b..d2fff960 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_blockers_iterators.h @@ -47,7 +47,6 @@ ReturnType MapIteratorType end_of_map; public: - Blocker_iterator_internal() : current_position() { } Blocker_iterator_internal(MapIteratorType position, MapIteratorType end_of_map_) : @@ -66,7 +65,6 @@ ReturnType } private: - /** * Let the current pair be (v,sigma) where v is a vertex and sigma is a blocker. * If v is not the first vertex of sigma then we already have seen sigma as a blocker diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h index c9482263..20d5600c 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h @@ -69,7 +69,8 @@ public boost::iterator_facade < Simplex_around_vertex_iterator link_v; std::shared_ptr trie; - std::list nodes_to_be_seen; // todo deque + // TODO(DS): use a deque instead + std::list nodes_to_be_seen; public: Simplex_around_vertex_iterator() : complex(0) { } @@ -161,7 +162,8 @@ public boost::iterator_facade < Simplex_around_vertex_iteratorvertex_range().begin()), - current_triangle_(complex, *current_vertex_), // xxx this line is problematic is the complex is empty + current_triangle_(complex, *current_vertex_), // this line is problematic is the complex is empty is_end_(false) { assert(!complex->empty()); gotoFirstTriangle(); @@ -185,8 +185,10 @@ typename SkeletonBlockerComplex::Simplex const // goto the next vertex that has a triangle pending or the // end vertex iterator if none exists void goto_next_vertex() { - assert(current_triangle_.finished()); // we mush have consume all triangles passing through the vertex - assert(!is_finished()); // we must not be done + // we must have consume all triangles passing through the vertex + assert(current_triangle_.finished()); + // we must not be done + assert(!is_finished()); ++current_vertex_; diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h index c1a0cf2d..4f052ba5 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h @@ -104,8 +104,8 @@ class Skeleton_blocker_complex { typedef typename Simplex::Simplex_vertex_const_iterator Simplex_handle_iterator; protected: - typedef typename boost::adjacency_list Graph; // todo/remark : edges are not sorted, it heavily penalizes computation for SuperiorLink // (eg Link with greater vertices) @@ -445,7 +445,7 @@ class Skeleton_blocker_complex { boost::optional res; int num_vertices = boost::num_vertices(skeleton); if (id.vertex < num_vertices) - res = Vertex_handle(id.vertex); // xxx + res = Vertex_handle(id.vertex); return res; } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h index 906d3e86..4db075b0 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_link_complex.h @@ -201,8 +201,8 @@ ComplexType> { * corresponding address in 'other_complex'. * It assumes that other_complex have a vertex 'this.get_id(address)' */ - boost::optional give_equivalent_vertex( - const ComplexType & other_complex, Vertex_handle address) const { + boost::optional give_equivalent_vertex(const ComplexType & other_complex, + Vertex_handle address) const { Root_vertex_handle id((*this)[address].get_id()); return other_complex.get_address(id); } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h index fcb6bafe..544e02e8 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h @@ -146,8 +146,7 @@ void Skeleton_blocker_complex::remove_star(Vertex_handle v) { * whenever the dimension of tau is at least 2. */ template -void Skeleton_blocker_complex::update_blockers_after_remove_star_of_vertex_or_edge( - const Simplex& simplex_to_be_removed) { +void Skeleton_blocker_complex::update_blockers_after_remove_star_of_vertex_or_edge(const Simplex& simplex_to_be_removed) { std::list blockers_to_update; if (simplex_to_be_removed.empty()) return; @@ -384,7 +383,8 @@ Skeleton_blocker_complex::contract_edge(Vertex_handle a, Vert template void Skeleton_blocker_complex::get_blockers_to_be_added_after_contraction(Vertex_handle a, - Vertex_handle b, std::set& blockers_to_add) { + Vertex_handle b, + std::set& blockers_to_add) { blockers_to_add.clear(); typedef Skeleton_blocker_link_complex > LinkComplexType; diff --git a/src/Skeleton_blocker/test/TestGeometricComplex.cpp b/src/Skeleton_blocker/test/TestGeometricComplex.cpp index 102162c5..c5351b04 100644 --- a/src/Skeleton_blocker/test/TestGeometricComplex.cpp +++ b/src/Skeleton_blocker/test/TestGeometricComplex.cpp @@ -25,26 +25,22 @@ #include #include #include -#include "gudhi/Test.h" -#include "gudhi/Skeleton_blocker.h" +#include +#include -using namespace std; -using namespace Gudhi; -using namespace skeleton_blocker; - struct Geometry_trait { typedef std::vector Point; }; typedef Geometry_trait::Point Point; -typedef Skeleton_blocker_simple_geometric_traits Complex_geometric_traits; -typedef Skeleton_blocker_geometric_complex< Complex_geometric_traits > Complex; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_simple_geometric_traits Complex_geometric_traits; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_geometric_complex< Complex_geometric_traits > Complex; typedef Complex::Vertex_handle Vertex_handle; bool test_constructor1() { Complex complex; - Skeleton_blocker_off_reader off_reader("test2.off", complex); + Gudhi::skeleton_blocker::Skeleton_blocker_off_reader off_reader("test2.off", complex); if (!off_reader.is_valid()) { std::cerr << "Unable to read file" << std::endl; return false; @@ -60,19 +56,19 @@ bool test_constructor1() { if (complex.num_vertices() != 7 || complex.num_edges() != 12 || complex.num_triangles() != 6) return false; - Skeleton_blocker_off_writer off_writer("tmp.off", complex); + Gudhi::skeleton_blocker::Skeleton_blocker_off_writer off_writer("tmp.off", complex); Complex same; - Skeleton_blocker_off_reader off_reader2("tmp.off", same); + Gudhi::skeleton_blocker::Skeleton_blocker_off_reader off_reader2("tmp.off", same); - std::cout << "\ncomplex:" << complex.to_string() << endl; - std::cout << "\nsame:" << same.to_string() << endl; + std::cout << "\ncomplex:" << complex.to_string() << std::endl; + std::cout << "\nsame:" << same.to_string() << std::endl; return (complex == same); } bool test_constructor2() { Complex complex; - Skeleton_blocker_off_reader off_reader("test2.off", complex); + Gudhi::skeleton_blocker::Skeleton_blocker_off_reader off_reader("test2.off", complex); if (!off_reader.is_valid()) { std::cerr << "Unable to read file" << std::endl; return false; @@ -89,7 +85,7 @@ bool test_constructor2() { auto link_0 = complex.abstract_link(Vertex_handle(0)); - std::cout << "\n link(0):" << link_0.to_string() << endl; + std::cout << "\n link(0):" << link_0.to_string() << std::endl; auto link_geometric_0 = complex.link(Vertex_handle(0)); diff --git a/src/Skeleton_blocker/test/TestSimplifiable.cpp b/src/Skeleton_blocker/test/TestSimplifiable.cpp index 6646734d..b5384318 100644 --- a/src/Skeleton_blocker/test/TestSimplifiable.cpp +++ b/src/Skeleton_blocker/test/TestSimplifiable.cpp @@ -25,21 +25,16 @@ #include #include #include -#include "gudhi/Test.h" -#include "gudhi/Skeleton_blocker.h" +#include +#include -using namespace std; - -using namespace Gudhi; - -using namespace skeleton_blocker; - template class Skeleton_blocker_sub_complex; -typedef Skeleton_blocker_complex Complex; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_simple_traits Traits; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_complex Complex; typedef Complex::Vertex_handle Vertex_handle; typedef Complex::Root_vertex_handle Root_vertex_handle; -typedef Skeleton_blocker_simplex Simplex; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_simplex Simplex; // true iff v \in complex bool assert_vertex(Complex &complex, Vertex_handle v) { @@ -80,12 +75,12 @@ bool test_contraction1() { static_cast (y))); // Print result - cerr << "complex before complex" << complex.to_string() << endl; + std::cerr << "complex before complex" << complex.to_string() << std::endl; - cerr << endl << endl; + std::cerr << std::endl << std::endl; complex.contract_edge(static_cast (a), static_cast (b)); // Print result - cerr << "ContractEdge(0,1)\n"; + std::cerr << "ContractEdge(0,1)\n"; PRINT(complex.to_string()); // verification @@ -120,13 +115,13 @@ bool test_contraction2() { complex.add_blocker(blocker); // Print result - cerr << "complex complex" << complex.to_string(); - cerr << endl << endl; + std::cerr << "complex complex" << complex.to_string(); + std::cerr << std::endl << std::endl; complex.contract_edge(static_cast (a), static_cast (b)); - cerr << "complex.ContractEdge(a,b)" << complex.to_string(); + std::cerr << "complex.ContractEdge(a,b)" << complex.to_string(); - cerr << endl << endl; + std::cerr << std::endl << std::endl; // there should be one blocker (a,c,d,e) in the complex bool test; @@ -145,8 +140,8 @@ bool test_link_condition1() { // Print result - cerr << "complex complex" << complex.to_string(); - cerr << endl << endl; + std::cerr << "complex complex" << complex.to_string(); + std::cerr << std::endl << std::endl; bool weak_link_condition = complex.link_condition(Vertex_handle(1), Vertex_handle(2), true); @@ -162,17 +157,17 @@ bool test_collapse0() { complex.add_edge_without_blockers(static_cast (2), static_cast (4)); complex.add_edge_without_blockers(static_cast (3), static_cast (4)); // Print result - cerr << "initial complex :\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "initial complex :\n" << complex.to_string(); + std::cerr << std::endl << std::endl; Simplex simplex_123(static_cast (1), static_cast (2), static_cast (3)); complex.remove_star(simplex_123); - cerr << "complex.remove_star(1,2,3):\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "complex.remove_star(1,2,3):\n" << complex.to_string(); + std::cerr << std::endl << std::endl; // verification bool blocker123_here = complex.contains_blocker(simplex_123); - cerr << "----> Ocomplex \n"; + std::cerr << "----> Ocomplex \n"; return blocker123_here; } @@ -181,18 +176,18 @@ bool test_collapse1() { build_complete(4, complex); complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3))); // Print result - cerr << "initial complex :\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "initial complex :\n" << complex.to_string(); + std::cerr << std::endl << std::endl; Simplex simplex_123(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)); complex.remove_star(simplex_123); - cerr << "complex.remove_star(1,2,3):\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "complex.remove_star(1,2,3):\n" << complex.to_string(); + std::cerr << std::endl << std::endl; // verification bool res = complex.contains_blocker(simplex_123); res = res && complex.num_blockers() == 1; - cerr << "----> Ocomplex \n"; + std::cerr << "----> Ocomplex \n"; return res; } @@ -205,13 +200,13 @@ bool test_collapse2() { complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4)); complex.add_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4))); // Print result - cerr << "initial complex :\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "initial complex :\n" << complex.to_string(); + std::cerr << std::endl << std::endl; Simplex sigma(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)); complex.remove_star(sigma); - cerr << "complex.remove_star(1,2,3):\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "complex.remove_star(1,2,3):\n" << complex.to_string(); + std::cerr << std::endl << std::endl; // verification bool blocker_removed = !complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4))); @@ -228,11 +223,11 @@ bool test_collapse3() { complex.add_edge_without_blockers(Vertex_handle(3), Vertex_handle(4)); complex.add_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4))); // Print result - cerr << "initial complex:\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "initial complex:\n" << complex.to_string(); + std::cerr << std::endl << std::endl; complex.remove_star(static_cast (2)); - cerr << "complex after remove star of 2:\n" << complex.to_string(); + std::cerr << "complex after remove star of 2:\n" << complex.to_string(); bool blocker134_here = complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(3), Vertex_handle(4))); bool blocker1234_here = complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3), Vertex_handle(4))); @@ -243,11 +238,11 @@ bool test_add_simplex() { Complex complex(4); build_complete(4, complex); complex.add_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(3))); - cerr << "initial complex:\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "initial complex:\n" << complex.to_string(); + std::cerr << std::endl << std::endl; complex.add_simplex(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(3))); - cerr << "complex after add_simplex:\n" << complex.to_string(); + std::cerr << "complex after add_simplex:\n" << complex.to_string(); return complex.num_blockers() == 1 && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3))); } @@ -256,8 +251,8 @@ bool test_add_simplex2() { Complex complex; build_complete(4, complex); // Print result - cerr << "initial complex:\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "initial complex:\n" << complex.to_string(); + std::cerr << std::endl << std::endl; Complex copy(complex.num_vertices()); @@ -273,7 +268,7 @@ bool test_add_simplex2() { } - cerr << "complex after add_simplex:\n" << copy.to_string(); + std::cerr << "complex after add_simplex:\n" << copy.to_string(); return complex.num_blockers() == copy.num_blockers() && @@ -288,11 +283,11 @@ bool test_add_simplex3() { Simplex sigma(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)); complex.add_blocker(sigma); // Print result - cerr << "initial complex:\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "initial complex:\n" << complex.to_string(); + std::cerr << std::endl << std::endl; complex.add_simplex(sigma); //should create two blockers 0123 and 0124 - cerr << "complex after adding simplex 012:\n" << complex.to_string(); + std::cerr << "complex after adding simplex 012:\n" << complex.to_string(); return complex.num_blockers() == 2 && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3))) && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(4))); @@ -334,11 +329,11 @@ bool test_add_edge() { complex.add_edge(Vertex_handle(i), Vertex_handle((i + 1) % 4)); // Print result - cerr << "initial complex:\n" << complex.to_string(); - cerr << endl << endl; + std::cerr << "initial complex:\n" << complex.to_string(); + std::cerr << std::endl << std::endl; complex.add_edge(Vertex_handle(1), Vertex_handle(3)); //should create two blockers 013 and 012 - cerr << "complex after adding edge 13:\n" << complex.to_string(); + std::cerr << "complex after adding edge 13:\n" << complex.to_string(); return complex.num_blockers() == 2 && complex.contains_blocker(Simplex(Vertex_handle(0), Vertex_handle(1), Vertex_handle(3))) && complex.contains_blocker(Simplex(Vertex_handle(1), Vertex_handle(2), Vertex_handle(3))); @@ -355,12 +350,12 @@ bool test_remove_popable_blockers() { complex.add_blocker(sigma1); complex.add_blocker(sigma2); - cerr << "complex complex" << complex.to_string(); - cerr << endl << endl; - cerr << "complex.RemovePopableBlockers();" << endl; + std::cerr << "complex complex" << complex.to_string(); + std::cerr << std::endl << std::endl; + std::cerr << "complex.RemovePopableBlockers();" << std::endl; complex.remove_popable_blockers(); - cerr << "complex complex" << complex.to_string(); - cerr << endl << endl; + std::cerr << "complex complex" << complex.to_string(); + std::cerr << std::endl << std::endl; bool test1 = (complex.num_blockers() == 1); @@ -380,13 +375,13 @@ bool test_remove_popable_blockers() { complex.add_blocker(sigma1); complex.add_blocker(sigma2); - cerr << "complex complex" << complex.to_string(); - cerr << endl << endl; - cerr << "complex.RemovePopableBlockers();" << endl; + std::cerr << "complex complex" << complex.to_string(); + std::cerr << std::endl << std::endl; + std::cerr << "complex.RemovePopableBlockers();" << std::endl; complex.remove_popable_blockers(); - cerr << "complex complex" << complex.to_string(); + std::cerr << "complex complex" << complex.to_string(); - cerr << endl << endl; + std::cerr << std::endl << std::endl; bool test2 = (complex.num_blockers() == 0); return test1&&test2; } diff --git a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp index f61cffac..c74f591e 100644 --- a/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp +++ b/src/Skeleton_blocker/test/TestSkeletonBlockerComplex.cpp @@ -24,18 +24,14 @@ #include #include #include -#include "gudhi/Debug_utils.h" -#include "gudhi/Test.h" -#include "gudhi/Skeleton_blocker.h" - -using namespace std; - -using namespace Gudhi; - -using namespace skeleton_blocker; - - -typedef Skeleton_blocker_complex Complex; +#include +#include +#include + +template class Skeleton_blocker_sub_complex; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_simple_traits Traits; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_complex Complex; +typedef Gudhi::skeleton_blocker::Skeleton_blocker_link_complex Skeleton_blocker_link_complex; typedef Complex::Vertex_handle Vertex_handle; typedef Complex::Root_vertex_handle Root_vertex_handle; typedef Complex::Simplex Simplex; @@ -120,10 +116,10 @@ bool test_num_simplices() { bool test_iterator_vertices1() { int n = 10; Complex complex(10); - cerr << "complex.num_vertices():" << complex.num_vertices() << endl; + std::cerr << "complex.num_vertices():" << complex.num_vertices() << std::endl; int num_vertex_seen = 0; for (auto vi : complex.vertex_range()) { - cerr << "vertex:" << vi << endl; + std::cerr << "vertex:" << vi << std::endl; ++num_vertex_seen; } return num_vertex_seen == n; @@ -133,11 +129,11 @@ bool test_iterator_vertices2() { int n = 10; Complex complex; build_complete(10, complex); - cerr << "complex.num_vertices():" << complex.num_vertices() << endl; - cerr << "complex.num_edges():" << complex.num_edges() << endl; + std::cerr << "complex.num_vertices():" << complex.num_vertices() << std::endl; + std::cerr << "complex.num_edges():" << complex.num_edges() << std::endl; int num_vertex_seen = 0; for (auto vi : complex.vertex_range(Vertex_handle(2))) { - cerr << "vertex:" << vi << endl; + std::cerr << "vertex:" << vi << std::endl; ++num_vertex_seen; } std::cerr << "num_vertex_seen:" << num_vertex_seen << std::endl; @@ -152,10 +148,10 @@ bool test_iterator_edge() { complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j)); complex.remove_edge(Vertex_handle(2), Vertex_handle(3)); complex.remove_edge(Vertex_handle(3), Vertex_handle(5)); - cerr << "complex.num_edges():" << complex.num_edges() << endl; + std::cerr << "complex.num_edges():" << complex.num_edges() << std::endl; int num_edges_seen = 0; for (auto edge : complex.edge_range()) { - cerr << "edge :" << complex[edge] << endl; + std::cerr << "edge :" << complex[edge] << std::endl; ++num_edges_seen; } @@ -170,10 +166,10 @@ bool test_iterator_edge2() { complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j)); complex.remove_edge(Vertex_handle(2), Vertex_handle(3)); complex.remove_edge(Vertex_handle(3), Vertex_handle(5)); - cerr << "complex.num_edges():" << complex.num_edges() << endl; + std::cerr << "complex.num_edges():" << complex.num_edges() << std::endl; int num_neigbors_seen = 0; for (auto neighbor : complex.vertex_range(Vertex_handle(2))) { - cerr << "neighbor" << neighbor << endl; + std::cerr << "neighbor" << neighbor << std::endl; ++num_neigbors_seen; } return num_neigbors_seen == 8; @@ -187,7 +183,7 @@ bool test_iterator_edge3() { complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j)); complex.remove_edge(Vertex_handle(2), Vertex_handle(3)); complex.remove_edge(Vertex_handle(3), Vertex_handle(5)); - cerr << "complex.num_edges():" << complex.num_edges() << endl; + std::cerr << "complex.num_edges():" << complex.num_edges() << std::endl; int num_neigbors_seen = 0; for (auto edge : complex.edge_range(Vertex_handle(2))) { std::cerr << edge << std::endl; @@ -432,7 +428,7 @@ bool test_link0() { complex.add_edge_without_blockers(Vertex_handle(b), Vertex_handle(c)); complex.add_edge_without_blockers(Vertex_handle(c), Vertex_handle(d)); Simplex alpha = Simplex(Vertex_handle(c)); - Skeleton_blocker_link_complex L(complex, alpha); + Skeleton_blocker_link_complex L(complex, alpha); auto L2 = complex.link(alpha); if (L != L2) return false; @@ -461,7 +457,7 @@ bool test_link1() { complex.add_edge_without_blockers(Vertex_handle(i), Vertex_handle(j)); } Simplex alpha(Vertex_handle(12), Vertex_handle(14)); - Skeleton_blocker_link_complex L(complex, alpha); + Skeleton_blocker_link_complex L(complex, alpha); // Complexes built auto L2 = complex.link(alpha); @@ -479,7 +475,7 @@ bool test_link1() { simplex.add_vertex(Root_vertex_handle(13)); bool test6(L.get_simplex_address(simplex)); bool test7 = L.contains(*(L.get_simplex_address(simplex))); - cerr << "----> Ocomplex \n"; + std::cerr << "----> Ocomplex \n"; return test1 && test2 && test3 && test4 && test5 && test6&&test7; } @@ -499,13 +495,13 @@ bool test_link2() { } complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(13))); alpha = Simplex(Vertex_handle(12), Vertex_handle(14)); - Skeleton_blocker_link_complex L(complex, alpha); + Skeleton_blocker_link_complex L(complex, alpha); // Complexes built // Print result - cerr << "complex complex" << complex.to_string(); - cerr << endl << endl; - cerr << "L= Link_complex(" << alpha << ") : \n" << L.to_string(); + std::cerr << "complex complex" << complex.to_string(); + std::cerr << std::endl << std::endl; + std::cerr << "L= Link_complex(" << alpha << ") : \n" << L.to_string(); auto L2 = complex.link(alpha); if (L != L2) return false; @@ -522,7 +518,7 @@ bool test_link2() { simplex.add_vertex(Root_vertex_handle(11)); simplex.add_vertex(Root_vertex_handle(13)); bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex))); - cerr << "----> Ocomplex \n"; + std::cerr << "----> Ocomplex \n"; return test1 && test2 && test3 && test4 && test5&&test6; } @@ -541,13 +537,13 @@ bool test_link3() { } complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(12))); alpha = Simplex(Vertex_handle(12), Vertex_handle(14)); - Skeleton_blocker_link_complex L(complex, alpha); + Skeleton_blocker_link_complex L(complex, alpha); // Complexes built // Print result - cerr << "complex complex" << complex.to_string(); - cerr << endl << endl; - cerr << "L= Link_complex(" << alpha << ") : \n" << L.to_string(); + std::cerr << "complex complex" << complex.to_string(); + std::cerr << std::endl << std::endl; + std::cerr << "L= Link_complex(" << alpha << ") : \n" << L.to_string(); auto L2 = complex.link(alpha); if (L != L2) return false; @@ -577,7 +573,7 @@ bool test_link4() { } complex.add_blocker(Simplex(Vertex_handle(10), Vertex_handle(11), Vertex_handle(12), Vertex_handle(13))); Simplex alpha(Vertex_handle(12), Vertex_handle(14)); - Skeleton_blocker_link_complex L(complex, alpha); + Skeleton_blocker_link_complex L(complex, alpha); // Complexes built // verification @@ -591,7 +587,7 @@ bool test_link4() { simplex.add_vertex(Root_vertex_handle(11)); simplex.add_vertex(Root_vertex_handle(13)); bool test6 = L.contains_blocker(*(L.get_simplex_address(simplex))); - cerr << "----> Ocomplex \n"; + std::cerr << "----> Ocomplex \n"; return test1 && test2 && test3 && test4 && test5&&test6; } @@ -605,11 +601,11 @@ bool test_link5() { Simplex alpha(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)); - Skeleton_blocker_link_complex L(complex, alpha); // Complexes built + Skeleton_blocker_link_complex L(complex, alpha); // Complexes built // Print result PRINT(complex.to_string()); - cerr << endl << endl; + std::cerr << std::endl << std::endl; PRINT(L.to_string()); // verification @@ -624,13 +620,13 @@ bool test_link6() { Simplex alpha(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2)); - Skeleton_blocker_link_complex link_blocker_alpha; + Skeleton_blocker_link_complex link_blocker_alpha; build_link_of_blocker(complex, alpha, link_blocker_alpha); // Print result PRINT(complex.to_string()); - cerr << endl << endl; + std::cerr << std::endl << std::endl; PRINT(link_blocker_alpha.to_string()); // verification @@ -653,7 +649,7 @@ bool test_link7() { Simplex alpha(Vertex_handle(3), Vertex_handle(4), Vertex_handle(5)); - Skeleton_blocker_link_complex link_blocker_alpha; + Skeleton_blocker_link_complex link_blocker_alpha; build_link_of_blocker(complex, alpha, link_blocker_alpha); @@ -661,10 +657,10 @@ bool test_link7() { // Print result PRINT(complex.to_string()); - cerr << endl << endl; + std::cerr << std::endl << std::endl; DBGVALUE(link_blocker_alpha.to_string()); - Skeleton_blocker_link_complex link_blocker_alpha_cpy = link_blocker_alpha; + Skeleton_blocker_link_complex link_blocker_alpha_cpy = link_blocker_alpha; DBGVALUE(link_blocker_alpha_cpy.to_string()); @@ -684,7 +680,7 @@ bool test_link7() { } template -void add_triangle_edges(int a, int b, int c, list& simplices) { +void add_triangle_edges(int a, int b, int c, std::list& simplices) { typedef SimplexHandle Simplex; typedef typename SimplexHandle::Vertex_handle Vertex_handle; @@ -694,14 +690,14 @@ void add_triangle_edges(int a, int b, int c, list& simplices) { } template -void add_triangle(int a, int b, int c, list& simplices) { +void add_triangle(int a, int b, int c, std::list& simplices) { typedef SimplexHandle Simplex; typedef typename SimplexHandle::Vertex_handle Vertex_handle; simplices.push_back(Simplex(Vertex_handle(a), Vertex_handle(b), Vertex_handle(c))); } bool test_constructor() { - list simplices; + std::list simplices; simplices.push_back(Simplex(Vertex_handle(0))); simplices.push_back(Simplex(Vertex_handle(1))); @@ -732,8 +728,8 @@ bool test_constructor() { return ( complex.num_vertices() == 6 && complex.num_edges() == 10 && complex.num_blockers() == 2); } -list subfaces(Simplex top_face) { - list res; +std::list subfaces(Simplex top_face) { + std::list res; if (top_face.dimension() == -1) return res; if (top_face.dimension() == 0) { res.push_back(top_face); @@ -742,7 +738,7 @@ list subfaces(Simplex top_face) { Vertex_handle first_vertex = top_face.first_vertex(); top_face.remove_vertex(first_vertex); res = subfaces(top_face); - list copy = res; + std::list copy = res; for (auto& simplex : copy) { simplex.add_vertex(first_vertex); } @@ -757,7 +753,7 @@ bool test_constructor2() { for (int i = 0; i < 5; ++i) simplex.add_vertex(static_cast (i)); - list simplices(subfaces(simplex)); + std::list simplices(subfaces(simplex)); simplices.remove(simplex); Complex complex(simplices.begin(), simplices.end()); @@ -765,7 +761,7 @@ bool test_constructor2() { PRINT(complex.to_string()); for (auto b : complex.const_blocker_range()) { - cout << "b:" << b << endl; + std::cout << "b:" << b << std::endl; } return ( complex.num_vertices() == 5 && complex.num_edges() == 10 && complex.num_blockers() == 1); @@ -873,7 +869,7 @@ bool test_constructor7() { simplices.push_back(Sh(Vh(3), Vh(0), Vh(1))); //get complex from top faces - Complex complex(make_complex_from_top_faces(simplices.begin(), simplices.end())); + Complex complex(Gudhi::skeleton_blocker::make_complex_from_top_faces(simplices.begin(), simplices.end())); DBGVALUE(complex.to_string()); @@ -895,7 +891,7 @@ bool test_constructor8() { simplices.push_back(Sh(Vh(2), Vh(3))); //get complex from top faces - Complex complex(make_complex_from_top_faces(simplices.begin(), simplices.end())); + Complex complex(Gudhi::skeleton_blocker::make_complex_from_top_faces(simplices.begin(), simplices.end())); DBGVALUE(complex.to_string()); -- cgit v1.2.3