cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
1
2
3
|
#ifndef STIM_GLOBJ_H
#define STIM_GLOBJ_H
|
98eecaa9
David Mayerich
VS and win32 updates
|
4
|
//#include <GL/glew.h>
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
5
6
|
#include <GL/glut.h>
#include <stim/math/vector.h>
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
7
|
#include <stim/visualization/obj.h>
|
b50c840e
David Mayerich
eliminated ANN fr...
|
8
|
#include <stim/gl/error.h>
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
9
10
11
12
13
14
15
16
|
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
|
17
18
|
template <typename T>
class glObj : public virtual stim::obj<T>
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
19
20
21
22
23
|
{
private:
using stim::obj<T>::L;
using stim::obj<T>::P;
using stim::obj<T>::F;
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
24
25
26
|
// using stim::obj<T>::numL();
// using std::vector<T>::size;
// using std::vector<T>::at;
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
27
28
29
30
|
GLuint dList;
void
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
31
|
init()
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
32
|
{
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
33
34
|
if(glIsList(dList))
glDeleteLists(dList, 1);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
35
|
dList = glGenLists(1);
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
36
|
glListBase(dList);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
37
|
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
38
|
glMatrixMode(GL_PROJECTION);
|
0311ab81
Pavel Govyadinov
fixed some issues...
|
39
|
glLoadIdentity();
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
40
|
glMatrixMode(GL_MODELVIEW);
|
0311ab81
Pavel Govyadinov
fixed some issues...
|
41
|
glLoadIdentity();
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
42
43
44
45
|
}
void
|
acc30a5e
Pavel Govyadinov
Added the ability...
|
46
|
Create(GLenum mode, bool blend = false, float opacity = 1.0, stim::vec3<float> point = stim::vec<float>(-10000.0, -10000.0, -10000.0))
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
47
|
{
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
48
49
50
51
|
// GLuint selectBuf[2048];
// GLint hits;
// glSelectBuffer(2048, selectBuf);
|
18cb8a07
Pavel Govyadinov
changed the wrong...
|
52
53
54
55
56
|
if(blend)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
57
|
int len = (int) stim::obj<T>::numL();
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
58
59
|
std::vector< stim::vec<float> > line;
glNewList(dList, GL_COMPILE);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
60
|
// glColor3f(0.0, 1.0, 0.0);
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
61
|
glLineWidth(3.5);
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
62
|
for(int i = 0; i < len; i++){
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
63
|
line = stim::obj<T>::getL_V(i);
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
64
65
66
67
|
if(mode == GL_SELECT)
{
glLoadName(i);
}
|
acc30a5e
Pavel Govyadinov
Added the ability...
|
68
69
70
71
72
73
74
75
76
|
if(blend == false)
glColor3f(0.0, 1.0, 0.05);
else if(blend && point[0] < -9999.9)
{
glColor4f(50.0/256.0,205.0/256.0, 50.0/256.0, opacity); ///Dark Green.
} else {
// ???????
}
|
1306fd96
Pavel Govyadinov
minor bug fixes i...
|
77
|
//glColor3ub(rand()%255, rand()%255, rand()%255);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
78
|
glBegin(GL_LINE_STRIP);
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
79
|
for(int j = 0; j < line.size(); j++){
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
80
|
glVertex3f(
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
81
82
83
84
85
86
87
|
line[j][0],
line[j][1],
line[j][2]
);
}
glEnd();
}
|
18cb8a07
Pavel Govyadinov
changed the wrong...
|
88
89
|
if(blend)
glDisable(GL_BLEND);
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
90
|
glEndList();
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
91
|
CHECK_OPENGL_ERROR
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
92
93
94
|
}
public:
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
95
|
glObj()
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
96
|
{
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
97
98
99
100
|
}
void
|
acc30a5e
Pavel Govyadinov
Added the ability...
|
101
102
103
104
105
106
107
108
|
createFromSelf(GLenum mode = GL_RENDER, bool blend = false, float opacity = 1.0)
{
// glPopMatrix();
init();
Create(mode, blend, opacity);
// glPushMatrix();
}
|
518258d3
Pavel Govyadinov
minor bug fixes
|
109
110
|
void
createFromSelf(stim::vec3<float> point, GLenum mode = GL_RENDER)
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
111
112
|
{
// glPopMatrix();
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
113
|
init();
|
518258d3
Pavel Govyadinov
minor bug fixes
|
114
|
Create(mode, true, 1.0, point);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
115
116
117
118
|
// glPushMatrix();
}
void
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
119
|
createFromFile(std::string filename, GLenum mode = GL_RENDER)
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
120
121
122
123
|
{
stim::obj<T>::load(filename);
glPushMatrix(); //Safety Operation to avoid changing the current matrix.
init();
|
84eff8b1
Pavel Govyadinov
Merged only the n...
|
124
|
Create(mode);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
125
126
|
glPopMatrix();
CHECK_OPENGL_ERROR
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
127
128
129
130
|
}
void
|
acc30a5e
Pavel Govyadinov
Added the ability...
|
131
|
Render(bool blend = false)
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
132
|
{
|
acc30a5e
Pavel Govyadinov
Added the ability...
|
133
134
135
136
137
|
if(blend)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
138
|
glCallList(dList);
|
acc30a5e
Pavel Govyadinov
Added the ability...
|
139
140
|
if(blend)
glDisable(GL_BLEND);
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
141
|
CHECK_OPENGL_ERROR
|
cce7daf9
Pavel Govyadinov
added glObj.h to ...
|
142
143
|
}
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
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
|
0311ab81
Pavel Govyadinov
fixed some issues...
|
164
|
RenderLine(std::vector< stim::vec3<T> > l)
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
{
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 ...
|
180
|
}
|
14b500f9
Pavel Govyadinov
minor bug fixes
|
181
|
#endif
|