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_CPointCloudColoured_H
00030 #define opengl_CPointCloudColoured_H
00031
00032 #include <mrpt/opengl/CRenderizable.h>
00033 #include <mrpt/utils/CImage.h>
00034 #include <mrpt/utils/stl_extensions.h>
00035
00036 namespace mrpt
00037 {
00038 namespace opengl
00039 {
00040 class OPENGL_IMPEXP CPointCloudColoured;
00041
00042
00043 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CPointCloudColoured, CRenderizable, OPENGL_IMPEXP )
00044
00045
00046
00047
00048
00049
00050
00051
00052 class OPENGL_IMPEXP CPointCloudColoured : public CRenderizable
00053 {
00054 DEFINE_SERIALIZABLE( CPointCloudColoured )
00055
00056 public:
00057 struct TPointColour
00058 {
00059 TPointColour( float _x=0,float _y=0,float _z=0,float _R=0,float _G=0,float _B=0 ) :
00060 x(_x),y(_y),z(_z),R(_R),G(_G),B(_B)
00061 { }
00062 float x,y,z,R,G,B;
00063 };
00064
00065 private:
00066 typedef std::vector<TPointColour> TListPointColour;
00067
00068 TListPointColour m_points;
00069 float m_pointSize;
00070
00071
00072
00073 CPointCloudColoured( ) :
00074 m_points(),
00075 m_pointSize(1)
00076 {
00077 }
00078
00079 virtual ~CPointCloudColoured() { }
00080
00081 public:
00082 typedef TListPointColour::iterator iterator;
00083 typedef TListPointColour::const_iterator const_iterator;
00084
00085 inline iterator begin() { return m_points.begin(); }
00086 inline const_iterator begin() const { return m_points.begin(); }
00087 inline iterator end() { return m_points.end(); }
00088 inline const_iterator end() const { return m_points.end(); }
00089
00090
00091 inline void push_back(float x,float y,float z, float R, float G, float B) {
00092 m_points.push_back(TPointColour(x,y,z,R,G,B));
00093 }
00094
00095 inline void reserve(size_t N) { m_points.reserve(N); }
00096 inline void resize(size_t N) { m_points.resize(N); }
00097
00098
00099 TPointColour &operator [](size_t i) { return m_points[i]; }
00100
00101 inline size_t size() const { return m_points.size(); }
00102 inline void clear() { m_points.clear(); }
00103
00104 inline void setPointSize(float pointSize) { m_pointSize = pointSize; }
00105 inline float getPointSize() const { return m_pointSize; }
00106
00107
00108
00109
00110
00111 template <class POINTSMAP>
00112 void loadFromPointsMap( const POINTSMAP *m)
00113 {
00114 if (m->hasColorPoints())
00115 {
00116 size_t N = m->size();
00117 m_points.resize(N);
00118 for (size_t i=0;i<N;i++)
00119 {
00120 m->getPoint(i,
00121 m_points[i].x,
00122 m_points[i].y,
00123 m_points[i].z,
00124 m_points[i].R,
00125 m_points[i].G,
00126 m_points[i].B );
00127 }
00128 }
00129 else
00130 {
00131
00132 vector_float xs,ys,zs;
00133 m->getAllPoints(xs,ys,zs);
00134
00135 size_t N = xs.size();
00136 m_points.resize(N);
00137 for (size_t i=0;i<N;i++)
00138 {
00139 m_points[i].x = xs[i];
00140 m_points[i].y = ys[i];
00141 m_points[i].z = zs[i];
00142 m_points[i].R = m_color_R;
00143 m_points[i].G = m_color_G;
00144 m_points[i].B = m_color_B;
00145 }
00146 }
00147 }
00148
00149
00150
00151 void render() const;
00152
00153 };
00154
00155 OPENGL_IMPEXP mrpt::utils::CStream& operator>>(mrpt::utils::CStream& in, CPointCloudColoured::TPointColour &o);
00156 OPENGL_IMPEXP mrpt::utils::CStream& operator<<(mrpt::utils::CStream& out, const CPointCloudColoured::TPointColour &o);
00157
00158 }
00159
00160 namespace utils
00161 {
00162 using namespace mrpt::opengl;
00163
00164
00165 MRPT_DECLARE_TTYPENAME(CPointCloudColoured::TPointColour)
00166 }
00167
00168 }
00169
00170
00171 #endif