CVB++ 15.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
12 CVB_BEGIN_INLINE_NS
13
15
18 class Cuboid final
19 {
20 public:
22
25 Cuboid() noexcept = default;
26
28
34 Cuboid(ValueRange<double> xRange, ValueRange<double> yRange, ValueRange<double> zRange)
35 : data_({xRange, yRange, zRange})
36 {
37 }
38
40
44 ValueRange<double> XRange() const noexcept
45 {
46 return data_[0];
47 }
48
50
54 void SetXRange(ValueRange<double> xRange) noexcept
55 {
56 data_[0] = xRange;
57 }
58
60
64 ValueRange<double> YRange() const noexcept
65 {
66 return data_[1];
67 }
68
70
74 void SetYRange(ValueRange<double> yRange) noexcept
75 {
76 data_[1] = yRange;
77 }
78
80
84 ValueRange<double> ZRange() const noexcept
85 {
86 return data_[2];
87 }
88
90
94 void SetZRange(ValueRange<double> zRange) noexcept
95 {
96 data_[2] = zRange;
97 }
98
100
105 bool Contains(Point3D<double> point) const noexcept
106 {
107 return data_[0].Contains(point[0]) && data_[1].Contains(point[1]) && data_[2].Contains(point[2]);
108 }
109
111
116 bool IntersectsWith(Cuboid other) const noexcept
117 {
118 return other.data_[0].IntersectsWith(data_[0]) && other.data_[1].IntersectsWith(data_[1])
119 && other.data_[2].IntersectsWith(data_[2]);
120 }
121
123
128 bool operator==(const Cuboid &cuboid) const noexcept
129 {
130 return data_ == cuboid.data_;
131 }
132
134
139 bool operator!=(const Cuboid &cuboid) const noexcept
140 {
141 return !(*this == cuboid);
142 }
143
144 private:
146 };
147
148 CVB_END_INLINE_NS
149
150} // namespace Cvb
ValueRange< double > XRange() const noexcept
Get the range regarding the x-axis.
Definition cuboid.hpp:44
bool IntersectsWith(Cuboid other) const noexcept
Check if this cuboid intersects with another cuboid.
Definition cuboid.hpp:116
bool operator==(const Cuboid &cuboid) const noexcept
Compares to an other cuboid.
Definition cuboid.hpp:128
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:105
ValueRange< double > ZRange() const noexcept
Get the range regarding the z-axis.
Definition cuboid.hpp:84
bool operator!=(const Cuboid &cuboid) const noexcept
Compares to an other cuboid.
Definition cuboid.hpp:139
void SetYRange(ValueRange< double > yRange) noexcept
Set the range regarding the y-axis.
Definition cuboid.hpp:74
void SetXRange(ValueRange< double > xRange) noexcept
Set the range regarding the x-axis.
Definition cuboid.hpp:54
ValueRange< double > YRange() const noexcept
Get the range regarding the y-axis.
Definition cuboid.hpp:64
void SetZRange(ValueRange< double > zRange) noexcept
Set the range regarding the z-axis.
Definition cuboid.hpp:94
Multi-purpose 3D vector class.
Definition point_3d.hpp:22
Container for range definitions.
Definition value_range.hpp:17
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17