IDS peak IPL v1.18.0
Loading...
Searching...
No Matches
peak_ipl_rect.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
8#include <type_traits>
9#include <cmath>
10#include <limits>
11#include <tuple>
12
18
19namespace peak
20{
21namespace ipl
22{
27class Rect2D
28{
29 Point2D m_point{};
30 Size2D m_size{};
31
32public:
33 constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
34 : Rect2D({ x, y }, { width, height })
35 {}
36
37 constexpr Rect2D(const Point2D& point, const Size2D& size)
38 : m_point(point)
39 , m_size(size)
40 {}
41
44 {
45 return m_point;
46 }
47
50 {
51 return m_size;
52 }
53
55 PEAK_IPL_NO_DISCARD constexpr size_t left() const
56 {
57 return m_point.x;
58 }
59
61 PEAK_IPL_NO_DISCARD constexpr size_t right() const
62 {
63 return m_point.x + m_size.width;
64 }
65
67 PEAK_IPL_NO_DISCARD constexpr size_t top() const
68 {
69 return m_point.y;
70 }
71
73 PEAK_IPL_NO_DISCARD constexpr size_t bottom() const
74 {
75 return m_point.y + m_size.height;
76 }
77
79 constexpr void setSize(const Size2D& size)
80 {
81 m_size = size;
82 }
83
85 constexpr void setWidth(size_t width)
86 {
87 m_size.width = width;
88 }
89
91 constexpr void setHeight(size_t height)
92 {
93 m_size.height = height;
94 }
95
97 constexpr void setX(size_t x)
98 {
99 m_point.x = x;
100 }
101
103 constexpr void setY(size_t y)
104 {
105 m_point.y = y;
106 }
107};
108
109constexpr bool operator==(const Rect2D& lhs, const Rect2D& rhs)
110{
111 return (lhs.topLeft() == rhs.topLeft() && lhs.size() == rhs.size());
112}
113
114constexpr bool operator!=(const Rect2D& lhs, const Rect2D& rhs)
115{
116 return !(lhs == rhs);
117}
118
119} /* namespace ipl */
120} /* namespace peak */
Rectangle type.
Definition peak_ipl_rect.hpp:28
constexpr size_t left() const
Definition peak_ipl_rect.hpp:55
constexpr void setX(size_t x)
Definition peak_ipl_rect.hpp:97
constexpr size_t top() const
Definition peak_ipl_rect.hpp:67
constexpr void setY(size_t y)
Definition peak_ipl_rect.hpp:103
constexpr void setWidth(size_t width)
Definition peak_ipl_rect.hpp:85
constexpr Point2D topLeft() const
Definition peak_ipl_rect.hpp:43
constexpr Size2D size() const
Definition peak_ipl_rect.hpp:49
constexpr Rect2D(size_t x, size_t y, size_t width, size_t height)
Definition peak_ipl_rect.hpp:33
constexpr void setHeight(size_t height)
Definition peak_ipl_rect.hpp:91
constexpr size_t right() const
Definition peak_ipl_rect.hpp:61
constexpr void setSize(const Size2D &size)
Definition peak_ipl_rect.hpp:79
constexpr Rect2D(const Point2D &point, const Size2D &size)
Definition peak_ipl_rect.hpp:37
constexpr size_t bottom() const
Definition peak_ipl_rect.hpp:73
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:425
bool operator==(const Sharpness::SharpnessROI &lhs, const Sharpness::SharpnessROI &rhs)
Definition peak_ipl_sharpness.hpp:419
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:20
2D position in an image.
Definition peak_ipl_simple_types.hpp:245
2D size of an image.
Definition peak_ipl_simple_types.hpp:220