Commit 3d648b23 authored by Max Lyon's avatar Max Lyon
Browse files

add elements and all_elements methods that return the range corresponding to the template argument

parent 34b2e958
...@@ -1169,6 +1169,9 @@ public: ...@@ -1169,6 +1169,9 @@ public:
&PolyConnectivity::faces_sbegin, &PolyConnectivity::faces_sbegin,
&PolyConnectivity::faces_end> ConstFaceRangeSkipping; &PolyConnectivity::faces_end> ConstFaceRangeSkipping;
template <typename HandleType>
struct ElementRange;
/** /**
* @return The vertices as a range object suitable * @return The vertices as a range object suitable
* for C++11 range based for loops. Will skip deleted vertices. * for C++11 range based for loops. Will skip deleted vertices.
...@@ -1217,6 +1220,21 @@ public: ...@@ -1217,6 +1220,21 @@ public:
*/ */
ConstFaceRange all_faces() const { return ConstFaceRange(*this); } ConstFaceRange all_faces() const { return ConstFaceRange(*this); }
/**
* @return The elements corresponding to the template type as a range object suitable
* for C++11 range based for loops. Will skip deleted faces.
*/
template <typename HandleType>
typename ElementRange<HandleType>::RangeSkipping elements() const;
/**
* @return The elements corresponding to the template type as a range object suitable
* for C++11 range based for loops. Will include deleted faces.
*/
template <typename HandleType>
typename ElementRange<HandleType>::Range all_elements() const;
/// Generic class for iterator ranges. /// Generic class for iterator ranges.
template< template<
typename CONTAINER_TYPE, typename CONTAINER_TYPE,
...@@ -1241,6 +1259,7 @@ public: ...@@ -1241,6 +1259,7 @@ public:
CENTER_ENTITY_TYPE center_; CENTER_ENTITY_TYPE center_;
}; };
typedef CirculatorRange< typedef CirculatorRange<
PolyConnectivity, PolyConnectivity,
ConstVertexVertexCWIter, ConstVertexVertexCWIter,
...@@ -1625,6 +1644,52 @@ private: // Working storage for add_face() ...@@ -1625,6 +1644,52 @@ private: // Working storage for add_face()
}; };
template <>
struct PolyConnectivity::ElementRange<VertexHandle>
{
using Range = ConstVertexRange;
using RangeSkipping = ConstVertexRangeSkipping;
};
template <>
struct PolyConnectivity::ElementRange<HalfedgeHandle>
{
using Range = ConstHalfedgeRange;
using RangeSkipping = ConstHalfedgeRangeSkipping;
};
template <>
struct PolyConnectivity::ElementRange<EdgeHandle>
{
using Range = ConstEdgeRange;
using RangeSkipping = ConstEdgeRangeSkipping;
};
template <>
struct PolyConnectivity::ElementRange<FaceHandle>
{
using Range = ConstFaceRange;
using RangeSkipping = ConstFaceRangeSkipping;
};
template <>
inline PolyConnectivity::ConstVertexRangeSkipping PolyConnectivity::elements<VertexHandle>() const { return ConstVertexRangeSkipping(*this); }
template <>
inline PolyConnectivity::ConstVertexRange PolyConnectivity::all_elements<VertexHandle>() const { return ConstVertexRange(*this); }
template <>
inline PolyConnectivity::ConstHalfedgeRangeSkipping PolyConnectivity::elements<HalfedgeHandle>() const { return ConstHalfedgeRangeSkipping(*this); }
template <>
inline PolyConnectivity::ConstHalfedgeRange PolyConnectivity::all_elements<HalfedgeHandle>() const { return ConstHalfedgeRange(*this); }
template <>
inline PolyConnectivity::ConstEdgeRangeSkipping PolyConnectivity::elements<EdgeHandle>() const { return ConstEdgeRangeSkipping(*this); }
template <>
inline PolyConnectivity::ConstEdgeRange PolyConnectivity::all_elements<EdgeHandle>() const { return ConstEdgeRange(*this); }
template <>
inline PolyConnectivity::ConstFaceRangeSkipping PolyConnectivity::elements<FaceHandle>() const { return ConstFaceRangeSkipping(*this); }
template <>
inline PolyConnectivity::ConstFaceRange PolyConnectivity::all_elements<FaceHandle>() const { return ConstFaceRange(*this); }
}//namespace OpenMesh }//namespace OpenMesh
#endif//OPENMESH_POLYCONNECTIVITY_HH #endif//OPENMESH_POLYCONNECTIVITY_HH
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