CVB++ 14.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
9
10namespace Cvb
11{
12
13CVB_BEGIN_INLINE_NS
14
15namespace Spectral
16{
17
18
20
23class CubeRange final
24{
25 public:
26
28
31 CubeRange() noexcept = default;
32
33
34
36
42 CubeRange(ValueRange<int> samples, ValueRange<int> lines, ValueRange<int> bands)
43 : data_({ samples, lines, bands })
44 {
45 }
46
47
48
50
55 ValueRange<int> Samples() const noexcept
56 {
57 return data_[0];
58 }
59
60
62
67 void SetSamples(ValueRange<int> samples) noexcept
68 {
69 data_[0] = samples;
70 }
71
73
78 ValueRange<int> Lines() const noexcept
79 {
80 return data_[1];
81 }
82
83
85
91 {
92 data_[1] = lines;
93 }
94
96
101 ValueRange<int> Bands() const noexcept
102 {
103 return data_[2];
104 }
105
107
112 void SetBands(ValueRange<int> bands) noexcept
113 {
114 data_[2] = bands;
115 }
116
117
118
120
126 bool Contains(Vector3D<int> value) const noexcept
127 {
128 return data_[0].Contains(value[0])
129 && data_[1].Contains(value[1])
130 && data_[2].Contains(value[2]);
131 }
132
133
135
141 bool IntersectsWith(CubeRange other) const noexcept
142 {
143 return other.data_[0].IntersectsWith(data_[0])
144 && other.data_[1].IntersectsWith(data_[1])
145 && other.data_[2].IntersectsWith(data_[2]);
146 }
147
149
154 bool operator==(const CubeRange& cubeRange) const noexcept
155 {
156 return data_ == cubeRange.data_;
157 }
158
160
165 bool operator!=(const CubeRange& cubeRange) const noexcept
166 {
167 return !(*this == cubeRange);
168 }
169
170
171
172 private:
173
174 std::array<ValueRange<int>, 3> data_{};
175};
176
177}
178
179
180CVB_END_INLINE_NS
181
182}
Multi-purpose 3D vector class.
Definition: point_3d.hpp:22
3D rectangle in the samples, lines and bands domain.
Definition: cube_range.hpp:24
void SetLines(ValueRange< int > lines)
Sets the range regarding the lines dimension.
Definition: cube_range.hpp:90
ValueRange< int > Samples() const noexcept
Gets the range regarding the samples dimension.
Definition: cube_range.hpp:55
ValueRange< int > Bands() const noexcept
Gets the range regarding bands dimension.
Definition: cube_range.hpp:101
void SetSamples(ValueRange< int > samples) noexcept
Sets the range regarding samples dimension.
Definition: cube_range.hpp:67
bool Contains(Vector3D< int > value) const noexcept
Checks if a the 3D value is inside the cube range.
Definition: cube_range.hpp:126
bool operator!=(const CubeRange &cubeRange) const noexcept
Compares to an other cube range.
Definition: cube_range.hpp:165
bool operator==(const CubeRange &cubeRange) const noexcept
Compares to an other cube range.
Definition: cube_range.hpp:154
void SetBands(ValueRange< int > bands) noexcept
Sets the range regarding bands dimension.
Definition: cube_range.hpp:112
bool IntersectsWith(CubeRange other) const noexcept
Checks if this cuboid intersects with another cube range.
Definition: cube_range.hpp:141
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:78
Container for range definitions.
Definition: value_range.hpp:17
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24