From 3bd89949a985e0c6b5494aee47de1576ce80b2c1 Mon Sep 17 00:00:00 2001 From: Hans-Christian Ebke Date: Tue, 11 Sep 2012 18:16:00 +0000 Subject: [PATCH] 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 --- src/OpenMesh/Core/Mesh/PolyConnectivity.hh | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.hh b/src/OpenMesh/Core/Mesh/PolyConnectivity.hh index 3f4415c1..48c65d81 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.hh +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.hh @@ -322,6 +322,40 @@ public: ConstFaceIter faces_end() const { return ConstFaceIter(*this, FaceHandle(n_faces())); } + template + 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 ConstVertexRange; + typedef EntityRange ConstHalfedgeRange; + typedef EntityRange ConstEdgeRange; + typedef EntityRange 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); } //@}