IDS peak IPL  v1.9.2
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 {
29 class Rect2D
30 {
31  Point2D m_point{};
32  Size2D m_size{};
33 
34 public:
35  constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
36  : Rect2D({ x, y }, { width, height })
37  {}
38 
39  constexpr Rect2D(const Point2D& point, const Size2D& size)
40  : m_point(point)
41  , m_size(size)
42  {}
43 
45  PEAK_IPL_NO_DISCARD constexpr Point2D topLeft() const
46  {
47  return m_point;
48  }
49 
51  PEAK_IPL_NO_DISCARD constexpr Size2D size() const
52  {
53  return m_size;
54  }
55 
57  PEAK_IPL_NO_DISCARD constexpr size_t left() const
58  {
59  return m_point.x;
60  }
61 
63  PEAK_IPL_NO_DISCARD constexpr size_t right() const
64  {
65  return m_point.x + m_size.width;
66  }
67 
69  PEAK_IPL_NO_DISCARD constexpr size_t top() const
70  {
71  return m_point.y;
72  }
73 
75  PEAK_IPL_NO_DISCARD constexpr size_t bottom() const
76  {
77  return m_point.y + m_size.height;
78  }
79 
81  void setSize(const Size2D& size)
82  {
83  m_size = size;
84  }
85 
87  void setWidth(size_t width)
88  {
89  m_size.width = width;
90  }
91 
93  void setHeight(size_t height)
94  {
95  m_size.height = height;
96  }
97 
99  void setX(size_t x)
100  {
101  m_point.x = x;
102  }
103 
105  void setY(size_t y)
106  {
107  m_point.y = y;
108  }
109 };
110 
111 inline bool operator==(const Rect2D& lhs, const Rect2D& rhs)
112 {
113  return (lhs.topLeft() == rhs.topLeft() && lhs.size() == rhs.size());
114 }
115 
116 inline bool operator!=(const Rect2D& lhs, const Rect2D& rhs)
117 {
118  return !(lhs == rhs);
119 }
120 
121 } /* namespace ipl */
122 } /* namespace peak */
#define PEAK_IPL_NO_DISCARD
Definition: peak_ipl_backend.h:26
constexpr Rect2D(const Point2D &point, const Size2D &size)
Definition: peak_ipl_rect.hpp:39
size_t height
Height of size.
Definition: peak_ipl_simple_types.hpp:206
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
2D size of an image.
Definition: peak_ipl_simple_types.hpp:203
bool operator!=(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition: peak_ipl_sharpness.hpp:425
bool operator==(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition: peak_ipl_sharpness.hpp:419
size_t width
Width of size.
Definition: peak_ipl_simple_types.hpp:205
Rectangle type.
Definition: peak_ipl_rect.hpp:29
constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
Definition: peak_ipl_rect.hpp:35