Main MRPT website > C++ reference for MRPT 1.9.9
pointcloud_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-2018, 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 #pragma once
10 
11 #include <cstdint>
12 
13 namespace mrpt
14 {
15 namespace opengl
16 {
17 /** \defgroup mrpt_adapters_grp Pointcloud adapter (wrapper) template classes
18  (in #include <mrpt/opengl/pointcloud_adapters.h>) \addtogroup mrpt_opengl_grp
19 */
20 
21 /** \addtogroup mrpt_adapters_grp
22  * @{ */
23 
24 /** An adapter to different kinds of point cloud object.
25  * Implemented as a pure C++ template with specializations for the highest
26  * 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>
40 
41 /** @} */ // end of grouping
42 
43 namespace detail
44 {
45 /** A helper base class for those PointCloudAdapter<> which do not handle RGB
46  * data; it declares needed interface methods which fall back to XYZ-only
47  * methods */
48 template <class POINTMAPTYPE, typename coords_t>
50 {
51  public:
53 
54  inline Derived& derived() { return *static_cast<Derived*>(this); }
55  inline const Derived& derived() const
56  {
57  return *static_cast<const Derived*>(this);
58  }
59 
60  /** Get XYZ_RGBf coordinates of i'th point */
61  template <typename T>
62  inline void getPointXYZ_RGBf(
63  const size_t idx, T& x, T& y, T& z, float& r, float& g, float& b) const
64  {
65  derived().getPointXYZ(idx, x, y, z);
66  r = g = b = 1.0f;
67  }
68  /** Set XYZ_RGBf coordinates of i'th point */
69  inline void setPointXYZ_RGBf(
70  const size_t idx, const coords_t x, const coords_t y, const coords_t z,
71  const float r, const float g, const float b)
72  {
76  derived().setPointXYZ(idx, x, y, z);
77  }
78 
79  /** Get XYZ_RGBu8 coordinates of i'th point */
80  template <typename T>
81  inline void getPointXYZ_RGBu8(
82  const size_t idx, T& x, T& y, T& z, uint8_t& r, uint8_t& g,
83  uint8_t& b) const
84  {
85  derived().getPointXYZ(idx, x, y, z);
86  r = g = b = 255;
87  }
88  /** Set XYZ_RGBu8 coordinates of i'th point */
89  inline void setPointXYZ_RGBu8(
90  const size_t idx, const coords_t x, const coords_t y, const coords_t z,
91  const uint8_t r, const uint8_t g, const uint8_t b)
92  {
96  derived().setPointXYZ(idx, x, y, z);
97  }
98 
99  /** Get RGBf color of i'th point */
100  inline void getPointRGBf(
101  const size_t idx, float& r, float& g, float& b) const
102  {
103  MRPT_UNUSED_PARAM(idx);
104  r = g = b = 1.0f;
105  }
106  /** Set XYZ_RGBf coordinates of i'th point */
107  inline void setPointRGBf(
108  const size_t idx, const float r, const float g, const float b)
109  {
110  MRPT_UNUSED_PARAM(idx);
114  }
115 
116  /** Get RGBu8 color of i'th point */
117  inline void getPointRGBu8(
118  const size_t idx, uint8_t& r, uint8_t& g, uint8_t& b) const
119  {
120  MRPT_UNUSED_PARAM(idx);
121  r = g = b = 255;
122  }
123  /** Set RGBu8 coordinates of i'th point */
124  inline void setPointRGBu8(
125  const size_t idx, const uint8_t r, const uint8_t g, const uint8_t b)
126  {
127  MRPT_UNUSED_PARAM(idx);
131  }
132 }; // end of PointCloudAdapterHelperNoRGB
133 } // End of namespace detail
134 
135 } // namespace opengl
136 } // namespace mrpt
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i&#39;th point.
GLdouble GLdouble z
Definition: glext.h:3872
unsigned char uint8_t
Definition: rptypes.h:41
An adapter to different kinds of point cloud object.
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.
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.
GLubyte g
Definition: glext.h:6279
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.
GLubyte GLubyte b
Definition: glext.h:6279
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i&#39;th point.
GLenum GLint GLint y
Definition: glext.h:3538
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
GLenum GLint x
Definition: glext.h:3538
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.
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.
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i&#39;th point.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019