diff options
author | Gard Spreemann <gspr@nonempty.org> | 2020-12-16 15:17:15 +0100 |
---|---|---|
committer | Gard Spreemann <gspr@nonempty.org> | 2020-12-16 15:17:15 +0100 |
commit | 289baa1aadd248940439698173caaa345ac0ba3d (patch) | |
tree | 719f4cee23b2eb5b98b51fb7520336df920024ae /src/Simplex_tree/include | |
parent | 5a450e1d5e0faac25085fb96d756d5963d0a15c4 (diff) | |
parent | b6a3def70b15baf2dda0844762dcd291e240d2c1 (diff) |
Merge branch 'dfsg/latest' into debian/sid
Diffstat (limited to 'src/Simplex_tree/include')
-rw-r--r-- | src/Simplex_tree/include/gudhi/Simplex_tree.h | 31 | ||||
-rw-r--r-- | src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h | 6 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h index 889dbd00..85d6c3b0 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h @@ -1667,6 +1667,37 @@ class Simplex_tree { return sh; // None of its faces has the same filtration. } + public: + /** \brief This function resets the filtration value of all the simplices of dimension at least min_dim. Resets all + * the Simplex_tree when `min_dim = 0`. + * `reset_filtration` may break the filtration property with `min_dim > 0`, and it is the user's responsibility to + * make it a valid filtration (using a large enough `filt_value`, or calling `make_filtration_non_decreasing` + * afterwards for instance). + * @param[in] filt_value The new filtration value. + * @param[in] min_dim The minimal dimension. Default value is 0. + */ + void reset_filtration(Filtration_value filt_value, int min_dim = 0) { + rec_reset_filtration(&root_, filt_value, min_dim); + clear_filtration(); // Drop the cache. + } + + private: + /** \brief Recursively resets filtration value when minimal depth <= 0. + * @param[in] sib Siblings to be parsed. + * @param[in] filt_value The new filtration value. + * @param[in] min_depth The minimal depth. + */ + void rec_reset_filtration(Siblings * sib, Filtration_value filt_value, int min_depth) { + for (auto sh = sib->members().begin(); sh != sib->members().end(); ++sh) { + if (min_depth <= 0) { + sh->second.assign_filtration(filt_value); + } + if (has_children(sh)) { + rec_reset_filtration(sh->second.children(), filt_value, min_depth - 1); + } + } + } + private: Vertex_handle null_vertex_; /** \brief Total number of simplices in the complex, without the empty simplex.*/ diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h index 9007b6bd..ee64a277 100644 --- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h +++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h @@ -85,6 +85,12 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade< typedef typename SimplexTree::Vertex_handle Vertex_handle; typedef typename SimplexTree::Siblings Siblings; + // For cython purpose only. The object it initializes should be overwritten ASAP and never used before it is overwritten. + Simplex_tree_boundary_simplex_iterator() + : sib_(nullptr), + st_(nullptr) { + } + // any end() iterator explicit Simplex_tree_boundary_simplex_iterator(SimplexTree * st) : last_(st->null_vertex()), |