PointCloud.hpp
Go to the documentation of this file.
1 
28  /*
29  * PointCloud.hpp
30  *
31  * Created on: 20.08.2011
32  * Author: Thomas Wiemann
33  */
34 
35 #ifndef POINTCLOUD_H_
36 #define POINTCLOUD_H_
37 
39 
41 
42 #include <vector>
43 #include <string>
44 #include <fstream>
45 
46 
47 using namespace std;
48 
49 
50 namespace lvr2
51 {
52 
53 enum
54 {
55  RenderPoints = 0x01,
56  RenderNormals = 0x02,
57 };
58 
59 class PointCloud : public Renderable{
60 public:
62  PointCloud();
63  PointCloud(ModelPtr loader, string name = "<unamed cloud>");
64  PointCloud(PointBufferPtr buffer, string name = "<unamed cloud>");
65 
66  virtual ~PointCloud();
67  virtual inline void render();
68 
69  vector<uColorVertex> getPoints(){return m_points;};
70  void setPoints(){};
71 
72  void addPoint(float x, float y, float z, unsigned char r, unsigned char g, unsigned char b)
73  {
74  m_boundingBox->expand(Vec(x, y, z));
75  m_points.push_back(uColorVertex(x, y, z, r, g, b));
76  };
77 
78  void addPoint(const uColorVertex& v)
79  {
80  m_boundingBox->expand(Vec(v.x, v.y, v.z));
81  m_points.push_back(v);
82  };
83 
84  void clear(){
85  delete m_boundingBox;
86  m_boundingBox = new BoundingBox<Vec>;
87  m_points.clear();
88  };
89 
90  void updateBuffer(PointBufferPtr buffer);
91 
92  void updateDisplayLists();
93 //private:
94  vector<uColorVertex> m_points;
95 
96  void setRenderMode(int mode) {m_renderMode = mode;}
97 
98 
99 private:
100  int getFieldsPerLine(string filename);
101  void init(PointBufferPtr buffer);
102 
106  size_t m_numNormals;
107 
108 };
109 
110 inline void PointCloud::render()
111 {
112  //cout << name << " : Active: " << " " << active << " selected : " << selected << endl;
113  if(m_listIndex != -1 && m_active)
114  {
115  // Increase point size if normal rendering is enabled
116  if(m_renderMode & RenderNormals)
117  {
118  glPointSize(5.0);
119  }
120  else
121  {
122  glPointSize(m_pointSize);
123  }
124  glDisable(GL_LIGHTING);
125  glPushMatrix();
126  glMultMatrixf(m_transformation.getData());
127 
128  // Render points
129  if(m_selected)
130  {
131  glCallList(m_activeListIndex);
132  }
133  else
134  {
135  glCallList(m_listIndex);
136  }
137 
138  // Render normals
139  if(m_renderMode & RenderNormals)
140  {
141  glCallList(m_normalListIndex);
142  }
143  glPointSize(1.0);
144  glEnable(GL_LIGHTING);
145  glPopMatrix();
146  }
147 }
148 
149 } // namespace lvr2
150 
151 #endif /* POINTCLOUD_H_ */
void render()
void addPoint(const uColorVertex &v)
Definition: PointCloud.hpp:78
ColorVertex< float, unsigned char > uColorVertex
floatArr m_normals
Definition: PointCloud.hpp:105
std::shared_ptr< PointBuffer > PointBufferPtr
A dynamic bounding box class.
Definition: BoundingBox.hpp:49
A color vertex.
Definition: ColorVertex.hpp:50
BaseVector< float > Vec
vector< uColorVertex > getPoints()
Definition: PointCloud.hpp:69
void setRenderMode(int mode)
Definition: PointCloud.hpp:96
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
void addPoint(float x, float y, float z, unsigned char r, unsigned char g, unsigned char b)
Definition: PointCloud.hpp:72
vector< uColorVertex > m_points
Definition: PointCloud.hpp:94
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
GLuint m_normalListIndex
Definition: PointCloud.hpp:104


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:08