StaticMesh.hpp
Go to the documentation of this file.
1 
28  /*
29  * StaticMesh.h
30  *
31  * Created on: 12.11.2008
32  * Author: Thomas Wiemann
33  */
34 
35 #ifndef STATICMESH_H_
36 #define STATICMESH_H_
37 
38 #ifdef WIN32
39 #pragma warning(disable: 4996)
40 #endif
41 
42 #include <stdlib.h>
43 #include <string>
44 #include <string.h>
45 #include <sstream>
46 
47 #ifdef _MSC_VER
48 #include <Windows.h>
49 #endif
50 
51 #ifndef __APPLE__
52 #include <GL/gl.h>
53 #else
54 #include <OpenGL/gl.h>
55 #endif
56 
59 
60 using namespace std;
61 
62 
63 namespace lvr2
64 {
65 
66 enum
67 {
72  RenderColors = 0x10,
73 };
74 
75 class StaticMesh : public Renderable
76 {
77 public:
78  StaticMesh();
79  StaticMesh( ModelPtr model, string name=""); // <unnamed static mesh>" );
80  StaticMesh( MeshBufferPtr buffer, string name=""); //<unnamed static mesh>" );
81 
82  StaticMesh(const StaticMesh &o);
83  ~StaticMesh();
84  inline void render();
85 
86  virtual void finalize();
87  virtual void savePLY(string filename);
88  virtual void setName(string name);
89 
90  floatArr getVertices();
91  uintArr getIndices();
92  float* getNormals();
93 
94  size_t getNumberOfVertices();
95  size_t getNumberOfFaces();
96 
97  void setRenderMode(int mode) { m_renderMode = mode;}
98  int getRenderMode() { return m_renderMode;}
99 
100 private:
101 
102  void init( MeshBufferPtr mesh );
103 
104  void interpolateNormals();
105  void setDefaultColors();
106  void calcBoundingBox();
107 
108 protected:
109 
110  //void compileDisplayLists();
111  void compileColoredMeshList();
112  void compileWireframeList();
113  void compileNameList();
114 
115  void setColorMaterial(float r, float g, float b);
116 
117 
118  void readPly(string filename);
119 
124  unsigned char* m_blackColors;
125 
127 
130 
132  size_t m_numFaces;
134 
136 
137 
141 
142 };
143 
145 
146  if(m_active)
147  {
148  if(m_finalized){
149  glPushMatrix();
150  glMultMatrixf(m_transformation.getData());
151  if(m_renderMode & RenderSurfaces)
152  {
153  glEnable(GL_LIGHTING);
154  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
155  glCallList(m_coloredMeshList);
156  glCallList(m_nameList);
157  }
158 
159  if(m_renderMode & RenderTriangles)
160  {
161  glDisable(GL_LIGHTING);
162  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
163  glLineWidth(m_lineWidth);
164  glColor3f(0.0, 0.0, 0.0);
165  glCallList(m_wireframeList);
166  glEnable(GL_LIGHTING);
167  }
168  glPopMatrix();
169 
170  }
171  }
172 }
173 
174 } // namespace lvr2
175 
176 #endif /* STATICMESH_H_ */
void render()
unsigned char * m_blackColors
Definition: StaticMesh.hpp:124
HalfEdgeMesh< Vec > mesh
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
boost::shared_array< unsigned int > uintArr
Definition: DataStruct.hpp:130
void setRenderMode(int mode)
Definition: StaticMesh.hpp:97
boost::shared_array< unsigned char > ucharArr
Definition: DataStruct.hpp:137
indexArray m_faces
Definition: StaticMesh.hpp:126
floatArr m_normals
Definition: StaticMesh.hpp:120
boost::shared_array< unsigned int > indexArray
Definition: DataStruct.hpp:128
float * m_faceNormals
Definition: StaticMesh.hpp:121
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
floatArr m_vertices
Definition: StaticMesh.hpp:122


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:09