Main MRPT website > C++ reference for MRPT 1.4.0
adapters.h
Go to the documentation of this file.
1/* +---------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | http://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6 | See: http://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See details in http://www.mrpt.org/License |
8 +---------------------------------------------------------------------------+ */
9#ifndef mrpt_utils_adapters_H
10#define mrpt_utils_adapters_H
11
13
14namespace mrpt
15{
16 namespace utils
17 {
18 /** \defgroup mrpt_adapters_grp Adapter (wrapper) template classes (in #include <mrpt/utils/adapters.h>)
19 \addtogroup mrpt_base_grp
20 */
21
22 /** \addtogroup mrpt_adapters_grp
23 * @{ */
24
25 /** An adapter to different kinds of point cloud object.
26 * Implemented as a pure C++ template with specializations for the highest flexibility and efficiency in compiler-generated implementations.
27 * Usage:
28 * \code
29 * PC my_obj;
30 * my_obj.specific_methods();
31 * // ...
32 * PointCloudAdapter<PC> pca(my_obj);
33 * pca.unified_interface_methods();
34 * // ...
35 * \endcode
36 * See specializations for details on the exposed API.
37 */
38 template <class POINTCLOUD> class PointCloudAdapter;
39
40 /** @} */ // end of grouping
41
42
43
44 namespace detail
45 {
46 /** A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed interface methods which fall back to XYZ-only methods */
47 template <class POINTMAPTYPE, typename coords_t>
49 {
50 public:
52
53 inline Derived & derived() { return *static_cast<Derived*>(this); }
54 inline const Derived & derived() const { return *static_cast<const Derived*>(this); }
55
56 /** Get XYZ_RGBf coordinates of i'th point */
57 template <typename T>
58 inline void getPointXYZ_RGBf(const size_t idx, T &x,T &y, T &z, float &r,float &g,float &b) const {
59 derived().getPointXYZ(idx,x,y,z);
60 r=g=b=1.0f;
61 }
62 /** Set XYZ_RGBf coordinates of i'th point */
63 inline void setPointXYZ_RGBf(const size_t idx, const coords_t x,const coords_t y, const coords_t z, const float r,const float g,const float b) {
65 derived().setPointXYZ(idx,x,y,z);
66 }
67
68 /** Get XYZ_RGBu8 coordinates of i'th point */
69 template <typename T>
70 inline void getPointXYZ_RGBu8(const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b) const {
71 derived().getPointXYZ(idx,x,y,z);
72 r=g=b=255;
73 }
74 /** Set XYZ_RGBu8 coordinates of i'th point */
75 inline void setPointXYZ_RGBu8(const size_t idx, const coords_t x,const coords_t y, const coords_t z, const uint8_t r,const uint8_t g,const uint8_t b) {
77 derived().setPointXYZ(idx,x,y,z);
78 }
79
80 /** Get RGBf color of i'th point */
81 inline void getPointRGBf(const size_t idx, float &r,float &g,float &b) const {
83 r=g=b=1.0f;
84 }
85 /** Set XYZ_RGBf coordinates of i'th point */
86 inline void setPointRGBf(const size_t idx, const float r,const float g,const float b) {
88 }
89
90 /** Get RGBu8 color of i'th point */
91 inline void getPointRGBu8(const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b) const {
93 r=g=b=255;
94 }
95 /** Set RGBu8 coordinates of i'th point */
96 inline void setPointRGBu8(const size_t idx,const uint8_t r,const uint8_t g,const uint8_t b) {
98 }
99 }; // end of PointCloudAdapterHelperNoRGB
100 } // End of namespace detail
101
102 } // End of namespace
103} // end of namespace
104#endif
An adapter to different kinds of point cloud object.
Definition: adapters.h:38
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
Definition: adapters.h:49
void setPointXYZ_RGBu8(const size_t idx, const coords_t x, const coords_t y, const coords_t z, const uint8_t r, const uint8_t g, const uint8_t b)
Set XYZ_RGBu8 coordinates of i'th point.
Definition: adapters.h:75
void setPointXYZ_RGBf(const size_t idx, const coords_t x, const coords_t y, const coords_t z, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
Definition: adapters.h:63
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i'th point.
Definition: adapters.h:81
void setPointRGBu8(const size_t idx, const uint8_t r, const uint8_t g, const uint8_t b)
Set RGBu8 coordinates of i'th point.
Definition: adapters.h:96
PointCloudAdapter< POINTMAPTYPE > Derived
Definition: adapters.h:51
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i'th point.
Definition: adapters.h:91
void getPointXYZ_RGBu8(const size_t idx, T &x, T &y, T &z, uint8_t &r, uint8_t &g, uint8_t &b) const
Get XYZ_RGBu8 coordinates of i'th point.
Definition: adapters.h:70
void getPointXYZ_RGBf(const size_t idx, T &x, T &y, T &z, float &r, float &g, float &b) const
Get XYZ_RGBf coordinates of i'th point.
Definition: adapters.h:58
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
Definition: adapters.h:86
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
Definition: mrpt_macros.h:290
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.4 for MRPT 1.4.0 SVN: at Sun Aug 14 11:28:23 UTC 2022