CVB++ 15.0
cube_range.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
14 namespace Spectral
15 {
16
18
21 class CubeRange final
22 {
23 public:
25
28 CubeRange() noexcept = default;
29
31
37 CubeRange(ValueRange<int> samples, ValueRange<int> lines, ValueRange<int> bands)
38 : data_({samples, lines, bands})
39 {
40 }
41
43
48 ValueRange<int> Samples() const noexcept
49 {
50 return data_[0];
51 }
52
54
59 void SetSamples(ValueRange<int> samples) noexcept
60 {
61 data_[0] = samples;
62 }
63
65
70 ValueRange<int> Lines() const noexcept
71 {
72 return data_[1];
73 }
74
76
82 {
83 data_[1] = lines;
84 }
85
87
92 ValueRange<int> Bands() const noexcept
93 {
94 return data_[2];
95 }
96
98
103 void SetBands(ValueRange<int> bands) noexcept
104 {
105 data_[2] = bands;
106 }
107
109
115 bool Contains(Vector3D<int> value) const noexcept
116 {
117 return data_[0].Contains(value[0]) && data_[1].Contains(value[1]) && data_[2].Contains(value[2]);
118 }
119
121
127 bool IntersectsWith(CubeRange other) const noexcept
128 {
129 return other.data_[0].IntersectsWith(data_[0]) && other.data_[1].IntersectsWith(data_[1])
130 && other.data_[2].IntersectsWith(data_[2]);
131 }
132
134
139 bool operator==(const CubeRange &cubeRange) const noexcept
140 {
141 return data_ == cubeRange.data_;
142 }
143
145
150 bool operator!=(const CubeRange &cubeRange) const noexcept
151 {
152 return !(*this == cubeRange);
153 }
154
155 private:
156 std::array<ValueRange<int>, 3> data_{};
157 };
158
159 } // namespace Spectral
160
161 CVB_END_INLINE_NS
162
163} // namespace Cvb
void SetLines(ValueRange< int > lines)
Sets the range regarding the lines dimension.
Definition cube_range.hpp:81
ValueRange< int > Samples() const noexcept
Gets the range regarding the samples dimension.
Definition cube_range.hpp:48
ValueRange< int > Bands() const noexcept
Gets the range regarding bands dimension.
Definition cube_range.hpp:92
void SetSamples(ValueRange< int > samples) noexcept
Sets the range regarding samples dimension.
Definition cube_range.hpp:59
bool Contains(Vector3D< int > value) const noexcept
Checks if a the 3D value is inside the cube range.
Definition cube_range.hpp:115
bool operator!=(const CubeRange &cubeRange) const noexcept
Compares to an other cube range.
Definition cube_range.hpp:150
bool operator==(const CubeRange &cubeRange) const noexcept
Compares to an other cube range.
Definition cube_range.hpp:139
void SetBands(ValueRange< int > bands) noexcept
Sets the range regarding bands dimension.
Definition cube_range.hpp:103
bool IntersectsWith(CubeRange other) const noexcept
Checks if this cuboid intersects with another cube range.
Definition cube_range.hpp:127
CubeRange() noexcept=default
Creates a default cube range with value ranges from 0.0 to 0.0.
ValueRange< int > Lines() const noexcept
Gets the range regarding lines dimension.
Definition cube_range.hpp:70
Container for range definitions.
Definition value_range.hpp:17
Namespace for the Spectral package.
Definition arithmetic.hpp:14
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
Point3D< T > Vector3D
Alias for Point3D.
Definition point_3d.hpp:363