CVB++ 14.0
cuboid.hpp
1#pragma once
2
3#include <cmath>
4
5#include "global.hpp"
6#include "value_range.hpp"
7#include "point_3d.hpp"
8
9namespace Cvb
10{
11
12CVB_BEGIN_INLINE_NS
13
15
18class Cuboid final
19{
20 public:
21
23
26 Cuboid() noexcept = default;
27
28
29
31
37 Cuboid(ValueRange<double> xRange, ValueRange<double> yRange, ValueRange<double> zRange)
38 : data_({ xRange, yRange, zRange })
39 {
40 }
41
42
43
45
49 ValueRange<double> XRange() const noexcept
50 {
51 return data_[0];
52 }
53
54
56
60 void SetXRange(ValueRange<double> xRange) noexcept
61 {
62 data_[0] = xRange;
63 }
64
66
70 ValueRange<double> YRange() const noexcept
71 {
72 return data_[1];
73 }
74
76
80 void SetYRange(ValueRange<double> yRange) noexcept
81 {
82 data_[1] = yRange;
83 }
84
86
90 ValueRange<double> ZRange() const noexcept
91 {
92 return data_[2];
93 }
94
95
97
101 void SetZRange(ValueRange<double> zRange) noexcept
102 {
103 data_[2] = zRange;
104 }
105
106
107
108
110
115 bool Contains(Point3D<double> point) const noexcept
116 {
117 return data_[0].Contains(point[0])
118 && data_[1].Contains(point[1])
119 && data_[2].Contains(point[2]);
120 }
121
122
124
129 bool IntersectsWith(Cuboid other) const noexcept
130 {
131 return other.data_[0].IntersectsWith(data_[0])
132 && other.data_[1].IntersectsWith(data_[1])
133 && other.data_[2].IntersectsWith(data_[2]);
134 }
135
137
142 bool operator==(const Cuboid& cuboid) const noexcept
143 {
144 return data_ == cuboid.data_;
145 }
146
148
153 bool operator!=(const Cuboid& cuboid) const noexcept
154 {
155 return !(*this == cuboid);
156 }
157
158
159
160 private:
161
163};
164
165
166
167
168CVB_END_INLINE_NS
169
170}
3D rectangle in the X, Y and Z domain.
Definition: cuboid.hpp:19
ValueRange< double > XRange() const noexcept
Get the range regarding the x-axis.
Definition: cuboid.hpp:49
bool IntersectsWith(Cuboid other) const noexcept
Check if this cuboid intersects with another cuboid.
Definition: cuboid.hpp:129
bool operator==(const Cuboid &cuboid) const noexcept
Compares to an other cuboid.
Definition: cuboid.hpp:142
Cuboid() noexcept=default
Creates a default cuboid with value ranges from 0.0 to 0.0.
bool Contains(Point3D< double > point) const noexcept
Check if a point is inside the cuboid.
Definition: cuboid.hpp:115
ValueRange< double > ZRange() const noexcept
Get the range regarding the z-axis.
Definition: cuboid.hpp:90
bool operator!=(const Cuboid &cuboid) const noexcept
Compares to an other cuboid.
Definition: cuboid.hpp:153
void SetYRange(ValueRange< double > yRange) noexcept
Set the range regarding the y-axis.
Definition: cuboid.hpp:80
void SetXRange(ValueRange< double > xRange) noexcept
Set the range regarding the x-axis.
Definition: cuboid.hpp:60
ValueRange< double > YRange() const noexcept
Get the range regarding the y-axis.
Definition: cuboid.hpp:70
void SetZRange(ValueRange< double > zRange) noexcept
Set the range regarding the z-axis.
Definition: cuboid.hpp:101
Container for range definitions.
Definition: value_range.hpp:17
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24