Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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 opengl
00038 {
00039 class OPENGL_IMPEXP CPointCloud;
00040
00041
00042 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CPointCloud, CRenderizable, OPENGL_IMPEXP )
00043
00044
00045
00046
00047
00048
00049 class OPENGL_IMPEXP CPointCloud : public CRenderizable
00050 {
00051 DEFINE_SERIALIZABLE( CPointCloud )
00052 protected:
00053 enum Axis { None=0, Z, Y, X} m_colorFromDepth;
00054 vector_float m_xs,m_ys,m_zs;
00055 float m_pointSize;
00056
00057 public:
00058 void enableColorFromX(bool v=true) { if(v) m_colorFromDepth=CPointCloud::X; }
00059 void enableColorFromY(bool v=true) { if(v) m_colorFromDepth=CPointCloud::Y; }
00060 void enableColorFromZ(bool v=true) { if(v) m_colorFromDepth=CPointCloud::Z; }
00061
00062 void resize(size_t N) { m_xs.resize(N); m_ys.resize(N); m_zs.resize(N); }
00063 void reserve(size_t N) { m_xs.reserve(N); m_ys.reserve(N); m_zs.reserve(N); }
00064
00065 vector_float & getArrayX() {return m_xs;}
00066 vector_float & getArrayY() {return m_ys;}
00067 vector_float & getArrayZ() {return m_zs;}
00068
00069 void setPointSize(float p) { m_pointSize=p; }
00070 float getPointSize() const { return m_pointSize; }
00071
00072
00073 void clear();
00074
00075
00076 void insertPoint( float x,float y, float z );
00077
00078
00079
00080
00081 template <class POINTSMAP>
00082 inline void loadFromPointsMap( const POINTSMAP *themap) {
00083 themap->getAllPoints(m_xs,m_ys,m_zs);
00084 }
00085
00086
00087
00088 template<class LISTOFPOINTS> void loadFromPointsList( LISTOFPOINTS &pointsList)
00089 {
00090 MRPT_START
00091
00092 size_t N = pointsList.size();
00093
00094 m_xs.resize(N);
00095 m_ys.resize(N);
00096 m_zs.resize(N);
00097
00098 vector_float::iterator X, Y, Z;
00099 typename LISTOFPOINTS::const_iterator it;
00100
00101 for ( it=pointsList.begin(), X=m_xs.begin(), Y=m_ys.begin(),Z=m_zs.begin(); it!=pointsList.end(); it++, X++, Y++, Z++)
00102 {
00103 *X = (*it).x;
00104 *Y = (*it).y;
00105 *Z = (*it).z;
00106 }
00107
00108 MRPT_END
00109
00110 }
00111
00112
00113
00114 void render() const;
00115
00116
00117 void setGradientColors( const mrpt::utils::TColorf &colorMin, const mrpt::utils::TColorf &colorMax );
00118
00119 private:
00120
00121 CPointCloud();
00122
00123
00124 virtual ~CPointCloud() { }
00125
00126 mutable float m_min, m_max;
00127 mutable bool m_minmax_valid;
00128
00129 mrpt::utils::TColorf m_colorFromDepth_min, m_colorFromDepth_max;
00130 };
00131
00132 }
00133
00134 }
00135
00136
00137 #endif