Commit 3bd89949 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Added range based for loops compatible ranges to PolyConnectivity.

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@668 fdac6126-5c0c-442c-9429-916003d36597
parent 27d5229f
......@@ -322,6 +322,40 @@ public:
ConstFaceIter faces_end() const
{ return ConstFaceIter(*this, FaceHandle(n_faces())); }
template<typename CONTAINER_TYPE, typename ITER_TYPE, ITER_TYPE (CONTAINER_TYPE::*begin_fn)(), ITER_TYPE (CONTAINER_TYPE::*end_fn)()>
class EntityRange {
public:
EntityRange(CONTAINER_TYPE &container) : container_(container) {}
ITER_TYPE begin() { return (container_.*begin_fn)(); }
ITER_TYPE end() { return (container_.*end_fn)(); }
private:
CONTAINER_TYPE &container_;
};
typedef EntityRange<const PolyConnectivity, PolyConnectivity::ConstVertexIter, &PolyConnectivity::vertices_begin, &PolyConnectivity::vertices_end> ConstVertexRange;
typedef EntityRange<const PolyConnectivity, PolyConnectivity::ConstHalfedgeIter, &PolyConnectivity::halfedges_begin, &PolyConnectivity::halfedges_end> ConstHalfedgeRange;
typedef EntityRange<const PolyConnectivity, PolyConnectivity::ConstEdgeIter, &PolyConnectivity::edges_begin, &PolyConnectivity::edges_end> ConstEdgeRange;
typedef EntityRange<const PolyConnectivity, PolyConnectivity::ConstFaceIter, &PolyConnectivity::faces_begin, &PolyConnectivity::faces_end> ConstFaceRange;
/**
* @return The vertices as a range object suitable for C++11 range based for loops.
*/
ConstVertexRange vertices() const { return ConstVertexRange(*this); }
/**
* @return The vertices as a range object suitable for C++11 range based for loops.
*/
ConstHalfedgeRange halfedges() const { return ConstHalfedgeRange(*this); }
/**
* @return The vertices as a range object suitable for C++11 range based for loops.
*/
ConstEdgeRange edges() const { return ConstEdgeRange(*this); }
/**
* @return The vertices as a range object suitable for C++11 range based for loops.
*/
ConstFaceRange faces() const { return ConstFaceRange(*this); }
//@}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment