CVB++ 14.0
detail_block_point_helper.hpp
1#pragma once
2
3#include "../../global.hpp"
4
5#include "../../point_2d.hpp"
6#include "../../point_3d.hpp"
7#include "../../point_3d_h.hpp"
8
9#include "detail_block.hpp"
10
11namespace Cvb
12{
13 CVB_BEGIN_INLINE_NS
14
15#pragma region Point2D
28 template <size_t I, class T, std::enable_if_t<less<I, 2>::value, int> = 0>
29 auto get(const Point2D<T> &point) noexcept -> decltype(point[I])
30 {
31 return point[I];
32 }
33
46 template <size_t I, class T, std::enable_if_t<less<I, 2>::value, int> = 0>
47 void set(Point2D<T> &point, const T &val) noexcept
48 {
49 point[I] = val;
50 }
51
52 /*
53 * \relates Point2D
54 * \sa Block, Visit
55 *
56 * \brief Set's the value of the \a I-th element in the Point2D<T> \a point to the value pointed to by \a
57 * val.
58 *
59 * \pre I < 2
60 *
61 * \tparam I The index of the element.
62 * \param point The Point2D<T> to retrieve the \a I-th element from.
63 * \param val The pointer to the value to be written to the \a I-th element of \a point.
64 */
65 template <size_t I, class T, std::enable_if_t<less<I, 2>::value, int> = 0>
66 void internal_set(Point2D<T> &point, const T *val) noexcept
67 {
68 assert(val != nullptr);
69 point[I] = *val;
70 }
71
72#ifndef CVB_DOXYGEN
73 template <class Type>
74 struct ComponentOf<Point2D<Type>, void>
75 {
76 using type = Type;
77 };
78
79 template <class Type>
80 struct NumComponentsOf<Point2D<Type>, void>
81 {
82 static constexpr size_t value = 2;
83 };
84#endif
85#pragma endregion Point2D
86
87#pragma region Point3D
100 template <size_t I, class T, std::enable_if_t<less<I, 3>::value, int> = 0>
101 auto get(const Point3D<T> &point) noexcept -> decltype(point[I])
102 {
103 return point[I];
104 }
105
118 template <size_t I, class T, std::enable_if_t<less<I, 3>::value, int> = 0>
119 void set(Point3D<T> &point, const T &val) noexcept
120 {
121 point[I] = val;
122 }
123
124 /*
125 * \relates Point3D
126 * \sa Block, Visit
127 *
128 * \brief Set's the value of the \a I-th element in the Point3D<T> \a point to the value pointed to by \a
129 * val.
130 *
131 * \pre I < 3
132 *
133 * \tparam I The index of the element.
134 * \param point The Point3D<T> to retrieve the \a I-th element from.
135 * \param val The pointer to the value to be written to the \a I-th element of \a point.
136 */
137 template <size_t I, class T, std::enable_if_t<less<I, 3>::value, int> = 0>
138 void internal_set(Point3D<T> &point, const T *val) noexcept
139 {
140 assert(val != nullptr);
141 point[I] = *val;
142 }
143
144#ifndef CVB_DOXYGEN
145 template <class Type>
146 struct ComponentOf<Point3D<Type>, void>
147 {
148 using type = Type;
149 };
150
151 template <class Type>
152 struct NumComponentsOf<Point3D<Type>, void>
153 {
154 static constexpr size_t value = 3;
155 };
156#endif
157#pragma endregion Point3D
158
159#pragma region Point3DH
160
173 template <size_t I, class T, std::enable_if_t<less<I, 4>::value, int> = 0>
174 auto get(const Point3DH<T> &point) noexcept -> decltype(point[I])
175 {
176 return point[I];
177 }
178
191 template <size_t I, class T, std::enable_if_t<less<I, 4>::value, int> = 0>
192 void set(Point3DH<T> &point, const T &val) noexcept
193 {
194 point[I] = val;
195 }
196
197 /*
198 * \relates Point3DH
199 * \sa Block, Visit
200 *
201 * \brief Set's the value of the \a I-th element in the Point3DH<T> \a point to the value pointed to by \a
202 * val.
203 *
204 * \pre I < 4
205 *
206 * \tparam I The index of the element.
207 * \param point The Point3DH<T> to retrieve the \a I-th element from.
208 * \param val The pointer to the value to be written to the \a I-th element of \a point.
209 */
210 template <size_t I, class T, std::enable_if_t<less<I, 4>::value, int> = 0>
211 void internal_set(Point3DH<T> &point, const T *val) noexcept
212 {
213 assert(val != nullptr);
214 point[I] = *val;
215 }
216
217#ifndef CVB_DOXYGEN
218 template <class Type>
219 struct ComponentOf<Point3DH<Type>, void>
220 {
221 using type = Type;
222 };
223
224 template <class Type>
225 struct NumComponentsOf<Point3DH<Type>, void>
226 {
227 static constexpr size_t value = 4;
228 };
229#endif
230#pragma endregion Point3DH
231
232#pragma region Point3DC
233
246 template <size_t I, class T, std::enable_if_t<less<I, 4>::value, int> = 0>
247 auto get(const Point3DC<T> &point) noexcept -> decltype(point[I])
248 {
249 return point[I];
250 }
251
264 template <size_t I, class T, std::enable_if_t<less<I, 4>::value, int> = 0>
265 void set(Point3DC<T> &point, const T &val) noexcept
266 {
267 point[I] = val;
268 }
269
270 /*
271 * \relates Point3DC
272 * \sa Block, Visit
273 *
274 * \brief Set's the value of the \a I-th element in the Point3DC<T> \a point to the value pointed to by \a
275 * val.
276 *
277 * \pre I < 4
278 *
279 * \tparam I The index of the element.
280 * \param point The Point3DC<T> to retrieve the \a I-th element from.
281 * \param val The pointer to the value to be written to the \a I-th element of \a point.
282 */
283 template <size_t I, class T, std::enable_if_t<less<I, 4>::value, int> = 0>
284 void internal_set(Point3DC<T> &point, const T *val) noexcept
285 {
286 assert(val != nullptr);
287 point[I] = *val;
288 }
289
290#ifndef CVB_DOXYGEN
291 template <class Type>
292 struct ComponentOf<Point3DC<Type>, void>
293 {
294 using type = Type;
295 };
296
297 template <class Type>
298 struct NumComponentsOf<Point3DC<Type>, void>
299 {
300 static constexpr size_t value = 4;
301 };
302#endif
303#pragma endregion Point3DC
304
305 CVB_END_INLINE_NS
306} // namespace Cvb
Multi-purpose 2D vector class.
Definition: point_2d.hpp:20
CVB_BEGIN_INLINE_NS auto get(const Point2D< T > &point) noexcept -> decltype(point[I])
Get's the I-th element of the Point2D<T>.
Definition: detail_block_point_helper.hpp:29
void set(Point2D< T > &point, const T &val) noexcept
Set's the value of the I-th element in the Point2D<T> point.
Definition: detail_block_point_helper.hpp:47
Multi-purpose 3D vector class with confidence.
Definition: point_3d_c.hpp:23
void set(Point3DC< T > &point, const T &val) noexcept
Set's the value of the I-th element in the Point3DC<T> point.
Definition: detail_block_point_helper.hpp:265
auto get(const Point3DC< T > &point) noexcept -> decltype(point[I])
Get's the I-th element of the Point3DC<T>.
Definition: detail_block_point_helper.hpp:247
Multi-purpose 3D vector class (homogeneous).
Definition: point_3d_h.hpp:22
void set(Point3DH< T > &point, const T &val) noexcept
Set's the value of the I-th element in the Point3DH<T> point.
Definition: detail_block_point_helper.hpp:192
auto get(const Point3DH< T > &point) noexcept -> decltype(point[I])
Get's the I-th element of the Point3DH<T>.
Definition: detail_block_point_helper.hpp:174
Multi-purpose 3D vector class.
Definition: point_3d.hpp:22
void set(Point3D< T > &point, const T &val) noexcept
Set's the value of the I-th element in the Point3D<T> point.
Definition: detail_block_point_helper.hpp:119
auto get(const Point3D< T > &point) noexcept -> decltype(point[I])
Get's the I-th element of the Point3D<T>.
Definition: detail_block_point_helper.hpp:101
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24