diff options
author | Maxim Pimenov <m@maps.me> | 2018-07-27 15:27:42 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <bykoianko@gmail.com> | 2018-08-01 13:45:25 +0300 |
commit | 00f2b4c78b3b4edb4218bcc59a5722e20f49a8e6 (patch) | |
tree | ad20c58cd0881fd33c121ea35666f48feb53c968 /geometry | |
parent | 2bc35257235bd3e4a6c6ba94f44d3eea8ad6a8fd (diff) |
[geometry] ForEachCorner and ForEachSide helpers in Rect.
Diffstat (limited to 'geometry')
-rw-r--r-- | geometry/rect2d.hpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/geometry/rect2d.hpp b/geometry/rect2d.hpp index e980a7b880..e0a26a37a3 100644 --- a/geometry/rect2d.hpp +++ b/geometry/rect2d.hpp @@ -122,6 +122,24 @@ public: Point<T> RightBottom() const { return Point<T>(m_maxX, m_minY); } Point<T> LeftBottom() const { return Point<T>(m_minX, m_minY); } + template <typename Fn> + void ForEachCorner(Fn && fn) const + { + fn(LeftTop()); + fn(LeftBottom()); + fn(RightBottom()); + fn(RightTop()); + } + + template <typename Fn> + void ForEachSide(Fn && fn) const + { + fn(LeftTop(), LeftBottom()); + fn(LeftBottom(), RightBottom()); + fn(RightBottom(), RightTop()); + fn(RightTop(), LeftTop()); + } + bool IsIntersect(Rect const & r) const { return !((m_maxX < r.m_minX) || (m_minX > r.m_maxX) || (m_maxY < r.m_minY) || |