Main MRPT website > C++ reference
MRPT logo
adapters.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef mrpt_utils_adapters_H
29 #define mrpt_utils_adapters_H
30 
31 #include <mrpt/utils/utils_defs.h>
32 
33 namespace mrpt
34 {
35  namespace utils
36  {
37  /** \defgroup mrpt_adapters_grp Adapter (wrapper) template classes
38  \addtogroup mrpt_base_grp
39  */
40 
41  /** \addtogroup mrpt_adapters_grp
42  * @{ */
43 
44  /** An adapter to different kinds of point cloud object.
45  * Implemented as a pure C++ template with specializations for the highest flexibility and efficiency in compiler-generated implementations.
46  * Usage:
47  * \code
48  * PC my_obj;
49  * my_obj.specific_methods();
50  * // ...
51  * PointCloudAdapter<PC> pca(my_obj);
52  * pca.unified_interface_methods();
53  * // ...
54  * \endcode
55  * See specializations for details on the exposed API.
56  */
57  template <class POINTCLOUD> class PointCloudAdapter;
58 
59  /** @} */ // end of grouping
60 
61 
62 
63  namespace detail
64  {
65  /** 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 */
66  template <class POINTMAPTYPE, typename coords_t>
68  {
69  public:
71 
72  inline Derived & derived() { return *static_cast<Derived*>(this); }
73  inline const Derived & derived() const { return *static_cast<const Derived*>(this); }
74 
75  /** Get XYZ_RGBf coordinates of i'th point */
76  template <typename T>
77  inline void getPointXYZ_RGBf(const size_t idx, T &x,T &y, T &z, float &r,float &g,float &b) const {
78  derived().getPointXYZ(idx,x,y,z);
79  r=g=b=1.0f;
80  }
81  /** Set XYZ_RGBf coordinates of i'th point */
82  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) {
83  derived().setPointXYZ(idx,x,y,z);
84  }
85 
86  /** Get XYZ_RGBu8 coordinates of i'th point */
87  template <typename T>
88  inline void getPointXYZ_RGBu8(const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b) const {
89  derived().getPointXYZ(idx,x,y,z);
90  r=g=b=255;
91  }
92  /** Set XYZ_RGBu8 coordinates of i'th point */
93  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) {
94  derived().setPointXYZ(idx,x,y,z);
95  }
96 
97  /** Get RGBf color of i'th point */
98  inline void getPointRGBf(const size_t idx, float &r,float &g,float &b) const { r=g=b=1.0f; }
99  /** Set XYZ_RGBf coordinates of i'th point */
100  inline void setPointRGBf(const size_t idx, const float r,const float g,const float b) { }
101 
102  /** Get RGBu8 color of i'th point */
103  inline void getPointRGBu8(const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b) const { r=g=b=255; }
104  /** Set RGBu8 coordinates of i'th point */
105  inline void setPointRGBu8(const size_t idx,const uint8_t r,const uint8_t g,const uint8_t b) { }
106  }; // end of PointCloudAdapterHelperNoRGB
107  } // End of namespace detail
108 
109  } // End of namespace
110 } // end of namespace
111 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013