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
mrpt::opengl::PointCloudAdapter
An adapter to different kinds of point cloud object.
Definition: pointcloud_adapters.h:39
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::setPointRGBu8
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: pointcloud_adapters.h:124
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::getPointRGBu8
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i'th point.
Definition: pointcloud_adapters.h:117
MRPT_UNUSED_PARAM
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::derived
const Derived & derived() const
Definition: pointcloud_adapters.h:55
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
g
GLubyte g
Definition: glext.h:6279
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
r
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::getPointRGBf
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i'th point.
Definition: pointcloud_adapters.h:100
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::setPointRGBf
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
Definition: pointcloud_adapters.h:107
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::derived
Derived & derived()
Definition: pointcloud_adapters.h:54
b
GLubyte GLubyte b
Definition: glext.h:6279
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::getPointXYZ_RGBf
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: pointcloud_adapters.h:62
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::setPointXYZ_RGBf
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: pointcloud_adapters.h:69
mrpt::opengl::PointCloudAdapter< pcl::PointCloud< pcl::PointXYZ > >
Specialization mrpt::opengl::PointCloudAdapter<pcl::PointCloud<pcl::PointXYZ> > for an XYZ point clou...
Definition: PCL_adapters.h:30
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::setPointXYZ_RGBu8
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: pointcloud_adapters.h:89
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
Definition: pointcloud_adapters.h:49
z
GLdouble GLdouble z
Definition: glext.h:3872
mrpt::opengl::detail::PointCloudAdapterHelperNoRGB::getPointXYZ_RGBu8
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: pointcloud_adapters.h:81
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST