CVB++ 15.0
dense_components_pointers_3d.hpp
1#pragma once
2
3#include "components_pointers_3d.hpp"
4#include "size_2d.hpp"
5
6namespace Cvb
7{
8
9 CVB_BEGIN_INLINE_NS
10
12
13 template <class T>
14 class DenseComponentsPointers3D final
15 {
16 friend class DensePointCloud;
17
18 public:
19 DenseComponentsPointers3D() = default;
20
22
26 std::uintptr_t BasePtrX() const noexcept
27 {
28 return components_.BasePtrX();
29 }
30
32
36 std::uintptr_t BasePtrY() const noexcept
37 {
38 return components_.BasePtrY();
39 }
40
42
46 std::uintptr_t BasePtrZ() const noexcept
47 {
48 return components_.BasePtrZ();
49 }
50
52
56 std::uintptr_t BasePtrW() const noexcept
57 {
58 return components_.BasePtrW();
59 }
60
62
67 {
68 return components_.BasePtrConfidence();
69 }
70
72
76 std::intptr_t XInc() const noexcept
77 {
78 return components_.XInc();
79 }
80
82
86 std::intptr_t YInc() const noexcept
87 {
88 return components_.YInc();
89 }
90
92
96 std::intptr_t ZInc() const noexcept
97 {
98 return components_.ZInc();
99 }
100
102
106 std::intptr_t WInc() const noexcept
107 {
108 return components_.WInc();
109 }
110
112
117 {
118 return components_.ConfidenceInc();
119 }
120
122
128 T PointAt(std::size_t indexX, std::size_t indexY) const noexcept
129 {
130 return InternalPointAt(indexX, indexY, TypeTag<T>{});
131 }
132
134
140 void SetPointAt(std::size_t indexX, std::size_t indexY, T point) noexcept
141 {
142 return InternalSetPointAt(indexX, indexY, point);
143 }
144
146
150 Size2D<int> LatticeSize() const noexcept
151 {
152 return latticeSize_;
153 }
154
155 private:
156 explicit DenseComponentsPointers3D(const ComponentsPointers3D &components, Size2D<int> latticeSize)
157 : components_(components)
158 , latticeSize_(latticeSize)
159 {
160 }
161
162 template <class TYPE>
163 struct TypeTag
164 {
165 };
166
167 template <class TYPE>
168 Point3DC<TYPE> InternalPointAt(std::size_t indexX, std::size_t indexY, TypeTag<Point3DC<TYPE>>) const noexcept
169 {
170 auto x = *reinterpret_cast<TYPE *>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc());
171 auto y = *reinterpret_cast<TYPE *>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc());
172 auto z = *reinterpret_cast<TYPE *>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc());
173 auto c = *reinterpret_cast<TYPE *>(BasePtrConfidence() + indexY * latticeSize_.Width() * ConfidenceInc()
174 + indexX * ConfidenceInc());
175 return Point3DC<TYPE>(x, y, z, c);
176 }
177
178 template <class TYPE>
179 Point3DH<TYPE> InternalPointAt(std::size_t indexX, std::size_t indexY, TypeTag<Point3DH<TYPE>>) const noexcept
180 {
181 auto x = *reinterpret_cast<TYPE *>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc());
182 auto y = *reinterpret_cast<TYPE *>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc());
183 auto z = *reinterpret_cast<TYPE *>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc());
184 auto w = *reinterpret_cast<TYPE *>(BasePtrW() + indexY * latticeSize_.Width() * WInc() + indexX * WInc());
185 return Point3DH<TYPE>(x, y, z, w);
186 }
187
188 template <class TYPE>
189 Point3D<TYPE> InternalPointAt(std::size_t indexX, std::size_t indexY, TypeTag<Point3D<TYPE>>) const noexcept
190 {
191 auto x = *reinterpret_cast<TYPE *>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc());
192 auto y = *reinterpret_cast<TYPE *>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc());
193 auto z = *reinterpret_cast<TYPE *>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc());
194 return Point3D<TYPE>(x, y, z);
195 }
196
197 template <class TYPE>
198 void InternalSetPointAt(std::size_t indexX, std::size_t indexY, Point3DC<TYPE> point) noexcept
199 {
200 *reinterpret_cast<TYPE *>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc()) = point.X();
201 *reinterpret_cast<TYPE *>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc()) = point.Y();
202 *reinterpret_cast<TYPE *>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc()) = point.Z();
203 *reinterpret_cast<TYPE *>(BasePtrConfidence() + indexY * latticeSize_.Width() * ConfidenceInc()
204 + indexX * ConfidenceInc()) = point.Confidence();
205 }
206
207 template <class TYPE>
208 void InternalSetPointAt(std::size_t indexX, std::size_t indexY, Point3DH<TYPE> point) noexcept
209 {
210 *reinterpret_cast<TYPE *>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc()) = point.X();
211 *reinterpret_cast<TYPE *>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc()) = point.Y();
212 *reinterpret_cast<TYPE *>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc()) = point.Z();
213 *reinterpret_cast<TYPE *>(BasePtrW() + indexY * latticeSize_.Width() * WInc() + indexX * WInc()) = point.W();
214 }
215
216 template <class TYPE>
217 void InternalSetPointAt(std::size_t indexX, std::size_t indexY, Point3D<TYPE> point) noexcept
218 {
219 *reinterpret_cast<TYPE *>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc()) = point.X();
220 *reinterpret_cast<TYPE *>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc()) = point.Y();
221 *reinterpret_cast<TYPE *>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc()) = point.Z();
222 }
223
224 ComponentsPointers3D components_;
225 Size2D<int> latticeSize_;
226 };
227
228 CVB_END_INLINE_NS
229
230} // namespace Cvb
Point components of the point cloud.
Definition components_pointers_3d.hpp:18
Point components of a dense point cloud.
Definition dense_components_pointers_3d.hpp:15
void SetPointAt(std::size_t indexX, std::size_t indexY, T point) noexcept
Sets the point at the specified index.
Definition dense_components_pointers_3d.hpp:140
Size2D< int > LatticeSize() const noexcept
Gets the number of x,y,z(,w) point rows and columns of the PointCloud these components refer to.
Definition dense_components_pointers_3d.hpp:150
std::intptr_t ZInc() const noexcept
Increment to the next Z-component of the next point in bytes.
Definition dense_components_pointers_3d.hpp:96
std::uintptr_t BasePtrX() const noexcept
Variable to receive the pointer to the first X-component of the first point.
Definition dense_components_pointers_3d.hpp:26
std::intptr_t XInc() const noexcept
Increment to the next X-component of the next point in bytes.
Definition dense_components_pointers_3d.hpp:76
std::uintptr_t BasePtrZ() const noexcept
Variable to receive the pointer to the first Z-component of the first point.
Definition dense_components_pointers_3d.hpp:46
std::intptr_t ConfidenceInc() const noexcept
Increment to the next confidence-component of the next point in bytes (if present; nullptr if not).
Definition dense_components_pointers_3d.hpp:116
std::uintptr_t BasePtrConfidence() const noexcept
Variable to receive the pointer to the first confidence-component of the first point.
Definition dense_components_pointers_3d.hpp:66
std::uintptr_t BasePtrY() const noexcept
Variable to receive the pointer to the first Y-component of the first point.
Definition dense_components_pointers_3d.hpp:36
std::intptr_t YInc() const noexcept
Increment to the next Y-component of the next point in bytes.
Definition dense_components_pointers_3d.hpp:86
T PointAt(std::size_t indexX, std::size_t indexY) const noexcept
Gets the point at the specified index.
Definition dense_components_pointers_3d.hpp:128
std::uintptr_t BasePtrW() const noexcept
Variable to receive the pointer to the first W-component of the first point.
Definition dense_components_pointers_3d.hpp:56
std::intptr_t WInc() const noexcept
Increment to the next W-component of the next point in bytes (if present; nullptr if not).
Definition dense_components_pointers_3d.hpp:106
Stores a pair of numbers that represents the width and the height of a subject, typically a rectangle...
Definition size_2d.hpp:20
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17