IDS peak IPL  v1.7.0
peak_ipl_rect.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <type_traits>
14 #include <cmath>
15 #include <limits>
16 #include <tuple>
17 
22 namespace peak
23 {
24 namespace ipl
25 {
30 class Rect2D
31 {
32  Point2D m_point{};
33  Size2D m_size{};
34 
35 public:
36  constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
37  : Rect2D({ x, y }, { width, height })
38  {}
39 
40  constexpr Rect2D(const Point2D& point, const Size2D& size)
41  : m_point(point)
42  , m_size(size)
43  {}
44 
46  constexpr Point2D topLeft() const
47  {
48  return m_point;
49  }
50 
52  constexpr Size2D size() const
53  {
54  return m_size;
55  }
56 
58  constexpr size_t left() const
59  {
60  return m_point.x;
61  }
62 
64  constexpr size_t right() const
65  {
66  return m_point.x + m_size.width;
67  }
68 
70  constexpr size_t top() const
71  {
72  return m_point.y;
73  }
74 
76  constexpr size_t bottom() const
77  {
78  return m_point.y + m_size.height;
79  }
80 
82  void setSize(const Size2D& size)
83  {
84  m_size = size;
85  }
86 
88  void setWidth(size_t width)
89  {
90  m_size.width = width;
91  }
92 
94  void setHeight(size_t height)
95  {
96  m_size.height = height;
97  }
98 
100  void setX(size_t x)
101  {
102  m_point.x = x;
103  }
104 
106  void setY(size_t y)
107  {
108  m_point.y = y;
109  }
110 };
111 
112 inline bool operator==(const Rect2D& lhs, const Rect2D& rhs)
113 {
114  return (lhs.topLeft() == rhs.topLeft() && lhs.size() == rhs.size());
115 }
116 
117 inline bool operator!=(const Rect2D& lhs, const Rect2D& rhs)
118 {
119  return !(lhs == rhs);
120 }
121 
122 } /* namespace ipl */
123 } /* namespace peak */
constexpr Point2D topLeft() const
Definition: peak_ipl_rect.hpp:46
constexpr Rect2D(const Point2D &point, const Size2D &size)
Definition: peak_ipl_rect.hpp:40
size_t height
Definition: peak_ipl_simple_types.hpp:180
void setY(size_t y)
Definition: peak_ipl_rect.hpp:106
constexpr size_t left() const
Definition: peak_ipl_rect.hpp:58
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
void setX(size_t x)
Definition: peak_ipl_rect.hpp:100
size_t x
Definition: peak_ipl_simple_types.hpp:197
2D size of an image.
Definition: peak_ipl_simple_types.hpp:177
bool operator!=(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition: peak_ipl_sharpness.hpp:325
void setWidth(size_t width)
Definition: peak_ipl_rect.hpp:88
2D position in an image.
Definition: peak_ipl_simple_types.hpp:195
constexpr size_t top() const
Definition: peak_ipl_rect.hpp:70
void setHeight(size_t height)
Definition: peak_ipl_rect.hpp:94
void setSize(const Size2D &size)
Definition: peak_ipl_rect.hpp:82
bool operator==(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition: peak_ipl_sharpness.hpp:319
constexpr size_t right() const
Definition: peak_ipl_rect.hpp:64
size_t width
Definition: peak_ipl_simple_types.hpp:179
constexpr size_t bottom() const
Definition: peak_ipl_rect.hpp:76
Rectangle.
Definition: peak_ipl_rect.hpp:30
constexpr Size2D size() const
Definition: peak_ipl_rect.hpp:52
constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
Definition: peak_ipl_rect.hpp:36
size_t y
Definition: peak_ipl_simple_types.hpp:198