From f3b0595a69340ca5fee47b8c5686f69262beaa58 Mon Sep 17 00:00:00 2001 From: salinasd Date: Thu, 18 Dec 2014 13:29:14 +0000 Subject: skbl add_simplex method git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@382 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 0d325bee25bf0f45741aadd29ffe9628dcabb413 --- .../include/gudhi/Skeleton_blocker.h | 4 ++- .../include/gudhi/Skeleton_blocker_complex.h | 1 + .../gudhi/Skeleton_blocker_simplifiable_complex.h | 42 +++++++++++++++++++--- 3 files changed, 42 insertions(+), 5 deletions(-) (limited to 'src/Skeleton_blocker/include/gudhi') diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h index 77f59e35..8f7e1590 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker.h @@ -180,7 +180,9 @@ The Euler Characteristic is 1 \subsection Acknowledgements 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 +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. diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h index 81ff0231..02dffc15 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h @@ -717,6 +717,7 @@ public: * returns a Blocker_handle toward it if was not present before and 0 otherwise. */ Blocker_handle add_blocker(const Simplex_handle& blocker){ + assert(blocker.dimension()>1); if (contains_blocker(blocker)) { //std::cerr << "ATTEMPT TO ADD A BLOCKER ALREADY THERE ---> BLOCKER IGNORED" << endl; 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 1a51e709..d254222d 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_simplifiable_complex.h @@ -251,22 +251,56 @@ public: else if (sigma.dimension()==1) remove_star(sigma.first_vertex(),sigma.last_vertex()); + else{ + remove_blocker_containing_simplex(sigma); + this->add_blocker(sigma); + } + } + + /** + * @brief add the simplex plus all its cofaces + * @details in the case where sigma is a vertex, the simplex + * added has an id which is set to the number of vertices + */ + void add_simplex(const Simplex_handle& sigma){ + assert(!this->contains(sigma)); + if (sigma.dimension()==0) + this->add_vertex(); + else + if (sigma.dimension()==1) + this->add_edge(sigma.first_vertex(),sigma.last_vertex()); else - update_blockers_after_remove_star_of_simplex(sigma); + remove_blocker_include_in_simplex(sigma); } private: - void update_blockers_after_remove_star_of_simplex(const Simplex_handle& sigma){ - std::list blockers_to_remove; + /** + * remove all blockers that contains sigma + */ + void remove_blocker_containing_simplex(const Simplex_handle& sigma){ + std::vector blockers_to_remove; for (auto blocker : this->blocker_range(sigma.first_vertex())){ if(blocker->contains(sigma)) blockers_to_remove.push_back(blocker); } for(auto blocker_to_update : blockers_to_remove) this->delete_blocker(blocker_to_update); - this->add_blocker(sigma); } + /** + * remove all blockers that contains sigma + */ + void remove_blocker_include_in_simplex(const Simplex_handle& sigma){ + std::vector blockers_to_remove; + for (auto blocker : this->blocker_range(sigma.first_vertex())){ + if(sigma.contains(*blocker)) + blockers_to_remove.push_back(blocker); + } + for(auto blocker_to_update : blockers_to_remove) + this->delete_blocker(blocker_to_update); + } + + public: enum simplifiable_status{ NOT_HOMOTOPY_EQ,MAYBE_HOMOTOPY_EQ,HOMOTOPY_EQ}; -- cgit v1.2.3