cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
1
2
3
|
#ifndef STIM_GLOBJ_H
#define STIM_GLOBJ_H
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
4
5
6
|
#include <GL/glew.h>
#include <GL/glut.h>
#include <stim/math/vector.h>
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
7
|
#include <stim/visualization/obj.h>
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
8
9
10
11
12
13
14
15
|
namespace stim
{
/** This class uses the loading functionality of the obj class in order to
* Assist with the visualization the segmented vessels.
* Uses
*/
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
16
17
|
template <typename T>
class glObj : public virtual stim::obj<T>
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
18
19
20
21
22
|
{
private:
using stim::obj<T>::L;
using stim::obj<T>::P;
using stim::obj<T>::F;
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
23
24
25
|
// using stim::obj<T>::numL();
// using std::vector<T>::size;
// using std::vector<T>::at;
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
26
27
28
29
|
GLuint dList;
void
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
30
|
init()
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
31
|
{
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
32
33
|
if(glIsList(dList))
glDeleteLists(dList, 1);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
34
|
dList = glGenLists(1);
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
35
|
glListBase(dList);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
36
|
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
37
38
39
40
41
42
43
44
|
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
}
void
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
45
|
Create(GLenum mode)
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
46
|
{
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
47
48
49
50
|
// GLuint selectBuf[2048];
// GLint hits;
// glSelectBuffer(2048, selectBuf);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
51
|
int len = (int) stim::obj<T>::numL();
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
52
53
|
std::vector< stim::vec<float> > line;
glNewList(dList, GL_COMPILE);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
54
|
// glColor3f(0.0, 1.0, 0.0);
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
55
|
glLineWidth(3.5);
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
56
|
for(int i = 0; i < len; i++){
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
57
|
line = stim::obj<T>::getL_V(i);
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
58
59
60
61
|
if(mode == GL_SELECT)
{
glLoadName(i);
}
|
1306fd96
Pavel Govyadinov
minor bug fixes i...
|
62
63
|
glColor3f(0.0, 1.0, 0.05);
//glColor3ub(rand()%255, rand()%255, rand()%255);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
64
|
glBegin(GL_LINE_STRIP);
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
65
|
for(int j = 0; j < line.size(); j++){
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
66
|
glVertex3f(
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
67
68
69
70
71
72
73
74
|
line[j][0],
line[j][1],
line[j][2]
);
}
glEnd();
}
glEndList();
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
75
|
CHECK_OPENGL_ERROR
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
76
77
78
|
}
public:
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
79
|
glObj()
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
80
|
{
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
81
82
83
84
|
}
void
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
85
|
createFromSelf(GLenum mode = GL_RENDER)
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
86
87
|
{
// glPopMatrix();
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
88
|
init();
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
89
|
Create(mode);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
90
91
92
93
|
// glPushMatrix();
}
void
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
94
|
createFromFile(std::string filename, GLenum mode = GL_RENDER)
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
95
96
97
98
|
{
stim::obj<T>::load(filename);
glPushMatrix(); //Safety Operation to avoid changing the current matrix.
init();
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
99
|
Create(mode);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
100
101
|
glPopMatrix();
CHECK_OPENGL_ERROR
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
102
103
104
105
106
107
108
|
}
void
Render()
{
glCallList(dList);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
109
|
CHECK_OPENGL_ERROR
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
110
111
|
}
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
void
RenderLine(int i)
{
std::vector < stim::vec<T> > line;
int len = (int) stim::obj<T>::numL();
line = stim::obj<T>::getL_V(i);
glColor3f(0.5, 1.0, 0.5);
glLineWidth(3.0);
glBegin(GL_LINE_STRIP);
for(int j = 0; j < line.size(); j++){
glVertex3f(
line[j][0],
line[j][1],
line[j][2]
);
}
glEnd();
}
void
RenderLine(std::vector< stim::vec<T> > l)
{
glColor3f(0.5, 1.0, 0.5);
glLineWidth(3.0);
glBegin(GL_LINE_STRIP);
for(int j = 0; j < l.size(); j++){
glVertex3f(
l[j][0],
l[j][1],
l[j][2]
);
}
glEnd();
}
};
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
148
|
}
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
149
|
#endif
|