CVB++ 14.1
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>
15 {
16 friend class DensePointCloud;
17
18 public:
19
20 DenseComponentsPointers3D() = default;
21
23
27 std::uintptr_t BasePtrX() const noexcept
28 {
29 return components_.BasePtrX();
30 }
31
33
37 std::uintptr_t BasePtrY() const noexcept
38 {
39 return components_.BasePtrY();
40 }
41
43
47 std::uintptr_t BasePtrZ() const noexcept
48 {
49 return components_.BasePtrZ();
50 }
51
53
57 std::uintptr_t BasePtrW() const noexcept
58 {
59 return components_.BasePtrW();
60 }
61
63
68 {
69 return components_.BasePtrConfidence();
70 }
71
73
77 std::intptr_t XInc() const noexcept
78 {
79 return components_.XInc();
80 }
81
83
87 std::intptr_t YInc() const noexcept
88 {
89 return components_.YInc();
90 }
91
93
97 std::intptr_t ZInc() const noexcept
98 {
99 return components_.ZInc();
100 }
101
103
107 std::intptr_t WInc() const noexcept
108 {
109 return components_.WInc();
110 }
111
113
118 {
119 return components_.ConfidenceInc();
120 }
121
123
129 T PointAt(std::size_t indexX, std::size_t indexY) const noexcept
130 {
131 return InternalPointAt(indexX, indexY, TypeTag<T>{});
132 }
133
135
141 void SetPointAt(std::size_t indexX, std::size_t indexY, T point) noexcept
142 {
143 return InternalSetPointAt(indexX, indexY, point);
144 }
145
147
151 Size2D<int> LatticeSize() const noexcept
152 {
153 return latticeSize_;
154 }
155
156 private:
157
158 explicit DenseComponentsPointers3D(const ComponentsPointers3D& components, Size2D<int> latticeSize)
159 : components_(components)
160 , latticeSize_(latticeSize)
161 {
162 }
163
164 template<class TYPE>
165 struct TypeTag {};
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() + indexX * ConfidenceInc());
174 return Point3DC<TYPE>(x, y, z, c);
175 }
176
177 template <class TYPE>
178 Point3DH<TYPE> InternalPointAt(std::size_t indexX, std::size_t indexY, TypeTag<Point3DH<TYPE>>) const noexcept
179 {
180 auto x = *reinterpret_cast<TYPE*>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc());
181 auto y = *reinterpret_cast<TYPE*>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc());
182 auto z = *reinterpret_cast<TYPE*>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc());
183 auto w = *reinterpret_cast<TYPE*>(BasePtrW() + indexY * latticeSize_.Width() * WInc() + indexX * WInc());
184 return Point3DH<TYPE>(x, y, z, w);
185 }
186
187 template <class TYPE>
188 Point3D<TYPE> InternalPointAt(std::size_t indexX, std::size_t indexY, TypeTag<Point3D<TYPE>>) const noexcept
189 {
190 auto x = *reinterpret_cast<TYPE*>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc());
191 auto y = *reinterpret_cast<TYPE*>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc());
192 auto z = *reinterpret_cast<TYPE*>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc());
193 return Point3D<TYPE>(x, y, z);
194 }
195
196 template <class TYPE>
197 void InternalSetPointAt(std::size_t indexX, std::size_t indexY, Point3DC<TYPE> point) noexcept
198 {
199 *reinterpret_cast<TYPE*>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc()) = point.X();
200 *reinterpret_cast<TYPE*>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc()) = point.Y();
201 *reinterpret_cast<TYPE*>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc()) = point.Z();
202 *reinterpret_cast<TYPE*>(BasePtrConfidence() + indexY * latticeSize_.Width() * ConfidenceInc() + indexX * ConfidenceInc()) = point.Confidence();
203 }
204
205 template <class TYPE>
206 void InternalSetPointAt(std::size_t indexX, std::size_t indexY, Point3DH<TYPE> point) noexcept
207 {
208 *reinterpret_cast<TYPE*>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc()) = point.X();
209 *reinterpret_cast<TYPE*>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc()) = point.Y();
210 *reinterpret_cast<TYPE*>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc()) = point.Z();
211 *reinterpret_cast<TYPE*>(BasePtrW() + indexY * latticeSize_.Width() * WInc() + indexX * WInc()) = point.W();
212 }
213
214 template <class TYPE>
215 void InternalSetPointAt(std::size_t indexX, std::size_t indexY, Point3D<TYPE> point) noexcept
216 {
217 *reinterpret_cast<TYPE*>(BasePtrX() + indexY * latticeSize_.Width() * XInc() + indexX * XInc()) = point.X();
218 *reinterpret_cast<TYPE*>(BasePtrY() + indexY * latticeSize_.Width() * YInc() + indexX * YInc()) = point.Y();
219 *reinterpret_cast<TYPE*>(BasePtrZ() + indexY * latticeSize_.Width() * ZInc() + indexX * ZInc()) = point.Z();
220 }
221
222 ComponentsPointers3D components_;
223 Size2D<int> latticeSize_;
224 };
225
226 CVB_END_INLINE_NS
227
228}
Point components of the point cloud.
Definition: components_pointers_3d.hpp:19
std::intptr_t ZInc() const noexcept
Increment to the next Z-component of the next point in bytes.
Definition: components_pointers_3d.hpp:102
std::uintptr_t BasePtrX() const noexcept
Variable to receive the pointer to the first X-component of the first point.
Definition: components_pointers_3d.hpp:32
std::intptr_t XInc() const noexcept
Increment to the next X-component of the next point in bytes.
Definition: components_pointers_3d.hpp:82
std::uintptr_t BasePtrZ() const noexcept
Variable to receive the pointer to the first Z-component of the first point.
Definition: components_pointers_3d.hpp:52
std::intptr_t ConfidenceInc() const noexcept
Increment to the next confidence-component of the next point in bytes (if present; nullptr if not).
Definition: components_pointers_3d.hpp:122
std::uintptr_t BasePtrConfidence() const noexcept
Variable to receive the pointer to the first confidence-component of the first point.
Definition: components_pointers_3d.hpp:72
std::uintptr_t BasePtrY() const noexcept
Variable to receive the pointer to the first Y-component of the first point.
Definition: components_pointers_3d.hpp:42
std::intptr_t YInc() const noexcept
Increment to the next Y-component of the next point in bytes.
Definition: components_pointers_3d.hpp:92
std::uintptr_t BasePtrW() const noexcept
Variable to receive the pointer to the first W-component of the first point.
Definition: components_pointers_3d.hpp:62
std::intptr_t WInc() const noexcept
Increment to the next W-component of the next point in bytes (if present; nullptr if not).
Definition: components_pointers_3d.hpp:112
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:141
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:151
std::intptr_t ZInc() const noexcept
Increment to the next Z-component of the next point in bytes.
Definition: dense_components_pointers_3d.hpp:97
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:27
std::intptr_t XInc() const noexcept
Increment to the next X-component of the next point in bytes.
Definition: dense_components_pointers_3d.hpp:77
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:47
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:117
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:67
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:37
std::intptr_t YInc() const noexcept
Increment to the next Y-component of the next point in bytes.
Definition: dense_components_pointers_3d.hpp:87
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:129
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:57
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:107
A dense Cartesian 3D point cloud object.
Definition: decl_dense_point_cloud.hpp:31
T Width() const noexcept
Gets the horizontal component of the size.
Definition: size_2d.hpp:59
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24