00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef mrpt_utils_adapters_H 00029 #define mrpt_utils_adapters_H 00030 00031 #include <mrpt/utils/utils_defs.h> 00032 00033 namespace mrpt 00034 { 00035 namespace utils 00036 { 00037 /** \defgroup mrpt_adapters_grp Adapter (wrapper) template classes 00038 \addtogroup mrpt_base_grp 00039 */ 00040 00041 /** \addtogroup mrpt_adapters_grp 00042 * @{ */ 00043 00044 /** An adapter to different kinds of point cloud object. 00045 * Implemented as a pure C++ template with specializations for the highest flexibility and efficiency in compiler-generated implementations. 00046 * Usage: 00047 * \code 00048 * PC my_obj; 00049 * my_obj.specific_methods(); 00050 * // ... 00051 * PointCloudAdapter<PC> pca(my_obj); 00052 * pca.unified_interface_methods(); 00053 * // ... 00054 * \endcode 00055 * See specializations for details on the exposed API. 00056 */ 00057 template <class POINTCLOUD> class PointCloudAdapter; 00058 00059 /** @} */ // end of grouping 00060 00061 00062 00063 namespace detail 00064 { 00065 /** 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 */ 00066 template <class POINTMAPTYPE, typename coords_t> 00067 class PointCloudAdapterHelperNoRGB 00068 { 00069 public: 00070 typedef PointCloudAdapter<POINTMAPTYPE> Derived; 00071 00072 inline Derived & derived() { return *static_cast<Derived*>(this); } 00073 inline const Derived & derived() const { return *static_cast<const Derived*>(this); } 00074 00075 /** Get XYZ_RGBf coordinates of i'th point */ 00076 template <typename T> 00077 inline void getPointXYZ_RGBf(const size_t idx, T &x,T &y, T &z, float &r,float &g,float &b) const { 00078 derived().getPointXYZ(idx,x,y,z); 00079 r=g=b=1.0f; 00080 } 00081 /** Set XYZ_RGBf coordinates of i'th point */ 00082 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) { 00083 derived().setPointXYZ(idx,x,y,z); 00084 } 00085 00086 /** Get XYZ_RGBu8 coordinates of i'th point */ 00087 template <typename T> 00088 inline void getPointXYZ_RGBu8(const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b) const { 00089 derived().getPointXYZ(idx,x,y,z); 00090 r=g=b=255; 00091 } 00092 /** Set XYZ_RGBu8 coordinates of i'th point */ 00093 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) { 00094 derived().setPointXYZ(idx,x,y,z); 00095 } 00096 00097 /** Get RGBf color of i'th point */ 00098 inline void getPointRGBf(const size_t idx, float &r,float &g,float &b) const { r=g=b=1.0f; } 00099 /** Set XYZ_RGBf coordinates of i'th point */ 00100 inline void setPointRGBf(const size_t idx, const float r,const float g,const float b) { } 00101 00102 /** Get RGBu8 color of i'th point */ 00103 inline void getPointRGBu8(const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b) const { r=g=b=255; } 00104 /** Set RGBu8 coordinates of i'th point */ 00105 inline void setPointRGBu8(const size_t idx,const uint8_t r,const uint8_t g,const uint8_t b) { } 00106 }; // end of PointCloudAdapterHelperNoRGB 00107 } // End of namespace detail 00108 00109 } // End of namespace 00110 } // end of namespace 00111 #endif
| Page generated by Doxygen 1.7.4 for MRPT 0.9.5 SVN:2717 at Sun Oct 16 16:08:03 PDT 2011 | Hosted on: |