IDS peak IPL v1.17.2
Loading...
Searching...
No Matches
peak_ipl_rect.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <type_traits>
14#include <cmath>
15#include <limits>
16#include <tuple>
17
23
24namespace peak
25{
26namespace ipl
27{
32class Rect2D
33{
34 Point2D m_point{};
35 Size2D m_size{};
36
37public:
38 constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
39 : Rect2D({ x, y }, { width, height })
40 {}
41
42 constexpr Rect2D(const Point2D& point, const Size2D& size)
43 : m_point(point)
44 , m_size(size)
45 {}
46
49 {
50 return m_point;
51 }
52
55 {
56 return m_size;
57 }
58
60 PEAK_IPL_NO_DISCARD constexpr size_t left() const
61 {
62 return m_point.x;
63 }
64
66 PEAK_IPL_NO_DISCARD constexpr size_t right() const
67 {
68 return m_point.x + m_size.width;
69 }
70
72 PEAK_IPL_NO_DISCARD constexpr size_t top() const
73 {
74 return m_point.y;
75 }
76
78 PEAK_IPL_NO_DISCARD constexpr size_t bottom() const
79 {
80 return m_point.y + m_size.height;
81 }
82
84 constexpr void setSize(const Size2D& size)
85 {
86 m_size = size;
87 }
88
90 constexpr void setWidth(size_t width)
91 {
92 m_size.width = width;
93 }
94
96 constexpr void setHeight(size_t height)
97 {
98 m_size.height = height;
99 }
100
102 constexpr void setX(size_t x)
103 {
104 m_point.x = x;
105 }
106
108 constexpr void setY(size_t y)
109 {
110 m_point.y = y;
111 }
112};
113
114constexpr bool operator==(const Rect2D& lhs, const Rect2D& rhs)
115{
116 return (lhs.topLeft() == rhs.topLeft() && lhs.size() == rhs.size());
117}
118
119constexpr bool operator!=(const Rect2D& lhs, const Rect2D& rhs)
120{
121 return !(lhs == rhs);
122}
123
124} /* namespace ipl */
125} /* namespace peak */
Rectangle type.
Definition peak_ipl_rect.hpp:33
constexpr size_t left() const
Definition peak_ipl_rect.hpp:60
constexpr void setX(size_t x)
Definition peak_ipl_rect.hpp:102
constexpr size_t top() const
Definition peak_ipl_rect.hpp:72
constexpr void setY(size_t y)
Definition peak_ipl_rect.hpp:108
constexpr void setWidth(size_t width)
Definition peak_ipl_rect.hpp:90
constexpr Point2D topLeft() const
Definition peak_ipl_rect.hpp:48
constexpr Size2D size() const
Definition peak_ipl_rect.hpp:54
constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
Definition peak_ipl_rect.hpp:38
constexpr void setHeight(size_t height)
Definition peak_ipl_rect.hpp:96
constexpr size_t right() const
Definition peak_ipl_rect.hpp:66
constexpr void setSize(const Size2D &size)
Definition peak_ipl_rect.hpp:84
constexpr Rect2D(const Point2D &point, const Size2D &size)
Definition peak_ipl_rect.hpp:42
constexpr size_t bottom() const
Definition peak_ipl_rect.hpp:78
The "peak::ipl" namespace contains the whole image processing library.
bool operator!=(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition peak_ipl_sharpness.hpp:430
bool operator==(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition peak_ipl_sharpness.hpp:424
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:25
2D position in an image.
Definition peak_ipl_simple_types.hpp:250
2D size of an image.
Definition peak_ipl_simple_types.hpp:225