CVB++ 14.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
149 void SetPointAt(std::size_t index, T point) noexcept
150 {
151 return InternalSetPointAt(index, point);
152 }
153
154 private:
155
156 explicit SparseComponentsPointers3D(const ComponentsPointers3D& components) noexcept
157 : components_(components)
158 {
159 }
160
161 template<class TYPE>
162 struct TypeTag {};
163
164 template <class TYPE>
165 Point3DH<TYPE> InternalPointAt(std::size_t index, TypeTag<Point3DH<TYPE>>) const noexcept
166 {
167 auto x = *reinterpret_cast<TYPE*>(BasePtrX() + index * XInc());
168 auto y = *reinterpret_cast<TYPE*>(BasePtrY() + index * YInc());
169 auto z = *reinterpret_cast<TYPE*>(BasePtrZ() + index * ZInc());
170 auto w = *reinterpret_cast<TYPE*>(BasePtrW() + index * WInc());
171 return Point3DH<TYPE>(x, y, z, w);
172 }
173
174 template <class TYPE>
175 Point3D<TYPE> InternalPointAt(std::size_t index, TypeTag<Point3D<TYPE>>) const noexcept
176 {
177 auto x = *reinterpret_cast<TYPE*>(BasePtrX() + index * XInc());
178 auto y = *reinterpret_cast<TYPE*>(BasePtrY() + index * YInc());
179 auto z = *reinterpret_cast<TYPE*>(BasePtrZ() + index * ZInc());
180 return Point3D<TYPE>(x, y, z);
181 }
182
183 template <class TYPE>
184 void InternalSetPointAt(std::size_t index, Point3DH<TYPE> point) noexcept
185 {
186 *reinterpret_cast<TYPE*>(BasePtrX() + index * XInc()) = point.X();
187 *reinterpret_cast<TYPE*>(BasePtrY() + index * YInc()) = point.Y();
188 *reinterpret_cast<TYPE*>(BasePtrZ() + index * ZInc()) = point.Z();
189 *reinterpret_cast<TYPE*>(BasePtrW() + index * WInc()) = point.W();
190
191 }
192
193 template <class TYPE>
194 void InternalSetPointAt(std::size_t index, Point3D<TYPE> point) noexcept
195 {
196 *reinterpret_cast<TYPE*>(BasePtrX() + index * XInc()) = point.X();
197 *reinterpret_cast<TYPE*>(BasePtrY() + index * YInc()) = point.Y();
198 *reinterpret_cast<TYPE*>(BasePtrZ() + index * ZInc()) = point.Z();
199 }
200
201 ComponentsPointers3D components_;
202};
203
204CVB_END_INLINE_NS
205
206}
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:149
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