Main MRPT website > C++ reference for MRPT 1.9.9
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-2017, 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 
12 #include <mrpt/utils/utils_defs.h>
13 
14 namespace mrpt
15 {
16 namespace utils
17 {
18 /** \defgroup mrpt_adapters_grp Adapter (wrapper) template classes (in #include
19  <mrpt/utils/adapters.h>)
20  \addtogroup mrpt_base_grp
21 */
22 
23 /** \addtogroup mrpt_adapters_grp
24  * @{ */
25 
26 /** An adapter to different kinds of point cloud object.
27  * Implemented as a pure C++ template with specializations for the highest
28  * flexibility and efficiency in compiler-generated implementations.
29  * Usage:
30  * \code
31  * PC my_obj;
32  * my_obj.specific_methods();
33  * // ...
34  * PointCloudAdapter<PC> pca(my_obj);
35  * pca.unified_interface_methods();
36  * // ...
37  * \endcode
38  * See specializations for details on the exposed API.
39  */
40 template <class POINTCLOUD>
42 
43 /** @} */ // end of grouping
44 
45 namespace detail
46 {
47 /** A helper base class for those PointCloudAdapter<> which do not handle RGB
48  * data; it declares needed interface methods which fall back to XYZ-only
49  * methods */
50 template <class POINTMAPTYPE, typename coords_t>
52 {
53  public:
55 
56  inline Derived& derived() { return *static_cast<Derived*>(this); }
57  inline const Derived& derived() const
58  {
59  return *static_cast<const Derived*>(this);
60  }
61 
62  /** Get XYZ_RGBf coordinates of i'th point */
63  template <typename T>
64  inline void getPointXYZ_RGBf(
65  const size_t idx, T& x, T& y, T& z, float& r, float& g, float& b) const
66  {
67  derived().getPointXYZ(idx, x, y, z);
68  r = g = b = 1.0f;
69  }
70  /** Set XYZ_RGBf coordinates of i'th point */
71  inline void setPointXYZ_RGBf(
72  const size_t idx, const coords_t x, const coords_t y, const coords_t z,
73  const float r, const float g, const float b)
74  {
78  derived().setPointXYZ(idx, x, y, z);
79  }
80 
81  /** Get XYZ_RGBu8 coordinates of i'th point */
82  template <typename T>
83  inline void getPointXYZ_RGBu8(
84  const size_t idx, T& x, T& y, T& z, uint8_t& r, uint8_t& g,
85  uint8_t& b) const
86  {
87  derived().getPointXYZ(idx, x, y, z);
88  r = g = b = 255;
89  }
90  /** Set XYZ_RGBu8 coordinates of i'th point */
91  inline void setPointXYZ_RGBu8(
92  const size_t idx, const coords_t x, const coords_t y, const coords_t z,
93  const uint8_t r, const uint8_t g, const uint8_t b)
94  {
98  derived().setPointXYZ(idx, x, y, z);
99  }
100 
101  /** Get RGBf color of i'th point */
102  inline void getPointRGBf(
103  const size_t idx, float& r, float& g, float& b) const
104  {
105  MRPT_UNUSED_PARAM(idx);
106  r = g = b = 1.0f;
107  }
108  /** Set XYZ_RGBf coordinates of i'th point */
109  inline void setPointRGBf(
110  const size_t idx, const float r, const float g, const float b)
111  {
112  MRPT_UNUSED_PARAM(idx);
116  }
117 
118  /** Get RGBu8 color of i'th point */
119  inline void getPointRGBu8(
120  const size_t idx, uint8_t& r, uint8_t& g, uint8_t& b) const
121  {
122  MRPT_UNUSED_PARAM(idx);
123  r = g = b = 255;
124  }
125  /** Set RGBu8 coordinates of i'th point */
126  inline void setPointRGBu8(
127  const size_t idx, const uint8_t r, const uint8_t g, const uint8_t b)
128  {
129  MRPT_UNUSED_PARAM(idx);
133  }
134 }; // end of PointCloudAdapterHelperNoRGB
135 } // End of namespace detail
136 
137 } // End of namespace
138 } // end of namespace
139 #endif
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i&#39;th point.
Definition: adapters.h:109
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i&#39;th point.
Definition: adapters.h:102
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i&#39;th point.
Definition: adapters.h:119
GLdouble GLdouble z
Definition: glext.h:3872
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&#39;th point.
Definition: adapters.h:83
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
Definition: adapters.h:51
unsigned char uint8_t
Definition: rptypes.h:41
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&#39;th point.
Definition: adapters.h:64
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
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&#39;th point.
Definition: adapters.h:71
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&#39;th point.
Definition: adapters.h:91
GLubyte g
Definition: glext.h:6279
GLubyte GLubyte b
Definition: glext.h:6279
PointCloudAdapter< POINTMAPTYPE > Derived
Definition: adapters.h:54
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
void setPointRGBu8(const size_t idx, const uint8_t r, const uint8_t g, const uint8_t b)
Set RGBu8 coordinates of i&#39;th point.
Definition: adapters.h:126
GLenum GLint GLint y
Definition: glext.h:3538
An adapter to different kinds of point cloud object.
Definition: adapters.h:41
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019