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 CSimplePointsMap_H 00029 #define CSimplePointsMap_H 00030 00031 #include <mrpt/slam/CPointsMap.h> 00032 #include <mrpt/slam/CObservation2DRangeScan.h> 00033 #include <mrpt/slam/CObservation3DRangeScan.h> 00034 #include <mrpt/utils/CSerializable.h> 00035 #include <mrpt/math/CMatrix.h> 00036 00037 #include <mrpt/maps/link_pragmas.h> 00038 00039 namespace mrpt 00040 { 00041 namespace slam 00042 { 00043 00044 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CSimplePointsMap , CPointsMap, MAPS_IMPEXP ) 00045 00046 /** A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. 00047 * This class only stores the coordinates (x,y,z) of each point. 00048 * 00049 * See mrpt::slam::CPointsMap and derived classes for other point cloud classes. 00050 * 00051 * \sa CMetricMap, CWeightedPointsMap, CPoint, mrpt::utils::CSerializable 00052 * \ingroup mrpt_maps_grp 00053 */ 00054 class MAPS_IMPEXP CSimplePointsMap : public CPointsMap 00055 { 00056 // This must be added to any CSerializable derived class: 00057 DEFINE_SERIALIZABLE( CSimplePointsMap ) 00058 00059 public: 00060 CSimplePointsMap(); //!< Default constructor 00061 virtual ~CSimplePointsMap(); //!< Destructor 00062 00063 // -------------------------------------------- 00064 /** @name Pure virtual interfaces to be implemented by any class derived from CPointsMap 00065 @{ */ 00066 00067 /** Reserves memory for a given number of points: the size of the map does not change, it only reserves the memory. 00068 * This is useful for situations where it is approximately known the final size of the map. This method is more 00069 * efficient than constantly increasing the size of the buffers. Refer to the STL C++ library's "reserve" methods. 00070 */ 00071 virtual void reserve(size_t newLength); 00072 00073 /** Resizes all point buffers so they can hold the given number of points: newly created points are set to default values, 00074 * and old contents are not changed. 00075 * \sa reserve, setPoint, setPointFast, setSize 00076 */ 00077 virtual void resize(size_t newLength); 00078 00079 /** Resizes all point buffers so they can hold the given number of points, *erasing* all previous contents 00080 * and leaving all points to default values. 00081 * \sa reserve, setPoint, setPointFast, setSize 00082 */ 00083 virtual void setSize(size_t newLength); 00084 00085 /** Changes the coordinates of the given point (0-based index), *without* checking for out-of-bounds and *without* calling mark_as_modified() \sa setPoint */ 00086 virtual void setPointFast(size_t index,float x, float y, float z); 00087 00088 /** The virtual method for \a insertPoint() *without* calling mark_as_modified() */ 00089 virtual void insertPointFast( float x, float y, float z = 0 ); 00090 00091 /** Virtual assignment operator, to be implemented in derived classes. 00092 */ 00093 virtual void copyFrom(const CPointsMap &obj); 00094 00095 /** Get all the data fields for one point as a vector: [X Y Z] 00096 * Unlike getPointAllFields(), this method does not check for index out of bounds 00097 * \sa getPointAllFields, setPointAllFields, setPointAllFieldsFast 00098 */ 00099 virtual void getPointAllFieldsFast( const size_t index, std::vector<float> & point_data ) const { 00100 point_data.resize(3); 00101 point_data[0] = x[index]; 00102 point_data[1] = y[index]; 00103 point_data[2] = z[index]; 00104 } 00105 00106 /** Set all the data fields for one point as a vector: [X Y Z] 00107 * Unlike setPointAllFields(), this method does not check for index out of bounds 00108 * \sa setPointAllFields, getPointAllFields, getPointAllFieldsFast 00109 */ 00110 virtual void setPointAllFieldsFast( const size_t index, const std::vector<float> & point_data ) { 00111 ASSERTDEB_(point_data.size()==3) 00112 x[index] = point_data[0]; 00113 y[index] = point_data[1]; 00114 z[index] = point_data[2]; 00115 } 00116 00117 /** See CPointsMap::loadFromRangeScan() */ 00118 virtual void loadFromRangeScan( 00119 const CObservation2DRangeScan &rangeScan, 00120 const CPose3D *robotPose = NULL ); 00121 00122 /** See CPointsMap::loadFromRangeScan() */ 00123 virtual void loadFromRangeScan( 00124 const CObservation3DRangeScan &rangeScan, 00125 const CPose3D *robotPose = NULL ); 00126 00127 00128 protected: 00129 00130 /** Auxiliary method called from within \a addFrom() automatically, to finish the copying of class-specific data */ 00131 virtual void addFrom_classSpecific(const CPointsMap &anotherMap, const size_t nPreviousPoints) { 00132 // No extra data. 00133 } 00134 00135 // Friend methods: 00136 template <class Derived> friend struct detail::loadFromRangeImpl; 00137 template <class Derived> friend struct detail::pointmap_traits; 00138 00139 public: 00140 00141 00142 /** @} */ 00143 // -------------------------------------------- 00144 00145 00146 /** If the map is a simple points map or it's a multi-metric map that contains EXACTLY one simple points map, return it. 00147 * Otherwise, return NULL 00148 */ 00149 virtual const CSimplePointsMap * getAsSimplePointsMap() const { return this; } 00150 virtual CSimplePointsMap * getAsSimplePointsMap() { return this; } 00151 00152 protected: 00153 /** Clear the map, erasing all the points. 00154 */ 00155 virtual void internal_clear(); 00156 00157 /** @name PLY Import virtual methods to implement in base classes 00158 @{ */ 00159 /** In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex */ 00160 virtual void PLY_import_set_vertex_count(const size_t N); 00161 /** @} */ 00162 00163 }; // End of class def. 00164 00165 } // End of namespace 00166 } // End of namespace 00167 00168 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |