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); } //@}