summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/include
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-01-30 10:39:46 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2015-01-30 10:39:46 +0000
commit56fdae5689fa3b99384a597af50cd92d2a4141d7 (patch)
treec18fb7f5273fc64733a3a5033ddf36eabc1e61e7 /src/Simplex_tree/include
parentd08910390a55140278dd079876c1995844520d37 (diff)
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
Diffstat (limited to 'src/Simplex_tree/include')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h37
1 files changed, 34 insertions, 3 deletions
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<class RandomAccessVertexRange>
- std::pair<Simplex_handle, bool> insert(RandomAccessVertexRange & simplex,
+ std::pair<Simplex_handle, bool> insert_simplex(RandomAccessVertexRange & simplex,
Filtration_value filtration) {
if (simplex.empty()) {
return std::pair<Simplex_handle, bool>(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<class RandomAccessVertexRange>
+ 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<T1, T2, T3> & 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);