diff options
author | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-12-07 14:45:43 +0000 |
---|---|---|
committer | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-12-07 14:45:43 +0000 |
commit | c4078affdbf6fac7150c10ade96fcb72270ac013 (patch) | |
tree | 1ad197bb90078a56036a49c6ee3766a032f85e63 /src/GudhUI/utils/Is_manifold.h | |
parent | f70e386fc98f1dbd8287d1cb7cc715710a8f751b (diff) | |
parent | 061e43a2a48525bc5a69482a1ea80f20ff505e55 (diff) |
Merged with trunk and removed unnecessary files
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/witness@934 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: d0ec52d222d22c102e9fe57590882cd0024c82d5
Diffstat (limited to 'src/GudhUI/utils/Is_manifold.h')
-rw-r--r-- | src/GudhUI/utils/Is_manifold.h | 117 |
1 files changed, 58 insertions, 59 deletions
diff --git a/src/GudhUI/utils/Is_manifold.h b/src/GudhUI/utils/Is_manifold.h index e708a6a4..0640ea47 100644 --- a/src/GudhUI/utils/Is_manifold.h +++ b/src/GudhUI/utils/Is_manifold.h @@ -7,7 +7,7 @@ * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,11 +25,10 @@ */ -#ifndef IS_MANIFOLD_H_ -#define IS_MANIFOLD_H_ +#ifndef UTILS_IS_MANIFOLD_H_ +#define UTILS_IS_MANIFOLD_H_ #include "utils/UI_utils.h" - #include "utils/Edge_contractor.h" /** @@ -38,67 +37,67 @@ * * todo do a sparsification with some parameter eps while growing */ -template<typename SkBlComplex> class Is_manifold{ -private: - const SkBlComplex& input_complex_; - typedef typename SkBlComplex::Vertex_handle Vertex_handle; +template<typename SkBlComplex> class Is_manifold { + private: + const SkBlComplex& input_complex_; + typedef typename SkBlComplex::Vertex_handle Vertex_handle; + public: + /* + * return dim the maximum dimension around one simplex and res which is true if the complex is a manifold. + * If the complex has dimension <= 3 then if res is false, the complex is not a manifold. + * For d-manifold with d>=4, res may be false while the complex is a manifold. + */ + Is_manifold(const SkBlComplex& input_complex, unsigned& dim, bool & res) : input_complex_(input_complex) { + res = true; + dim = -1; + if (!input_complex_.empty()) { + for (auto v : input_complex_.vertex_range()) { + dim = local_dimension(v); + break; + } + // check that the link of every vertex is a dim-1 sphere + for (auto v : input_complex_.vertex_range()) { + if (!is_k_sphere(v, dim - 1)) { + res = false; + break; + } + } + } + } -public: - /* - * return dim the maximum dimension around one simplex and res which is true if the complex is a manifold. - * If the complex has dimension <= 3 then if res is false, the complex is not a manifold. - * For d-manifold with d>=4, res may be false while the complex is a manifold. - */ - Is_manifold(const SkBlComplex& input_complex,unsigned& dim,bool & res):input_complex_(input_complex){ - res = true; - dim = -1; - if(!input_complex_.empty()){ - for(auto v : input_complex_.vertex_range()){ - dim = local_dimension(v); - break; - } - //check that the link of every vertex is a dim-1 sphere - for(auto v : input_complex_.vertex_range()){ - if(!is_k_sphere(v,dim-1)) { - res = false; - break; - } - } - } - } + private: + unsigned local_dimension(Vertex_handle v) { + unsigned dim = 0; + for (const auto& s : input_complex_.star_simplex_range(v)) + dim = (std::max)(dim, (unsigned) s.dimension()); + return dim; + } -private: - unsigned local_dimension(Vertex_handle v){ - unsigned dim = 0; - for(const auto& s: input_complex_.simplex_range(v)) - dim = (std::max)(dim,(unsigned)s.dimension()); - return dim; - } + bool is_k_sphere(Vertex_handle v, int k) { + auto link = input_complex_.link(v); + Edge_contractor<Complex> contractor(link, link.num_vertices() - 1); + return (is_sphere_simplex(link) == k); + } - bool is_k_sphere(Vertex_handle v,int k){ - auto link = input_complex_.link(v); - Edge_contractor<Complex> contractor(link,link.num_vertices()-1); - return (is_sphere_simplex(link)==k); - } + // A minimal sphere is a complex that contains vertices v1...vn and all faces + // made upon this set except the face {v1,...,vn} + // return -2 if not a minimal sphere + // and d otherwise if complex is a d minimal sphere - // A minimal sphere is a complex that contains vertices v1...vn and all faces - // made upon this set except the face {v1,...,vn} - // return -2 if not a minimal sphere - // and d otherwise if complex is a d minimal sphere - template<typename SubComplex> - int is_sphere_simplex(const SubComplex& complex){ - if(complex.empty()) return -1; - if(complex.num_blockers()!=1) return -2; + template<typename SubComplex> + int is_sphere_simplex(const SubComplex& complex) { + if (complex.empty()) return -1; + if (complex.num_blockers() != 1) return -2; - //necessary and sufficient condition : there exists a unique blocker that passes through all vertices - auto first_blocker = *(complex.const_blocker_range().begin()); + // necessary and sufficient condition : there exists a unique blocker that passes through all vertices + auto first_blocker = *(complex.const_blocker_range().begin()); - if (first_blocker->dimension()+1 != complex.num_vertices()) - return -2; - else - return (first_blocker->dimension()-1); - } + if (first_blocker->dimension() + 1 != complex.num_vertices()) + return -2; + else + return (first_blocker->dimension() - 1); + } }; -#endif /* IS_MANIFOLD_H_ */ +#endif // UTILS_IS_MANIFOLD_H_ |