9c97e126
David Mayerich
added an axis-ali...
|
1
2
3
4
|
#ifndef STIM_GL_NETWORK
#define STIM_GL_NETWORK
#include <stim/biomodels/network.h>
|
b3a38641
David Mayerich
added the ability...
|
5
|
#include <stim/visualization/aaboundingbox.h>
|
9c97e126
David Mayerich
added an axis-ali...
|
6
7
8
9
10
11
12
13
14
15
|
namespace stim{
template <typename T>
class gl_network : public stim::network<T>{
protected:
using stim::network<T>::E;
using stim::network<T>::V;
|
649a5e34
David Mayerich
implemented displ...
|
16
17
|
GLuint dlist;
|
9c97e126
David Mayerich
added an axis-ali...
|
18
19
20
|
public:
/// Default constructor
|
649a5e34
David Mayerich
implemented displ...
|
21
22
23
|
gl_network() : stim::network<T>(){
dlist = 0;
}
|
9c97e126
David Mayerich
added an axis-ali...
|
24
25
|
/// Constructor creates a gl_network from a stim::network
|
649a5e34
David Mayerich
implemented displ...
|
26
27
28
|
gl_network(stim::network<T> N) : stim::network<T>(N){
dlist = 0;
}
|
9c97e126
David Mayerich
added an axis-ali...
|
29
30
31
|
/// Fills the parameters with the minimum and maximum spatial positions in the network,
/// specifying a bounding box for the network geometry
|
b3a38641
David Mayerich
added the ability...
|
32
|
aaboundingbox<T> boundingbox(){
|
9c97e126
David Mayerich
added an axis-ali...
|
33
|
|
b3a38641
David Mayerich
added the ability...
|
34
|
aaboundingbox<T> bb; //create a bounding box
|
9c97e126
David Mayerich
added an axis-ali...
|
35
36
37
38
39
40
41
42
43
44
45
|
//loop through every edge
for(unsigned e = 0; e < E.size(); e++){
//loop through every point
for(unsigned p = 0; p < E[e].size(); p++)
bb.expand(E[e][p]); //expand the bounding box to include the point
}
return bb; //return the bounding box
}
|
6b317c71
Jiaming Guo
add function to r...
|
46
47
48
49
50
51
52
53
54
55
|
///render cylinder based on points from the top/bottom hat
///@param C1 set of points from one of the hat
void renderCylinder(std::vector< stim::vec3<T> > C1, std::vector< stim::vec3<T> > C2) {
glBegin(GL_QUAD_STRIP);
for (unsigned i = 0; i < C1.size(); i++) { // for every point on the circle
glVertex3f(C1[i][0], C1[i][1], C1[i][2]);
glVertex3f(C2[i][0], C2[i][1], C2[i][2]);
}
glEnd();
//glFlush();
|
b019bc5e
Jiaming Guo
add function to r...
|
56
57
|
}
|
6b317c71
Jiaming Guo
add function to r...
|
58
59
60
61
|
///render the vertex as sphere
///@param x, y, z are the three coordinates of the center point
///@param radius is the radius of the sphere
///@param subdivisions is the slice/stride along/around z-axis
|
b019bc5e
Jiaming Guo
add function to r...
|
62
63
64
65
66
67
68
|
void renderBall(T x, T y, T z, T radius, int subdivisions) {
glPushMatrix();
glTranslatef(x, y, z);
glutSolidSphere(radius, subdivisions, subdivisions);
glPopMatrix();
}
|
9c97e126
David Mayerich
added an axis-ali...
|
69
|
/// Render the network centerline as a series of line strips.
|
fdfdeda0
Jiaming Guo
fix minor mistakes
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/// glCenterline0 is for only one input
void glCenterline0(){
if (!glIsList(dlist)) { //if dlist isn't a display list, create it
dlist = glGenLists(1); //generate a display list
glNewList(dlist, GL_COMPILE); //start a new display list
for (unsigned e = 0; e < E.size(); e++) { //for each edge in the network
glBegin(GL_LINE_STRIP);
for (unsigned p = 0; p < E[e].size(); p++) { //for each point on that edge
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); //set the vertex position based on the current point
glTexCoord1f(0); //set white color
}
glEnd();
}
glEndList(); //end the display list
}
glCallList(dlist); // render the display list
}
|
b3a38641
David Mayerich
added the ability...
|
87
|
|
1599ae65
Jiaming Guo
add swc.h and fun...
|
88
89
90
91
92
93
94
|
/// render the network centerline from swc file as a series of strips in different colors based on the neuronal type
/// glCenterline0_swc is for only one input
void glCenterline0_swc() {
if (!glIsList(dlist)) { // if dlist isn't a display list, create it
dlist = glGenLists(1); // generate a display list
glNewList(dlist, GL_COMPILE); // start a new display list
for (unsigned e = 0; e < E.size(); e++) {
|
58674036
Jiaming Guo
fix minor error f...
|
95
|
int type = NT[e]; // get the neuronal type
|
1599ae65
Jiaming Guo
add swc.h and fun...
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
switch (type) {
case 0:
glColor3f(1.0f, 1.0f, 1.0f); // white for undefined
glBegin(GL_LINE_STRIP);
for (unsigned p = 0; p < E[e].size(); p++) {
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
break;
case 1:
glColor3f(1.0f, 0.0f, 0.0f); // red for soma
glBegin(GL_LINE_STRIP);
for (unsigned p = 0; p < E[e].size(); p++) {
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
break;
case 2:
glColor3f(1.0f, 0.5f, 0.0f); // orange for axon
glBegin(GL_LINE_STRIP);
for (unsigned p = 0; p < E[e].size(); p++) {
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
break;
case 3:
glColor3f(1.0f, 1.0f, 0.0f); // yellow for undefined
glBegin(GL_LINE_STRIP);
for (unsigned p = 0; p < E[e].size(); p++) {
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
break;
case 4:
glColor3f(0.0f, 1.0f, 0.0f); // green for undefined
glBegin(GL_LINE_STRIP);
for (unsigned p = 0; p < E[e].size(); p++) {
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
break;
case 5:
glColor3f(0.0f, 1.0f, 1.0f); // verdant for undefined
glBegin(GL_LINE_STRIP);
for (unsigned p = 0; p < E[e].size(); p++) {
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
break;
case 6:
glColor3f(0.0f, 0.0f, 1.0f); // blue for undefined
glBegin(GL_LINE_STRIP);
for (unsigned p = 0; p < E[e].size(); p++) {
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
break;
case 7:
glColor3f(0.5f, 0.0f, 1.0f); // purple for undefined
glBegin(GL_LINE_STRIP);
for (unsigned p = 0; p < E[e].size(); p++) {
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
break;
}
}
glEndList(); //end the display list
}
glCallList(dlist); // render the display list
}
|
58674036
Jiaming Guo
fix minor error f...
|
168
169
|
///render the network centerline as a series of line strips(when loading at least two networks, otherwise using glCenterline0())
///colors are based on metric values
|
0d0ef1a9
David Mayerich
Adapted classes t...
|
170
|
void glCenterline(){
|
9c97e126
David Mayerich
added an axis-ali...
|
171
|
|
649a5e34
David Mayerich
implemented displ...
|
172
|
if(!glIsList(dlist)){ //if dlist isn't a display list, create it
|
b019bc5e
Jiaming Guo
add function to r...
|
173
|
dlist = glGenLists(1); //generate a display list
|
649a5e34
David Mayerich
implemented displ...
|
174
175
|
glNewList(dlist, GL_COMPILE); //start a new display list
for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network
|
0d0ef1a9
David Mayerich
Adapted classes t...
|
176
|
//unsigned errormag_id = E[e].nmags() - 1;
|
649a5e34
David Mayerich
implemented displ...
|
177
|
glBegin(GL_LINE_STRIP);
|
b3a38641
David Mayerich
added the ability...
|
178
179
|
for(unsigned p = 0; p < E[e].size(); p++){ //for each point on that edge
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]); //set the vertex position based on the current point
|
1599ae65
Jiaming Guo
add swc.h and fun...
|
180
|
glTexCoord1f(E[e].r(p)); //set the texture coordinate based on the specified magnitude index
|
649a5e34
David Mayerich
implemented displ...
|
181
182
|
}
glEnd();
|
9c97e126
David Mayerich
added an axis-ali...
|
183
|
}
|
649a5e34
David Mayerich
implemented displ...
|
184
185
|
glEndList(); //end the display list
}
|
6b317c71
Jiaming Guo
add function to r...
|
186
|
glCallList(dlist); //render the display list
|
c72184d1
Jiaming Guo
add many function...
|
187
|
}
|
9c97e126
David Mayerich
added an axis-ali...
|
188
|
|
58674036
Jiaming Guo
fix minor error f...
|
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
///render the network cylinder as a series of tubes
///colors are based on metric values
void glCylinder() {
if (!glIsList(dlist)) { //if dlist isn't a display list, create it
dlist = glGenLists(1); //generate a display list
glNewList(dlist, GL_COMPILE); //start a new display list
for (unsigned e = 0; e < E.size(); e++) { //for each edge in the network
for (unsigned p = 1; p < E[e].size(); p++) { // for each point on that edge
stim::circle<T> C1 = E[e].circ(p - 1);
stim::circle<T> C2 = E[e].circ(p);
C1.set_R(10); // scale the circle to the same
C2.set_R(10);
std::vector< stim::vec3<T> >Cp1 = C1.points(20);
std::vector< stim::vec3<T> >Cp2 = C2.points(20);
glBegin(GL_QUAD_STRIP);
for (unsigned i = 0; i < Cp1.size(); i++) { // for every point on the circle
glVertex3f(Cp1[i][0], Cp1[i][1], Cp1[i][2]);
glVertex3f(Cp2[i][0], Cp2[i][1], Cp2[i][2]);
glTexCoord1f(E[e].r(p));
}
glEnd();
} //set the texture coordinate based on the specified magnitude index
}
glEndList(); //end the display list
}
glCallList(dlist); //render the display list
}
|
6b317c71
Jiaming Guo
add function to r...
|
217
218
219
220
|
///render the GT network cylinder as series of tubes
///@param dlist1 is the display list
///@param map is the mapping relationship between two networks
///@param colormap is the random generated color set for render
|
58674036
Jiaming Guo
fix minor error f...
|
221
|
void glRandColorCylinder1(GLuint &dlist1, std::vector<unsigned> map, std::vector<T> colormap) {
|
6b317c71
Jiaming Guo
add function to r...
|
222
223
224
225
226
227
228
229
230
|
if (!glIsList(dlist1)) { // if dlist1 isn't a display list, create it
dlist1 = glGenLists(1); // generate a display list
glNewList(dlist1, GL_COMPILE); // start a new display list
for (unsigned e = 0; e < E.size(); e++) { // for each edge in the network
if (map[e] != unsigned(-1)) {
glColor3f(colormap[e * 3 + 0], colormap[e * 3 + 1], colormap[e * 3 + 2]);
for (unsigned p = 1; p < E[e].size(); p++) {// for each point on that edge
stim::circle<T> C1 = E[e].circ(p - 1);
stim::circle<T> C2 = E[e].circ(p);
|
1599ae65
Jiaming Guo
add swc.h and fun...
|
231
|
C1.set_R(10); // scale the circle to the same
|
6b317c71
Jiaming Guo
add function to r...
|
232
233
234
235
236
237
238
239
|
C2.set_R(10);
std::vector< stim::vec3<T> >Cp1 = C1.points(20);
std::vector< stim::vec3<T> >Cp2 = C2.points(20);
renderCylinder(Cp1, Cp2);
}
}
else {
glColor3f(1.0f, 1.0f, 1.0f); // white color for the un-mapping edges
|
1599ae65
Jiaming Guo
add swc.h and fun...
|
240
|
for (unsigned p = 1; p < E[e].size(); p++) { // for each point on that edge
|
6b317c71
Jiaming Guo
add function to r...
|
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
stim::circle<T> C1 = E[e].circ(p - 1);
stim::circle<T> C2 = E[e].circ(p);
C1.set_R(10); // scale the circle to the same
C2.set_R(10);
std::vector< stim::vec3<T> >Cp1 = C1.points(20);
std::vector< stim::vec3<T> >Cp2 = C2.points(20);
renderCylinder(Cp1, Cp2);
}
}
}
for (unsigned v = 0; v < V.size(); v++) {
size_t num_edge = V[v].e[0].size() + V[v].e[1].size();
if (num_edge > 1) { // if it is the joint vertex
glColor3f(0.3, 0.3, 0.3); // gray color
renderBall(V[v][0], V[v][1], V[v][2], 20, 20);
}
else { // if it is the terminal vertex
glColor3f(0.6, 0.6, 0.6); // more white gray
renderBall(V[v][0], V[v][1], V[v][2], 20, 20);
}
}
glEndList();
}
glCallList(dlist1);
}
|
58674036
Jiaming Guo
fix minor error f...
|
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
void glRandColorCylinder1_swc(GLuint &dlist1, std::vector<unsigned> map, std::vector<T> colormap) {
if (!glIsList(dlist1)) { // if dlist1 isn't a display list, create it
dlist1 = glGenLists(1); // generate a display list
glNewList(dlist1, GL_COMPILE); // start a new display list
for (unsigned e = 0; e < E.size(); e++) { // for each edge in the network
if (map[e] != unsigned(-1)) {
glColor3f(colormap[e * 3 + 0], colormap[e * 3 + 1], colormap[e * 3 + 2]);
for (unsigned p = 1; p < E[e].size(); p++) {// for each point on that edge
stim::circle<T> C1 = E[e].circ(p - 1);
stim::circle<T> C2 = E[e].circ(p);
C1.set_R(0.5); // scale the circle to the same
C2.set_R(0.5);
std::vector< stim::vec3<T> >Cp1 = C1.points(20);
std::vector< stim::vec3<T> >Cp2 = C2.points(20);
renderCylinder(Cp1, Cp2);
}
}
else {
glColor3f(1.0f, 1.0f, 1.0f); // white color for the un-mapping edges
for (unsigned p = 1; p < E[e].size(); p++) { // for each point on that edge
stim::circle<T> C1 = E[e].circ(p - 1);
stim::circle<T> C2 = E[e].circ(p);
C1.set_R(0.5); // scale the circle to the same
C2.set_R(0.5);
std::vector< stim::vec3<T> >Cp1 = C1.points(20);
std::vector< stim::vec3<T> >Cp2 = C2.points(20);
renderCylinder(Cp1, Cp2);
}
}
}
for (unsigned v = 0; v < V.size(); v++) {
size_t num_edge = V[v].e[0].size() + V[v].e[1].size();
if (num_edge > 1) { // if it is the joint vertex
glColor3f(0.3, 0.3, 0.3); // gray color
renderBall(V[v][0], V[v][1], V[v][2], 1, 20);
}
else { // if it is the terminal vertex
glColor3f(0.6, 0.6, 0.6); // more white gray
renderBall(V[v][0], V[v][1], V[v][2], 1, 20);
}
}
glEndList();
}
glCallList(dlist1);
}
|
6b317c71
Jiaming Guo
add function to r...
|
313
314
315
316
|
///render the T network cylinder as series of tubes
///@param dlist2 is the display list
///@param map is the mapping relationship between two networks
///@param colormap is the random generated color set for render
|
58674036
Jiaming Guo
fix minor error f...
|
317
|
void glRandColorCylinder2(GLuint &dlist2, std::vector<unsigned> map, std::vector<T> colormap) {
|
6b317c71
Jiaming Guo
add function to r...
|
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
if (!glIsList(dlist2)) {
dlist2 = glGenLists(1);
glNewList(dlist2, GL_COMPILE);
for (unsigned e = 0; e < E.size(); e++) { // for each edge in the network
if (map[e] != unsigned(-1)) {
glColor3f(colormap[map[e] * 3 + 0], colormap[map[e] * 3 + 1], colormap[map[e] * 3 + 2]);
for (unsigned p = 0; p < E[e].size() - 1; p++) {// for each point on that edge
stim::circle<T> C1 = E[e].circ(p);
stim::circle<T> C2 = E[e].circ(p + 1);
C1.set_R(10); // scale the circle to the same
C2.set_R(10);
std::vector< stim::vec3<T> >Cp1 = C1.points(20);
std::vector< stim::vec3<T> >Cp2 = C2.points(20);
renderCylinder(Cp1, Cp2);
}
}
else {
glColor3f(1.0f, 1.0f, 1.0f); // white color for the un-mapping edges
for (unsigned p = 0; p < E[e].size() - 1; p++) {// for each point on that edge
stim::circle<T> C1 = E[e].circ(p);
stim::circle<T> C2 = E[e].circ(p + 1);
C1.set_R(10); // scale the circle to the same
C2.set_R(10);
std::vector< stim::vec3<T> >Cp1 = C1.points(20);
std::vector< stim::vec3<T> >Cp2 = C2.points(20);
renderCylinder(Cp1, Cp2);
}
}
}
for (unsigned v = 0; v < V.size(); v++) {
size_t num_edge = V[v].e[0].size() + V[v].e[1].size();
if (num_edge > 1) { // if it is the joint vertex
glColor3f(0.3, 0.3, 0.3); // gray color
renderBall(V[v][0], V[v][1], V[v][2], 20, 20);
}
else { // if it is the terminal vertex
glColor3f(0.6, 0.6, 0.6); // more white gray
renderBall(V[v][0], V[v][1], V[v][2], 20, 20);
}
}
glEndList();
}
glCallList(dlist2);
}
|
58674036
Jiaming Guo
fix minor error f...
|
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
void glRandColorCylinder2_swc(GLuint &dlist2, std::vector<unsigned> map, std::vector<T> colormap) {
if (!glIsList(dlist2)) {
dlist2 = glGenLists(1);
glNewList(dlist2, GL_COMPILE);
for (unsigned e = 0; e < E.size(); e++) { // for each edge in the network
if (map[e] != unsigned(-1)) {
glColor3f(colormap[map[e] * 3 + 0], colormap[map[e] * 3 + 1], colormap[map[e] * 3 + 2]);
for (unsigned p = 0; p < E[e].size() - 1; p++) {// for each point on that edge
stim::circle<T> C1 = E[e].circ(p);
stim::circle<T> C2 = E[e].circ(p + 1);
C1.set_R(0.5); // scale the circle to the same
C2.set_R(0.5);
std::vector< stim::vec3<T> >Cp1 = C1.points(20);
std::vector< stim::vec3<T> >Cp2 = C2.points(20);
renderCylinder(Cp1, Cp2);
}
}
else {
glColor3f(1.0f, 1.0f, 1.0f); // white color for the un-mapping edges
for (unsigned p = 0; p < E[e].size() - 1; p++) {// for each point on that edge
stim::circle<T> C1 = E[e].circ(p);
stim::circle<T> C2 = E[e].circ(p + 1);
C1.set_R(0.5); // scale the circle to the same
C2.set_R(0.5);
std::vector< stim::vec3<T> >Cp1 = C1.points(20);
std::vector< stim::vec3<T> >Cp2 = C2.points(20);
renderCylinder(Cp1, Cp2);
}
}
}
for (unsigned v = 0; v < V.size(); v++) {
size_t num_edge = V[v].e[0].size() + V[v].e[1].size();
if (num_edge > 1) { // if it is the joint vertex
glColor3f(0.3, 0.3, 0.3); // gray color
renderBall(V[v][0], V[v][1], V[v][2], 1, 20);
}
else { // if it is the terminal vertex
glColor3f(0.6, 0.6, 0.6); // more white gray
renderBall(V[v][0], V[v][1], V[v][2], 1, 20);
}
}
glEndList();
}
glCallList(dlist2);
}
|
6b317c71
Jiaming Guo
add function to r...
|
409
410
411
412
|
/// Render the GT network centerline as a series of line strips in random different color
///@param dlist1 is the display list
///@param map is the mapping relationship between two networks
///@param colormap is the random generated color set for render
|
58674036
Jiaming Guo
fix minor error f...
|
413
|
void glRandColorCenterline1(GLuint &dlist1, std::vector<unsigned> map, std::vector<T> colormap) {
|
6b317c71
Jiaming Guo
add function to r...
|
414
|
if (!glIsList(dlist1)) {
|
b019bc5e
Jiaming Guo
add function to r...
|
415
|
dlist1 = glGenLists(1);
|
c72184d1
Jiaming Guo
add many function...
|
416
|
glNewList(dlist1, GL_COMPILE);
|
6b317c71
Jiaming Guo
add function to r...
|
417
418
|
for (unsigned e = 0; e < E.size(); e++) {
if (map[e] != unsigned(-1)) { // if it has corresponding edge in another network
|
c72184d1
Jiaming Guo
add many function...
|
419
420
|
glColor3f(colormap[e * 3 + 0], colormap[e * 3 + 1], colormap[e * 3 + 2]);
glBegin(GL_LINE_STRIP);
|
6b317c71
Jiaming Guo
add function to r...
|
421
|
for (unsigned p = 0; p < E[e].size(); p++) {
|
c72184d1
Jiaming Guo
add many function...
|
422
423
424
|
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
|
c72184d1
Jiaming Guo
add many function...
|
425
|
}
|
6b317c71
Jiaming Guo
add function to r...
|
426
427
|
else {
glColor3f(1.0, 1.0, 1.0); // white color
|
c72184d1
Jiaming Guo
add many function...
|
428
|
glBegin(GL_LINE_STRIP);
|
6b317c71
Jiaming Guo
add function to r...
|
429
|
for (unsigned p = 0; p < E[e].size(); p++) {
|
c72184d1
Jiaming Guo
add many function...
|
430
431
432
433
434
|
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
}
}
|
c72184d1
Jiaming Guo
add many function...
|
435
436
437
438
439
|
glEndList();
}
glCallList(dlist1);
}
|
6b317c71
Jiaming Guo
add function to r...
|
440
441
442
443
|
/// Render the T network centerline as a series of line strips in random different color
///@param dlist2 is the display list
///@param map is the mapping relationship between two networks
///@param colormap is the random generated color set for render
|
58674036
Jiaming Guo
fix minor error f...
|
444
|
void glRandColorCenterline2(GLuint &dlist2, std::vector<unsigned> map, std::vector<T> colormap) {
|
6b317c71
Jiaming Guo
add function to r...
|
445
|
if (!glIsList(dlist2)) {
|
b019bc5e
Jiaming Guo
add function to r...
|
446
|
dlist2 = glGenLists(1);
|
c72184d1
Jiaming Guo
add many function...
|
447
|
glNewList(dlist2, GL_COMPILE);
|
6b317c71
Jiaming Guo
add function to r...
|
448
449
|
for (unsigned e = 0; e < E.size(); e++) {
if (map[e] != unsigned(-1)) { // if it has corresponding edge in another network
|
c72184d1
Jiaming Guo
add many function...
|
450
451
|
glColor3f(colormap[map[e] * 3 + 0], colormap[map[e] * 3 + 1], colormap[map[e] * 3 + 2]);
glBegin(GL_LINE_STRIP);
|
6b317c71
Jiaming Guo
add function to r...
|
452
|
for (unsigned p = 0; p < E[e].size(); p++) {
|
c72184d1
Jiaming Guo
add many function...
|
453
454
455
|
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
|
c72184d1
Jiaming Guo
add many function...
|
456
|
}
|
6b317c71
Jiaming Guo
add function to r...
|
457
458
|
else {
glColor3f(1.0, 1.0, 1.0); // white color
|
c72184d1
Jiaming Guo
add many function...
|
459
|
glBegin(GL_LINE_STRIP);
|
6b317c71
Jiaming Guo
add function to r...
|
460
|
for (unsigned p = 0; p < E[e].size(); p++) {
|
c72184d1
Jiaming Guo
add many function...
|
461
462
463
464
465
|
glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
}
glEnd();
}
}
|
c72184d1
Jiaming Guo
add many function...
|
466
467
468
|
glEndList();
}
glCallList(dlist2);
|
9c97e126
David Mayerich
added an axis-ali...
|
469
470
|
}
|
6b317c71
Jiaming Guo
add function to r...
|
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
|
//void glRandColorCenterlineGT(GLuint &dlist1, std::vector<unsigned> map, std::vector<T> colormap){
// if(!glIsList(dlist1)){
// dlist1 = glGenLists(1);
// glNewList(dlist1, GL_COMPILE);
// for(unsigned e = 0; e < E.size(); e++){
// if(map[e] != unsigned(-1)){
// glColor3f(colormap[e * 3 + 0], colormap[e * 3 + 1], colormap[e * 3 + 2]);
// glBegin(GL_LINE_STRIP);
// for(unsigned p = 0; p < E[e].size(); p++){
// glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
// }
// glEnd();
// for (unsigned p = 0; p < E[e].size() - 1; p++) {
// renderCylinder(E[e][p][0], E[e][p][1], E[e][p][2], E[e][p + 1][0], E[e][p + 1][1], E[e][p + 1][2], 10, 20);
// }
// }
// else{
// glColor3f(1.0, 1.0, 1.0);
// glBegin(GL_LINE_STRIP);
// for(unsigned p = 0; p < E[e].size(); p++){
// glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
// }
// glEnd();
// }
// }
// for (unsigned v = 0; v < V.size(); v++) {
// size_t num_edge = V[v].e[0].size() + V[v].e[1].size();
// if (num_edge > 1) {
// glColor3f(0.3, 0.3, 0.3); // gray color for vertex
// renderBall(V[v][0], V[v][1], V[v][2], 20, 20);
// }
// }
// glEndList();
// }
// glCallList(dlist1);
//}
//void glRandColorCenterlineT(GLuint &dlist2, std::vector<unsigned> map, std::vector<T> colormap){
// if(!glIsList(dlist2)){
// dlist2 = glGenLists(1);
// glNewList(dlist2, GL_COMPILE);
// for(unsigned e = 0; e < E.size(); e++){
// if(map[e] != unsigned(-1)){
// glColor3f(colormap[map[e] * 3 + 0], colormap[map[e] * 3 + 1], colormap[map[e] * 3 + 2]);
// glBegin(GL_LINE_STRIP);
// for(unsigned p = 0; p < E[e].size(); p++){
// glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
// }
// glEnd();
// for (unsigned p = 0; p < E[e].size() - 1; p++) {
// renderCylinder(E[e][p][0], E[e][p][1], E[e][p][2], E[e][p + 1][0], E[e][p + 1][1], E[e][p + 1][2], 10, 20);
// }
// }
// else{
// glColor3f(1.0, 1.0, 1.0);
// glBegin(GL_LINE_STRIP);
// for(unsigned p = 0; p < E[e].size(); p++){
// glVertex3f(E[e][p][0], E[e][p][1], E[e][p][2]);
// }
// glEnd();
// }
// }
// for (unsigned v = 0; v < V.size(); v++) {
// size_t num_edge = V[v].e[0].size() + V[v].e[1].size();
// if (num_edge > 1) {
// glColor3f(0.3, 0.3, 0.3); // gray color for vertex
// renderBall(V[v][0], V[v][1], V[v][2], 20, 20);
// }
// }
// glEndList();
// }
// glCallList(dlist2);
//}
|
58674036
Jiaming Guo
fix minor error f...
|
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
|
//void renderCylinder(T x1, T y1, T z1, T x2, T y2, T z2, T radius, int subdivisions) {
// T dx = x2 - x1;
// T dy = y2 - y1;
// T dz = z2 - z1;
// /// handle the degenerate case with an approximation
// if (dz == 0)
// dz = .00000001;
// T d = sqrt(dx*dx + dy*dy + dz*dz);
// T ax = 57.2957795*acos(dz / d); // 180°/pi
// if (dz < 0.0)
// ax = -ax;
// T rx = -dy*dz;
// T ry = dx*dz;
// glPushMatrix();
// glTranslatef(x1, y1, z1);
// glRotatef(ax, rx, ry, 0.0);
// glutSolidCylinder(radius, d, subdivisions, 1);
// glPopMatrix();
//}
|
9c97e126
David Mayerich
added an axis-ali...
|
568
569
570
571
572
573
|
}; //end stim::gl_network class
}; //end stim namespace
#endif
|