From 56fdae5689fa3b99384a597af50cd92d2a4141d7 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Fri, 30 Jan 2015 10:39:46 +0000 Subject: Add insert_simplex_and_subfaces. Insert renamed insert_simplex. TU modified. Filtration propagation to be done. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@446 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 26cbe4f4abb3bdd5fb88959fd94f6ef30d283c3f --- src/Simplex_tree/include/gudhi/Simplex_tree.h | 37 ++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'src/Simplex_tree/include') diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 8d5dddce..2fbcb18c 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -234,7 +234,7 @@ class Simplex_tree { * * The filtration must be valid. If the filtration has not been initialized yet, the * method initializes it (i.e. order the simplices). */ - Filtration_simplex_range filtration_simplex_range(linear_indexing_tag) { + Filtration_simplex_range filtration_simplex_range(Indexing_tag) { if (filtration_vect_.empty()) { initialize_filtration(); } @@ -449,7 +449,7 @@ class Simplex_tree { * The type RandomAccessVertexRange must be a range for which .begin() and * .end() return random access iterators, with 'value_type' Vertex_handle. */ template - std::pair insert(RandomAccessVertexRange & simplex, + std::pair insert_simplex(RandomAccessVertexRange & simplex, Filtration_value filtration) { if (simplex.empty()) { return std::pair(null_simplex(), true); @@ -479,6 +479,37 @@ class Simplex_tree { return res_insert; } + + /** \brief Insert a N-simplex and all his subfaces, from a N-simplex represented by a range of + * Vertex_handles, in the simplicial complex. + * + * @param[in] Nsimplex range of Vertex_handles, representing the vertices of the new N-simplex + * @param[in] filtration the filtration value assigned to the new N-simplex. + */ + template + void insert_simplex_and_subfaces(RandomAccessVertexRange& Nsimplex, + Filtration_value filtration = 0.0) { + if (Nsimplex.size() > 1) { + for (unsigned int NIndex = 0; NIndex < Nsimplex.size(); NIndex++) { + // insert N (N-1)-Simplex + RandomAccessVertexRange NsimplexMinusOne; + for (unsigned int NListIter = 0; NListIter < Nsimplex.size() - 1; NListIter++) { + // (N-1)-Simplex creation + NsimplexMinusOne.push_back( Nsimplex[(NIndex + NListIter) % Nsimplex.size()]); + } + // (N-1)-Simplex recursive call + insert_simplex_and_subfaces(NsimplexMinusOne); + } + // N-Simplex insert + insert_simplex(Nsimplex, filtration); + } else if (Nsimplex.size() == 1) { + // 1-Simplex insert - End of recursivity + insert_simplex(Nsimplex, filtration); + } else { + // Nothing to insert - empty vector + } + } + /** \brief Assign a value 'key' to the key of the simplex * represented by the Simplex_handle 'sh'. */ void assign_key(Simplex_handle sh, Simplex_key key) { @@ -832,7 +863,7 @@ std::istream& operator>>(std::istream & is, Simplex_tree & st) { if (max_fil < fil) { max_fil = fil; } - st.insert(simplex, fil); // insert every simplex in the simplex tree + st.insert_simplex(simplex, fil); // insert every simplex in the simplex tree simplex.clear(); } st.set_num_simplices(num_simplices); -- cgit v1.2.3