00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 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 00029 #ifndef opengl_CPointCloud_H 00030 #define opengl_CPointCloud_H 00031 00032 #include <mrpt/opengl/CRenderizable.h> 00033 #include <mrpt/utils/CImage.h> 00034 00035 namespace mrpt 00036 { 00037 namespace slam { class CPointsMap; } 00038 00039 namespace opengl 00040 { 00041 class MRPTDLLIMPEXP CPointCloud; 00042 00043 // This must be added to any CSerializable derived class: 00044 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( CPointCloud, CRenderizable ) 00045 00046 00047 /** A cloud of points, all with the same color or each depending on its value along a particular coordinate axis. 00048 * \sa opengl::CPlanarLaserScan, opengl::COpenGLScene, opengl::CPointCloudColoured 00049 */ 00050 class MRPTDLLIMPEXP CPointCloud : public CRenderizable 00051 { 00052 DEFINE_SERIALIZABLE( CPointCloud ) 00053 protected: 00054 enum Axis { None=0, Z, Y, X} m_colorFromDepth; 00055 vector_float m_xs,m_ys,m_zs; 00056 float m_pointSize; //!< By default is 1.0 00057 00058 public: 00059 void enableColorFromX(bool v=true) { if(v) m_colorFromDepth=CPointCloud::X; } 00060 void enableColorFromY(bool v=true) { if(v) m_colorFromDepth=CPointCloud::Y; } 00061 void enableColorFromZ(bool v=true) { if(v) m_colorFromDepth=CPointCloud::Z; } 00062 00063 vector_float & getArrayX() {return m_xs;} //!< Get a reference to the internal array of X coordinates 00064 vector_float & getArrayY() {return m_ys;} //!< Get a reference to the internal array of Y coordinates 00065 vector_float & getArrayZ() {return m_zs;} //!< Get a reference to the internal array of Z coordinates 00066 00067 void setPointSize(float p) { m_pointSize=p; } //!< By default is 1.0 00068 float getPointSize() const { return m_pointSize; } 00069 00070 /** Empty the list of points. */ 00071 void clear(); 00072 00073 /** Adds a new point to the cloud */ 00074 void insertPoint( float x,float y, float z ); 00075 00076 /** Load the points from a points map 00077 */ 00078 void loadFromPointsMap( const mrpt::slam::CPointsMap *map); 00079 00080 /** Render 00081 */ 00082 void render() const; 00083 00084 /** Sets the colors used as extremes when colorFromDepth is enabled. */ 00085 void setGradientColors( const mrpt::utils::TColorf &colorMin, const mrpt::utils::TColorf &colorMax ); 00086 00087 private: 00088 /** Constructor */ 00089 CPointCloud(); 00090 00091 /** Private, virtual destructor: only can be deleted from smart pointers */ 00092 virtual ~CPointCloud() { } 00093 00094 mutable float m_min, m_max; //!< Buffer for min/max coords when m_colorFromDepth is true. 00095 mutable bool m_minmax_valid; 00096 00097 mrpt::utils::TColorf m_colorFromDepth_min, m_colorFromDepth_max; //!< The colors used to interpolate when m_colorFromDepth is true. 00098 }; 00099 00100 } // end namespace 00101 00102 } // End of namespace 00103 00104 00105 #endif
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 23:02:22 EDT 2009 |