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_ */
lvr2::floatArr
boost::shared_array< float > floatArr
Definition: DataStruct.hpp:133
lvr2::StaticMesh::m_renderMode
int m_renderMode
Definition: StaticMesh.hpp:135
lvr2::StaticMesh::m_faces
indexArray m_faces
Definition: StaticMesh.hpp:126
lvr2::StaticMesh::m_faceNormals
float * m_faceNormals
Definition: StaticMesh.hpp:121
lvr2::indexArray
boost::shared_array< unsigned int > indexArray
Definition: DataStruct.hpp:128
lvr2::StaticMesh::m_numFaces
size_t m_numFaces
Definition: StaticMesh.hpp:132
render
void render()
lvr2::RenderColors
@ RenderColors
Definition: StaticMesh.hpp:72
lvr2::RenderTriangles
@ RenderTriangles
Definition: StaticMesh.hpp:69
lvr2::StaticMesh::m_wireframeList
int m_wireframeList
Definition: StaticMesh.hpp:139
lvr2::StaticMesh::m_normals
floatArr m_normals
Definition: StaticMesh.hpp:120
lvr2::StaticMesh::m_blackColors
unsigned char * m_blackColors
Definition: StaticMesh.hpp:124
lvr2::StaticMesh
Definition: StaticMesh.hpp:75
lvr2::StaticMesh::m_finalized
bool m_finalized
Definition: StaticMesh.hpp:128
lvr2::RenderSurfaceNormals
@ RenderSurfaceNormals
Definition: StaticMesh.hpp:70
lvr2::RenderVertexNormals
@ RenderVertexNormals
Definition: StaticMesh.hpp:71
scripts.normalize_multiple.filename
filename
Definition: normalize_multiple.py:60
lvr2::Renderable
Definition: Renderable.hpp:65
Renderable.hpp
lvr2::StaticMesh::m_numMaterials
size_t m_numMaterials
Definition: StaticMesh.hpp:133
lvr2::ucharArr
boost::shared_array< unsigned char > ucharArr
Definition: DataStruct.hpp:137
lvr2::StaticMesh::getRenderMode
int getRenderMode()
Definition: StaticMesh.hpp:98
std
Definition: HalfEdge.hpp:124
lvr2::StaticMesh::setRenderMode
void setRenderMode(int mode)
Definition: StaticMesh.hpp:97
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::StaticMesh::m_colors
ucharArr m_colors
Definition: StaticMesh.hpp:123
lvr2::ModelPtr
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
lvr2::StaticMesh::m_numVertices
size_t m_numVertices
Definition: StaticMesh.hpp:131
lvr2::StaticMesh::m_haveMaterials
bool m_haveMaterials
Definition: StaticMesh.hpp:129
lvr2::StaticMesh::m_vertices
floatArr m_vertices
Definition: StaticMesh.hpp:122
lvr2::MeshBufferPtr
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
mesh
HalfEdgeMesh< Vec > mesh
Definition: src/tools/lvr2_gs_reconstruction/Main.cpp:26
lvr2::StaticMesh::m_nameList
int m_nameList
Definition: StaticMesh.hpp:140
lvr2::StaticMesh::m_coloredMeshList
int m_coloredMeshList
Definition: StaticMesh.hpp:138
BoundingBox.hpp
lvr2::RenderSurfaces
@ RenderSurfaces
Definition: StaticMesh.hpp:68
lvr2::uintArr
boost::shared_array< unsigned int > uintArr
Definition: DataStruct.hpp:130


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 Wed Mar 2 2022 00:37:25