CVB++ 15.0
sparse_components_pointers_3d.hpp
1#pragma once
2
3#include "components_pointers_3d.hpp"
4
5namespace Cvb
6{
7
8 CVB_BEGIN_INLINE_NS
9
11
12 template <class T>
13 class SparseComponentsPointers3D final
14 {
15 friend class SparsePointCloud;
16
17 public:
18 SparseComponentsPointers3D() = default;
19
21
25 std::uintptr_t BasePtrX() const noexcept
26 {
27 return components_.BasePtrX();
28 }
29
31
35 std::uintptr_t BasePtrY() const noexcept
36 {
37 return components_.BasePtrY();
38 }
39
41
45 std::uintptr_t BasePtrZ() const noexcept
46 {
47 return components_.BasePtrZ();
48 }
49
51
55 std::uintptr_t BasePtrW() const noexcept
56 {
57 return components_.BasePtrW();
58 }
59
61
66 {
67 return components_.BasePtrConfidence();
68 }
69
71
75 std::intptr_t XInc() const noexcept
76 {
77 return components_.XInc();
78 }
79
81
85 std::intptr_t YInc() const noexcept
86 {
87 return components_.YInc();
88 }
89
91
95 std::intptr_t ZInc() const noexcept
96 {
97 return components_.ZInc();
98 }
99
101
105 std::intptr_t WInc() const noexcept
106 {
107 return components_.WInc();
108 }
109
111
116 {
117 return components_.ConfidenceInc();
118 }
119
121
125 std::size_t NumPoints() const noexcept
126 {
127 return components_.NumPoints();
128 }
129
131
136 T PointAt(std::size_t index) const noexcept
137 {
138 return InternalPointAt(index, TypeTag<T>{});
139 }
140
142
147 void SetPointAt(std::size_t index, T point) noexcept
148 {
149 return InternalSetPointAt(index, point);
150 }
151
152 private:
153 explicit SparseComponentsPointers3D(const ComponentsPointers3D &components) noexcept
154 : components_(components)
155 {
156 }
157
158 template <class TYPE>
159 struct TypeTag
160 {
161 };
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 template <class TYPE>
192 void InternalSetPointAt(std::size_t index, Point3D<TYPE> point) noexcept
193 {
194 *reinterpret_cast<TYPE *>(BasePtrX() + index * XInc()) = point.X();
195 *reinterpret_cast<TYPE *>(BasePtrY() + index * YInc()) = point.Y();
196 *reinterpret_cast<TYPE *>(BasePtrZ() + index * ZInc()) = point.Z();
197 }
198
199 ComponentsPointers3D components_;
200 };
201
202 CVB_END_INLINE_NS
203
204} // namespace Cvb
Point components of the point cloud.
Definition components_pointers_3d.hpp:18
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:147
T PointAt(std::size_t index) const noexcept
Gets the point at the specified index.
Definition sparse_components_pointers_3d.hpp:136
std::intptr_t ZInc() const noexcept
Increment to the next Z-component of the next point in bytes.
Definition sparse_components_pointers_3d.hpp:95
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:25
std::intptr_t XInc() const noexcept
Increment to the next X-component of the next point in bytes.
Definition sparse_components_pointers_3d.hpp:75
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:45
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:115
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:65
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:35
std::intptr_t YInc() const noexcept
Increment to the next Y-component of the next point in bytes.
Definition sparse_components_pointers_3d.hpp:85
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:55
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:105
std::size_t NumPoints() const noexcept
Variable to be filled with the number of points in point cloud.
Definition sparse_components_pointers_3d.hpp:125
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17