From 05bd4b83bd56e7b3dedcc513c07fd82be2198d3d Mon Sep 17 00:00:00 2001 From: salinasd Date: Mon, 23 Feb 2015 13:58:21 +0000 Subject: skbl renaming, new link methods for abstract link of geometrical complex git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@468 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cb85e1ae86635857fbaaa0781526cb3eeaa9a50a --- .../Skeleton_blocker/Skeleton_blocker_off_io.h | 6 +-- .../iterators/Skeleton_blockers_edges_iterators.h | 24 ++++----- .../Skeleton_blockers_simplices_iterators.h | 8 ++- .../Skeleton_blockers_triangles_iterators.h | 7 +-- .../Skeleton_blockers_vertices_iterators.h | 26 +++++----- .../include/gudhi/Skeleton_blocker_complex.h | 57 ++++++++++++---------- .../gudhi/Skeleton_blocker_geometric_complex.h | 31 +++++++++++- 7 files changed, 97 insertions(+), 62 deletions(-) (limited to 'src/Skeleton_blocker/include/gudhi') diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h index aaa682c3..c98b0b45 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/Skeleton_blocker_off_io.h @@ -134,7 +134,7 @@ public: Skeleton_blocker_off_reader(const std::string & name_file, Complex& read_complex, bool read_only_points = false,bool is_flag = false):valid_(false) { std::ifstream stream(name_file); if (stream.is_open()) { - if(is_flag){ + if(is_flag || read_only_points){ Skeleton_blocker_off_flag_visitor_reader off_visitor(read_complex, read_only_points); Off_reader off_reader(stream); valid_ = off_reader.read(off_visitor); @@ -184,8 +184,8 @@ public: for(auto v : save_complex.vertex_range()){ vertex_num[v]=current_vertex++; const auto& pt(save_complex.point(v)); - for(auto it = pt.begin();it!=pt.end();++it) - stream<<*it<<" "; + for(auto x : pt) + stream< -class Complex_edge_around_vertex_iterator : - public boost::iterator_facade < Complex_edge_around_vertex_iterator +class Edge_around_vertex_iterator : + public boost::iterator_facade < Edge_around_vertex_iterator , typename SkeletonBlockerComplex::Edge_handle const , boost::forward_traversal_tag , typename SkeletonBlockerComplex::Edge_handle const @@ -54,10 +54,10 @@ private: public: - Complex_edge_around_vertex_iterator():complex(NULL){ + Edge_around_vertex_iterator():complex(NULL){ } - Complex_edge_around_vertex_iterator(const Complex* complex_,Vertex_handle v_): + Edge_around_vertex_iterator(const Complex* complex_,Vertex_handle v_): complex(complex_), v(v_) { @@ -67,7 +67,7 @@ public: /** * returns an iterator to the end */ - Complex_edge_around_vertex_iterator(const Complex* complex_,Vertex_handle v_,int end): + Edge_around_vertex_iterator(const Complex* complex_,Vertex_handle v_,int end): complex(complex_), v(v_) { @@ -75,7 +75,7 @@ public: set_end(); } - bool equal(const Complex_edge_around_vertex_iterator& other) const{ + bool equal(const Edge_around_vertex_iterator& other) const{ return (complex== other.complex) && (v == other.v) && (current_ == other.current_) && (end_ == other.end_); } @@ -102,8 +102,8 @@ private: * */ template -class Complex_edge_iterator : -public boost::iterator_facade < Complex_edge_iterator +class Edge_iterator : +public boost::iterator_facade < Edge_iterator , typename SkeletonBlockerComplex::Edge_handle const , boost::forward_traversal_tag , typename SkeletonBlockerComplex::Edge_handle const @@ -120,10 +120,10 @@ public: const Complex* complex; std::pair edge_iterator ; - Complex_edge_iterator():complex(NULL){ + Edge_iterator():complex(NULL){ } - Complex_edge_iterator(const SkeletonBlockerComplex* complex_): + Edge_iterator(const SkeletonBlockerComplex* complex_): complex(complex_), edge_iterator(boost::edges(complex_->skeleton)) { @@ -132,7 +132,7 @@ public: /** * return an iterator to the end */ - Complex_edge_iterator(const SkeletonBlockerComplex* complex_,int end): + Edge_iterator(const SkeletonBlockerComplex* complex_,int end): complex(complex_), edge_iterator(boost::edges(complex_->skeleton)) { @@ -140,7 +140,7 @@ public: } - bool equal(const Complex_edge_iterator& other) const{ + bool equal(const Edge_iterator& other) const{ return (complex == other.complex) && (edge_iterator == other.edge_iterator); } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h index 0b397f56..666ce430 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_simplices_iterators.h @@ -67,7 +67,6 @@ class Simplex_around_vertex_iterator : typedef typename Link::Vertex_handle Link_vertex_handle; // Link_vertex_handle == Complex_Vertex_handle but this renaming helps avoiding confusion - typedef typename Gudhi::skbl::Trie Trie; @@ -97,8 +96,7 @@ public: v(other.v), link_v(other.link_v), trie(other.trie), - nodes_to_be_seen(other.nodes_to_be_seen) - { + nodes_to_be_seen(other.nodes_to_be_seen){ if(!other.is_end()){ } } @@ -237,7 +235,7 @@ class Simplex_iterator : typedef typename Complex::Edge_handle Edge_handle; typedef typename Complex::Simplex_handle Simplex_handle; - typedef typename Complex::CVI CVI; + typedef typename Complex::Complex_vertex_iterator Complex_vertex_iterator; typedef typename Link::Vertex_handle Link_vertex_handle; @@ -245,7 +243,7 @@ class Simplex_iterator : private: const Complex* complex_; - CVI current_vertex_; + Complex_vertex_iterator current_vertex_; typedef Simplex_around_vertex_iterator SAVI; SAVI current_simplex_around_current_vertex_; diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h index 1fdbdfc9..e137d1ea 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_triangles_iterators.h @@ -49,7 +49,7 @@ private: typedef typename LinkType::Vertex_handle Vertex_handle; typedef typename LinkType::Root_vertex_handle Root_vertex_handle; typedef typename LinkType::Simplex_handle Simplex_handle; - typedef Complex_edge_iterator Complex_edge_iterator_; + typedef typename Complex::Complex_edge_iterator Complex_edge_iterator_; const Complex* complex_; Vertex_handle v_; @@ -133,9 +133,10 @@ private: typedef typename SkeletonBlockerComplex::Root_vertex_handle Root_vertex_handle; typedef typename SkeletonBlockerComplex::Simplex_handle Simplex_handle; typedef typename SkeletonBlockerComplex::Superior_triangle_around_vertex_iterator STAVI; + typedef typename SkeletonBlockerComplex::Complex_vertex_iterator Complex_vertex_iterator; const SkeletonBlockerComplex* complex_; - Complex_vertex_iterator current_vertex_; + Complex_vertex_iterator current_vertex_; STAVI current_triangle_; bool is_end_; public: @@ -176,7 +177,7 @@ public: Triangle_iterator& operator=(const Triangle_iterator & other){ complex_ = other.complex_; - Complex_vertex_iterator current_vertex_; + Complex_vertex_iterator current_vertex_; STAVI current_triangle_; return *this; } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h index 4c90ee51..a9d4e373 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker/iterators/Skeleton_blockers_vertices_iterators.h @@ -35,8 +35,8 @@ namespace skbl { *@remark Incrementation increases Vertex_handle. */ template -class Complex_vertex_iterator : public boost::iterator_facade -< Complex_vertex_iterator +class Vertex_iterator : public boost::iterator_facade +< Vertex_iterator , typename SkeletonBlockerComplex::Vertex_handle const , boost::forward_traversal_tag , typename SkeletonBlockerComplex::Vertex_handle const @@ -52,10 +52,10 @@ private: public: - Complex_vertex_iterator():complex(NULL){ + Vertex_iterator():complex(NULL){ } - Complex_vertex_iterator(const SkeletonBlockerComplex* complex_): + Vertex_iterator(const SkeletonBlockerComplex* complex_): complex(complex_), vertexIterator(vertices(complex_->skeleton)){ if(!finished() && !is_active()) { @@ -66,7 +66,7 @@ public: /** * return an iterator to the end. */ - Complex_vertex_iterator(const SkeletonBlockerComplex* complex_,int end): + Vertex_iterator(const SkeletonBlockerComplex* complex_,int end): complex(complex_),vertexIterator(vertices(complex_->skeleton)){ vertexIterator.first = vertexIterator.second ; } @@ -77,11 +77,11 @@ public: return(Vertex_handle(*(vertexIterator.first))); } - bool equal(const Complex_vertex_iterator& other) const{ + bool equal(const Vertex_iterator& other) const{ return vertexIterator == other.vertexIterator && complex == other.complex; } - bool operator<(const Complex_vertex_iterator& other) const{ + bool operator<(const Vertex_iterator& other) const{ return dereference() -class Complex_neighbors_vertices_iterator -: public boost::iterator_facade < Complex_neighbors_vertices_iterator +class Neighbors_vertices_iterator +: public boost::iterator_facade < Neighbors_vertices_iterator , typename SkeletonBlockerComplex::Vertex_handle const , boost::forward_traversal_tag , typename SkeletonBlockerComplex::Vertex_handle const @@ -133,10 +133,10 @@ public: // boost_adjacency_iterator ai, ai_end; // for (tie(ai, ai_end) = adjacent_vertices(v.vertex, skeleton); ai != ai_end; ++ai){ - Complex_neighbors_vertices_iterator():complex(NULL){ + Neighbors_vertices_iterator():complex(NULL){ } - Complex_neighbors_vertices_iterator(const Complex* complex_,Vertex_handle v_): + Neighbors_vertices_iterator(const Complex* complex_,Vertex_handle v_): complex(complex_), v(v_){ tie(current_,end_) = adjacent_vertices(v.vertex, complex->skeleton); @@ -145,7 +145,7 @@ public: /** * returns an iterator to the end */ - Complex_neighbors_vertices_iterator(const Complex* complex_,Vertex_handle v_,int end): + Neighbors_vertices_iterator(const Complex* complex_,Vertex_handle v_,int end): complex(complex_), v(v_){ tie(current_,end_) = adjacent_vertices(v.vertex, complex->skeleton); @@ -162,7 +162,7 @@ public: return(Vertex_handle(*current_)); } - bool equal(const Complex_neighbors_vertices_iterator& other) const{ + bool equal(const Neighbors_vertices_iterator& other) const{ return (complex== other.complex) && (v == other.v) && (current_ == other.current_) && (end_ == other.end_); } diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h index 893c65c6..5b2c1f27 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_complex.h @@ -63,10 +63,10 @@ namespace skbl { */ template class Skeleton_blocker_complex { - template friend class Complex_vertex_iterator; - template friend class Complex_neighbors_vertices_iterator; - template friend class Complex_edge_iterator; - template friend class Complex_edge_around_vertex_iterator; + template friend class Vertex_iterator; + template friend class Neighbors_vertices_iterator; + template friend class Edge_iterator; + template friend class Edge_around_vertex_iterator; template friend class Skeleton_blocker_link_complex; template friend class Skeleton_blocker_link_superior; @@ -587,7 +587,6 @@ public: if (found) { if (visitor) visitor->on_remove_edge(a, b); - // if (heapCollapse.Contains(edge)) heapCollapse.Delete(edge); boost::remove_edge(a.vertex, b.vertex, skeleton); degree_[a.vertex]--; degree_[b.vertex]--; @@ -1237,35 +1236,34 @@ public: /** @name Vertex iterators */ //@{ - typedef Complex_vertex_iterator CVI; // todo rename + typedef Vertex_iterator Complex_vertex_iterator; // - // @brief Range over the vertices of the simplicial complex. + // Range over the vertices of the simplicial complex. // Methods .begin() and .end() return a Complex_vertex_iterator. // - typedef boost::iterator_range< - Complex_vertex_iterator > Complex_vertex_range; + typedef boost::iterator_range Complex_vertex_range; /** * @brief Returns a Complex_vertex_range over all vertices of the complex */ Complex_vertex_range vertex_range() const { - auto begin = Complex_vertex_iterator(this); - auto end = Complex_vertex_iterator(this, 0); + auto begin = Complex_vertex_iterator(this); + auto end = Complex_vertex_iterator(this, 0); return Complex_vertex_range(begin, end); } - typedef boost::iterator_range< - Complex_neighbors_vertices_iterator > Complex_neighbors_vertices_range; + typedef Neighbors_vertices_iterator Complex_neighbors_vertices_iterator; + + + typedef boost::iterator_range Complex_neighbors_vertices_range; /** * @brief Returns a Complex_edge_range over all edges of the simplicial complex that passes trough v */ Complex_neighbors_vertices_range vertex_range(Vertex_handle v) const { - auto begin = Complex_neighbors_vertices_iterator( - this, v); - auto end = Complex_neighbors_vertices_iterator( - this, v, 0); + auto begin = Complex_neighbors_vertices_iterator(this, v); + auto end = Complex_neighbors_vertices_iterator(this, v, 0); return Complex_neighbors_vertices_range(begin, end); } @@ -1275,28 +1273,33 @@ public: */ //@{ - typedef boost::iterator_range< - Complex_edge_iterator>> Complex_edge_range; + typedef Edge_iterator Complex_edge_iterator; + + + typedef boost::iterator_range Complex_edge_range; /** * @brief Returns a Complex_edge_range over all edges of the simplicial complex */ Complex_edge_range edge_range() const { - auto begin = Complex_edge_iterator> (this); - auto end = Complex_edge_iterator> (this, 0); + auto begin = Complex_edge_iterator(this); + auto end = Complex_edge_iterator(this, 0); return Complex_edge_range(begin, end); } - typedef boost::iterator_range >> - Complex_edge_around_vertex_range; + + typedef Edge_around_vertex_iterator Complex_edge_around_vertex_iterator; + + + typedef boost::iterator_range Complex_edge_around_vertex_range; /** * @brief Returns a Complex_edge_range over all edges of the simplicial complex that passes * through 'v' */ Complex_edge_around_vertex_range edge_range(Vertex_handle v) const { - auto begin = Complex_edge_around_vertex_iterator> (this, v); - auto end = Complex_edge_around_vertex_iterator> (this, v, 0); + auto begin = Complex_edge_around_vertex_iterator(this, v); + auto end = Complex_edge_around_vertex_iterator(this, v, 0); return Complex_edge_around_vertex_range(begin, end); } @@ -1327,6 +1330,10 @@ public: typedef boost::iterator_range > Complex_triangle_range; + + typedef Triangle_iterator Complex_triangle_iterator; + + /** * @brief Range over triangles of the simplicial complex. * Methods .begin() and .end() return a Triangle_around_vertex_iterator. diff --git a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h index bb58d0dc..ee56ce3b 100644 --- a/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h +++ b/src/Skeleton_blocker/include/gudhi/Skeleton_blocker_geometric_complex.h @@ -92,7 +92,8 @@ class Skeleton_blocker_geometric_complex : unsigned current = 0; complex=make_complex_from_top_faces(simplex_begin,simplex_end,is_flag_complex); for(auto point = points_begin; point != points_end; ++point) - complex.point(Vertex_handle(current++)) = Point(point->begin(),point->end()); + // complex.point(Vertex_handle(current++)) = Point(point->begin(),point->end()); + complex.point(Vertex_handle(current++)) = Point(*point); return complex; } @@ -185,6 +186,31 @@ class Skeleton_blocker_geometric_complex : return link; } + typedef Skeleton_blocker_link_complex> Abstract_link; + + /** + * Constructs the abstract link of v (without points coordinates). + */ + Abstract_link abstract_link(Vertex_handle v) const { + return Abstract_link(*this, Simplex_handle(v)); + } + + /** + * Constructs the link of 'simplex' with points coordinates. + */ + Geometric_link abstract_link(const Simplex_handle& simplex) const { + return Abstract_link(*this, simplex); + } + + /** + * Constructs the link of 'simplex' with points coordinates. + */ + Geometric_link abstract_link(Edge_handle edge) const { + return Abstract_link(*this, edge); + } + + + private: void add_points_to_link(Geometric_link& link) const { @@ -193,6 +219,9 @@ class Skeleton_blocker_geometric_complex : link.point(v) = (*this).point(v_root); } } + + + }; } // namespace skbl -- cgit v1.2.3