CVB++ 15.0
sparse_components_pointers_3d.hpp
1#pragma once
2
3#include "components_pointers_3d.hpp"
4
5namespace Cvb
6{
7
8CVB_BEGIN_INLINE_NS
9
11
12template<class T>
14{
15 friend class SparsePointCloud;
16
17 public:
18
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
126 std::size_t NumPoints() const noexcept
127 {
128 return components_.NumPoints();
129 }
130
132
137 T PointAt(std::size_t index) const noexcept
138 {
139 return InternalPointAt(index, TypeTag<T>{});
140 }
141
143
148 void SetPointAt(std::size_t index, T point) noexcept
149 {
150 return InternalSetPointAt(index, point);
151 }
152
153 private:
154
155 explicit SparseComponentsPointers3D(const ComponentsPointers3D& components) noexcept
156 : components_(components)
157 {
158 }
159
160 template<class TYPE>
161 struct TypeTag {};
162
163 template <class TYPE>
164 Point3DH<TYPE> InternalPointAt(std::size_t index, TypeTag<Point3DH<TYPE>>) const noexcept
165 {
166 auto x = *reinterpret_cast<TYPE*>(BasePtrX() + index * XInc());
167 auto y = *reinterpret_cast<TYPE*>(BasePtrY() + index * YInc());
168 auto z = *reinterpret_cast<TYPE*>(BasePtrZ() + index * ZInc());
169 auto w = *reinterpret_cast<TYPE*>(BasePtrW() + index * WInc());
170 return Point3DH<TYPE>(x, y, z, w);
171 }
172
173 template <class TYPE>
174 Point3D<TYPE> InternalPointAt(std::size_t index, TypeTag<Point3D<TYPE>>) const noexcept
175 {
176 auto x = *reinterpret_cast<TYPE*>(BasePtrX() + index * XInc());
177 auto y = *reinterpret_cast<TYPE*>(BasePtrY() + index * YInc());
178 auto z = *reinterpret_cast<TYPE*>(BasePtrZ() + index * ZInc());
179 return Point3D<TYPE>(x, y, z);
180 }
181
182 template <class TYPE>
183 void InternalSetPointAt(std::size_t index, Point3DH<TYPE> point) noexcept
184 {
185 *reinterpret_cast<TYPE*>(BasePtrX() + index * XInc()) = point.X();
186 *reinterpret_cast<TYPE*>(BasePtrY() + index * YInc()) = point.Y();
187 *reinterpret_cast<TYPE*>(BasePtrZ() + index * ZInc()) = point.Z();
188 *reinterpret_cast<TYPE*>(BasePtrW() + index * WInc()) = point.W();
189
190 }
191
192 template <class TYPE>
193 void InternalSetPointAt(std::size_t index, Point3D<TYPE> point) noexcept
194 {
195 *reinterpret_cast<TYPE*>(BasePtrX() + index * XInc()) = point.X();
196 *reinterpret_cast<TYPE*>(BasePtrY() + index * YInc()) = point.Y();
197 *reinterpret_cast<TYPE*>(BasePtrZ() + index * ZInc()) = point.Z();
198 }
199
200 ComponentsPointers3D components_;
201};
202
203CVB_END_INLINE_NS
204
205}
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
std::size_t NumPoints() const noexcept
Variable to be filled with the number of points in point cloud.
Definition: components_pointers_3d.hpp:132
Point components of a sparse point cloud.
Definition: sparse_components_pointers_3d.hpp:14
void SetPointAt(std::size_t index, T point) noexcept
Sets the point at the specified index.
Definition: sparse_components_pointers_3d.hpp:148
T PointAt(std::size_t index) const noexcept
Gets the point at the specified index.
Definition: sparse_components_pointers_3d.hpp:137
std::intptr_t ZInc() const noexcept
Increment to the next Z-component of the next point in bytes.
Definition: sparse_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: sparse_components_pointers_3d.hpp:26
std::intptr_t XInc() const noexcept
Increment to the next X-component of the next point in bytes.
Definition: sparse_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: sparse_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: sparse_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: sparse_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: sparse_components_pointers_3d.hpp:36
std::intptr_t YInc() const noexcept
Increment to the next Y-component of the next point in bytes.
Definition: sparse_components_pointers_3d.hpp:86
std::uintptr_t BasePtrW() const noexcept
Variable to receive the pointer to the first W-component of the first point.
Definition: sparse_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: sparse_components_pointers_3d.hpp:106
std::size_t NumPoints() const noexcept
Variable to be filled with the number of points in point cloud.
Definition: sparse_components_pointers_3d.hpp:126
A sparse Cartesian 3D point cloud object.
Definition: decl_sparse_point_cloud.hpp:30
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24