Main MRPT website > C++ reference for MRPT 1.5.7
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 <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 {
82  MRPT_UNUSED_PARAM(idx);
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 {
92  MRPT_UNUSED_PARAM(idx);
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
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:86
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i&#39;th point.
Definition: adapters.h:81
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:91
GLdouble GLdouble z
Definition: glext.h:3734
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:70
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
Definition: adapters.h:48
unsigned char uint8_t
Definition: rptypes.h:43
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:58
#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:63
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:75
GLubyte g
Definition: glext.h:5575
GLubyte GLubyte b
Definition: glext.h:5575
PointCloudAdapter< POINTMAPTYPE > Derived
Definition: adapters.h:51
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
Definition: glext.h:3618
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:96
GLenum GLint GLint y
Definition: glext.h:3516
An adapter to different kinds of point cloud object.
Definition: adapters.h:38
GLenum GLint x
Definition: glext.h:3516



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019