IDS peak IPL v1.17.0
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{
31class Rect2D
32{
33 Point2D m_point{};
34 Size2D m_size{};
35
36public:
37 constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
38 : Rect2D({ x, y }, { width, height })
39 {}
40
41 constexpr Rect2D(const Point2D& point, const Size2D& size)
42 : m_point(point)
43 , m_size(size)
44 {}
45
48 {
49 return m_point;
50 }
51
54 {
55 return m_size;
56 }
57
59 PEAK_IPL_NO_DISCARD constexpr size_t left() const
60 {
61 return m_point.x;
62 }
63
65 PEAK_IPL_NO_DISCARD constexpr size_t right() const
66 {
67 return m_point.x + m_size.width;
68 }
69
71 PEAK_IPL_NO_DISCARD constexpr size_t top() const
72 {
73 return m_point.y;
74 }
75
77 PEAK_IPL_NO_DISCARD constexpr size_t bottom() const
78 {
79 return m_point.y + m_size.height;
80 }
81
83 constexpr void setSize(const Size2D& size)
84 {
85 m_size = size;
86 }
87
89 constexpr void setWidth(size_t width)
90 {
91 m_size.width = width;
92 }
93
95 constexpr void setHeight(size_t height)
96 {
97 m_size.height = height;
98 }
99
101 constexpr void setX(size_t x)
102 {
103 m_point.x = x;
104 }
105
107 constexpr void setY(size_t y)
108 {
109 m_point.y = y;
110 }
111};
112
113constexpr bool operator==(const Rect2D& lhs, const Rect2D& rhs)
114{
115 return (lhs.topLeft() == rhs.topLeft() && lhs.size() == rhs.size());
116}
117
118constexpr bool operator!=(const Rect2D& lhs, const Rect2D& rhs)
119{
120 return !(lhs == rhs);
121}
122
123} /* namespace ipl */
124} /* namespace peak */
Rectangle type.
Definition peak_ipl_rect.hpp:32
constexpr size_t left() const
Definition peak_ipl_rect.hpp:59
constexpr void setX(size_t x)
Definition peak_ipl_rect.hpp:101
constexpr size_t top() const
Definition peak_ipl_rect.hpp:71
constexpr void setY(size_t y)
Definition peak_ipl_rect.hpp:107
constexpr void setWidth(size_t width)
Definition peak_ipl_rect.hpp:89
constexpr Point2D topLeft() const
Definition peak_ipl_rect.hpp:47
constexpr Size2D size() const
Definition peak_ipl_rect.hpp:53
constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
Definition peak_ipl_rect.hpp:37
constexpr void setHeight(size_t height)
Definition peak_ipl_rect.hpp:95
constexpr size_t right() const
Definition peak_ipl_rect.hpp:65
constexpr void setSize(const Size2D &size)
Definition peak_ipl_rect.hpp:83
constexpr Rect2D(const Point2D &point, const Size2D &size)
Definition peak_ipl_rect.hpp:41
constexpr size_t bottom() const
Definition peak_ipl_rect.hpp:77
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:429
bool operator==(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition peak_ipl_sharpness.hpp:423
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:25
2D position in an image.
Definition peak_ipl_simple_types.hpp:242
2D size of an image.
Definition peak_ipl_simple_types.hpp:218