summaryrefslogtreecommitdiff
path: root/src/python/include
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2020-03-17 13:57:29 +0100
committerMarc Glisse <marc.glisse@inria.fr>2020-03-17 13:57:29 +0100
commit2d3ab6a6a93c272827624e55ef39b093b3a9805b (patch)
tree08b278460a8d3212b3dcd03c2a5c06c77c7cf0c0 /src/python/include
parent55c1385419edd4e152df219dfff596d2631367f1 (diff)
parent559df19e65a7e2d45af9cc85e06af14b86d06009 (diff)
Merge remote-tracking branch 'origin/master' into gen2
Diffstat (limited to 'src/python/include')
-rw-r--r--src/python/include/Simplex_tree_interface.h64
1 files changed, 41 insertions, 23 deletions
diff --git a/src/python/include/Simplex_tree_interface.h b/src/python/include/Simplex_tree_interface.h
index 06f31341..4a7062d6 100644
--- a/src/python/include/Simplex_tree_interface.h
+++ b/src/python/include/Simplex_tree_interface.h
@@ -33,7 +33,10 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
using Simplex_handle = typename Base::Simplex_handle;
using Insertion_result = typename std::pair<Simplex_handle, bool>;
using Simplex = std::vector<Vertex_handle>;
- using Filtered_simplices = std::vector<std::pair<Simplex, Filtration_value>>;
+ using Simplex_and_filtration = std::pair<Simplex, Filtration_value>;
+ using Filtered_simplices = std::vector<Simplex_and_filtration>;
+ using Skeleton_simplex_iterator = typename Base::Skeleton_simplex_iterator;
+ using Complex_simplex_iterator = typename Base::Complex_simplex_iterator;
public:
bool find_simplex(const Simplex& vh) {
@@ -82,29 +85,12 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
Base::initialize_filtration();
}
- Filtered_simplices get_filtration() {
- Base::initialize_filtration();
- Filtered_simplices filtrations;
- for (auto f_simplex : Base::filtration_simplex_range()) {
- Simplex simplex;
- for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
- simplex.insert(simplex.begin(), vertex);
- }
- filtrations.push_back(std::make_pair(simplex, Base::filtration(f_simplex)));
- }
- return filtrations;
- }
-
- Filtered_simplices get_skeleton(int dimension) {
- Filtered_simplices skeletons;
- for (auto f_simplex : Base::skeleton_simplex_range(dimension)) {
- Simplex simplex;
- for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
- simplex.insert(simplex.begin(), vertex);
- }
- skeletons.push_back(std::make_pair(simplex, Base::filtration(f_simplex)));
+ Simplex_and_filtration get_simplex_and_filtration(Simplex_handle f_simplex) {
+ Simplex simplex;
+ for (auto vertex : Base::simplex_vertex_range(f_simplex)) {
+ simplex.insert(simplex.begin(), vertex);
}
- return skeletons;
+ return std::make_pair(std::move(simplex), Base::filtration(f_simplex));
}
Filtered_simplices get_star(const Simplex& simplex) {
@@ -135,6 +121,38 @@ class Simplex_tree_interface : public Simplex_tree<SimplexTreeOptions> {
Base::initialize_filtration();
pcoh = new Gudhi::Persistent_cohomology_interface<Base>(*this);
}
+
+ // Iterator over the simplex tree
+ Complex_simplex_iterator get_simplices_iterator_begin() {
+ // this specific case works because the range is just a pair of iterators - won't work if range was a vector
+ return Base::complex_simplex_range().begin();
+ }
+
+ Complex_simplex_iterator get_simplices_iterator_end() {
+ // this specific case works because the range is just a pair of iterators - won't work if range was a vector
+ return Base::complex_simplex_range().end();
+ }
+
+ typename std::vector<Simplex_handle>::const_iterator get_filtration_iterator_begin() {
+ // Base::initialize_filtration(); already performed in filtration_simplex_range
+ // this specific case works because the range is just a pair of iterators - won't work if range was a vector
+ return Base::filtration_simplex_range().begin();
+ }
+
+ typename std::vector<Simplex_handle>::const_iterator get_filtration_iterator_end() {
+ // this specific case works because the range is just a pair of iterators - won't work if range was a vector
+ return Base::filtration_simplex_range().end();
+ }
+
+ Skeleton_simplex_iterator get_skeleton_iterator_begin(int dimension) {
+ // this specific case works because the range is just a pair of iterators - won't work if range was a vector
+ return Base::skeleton_simplex_range(dimension).begin();
+ }
+
+ Skeleton_simplex_iterator get_skeleton_iterator_end(int dimension) {
+ // this specific case works because the range is just a pair of iterators - won't work if range was a vector
+ return Base::skeleton_simplex_range(dimension).end();
+ }
};
} // namespace Gudhi