IDS peak IPL v1.12.1
Loading...
Searching...
No Matches
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
22namespace peak
23{
24namespace ipl
25{
29class Rect2D
30{
31 Point2D m_point{};
32 Size2D m_size{};
33
34public:
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
46 {
47 return m_point;
48 }
49
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
111inline bool operator==(const Rect2D& lhs, const Rect2D& rhs)
112{
113 return (lhs.topLeft() == rhs.topLeft() && lhs.size() == rhs.size());
114}
115
116inline bool operator!=(const Rect2D& lhs, const Rect2D& rhs)
117{
118 return !(lhs == rhs);
119}
120
121} /* namespace ipl */
122} /* namespace peak */
Rectangle type.
Definition peak_ipl_rect.hpp:30
constexpr size_t left() const
Definition peak_ipl_rect.hpp:57
constexpr size_t top() const
Definition peak_ipl_rect.hpp:69
void setWidth(size_t width)
Definition peak_ipl_rect.hpp:87
constexpr Point2D topLeft() const
Definition peak_ipl_rect.hpp:45
constexpr Size2D size() const
Definition peak_ipl_rect.hpp:51
void setY(size_t y)
Definition peak_ipl_rect.hpp:105
constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
Definition peak_ipl_rect.hpp:35
void setX(size_t x)
Definition peak_ipl_rect.hpp:99
void setHeight(size_t height)
Definition peak_ipl_rect.hpp:93
void setSize(const Size2D &size)
Definition peak_ipl_rect.hpp:81
constexpr size_t right() const
Definition peak_ipl_rect.hpp:63
constexpr Rect2D(const Point2D &point, const Size2D &size)
Definition peak_ipl_rect.hpp:39
constexpr size_t bottom() const
Definition peak_ipl_rect.hpp:75
bool operator!=(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition peak_ipl_sharpness.hpp:427
bool operator==(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition peak_ipl_sharpness.hpp:421
The "peak::ipl" namespace contains the whole image processing library.
Definition peak_ipl_binning.hpp:23
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_backend.h:26
2D position in an image.
Definition peak_ipl_simple_types.hpp:240
size_t x
X position.
Definition peak_ipl_simple_types.hpp:241
size_t y
Y position.
Definition peak_ipl_simple_types.hpp:242
2D size of an image.
Definition peak_ipl_simple_types.hpp:216
size_t height
Height of size.
Definition peak_ipl_simple_types.hpp:218
size_t width
Width of size.
Definition peak_ipl_simple_types.hpp:217