|
1
|
+++ a/DrawingFunctions.h |
|
1
|
+#include "rtsFiberNetwork.h" |
|
2
|
+#include "rts/rts_glShaderProgram.h" |
|
3
|
+#include "GL/glut.h" |
|
4
|
+#include "rts/rts_glutRenderWindow.h" |
|
5
|
+#include <time.h> |
|
6
|
+ |
|
7
|
+extern void ComputeNetMets(); |
|
8
|
+extern rtsFiberNetwork* goldNetwork; |
|
9
|
+extern rtsFiberNetwork* testNetwork; |
|
10
|
+extern float sigmaG, sigmaC; |
|
11
|
+float network_span; |
|
12
|
+CoreGraphList coreGraph; |
|
13
|
+vector<point3D<float> > sequenceColors; |
|
14
|
+int current_sequence = 0; |
|
15
|
+ |
|
16
|
+//shader variables |
|
17
|
+rts_glShaderProgram Edge_ErrorShader; |
|
18
|
+rts_glShaderProgram Node_ErrorShader; |
|
19
|
+rts_glShaderProgram Smooth_Shader; |
|
20
|
+ |
|
21
|
+//display lists |
|
22
|
+GLuint GT_FibersList=0; |
|
23
|
+GLuint T_FibersList=0; |
|
24
|
+GLuint GT_EndCaps=0; |
|
25
|
+GLuint T_EndCaps=0; |
|
26
|
+GLuint GT_NodesList=0; |
|
27
|
+GLuint T_NodesList=0; |
|
28
|
+GLuint T_PathList=0; |
|
29
|
+GLuint GT_PathList=0; |
|
30
|
+ |
|
31
|
+//drawing variables |
|
32
|
+int tube_subdivisions = 20; |
|
33
|
+float node_radius_factor = 0.7; |
|
34
|
+float fiber_radius_factor = 0.5; |
|
35
|
+float cull_test_case_threshold = 1.0; |
|
36
|
+ |
|
37
|
+#define DISPLAY_GT_NETWORK 1 |
|
38
|
+#define DISPLAY_T_NETWORK 2 |
|
39
|
+#define DISPLAY_GT_GRAPH 3 |
|
40
|
+#define DISPLAY_T_GRAPH 4 |
|
41
|
+#define DISPLAY_GT_SELECTED 5 |
|
42
|
+#define DISPLAY_T_SELECTED 6 |
|
43
|
+ |
|
44
|
+//menu options |
|
45
|
+#define NETCOMP_EXIT 0 |
|
46
|
+#define DISPLAY_NETWORK 1 |
|
47
|
+#define DISPLAY_GRAPH 2 |
|
48
|
+#define DISPLAY_CONNECTED 3 |
|
49
|
+#define DISPLAY_SELECTED 4 |
|
50
|
+#define COLORMAP_ISOLUMINANT 5 |
|
51
|
+#define COLORMAP_BLACKBODY 6 |
|
52
|
+#define COLORMAP_BREWER 7 |
|
53
|
+#define COLORMAP_POLAR_CIELAB 8 |
|
54
|
+#define COLORMAP_RAINBOW 9 |
|
55
|
+#define CULL_TEST_CASE 10 |
|
56
|
+#define RECOMPUTE_METRIC 11 |
|
57
|
+ |
|
58
|
+ |
|
59
|
+//fibers to render in Graph Mode |
|
60
|
+//list<int> T_DisplayEdges; |
|
61
|
+//list<int> GT_DisplayEdges; |
|
62
|
+ |
|
63
|
+int DisplayMode = DISPLAY_NETWORK; |
|
64
|
+float L0_pos[3]; |
|
65
|
+float L1_pos[3]; |
|
66
|
+//GLuint texColorMap=0; |
|
67
|
+rts_glTextureMap texColorMap; |
|
68
|
+ |
|
69
|
+ |
|
70
|
+ |
|
71
|
+ |
|
72
|
+void makeColormap(int ColorMapType = COLORMAP_BREWER) |
|
73
|
+{ |
|
74
|
+ //if(texColorMap != 0) |
|
75
|
+ // glDeleteTextures(1, &texColorMap); |
|
76
|
+ |
|
77
|
+ point3D<float>* ctrlPts; |
|
78
|
+ int num_points = 0; |
|
79
|
+ if(ColorMapType == COLORMAP_ISOLUMINANT) |
|
80
|
+ { |
|
81
|
+ //allocate memory for the colormap |
|
82
|
+ num_points = 2; |
|
83
|
+ ctrlPts = new point3D<float>[num_points]; |
|
84
|
+ //memset(ctrlPts, 0, num_points*sizeof(point3D<float>)); |
|
85
|
+ |
|
86
|
+ ctrlPts[0] = point3D<float>(0.0, 1.0, 0.0); |
|
87
|
+ ctrlPts[1] = point3D<float>(1.0, 0.0, 0.0); |
|
88
|
+ } |
|
89
|
+ else if(ColorMapType == COLORMAP_RAINBOW) |
|
90
|
+ { |
|
91
|
+ //allocate memory for the colormap |
|
92
|
+ num_points = 5; |
|
93
|
+ ctrlPts = new point3D<float>[num_points]; |
|
94
|
+ //memset(ctrlPts, 0, num_points*sizeof(point3D<float>)); |
|
95
|
+ |
|
96
|
+ //ctrlPts[0] = point3D<float>(0.7, 0, 0.7); |
|
97
|
+ ctrlPts[0] = point3D<float>(0, 0, 1); |
|
98
|
+ ctrlPts[1] = point3D<float>(0, 0.7, 0.7); |
|
99
|
+ ctrlPts[2] = point3D<float>(0, 1, 0); |
|
100
|
+ ctrlPts[3] = point3D<float>(0.7, 0.7, 0); |
|
101
|
+ ctrlPts[4] = point3D<float>(1, 0, 0); |
|
102
|
+ } |
|
103
|
+ else if(ColorMapType == COLORMAP_BLACKBODY) |
|
104
|
+ { |
|
105
|
+ //allocate memory for the colormap |
|
106
|
+ num_points = 4; |
|
107
|
+ ctrlPts = new point3D<float>[num_points]; |
|
108
|
+ //memset(ctrlPts, 0, num_points*sizeof(point3D<float>)); |
|
109
|
+ |
|
110
|
+ ctrlPts[0] = point3D<float>(0.0, 0.0, 0.0); |
|
111
|
+ ctrlPts[1] = point3D<float>(1.0, 0.0, 0.0); |
|
112
|
+ ctrlPts[2] = point3D<float>(1.0, 1.0, 0.0); |
|
113
|
+ ctrlPts[3] = point3D<float>(1.0, 1.0, 1.0); |
|
114
|
+ } |
|
115
|
+ else if(ColorMapType == COLORMAP_BREWER) |
|
116
|
+ { |
|
117
|
+ //allocate memory for the colormap |
|
118
|
+ num_points = 11; |
|
119
|
+ ctrlPts = new point3D<float>[num_points]; |
|
120
|
+ //memset(ctrlPts, 0, num_points*sizeof(point3D<float>)); |
|
121
|
+ |
|
122
|
+ ctrlPts[0] = point3D<float>(0.192157, 0.211765, 0.584314); |
|
123
|
+ ctrlPts[1] = point3D<float>(0.270588, 0.458824, 0.705882); |
|
124
|
+ ctrlPts[2] = point3D<float>(0.454902, 0.678431, 0.819608); |
|
125
|
+ ctrlPts[3] = point3D<float>(0.670588, 0.85098, 0.913725); |
|
126
|
+ ctrlPts[4] = point3D<float>(0.878431, 0.952941, 0.972549); |
|
127
|
+ ctrlPts[5] = point3D<float>(1, 1, 0.74902); |
|
128
|
+ ctrlPts[6] = point3D<float>(0.996078, 0.878431, 0.564706); |
|
129
|
+ ctrlPts[7] = point3D<float>(0.992157, 0.682353, 0.380392); |
|
130
|
+ ctrlPts[8] = point3D<float>(0.956863, 0.427451, 0.262745); |
|
131
|
+ ctrlPts[9] = point3D<float>(0.843137, 0.188235, 0.152941); |
|
132
|
+ ctrlPts[10] = point3D<float>(0.647059, 0, 0.14902); |
|
133
|
+ |
|
134
|
+ } |
|
135
|
+ else if(ColorMapType == COLORMAP_POLAR_CIELAB) |
|
136
|
+ { |
|
137
|
+ //allocate memory for the colormap |
|
138
|
+ num_points = 33; |
|
139
|
+ ctrlPts = new point3D<float>[num_points]; |
|
140
|
+ //memset(ctrlPts, 0, num_points*sizeof(point3D<float>)); |
|
141
|
+ |
|
142
|
+ ctrlPts[0] = point3D<float>(0.07514311, 0.468049805,1); |
|
143
|
+ ctrlPts[1] = point3D<float>(0.247872569, 0.498782363,1); |
|
144
|
+ ctrlPts[2] = point3D<float>(0.339526309, 0.528909511,1); |
|
145
|
+ ctrlPts[3] = point3D<float>(0.409505078, 0.558608486,1); |
|
146
|
+ ctrlPts[4] = point3D<float>(0.468487184, 0.588057293,1); |
|
147
|
+ ctrlPts[5] = point3D<float>(0.520796675, 0.617435078,1); |
|
148
|
+ ctrlPts[6] = point3D<float>(0.568724526, 0.646924167,1); |
|
149
|
+ ctrlPts[7] = point3D<float>(0.613686735, 0.676713218,1); |
|
150
|
+ ctrlPts[8] = point3D<float>(0.656658579, 0.707001303,1); |
|
151
|
+ ctrlPts[9] = point3D<float>(0.698372844, 0.738002964,1); |
|
152
|
+ ctrlPts[10] = point3D<float>(0.739424025, 0.769954435,1); |
|
153
|
+ ctrlPts[11] = point3D<float>(0.780330104, 0.803121429,1); |
|
154
|
+ ctrlPts[12] = point3D<float>(0.821573924, 0.837809045,1); |
|
155
|
+ ctrlPts[13] = point3D<float>(0.863634967, 0.874374691,1); |
|
156
|
+ ctrlPts[14] = point3D<float>(0.907017747, 0.913245283,1); |
|
157
|
+ ctrlPts[15] = point3D<float>(0.936129275, 0.938743558, 0.983038586); |
|
158
|
+ ctrlPts[16] = point3D<float>(0.943467973, 0.943498599, 0.943398095); |
|
159
|
+ ctrlPts[17] = point3D<float>(0.990146732, 0.928791426, 0.917447482); |
|
160
|
+ ctrlPts[18] = point3D<float>(1, 0.88332677, 0.861943246); |
|
161
|
+ ctrlPts[19] = point3D<float>(1, 0.833985467, 0.803839606); |
|
162
|
+ ctrlPts[20] = point3D<float>(1, 0.788626485, 0.750707739); |
|
163
|
+ ctrlPts[21] = point3D<float>(1, 0.746206642, 0.701389973); |
|
164
|
+ ctrlPts[22] = point3D<float>(1, 0.70590052, 0.654994046); |
|
165
|
+ ctrlPts[23] = point3D<float>(1, 0.667019783, 0.610806959); |
|
166
|
+ ctrlPts[24] = point3D<float>(1, 0.6289553, 0.568237474); |
|
167
|
+ ctrlPts[25] = point3D<float>(1, 0.591130233, 0.526775617); |
|
168
|
+ ctrlPts[26] = point3D<float>(1, 0.552955184, 0.485962266); |
|
169
|
+ ctrlPts[27] = point3D<float>(1, 0.513776083, 0.445364274); |
|
170
|
+ ctrlPts[28] = point3D<float>(1, 0.472800903, 0.404551679); |
|
171
|
+ ctrlPts[29] = point3D<float>(1, 0.428977855, 0.363073592); |
|
172
|
+ ctrlPts[30] = point3D<float>(1, 0.380759558, 0.320428137); |
|
173
|
+ ctrlPts[31] = point3D<float>(0.961891484, 0.313155629, 0.265499262); |
|
174
|
+ ctrlPts[32] = point3D<float>(0.916482116, 0.236630659, 0.209939162); |
|
175
|
+ |
|
176
|
+ } |
|
177
|
+ |
|
178
|
+ texColorMap.Init(ctrlPts, GL_TEXTURE_1D, num_points, 0, 0, GL_RGB, GL_RGB, GL_FLOAT); |
|
179
|
+ |
|
180
|
+ //glGenTextures(1, &texColorMap); |
|
181
|
+ //glBindTexture(GL_TEXTURE_1D, texColorMap); |
|
182
|
+ //glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, num_points, 0, GL_RGB, GL_FLOAT, ctrlPts); |
|
183
|
+} |
|
184
|
+ |
|
185
|
+ |
|
186
|
+ |
|
187
|
+point3D<float> HSLtoRGB(point3D<float> HSL) |
|
188
|
+{ |
|
189
|
+ float H = HSL.x; |
|
190
|
+ float S = HSL.y; |
|
191
|
+ float L = HSL.z; |
|
192
|
+ |
|
193
|
+ float temp2; |
|
194
|
+ if(L < 0.5) |
|
195
|
+ temp2 = L*(1.0+S); |
|
196
|
+ else |
|
197
|
+ temp2 = L+S - L*S; |
|
198
|
+ |
|
199
|
+ float temp1 = 2.0*L - temp2; |
|
200
|
+ |
|
201
|
+ point3D<float> temp3(H+1.0/3.0, H, H-1.0/3.0); |
|
202
|
+ if(temp3.x < 0.0) temp3.x = temp3.x+1.0; |
|
203
|
+ if(temp3.y < 0.0) temp3.y = temp3.y+1.0; |
|
204
|
+ if(temp3.z < 0.0) temp3.z = temp3.z+1.0; |
|
205
|
+ |
|
206
|
+ if(temp3.x > 1.0) temp3.x = temp3.x - 1.0; |
|
207
|
+ if(temp3.y > 1.0) temp3.y = temp3.y - 1.0; |
|
208
|
+ if(temp3.z > 1.0) temp3.z = temp3.z - 1.0; |
|
209
|
+ |
|
210
|
+ point3D<float> result; |
|
211
|
+ if(6.0*temp3.x < 1.0) result.x = temp1 +(temp2 - temp1)*6.0*temp3.x; |
|
212
|
+ else if(2.0*temp3.x < 1.0) result.x = temp2; |
|
213
|
+ else if(3.0*temp3.x < 2.0) result.x = temp1+(temp2-temp1)*((2.0/3.0) - temp3.x)*6.0; |
|
214
|
+ else result.x = temp1; |
|
215
|
+ |
|
216
|
+ if(6.0*temp3.y < 1.0) result.y = temp1 +(temp2 - temp1)*6.0*temp3.y; |
|
217
|
+ else if(2.0*temp3.y < 1.0) result.y = temp2; |
|
218
|
+ else if(3.0*temp3.y < 2.0) result.y = temp1+(temp2-temp1)*((2.0/3.0) - temp3.y)*6.0; |
|
219
|
+ else result.y = temp1; |
|
220
|
+ |
|
221
|
+ if(6.0*temp3.z < 1.0) result.z = temp1 +(temp2 - temp1)*6.0*temp3.z; |
|
222
|
+ else if(2.0*temp3.z < 1.0) result.z = temp2; |
|
223
|
+ else if(3.0*temp3.z < 2.0) result.z = temp1+(temp2-temp1)*((2.0/3.0) - temp3.z)*6.0; |
|
224
|
+ else result.z = temp1; |
|
225
|
+ |
|
226
|
+ //result.a = 0.0; |
|
227
|
+ return result; |
|
228
|
+} |
|
229
|
+void ColorFibers() |
|
230
|
+{ |
|
231
|
+ //srand(time(NULL)); |
|
232
|
+ sequenceColors.clear(); |
|
233
|
+ //for each fiber |
|
234
|
+ for(CoreGraphList::iterator i = coreGraph.begin(); i!=coreGraph.end(); i++) |
|
235
|
+ { |
|
236
|
+ float random_hue = (double)rand()/(double)RAND_MAX; |
|
237
|
+ //cout<<"Random Hue: "<<random_hue<<endl; |
|
238
|
+ float random_saturation = 1.0;//(double)rand()/(double)RAND_MAX; |
|
239
|
+ point3D<float> rgb = HSLtoRGB(point3D<float>(random_hue, random_saturation, 0.5)); |
|
240
|
+ //point3D<float> rgb((double)rand()/(double)RAND_MAX, (double)rand()/(double)RAND_MAX, (double)rand()/(double)RAND_MAX); |
|
241
|
+ sequenceColors.push_back(rgb); |
|
242
|
+ } |
|
243
|
+ |
|
244
|
+ |
|
245
|
+} |
|
246
|
+void CenterCameraToSelected() |
|
247
|
+{ |
|
248
|
+ if(coreGraph.size() == 0) |
|
249
|
+ return; |
|
250
|
+ |
|
251
|
+ //center the fiber in both networks |
|
252
|
+ point3D<float> min_pt(9999, 9999, 9999); |
|
253
|
+ point3D<float> max_pt(-9999, -9999, -9999); |
|
254
|
+ |
|
255
|
+ //iterate through the first edge sequence |
|
256
|
+ EdgeSequence::iterator i; |
|
257
|
+ int node; |
|
258
|
+ point3D<float> test; |
|
259
|
+ for(i=coreGraph[current_sequence].first.begin(); i!=coreGraph[current_sequence].first.end(); i++) |
|
260
|
+ { |
|
261
|
+ node = testNetwork->FiberList[*i].n0; |
|
262
|
+ test = testNetwork->NodeList[node].p; |
|
263
|
+ min_pt.x = min(test.x, min_pt.x); |
|
264
|
+ min_pt.y = min(test.y, min_pt.y); |
|
265
|
+ min_pt.z = min(test.z, min_pt.z); |
|
266
|
+ max_pt.x = max(test.x, max_pt.x); |
|
267
|
+ max_pt.y = max(test.y, max_pt.y); |
|
268
|
+ max_pt.z = max(test.z, max_pt.z); |
|
269
|
+ |
|
270
|
+ node = testNetwork->FiberList[*i].n1; |
|
271
|
+ test = testNetwork->NodeList[node].p; |
|
272
|
+ min_pt.x = min(test.x, min_pt.x); |
|
273
|
+ min_pt.y = min(test.y, min_pt.y); |
|
274
|
+ min_pt.z = min(test.z, min_pt.z); |
|
275
|
+ max_pt.x = max(test.x, max_pt.x); |
|
276
|
+ max_pt.y = max(test.y, max_pt.y); |
|
277
|
+ max_pt.z = max(test.z, max_pt.z); |
|
278
|
+ } |
|
279
|
+ point3D<float> middle = min_pt+0.5*(max_pt - min_pt); |
|
280
|
+ |
|
281
|
+ rts_glut_camera.LookAt(middle); |
|
282
|
+ |
|
283
|
+} |
|
284
|
+void IncrementSelectedFiber(int i) |
|
285
|
+{ |
|
286
|
+ //get the currently selected fiber id |
|
287
|
+ if(coreGraph.size() <= 0) |
|
288
|
+ return; |
|
289
|
+ |
|
290
|
+ //get the number of fibers |
|
291
|
+ int end_id = coreGraph.size(); |
|
292
|
+ |
|
293
|
+ current_sequence+=i; |
|
294
|
+ if(current_sequence >= end_id) |
|
295
|
+ current_sequence = 0; |
|
296
|
+ if(current_sequence < 0) |
|
297
|
+ current_sequence = coreGraph.size()-1; |
|
298
|
+ |
|
299
|
+ //print the selected edges |
|
300
|
+ EdgeSequence::iterator EdgeI; |
|
301
|
+ |
|
302
|
+ for(EdgeI = coreGraph[current_sequence].first.begin(); EdgeI != coreGraph[current_sequence].first.end(); EdgeI++) |
|
303
|
+ cout<<*EdgeI<<" "; |
|
304
|
+ cout<<"--->"; |
|
305
|
+ for(EdgeI = coreGraph[current_sequence].second.begin(); EdgeI != coreGraph[current_sequence].second.end(); EdgeI++) |
|
306
|
+ cout<<*EdgeI<<" "; |
|
307
|
+ cout<<endl; |
|
308
|
+ |
|
309
|
+ |
|
310
|
+ CenterCameraToSelected(); |
|
311
|
+ |
|
312
|
+} |
|
313
|
+void DrawNodeSphere(rtsFiberNetwork* network, int n, float radius) |
|
314
|
+{ |
|
315
|
+ GLUquadricObj* quadric = gluNewQuadric(); |
|
316
|
+ gluQuadricNormals(quadric, GLU_SMOOTH); |
|
317
|
+ |
|
318
|
+ glMatrixMode(GL_MODELVIEW); |
|
319
|
+ |
|
320
|
+ glPushMatrix(); |
|
321
|
+ |
|
322
|
+ point3D<float> p; |
|
323
|
+ //glColor3f(network->NodeList[n].error, 0.0, 0.0); |
|
324
|
+ p = network->NodeList[n].p; |
|
325
|
+ |
|
326
|
+ glTranslatef(p.x, p.y, p.z); |
|
327
|
+ //glutSolidSphere(node_radius*standard_deviation, 20, 20); |
|
328
|
+ glTexCoord1f(network->NodeList[n].error); |
|
329
|
+ if(network->NodeList[n].color < 0) |
|
330
|
+ glColor3f(1.0, 0.0, 0.0); |
|
331
|
+ else |
|
332
|
+ glColor3f(1.0, 1.0, 1.0); |
|
333
|
+ gluSphere(quadric,radius,32,32); |
|
334
|
+ |
|
335
|
+ glPopMatrix(); |
|
336
|
+ |
|
337
|
+} |
|
338
|
+void DrawNodeSpheres(rtsFiberNetwork* network, float radius) |
|
339
|
+{ |
|
340
|
+ |
|
341
|
+ |
|
342
|
+ unsigned int n; |
|
343
|
+ for(n=0; n != network->FiberList.size(); n++) |
|
344
|
+ { |
|
345
|
+ if(!network->isCulled(n)) |
|
346
|
+ { |
|
347
|
+ DrawNodeSphere(network, network->FiberList[n].n0,radius); |
|
348
|
+ DrawNodeSphere(network, network->FiberList[n].n1,radius); |
|
349
|
+ } |
|
350
|
+ } |
|
351
|
+} |
|
352
|
+ |
|
353
|
+void FrenetFrame(vector3D<float> &x, vector3D<float> &y, vector3D<float> &z) |
|
354
|
+{ |
|
355
|
+ x = vector3D<float>(0.0, 0.0, 1.0); |
|
356
|
+ y = x.X(z); |
|
357
|
+ x = z.X(y); |
|
358
|
+ x.Normalize(); |
|
359
|
+ y.Normalize(); |
|
360
|
+ z.Normalize(); |
|
361
|
+} |
|
362
|
+ |
|
363
|
+vector3D<float> GetColor(float error) |
|
364
|
+{ |
|
365
|
+ //This function converts an error value to a color |
|
366
|
+ //The conversion is done by creating an HSV color from the error value and converting that HSV color to RGB |
|
367
|
+ float H = (240.0/60.0)*(1.0 - error); |
|
368
|
+ float S = 1.0; |
|
369
|
+ float V = 1.0; |
|
370
|
+ |
|
371
|
+ int i = floor(H); |
|
372
|
+ float f = H - i; |
|
373
|
+ if(i%2 == 0) |
|
374
|
+ f = 1-f; |
|
375
|
+ float m = V*(1 - S); |
|
376
|
+ float n = V*(1-S*f); |
|
377
|
+ switch(i) |
|
378
|
+ { |
|
379
|
+ case 0: |
|
380
|
+ return vector3D<float>(V, n, m); |
|
381
|
+ case 1: |
|
382
|
+ return vector3D<float>(n, V, m); |
|
383
|
+ case 2: |
|
384
|
+ return vector3D<float>(m, V, n); |
|
385
|
+ case 3: |
|
386
|
+ return vector3D<float>(m, n, V); |
|
387
|
+ case 4: |
|
388
|
+ return vector3D<float>(n, m, V); |
|
389
|
+ case 5: |
|
390
|
+ return vector3D<float>(V, m, n); |
|
391
|
+ default: |
|
392
|
+ return vector3D<float>(0, 0, 0); |
|
393
|
+ } |
|
394
|
+ |
|
395
|
+} |
|
396
|
+ |
|
397
|
+void DrawTube(point3D<float> p0, vector3D<float> d0, point3D<float> p1, vector3D<float> d1, float error0, float error1, float radius, int subdiv) |
|
398
|
+{ |
|
399
|
+ |
|
400
|
+ //draw the first circle |
|
401
|
+ vector3D<float> x0, y0, z0, x1, y1, z1; |
|
402
|
+ z0 = d0; |
|
403
|
+ FrenetFrame(x0, y0, z0); |
|
404
|
+ |
|
405
|
+ z1 = d1; |
|
406
|
+ FrenetFrame(x1, y1, z1); |
|
407
|
+ |
|
408
|
+ float t_step = (2*3.14159)/subdiv; |
|
409
|
+ |
|
410
|
+ |
|
411
|
+ float u, v; |
|
412
|
+ |
|
413
|
+ //get the RGB color |
|
414
|
+ point3D<float> circle0, circle1; |
|
415
|
+ vector3D<float> RGB0, RGB1; |
|
416
|
+ vector3D<float> normal; |
|
417
|
+ |
|
418
|
+ //RGB0 = GetColor(color0); |
|
419
|
+ //RGB1 = GetColor(color1); |
|
420
|
+ |
|
421
|
+ glBegin(GL_TRIANGLE_STRIP); |
|
422
|
+ for(int t=0; t<=subdiv; t++) |
|
423
|
+ { |
|
424
|
+ u = radius * cos(t*t_step); |
|
425
|
+ v = radius * sin(t*t_step); |
|
426
|
+ normal = u*x0 + v*y0; |
|
427
|
+ circle0 = p0 + normal; |
|
428
|
+ normal.Normalize(); |
|
429
|
+ |
|
430
|
+ glTexCoord1f(error0); |
|
431
|
+ //glColor4f(error0, 0.0, 0.0, 1.0); |
|
432
|
+ glNormal3f(normal.x, normal.y, normal.z); |
|
433
|
+ glVertex3f(circle0.x, circle0.y, circle0.z); |
|
434
|
+ |
|
435
|
+ normal = u*x1 + v*y1; |
|
436
|
+ circle1 = p1 + normal; |
|
437
|
+ normal.Normalize(); |
|
438
|
+ |
|
439
|
+ glTexCoord1f(error1); |
|
440
|
+ //glColor4f(error1, 0.0, 0.0, 1.0); |
|
441
|
+ glNormal3f(normal.x, normal.y, normal.z); |
|
442
|
+ glVertex3f(circle1.x, circle1.y, circle1.z); |
|
443
|
+ |
|
444
|
+ } |
|
445
|
+ glEnd(); |
|
446
|
+ CHECK_OPENGL_ERROR |
|
447
|
+} |
|
448
|
+ |
|
449
|
+void ExtrudeFiber(rtsFiberNetwork* network, int fiber, float radius) |
|
450
|
+{ |
|
451
|
+ vector3D<float> x, y, z; |
|
452
|
+ point3D<float> p0, p1, p2, p3; |
|
453
|
+ vector3D<float> d1, d2; |
|
454
|
+ float e1, e2; |
|
455
|
+ |
|
456
|
+ //get the first point |
|
457
|
+ int node = network->FiberList[fiber].n0; |
|
458
|
+ p1 = network->NodeList[node].p; |
|
459
|
+ e1 = network->NodeList[node].error; |
|
460
|
+ |
|
461
|
+ //for each vertex in the fiber |
|
462
|
+ int num_points = (int)network->FiberList[fiber].pointList.size(); |
|
463
|
+ for(int v=0; v<num_points; v++) |
|
464
|
+ { |
|
465
|
+ //get the next point |
|
466
|
+ p2 = network->FiberList[fiber].pointList[v]; |
|
467
|
+ e2 = network->FiberList[fiber].errorList[v]; |
|
468
|
+ |
|
469
|
+ if(v<num_points-1) |
|
470
|
+ p3 = network->FiberList[fiber].pointList[v+1]; |
|
471
|
+ else |
|
472
|
+ { |
|
473
|
+ node = network->FiberList[fiber].n1; |
|
474
|
+ p3 = network->NodeList[node].p; |
|
475
|
+ } |
|
476
|
+ |
|
477
|
+ d2 = p3-p1; |
|
478
|
+ |
|
479
|
+ //compute the fiber derivatives at p1 and p2 |
|
480
|
+ if(v==0) //if this is the first fiber |
|
481
|
+ d1 = p2 - p1; |
|
482
|
+ else |
|
483
|
+ { |
|
484
|
+ d1 = p2 - p0; |
|
485
|
+ } |
|
486
|
+ |
|
487
|
+ DrawTube(p1, d1, p2, d2, e1, e2, radius, tube_subdivisions); |
|
488
|
+ |
|
489
|
+ //shift |
|
490
|
+ p0 = p1; |
|
491
|
+ p1 = p2; |
|
492
|
+ e1 = e2; |
|
493
|
+ } |
|
494
|
+ //make the last tube |
|
495
|
+ |
|
496
|
+ //if there were any points in the pointlist |
|
497
|
+ if(num_points > 0) |
|
498
|
+ { |
|
499
|
+ p2 = p3; |
|
500
|
+ node = network->FiberList[fiber].n1; |
|
501
|
+ e2 = network->NodeList[node].error; |
|
502
|
+ d1 = p2-p0; |
|
503
|
+ d2 = p2-p1; |
|
504
|
+ DrawTube(p1, d1, p2, d2, e1, e2, radius, tube_subdivisions); |
|
505
|
+ } |
|
506
|
+ //if there are only the two node points |
|
507
|
+ else |
|
508
|
+ { |
|
509
|
+ node = network->FiberList[fiber].n1; |
|
510
|
+ p2 = network->NodeList[node].p; |
|
511
|
+ e2 = network->NodeList[node].error; |
|
512
|
+ d1 = p2 - p1; |
|
513
|
+ d2 = p2 - p1; |
|
514
|
+ DrawTube(p1, d1, p2, d2, e1, e2, radius, tube_subdivisions); |
|
515
|
+ } |
|
516
|
+} |
|
517
|
+ |
|
518
|
+void DrawLineFiber(rtsFiberNetwork* network, int f) |
|
519
|
+{ |
|
520
|
+ point3D<float> p; |
|
521
|
+ int node = network->FiberList[f].n0; |
|
522
|
+ p = network->NodeList[node].p; |
|
523
|
+ |
|
524
|
+ glBegin(GL_LINE_STRIP); |
|
525
|
+ glVertex3f(p.x, p.y, p.z); |
|
526
|
+ for(int v=0; v!=network->FiberList[f].pointList.size(); v++) |
|
527
|
+ { |
|
528
|
+ p = network->FiberList[f].pointList[v]; |
|
529
|
+ glVertex3f(p.x, p.y, p.z); |
|
530
|
+ } |
|
531
|
+ node = network->FiberList[f].n1; |
|
532
|
+ p = network->NodeList[node].p; |
|
533
|
+ glVertex3f(p.x, p.y, p.z); |
|
534
|
+ glEnd(); |
|
535
|
+ |
|
536
|
+} |
|
537
|
+void DrawLineNetwork(rtsFiberNetwork* network) |
|
538
|
+{ |
|
539
|
+ |
|
540
|
+ int num_fibers = network->FiberList.size(); |
|
541
|
+ for(int f = 0; f < num_fibers; f++) |
|
542
|
+ { |
|
543
|
+ /*if(network->FiberList[f].mapped_to == -1) |
|
544
|
+ glColor3f(0.0,0.0, 0.0); |
|
545
|
+ else |
|
546
|
+ glColor3f(1.0, 0.0, 0.0); |
|
547
|
+ */ |
|
548
|
+ DrawLineFiber(network, f); |
|
549
|
+ CHECK_OPENGL_ERROR |
|
550
|
+ } |
|
551
|
+ |
|
552
|
+ |
|
553
|
+} |
|
554
|
+void DrawGraphNodes(rtsFiberNetwork* network) |
|
555
|
+{ |
|
556
|
+ //renders graph nodes, colored based on their node color |
|
557
|
+ glMatrixMode(GL_MODELVIEW); |
|
558
|
+ |
|
559
|
+ unsigned int n; |
|
560
|
+ for(n=0; n != network->NodeList.size(); n++) |
|
561
|
+ { |
|
562
|
+ glPushMatrix(); |
|
563
|
+ |
|
564
|
+ point3D<float> p; |
|
565
|
+ /*if(network->NodeList[n].color < 0) |
|
566
|
+ glColor3f(1.0, 0.0, 0.0); |
|
567
|
+ else |
|
568
|
+ glColor3f(0.0, 1.0, 0.0); |
|
569
|
+ */ |
|
570
|
+ //glColor3f(network->NodeList[n].error, 0.0, 0.0); |
|
571
|
+ p = network->NodeList[n].p; |
|
572
|
+ |
|
573
|
+ glTranslatef(p.x, p.y, p.z); |
|
574
|
+ glutSolidSphere(node_radius_factor*sigmaC, 20, 20); |
|
575
|
+ |
|
576
|
+ glPopMatrix(); |
|
577
|
+ } |
|
578
|
+} |
|
579
|
+void DrawFiberSequence(rtsFiberNetwork* network, EdgeSequence sequence, float fiber_radius, float node_radius) |
|
580
|
+{ |
|
581
|
+ //glClear(GL_DEPTH_BUFFER_BIT); |
|
582
|
+ for(EdgeSequence::iterator i = sequence.begin(); i != sequence.end(); i++) |
|
583
|
+ { |
|
584
|
+ ExtrudeFiber(network, *i, fiber_radius); |
|
585
|
+ glPushAttrib(GL_CURRENT_BIT); |
|
586
|
+ DrawNodeSphere(network, network->FiberList[*i].n0, node_radius); |
|
587
|
+ DrawNodeSphere(network, network->FiberList[*i].n1, node_radius); |
|
588
|
+ glPopAttrib(); |
|
589
|
+ } |
|
590
|
+ |
|
591
|
+ |
|
592
|
+} |
|
593
|
+GLuint CreateFiberDisplayList(rtsFiberNetwork* network, float radius) |
|
594
|
+{ |
|
595
|
+ GLuint result = glGenLists(1); |
|
596
|
+ glNewList(result, GL_COMPILE); |
|
597
|
+ |
|
598
|
+ int num_fibers = network->FiberList.size(); |
|
599
|
+ for(int f = 0; f < num_fibers; f++) |
|
600
|
+ { |
|
601
|
+ if(!network->isCulled(f)) |
|
602
|
+ { |
|
603
|
+ ExtrudeFiber(network, f, radius); |
|
604
|
+ CHECK_OPENGL_ERROR |
|
605
|
+ } |
|
606
|
+ } |
|
607
|
+ glEndList(); |
|
608
|
+ return result; |
|
609
|
+} |
|
610
|
+ |
|
611
|
+GLuint CreateNodeDisplayList(rtsFiberNetwork* network, float radius) |
|
612
|
+{ |
|
613
|
+ GLuint result = glGenLists(1); |
|
614
|
+ glNewList(result, GL_COMPILE); |
|
615
|
+ DrawNodeSpheres(network, radius); |
|
616
|
+ glEndList(); |
|
617
|
+ return result; |
|
618
|
+} |
|
619
|
+ |
|
620
|
+ |
|
621
|
+void CreateFiberPathLists(float fiber_radius, float node_radius) |
|
622
|
+{ |
|
623
|
+ GT_PathList = glGenLists(1); |
|
624
|
+ glNewList(GT_PathList, GL_COMPILE); |
|
625
|
+ |
|
626
|
+ if(coreGraph.size() > 0) |
|
627
|
+ { |
|
628
|
+ for(unsigned int i=0; i<sequenceColors.size(); i++) |
|
629
|
+ { |
|
630
|
+ point3D<float> rgb = sequenceColors[i]; |
|
631
|
+ glColor3f(rgb.x, rgb.y, rgb.z); |
|
632
|
+ DrawFiberSequence(goldNetwork, coreGraph[i].second, fiber_radius, node_radius); |
|
633
|
+ } |
|
634
|
+ } |
|
635
|
+ glEndList(); |
|
636
|
+ |
|
637
|
+ T_PathList = glGenLists(1); |
|
638
|
+ glNewList(T_PathList, GL_COMPILE); |
|
639
|
+ |
|
640
|
+ if(coreGraph.size() > 0) |
|
641
|
+ { |
|
642
|
+ for(unsigned int i=0; i<sequenceColors.size(); i++) |
|
643
|
+ { |
|
644
|
+ point3D<float> rgb = sequenceColors[i]; |
|
645
|
+ glColor3f(rgb.x, rgb.y, rgb.z); |
|
646
|
+ DrawFiberSequence(testNetwork, coreGraph[i].first, fiber_radius, node_radius); |
|
647
|
+ } |
|
648
|
+ } |
|
649
|
+ glEndList(); |
|
650
|
+ |
|
651
|
+} |
|
652
|
+void CreateDisplayLists() |
|
653
|
+{ |
|
654
|
+ if(GT_FibersList != 0) |
|
655
|
+ glDeleteLists(GT_FibersList, 1); |
|
656
|
+ if(T_FibersList != 0) |
|
657
|
+ glDeleteLists(T_FibersList, 1); |
|
658
|
+ if(GT_NodesList != 0) |
|
659
|
+ glDeleteLists(GT_NodesList, 1); |
|
660
|
+ if(T_NodesList != 0) |
|
661
|
+ glDeleteLists(T_NodesList, 1); |
|
662
|
+ if(GT_EndCaps != 0) |
|
663
|
+ glDeleteLists(GT_EndCaps, 1); |
|
664
|
+ if(T_EndCaps != 0) |
|
665
|
+ glDeleteLists(T_EndCaps, 1); |
|
666
|
+ |
|
667
|
+ //create the display lists |
|
668
|
+ GT_FibersList = CreateFiberDisplayList(goldNetwork, sigmaG*fiber_radius_factor); |
|
669
|
+ T_FibersList = CreateFiberDisplayList(testNetwork, sigmaG*fiber_radius_factor); |
|
670
|
+ GT_NodesList = CreateNodeDisplayList(goldNetwork, sigmaG*node_radius_factor); |
|
671
|
+ T_NodesList = CreateNodeDisplayList(testNetwork, sigmaG*node_radius_factor); |
|
672
|
+ GT_EndCaps = CreateNodeDisplayList(goldNetwork, sigmaG*fiber_radius_factor); |
|
673
|
+ T_EndCaps = CreateNodeDisplayList(testNetwork, sigmaG*fiber_radius_factor); |
|
674
|
+ |
|
675
|
+ if(GT_PathList != 0) |
|
676
|
+ glDeleteLists(GT_PathList,1); |
|
677
|
+ if(T_PathList != 0) |
|
678
|
+ glDeleteLists(T_PathList,1); |
|
679
|
+ CreateFiberPathLists(fiber_radius_factor*sigmaG, node_radius_factor*sigmaG); |
|
680
|
+} |
|
681
|
+void RenderViewCamera() |
|
682
|
+{ |
|
683
|
+ glMatrixMode(GL_PROJECTION); |
|
684
|
+ glLoadIdentity(); |
|
685
|
+ //compute the aspect ratio |
|
686
|
+ float aspect_ratio = (float)glutGet(GLUT_WINDOW_WIDTH)/2.0/(float)glutGet(GLUT_WINDOW_HEIGHT); |
|
687
|
+ gluPerspective(rts_glut_camera.getFOV(), aspect_ratio, network_span/10, network_span*10); |
|
688
|
+ |
|
689
|
+ //render the camera |
|
690
|
+ glMatrixMode(GL_MODELVIEW); |
|
691
|
+ glLoadIdentity(); |
|
692
|
+ |
|
693
|
+ point3D<float> camera_position = rts_glut_camera.getPosition(); |
|
694
|
+ vector3D<float> camera_up = rts_glut_camera.getUp(); |
|
695
|
+ point3D<float> camera_lookat = rts_glut_camera.getLookAt(); |
|
696
|
+ gluLookAt(camera_position.x, |
|
697
|
+ camera_position.y, |
|
698
|
+ camera_position.z, |
|
699
|
+ camera_lookat.x, |
|
700
|
+ camera_lookat.y, |
|
701
|
+ camera_lookat.z, |
|
702
|
+ camera_up.x, |
|
703
|
+ camera_up.y, |
|
704
|
+ camera_up.z); |
|
705
|
+ |
|
706
|
+ |
|
707
|
+ //get the light positions (lights move with the camera) |
|
708
|
+ vector3D<float> up = rts_glut_camera.getUp(); |
|
709
|
+ vector3D<float> dir = rts_glut_camera.getDirection(); |
|
710
|
+ vector3D<float> side = dir.X(up); |
|
711
|
+ L0_pos[0] = side.x; |
|
712
|
+ L0_pos[1] = side.y; |
|
713
|
+ L0_pos[2] = side.z; |
|
714
|
+ |
|
715
|
+ L1_pos[0] = -dir.x; |
|
716
|
+ L1_pos[1] = -dir.y; |
|
717
|
+ L1_pos[2] = -dir.z; |
|
718
|
+ |
|
719
|
+ //scale the viewport to the network |
|
720
|
+ /*vector3D<float> span = max_point - min_point; |
|
721
|
+ float scale = 1.0/span.Length(); |
|
722
|
+ //compute center point |
|
723
|
+ point3D<float> center = min_point + 0.5*span; |
|
724
|
+ glScalef(scale, scale, scale); |
|
725
|
+ glTranslatef(-center.x, -center.y, -center.z);*/ |
|
726
|
+ |
|
727
|
+ |
|
728
|
+} |
|
729
|
+void RecenterCamera() |
|
730
|
+{ |
|
731
|
+ point3D<float> min_point0 = goldNetwork->min_pos; |
|
732
|
+ point3D<float> min_point1 = testNetwork->min_pos; |
|
733
|
+ |
|
734
|
+ point3D<float> max_point0 = goldNetwork->max_pos; |
|
735
|
+ point3D<float> max_point1 = testNetwork->max_pos; |
|
736
|
+ |
|
737
|
+ point3D<float> min_point(min(min_point0.x, min_point1.x), min(min_point0.y, min_point1.y), min(min_point0.z, min_point1.z)); |
|
738
|
+ point3D<float> max_point(max(max_point0.x, max_point1.x), max(max_point0.y, max_point1.y), max(max_point0.z, max_point1.z)); |
|
739
|
+ point3D<float> center_point = min_point + 0.5*(max_point - min_point); |
|
740
|
+ |
|
741
|
+ |
|
742
|
+ network_span = (max_point - point3D<float>(0, 0, 0)).Length(); |
|
743
|
+ rts_glut_camera.setPosition(0, 0, 3*network_span); |
|
744
|
+ rts_glut_camera.LookAt(center_point, vector3D<float>(0.0, 1.0, 0.0)); |
|
745
|
+ |
|
746
|
+} |
|
747
|
+void DrawNetwork(int Display) |
|
748
|
+{ |
|
749
|
+ //draw the network fibers |
|
750
|
+ switch(Display) |
|
751
|
+ { |
|
752
|
+ case DISPLAY_GT_NETWORK: |
|
753
|
+ Edge_ErrorShader.UpdateGlobalUniforms(); |
|
754
|
+ Edge_ErrorShader.BeginProgram(); |
|
755
|
+ glCallList(GT_FibersList); |
|
756
|
+ Edge_ErrorShader.EndProgram(); |
|
757
|
+ |
|
758
|
+ Node_ErrorShader.UpdateGlobalUniforms(); |
|
759
|
+ Node_ErrorShader.BeginProgram(); |
|
760
|
+ glCallList(GT_EndCaps); |
|
761
|
+ Node_ErrorShader.EndProgram(); |
|
762
|
+ break; |
|
763
|
+ case DISPLAY_T_NETWORK: |
|
764
|
+ Edge_ErrorShader.UpdateGlobalUniforms(); |
|
765
|
+ Edge_ErrorShader.BeginProgram(); |
|
766
|
+ glCallList(T_FibersList); |
|
767
|
+ Edge_ErrorShader.EndProgram(); |
|
768
|
+ |
|
769
|
+ Node_ErrorShader.UpdateGlobalUniforms(); |
|
770
|
+ Node_ErrorShader.BeginProgram(); |
|
771
|
+ glCallList(T_EndCaps); |
|
772
|
+ Node_ErrorShader.EndProgram(); |
|
773
|
+ break; |
|
774
|
+ case DISPLAY_GT_GRAPH: |
|
775
|
+ glColor3f(1.0, 1.0, 1.0); |
|
776
|
+ Smooth_Shader.UpdateGlobalUniforms(); |
|
777
|
+ Smooth_Shader.BeginProgram(); |
|
778
|
+ glCallList(GT_PathList); |
|
779
|
+ glColor3f(1.0, 1.0, 1.0); |
|
780
|
+ glCallList(GT_FibersList); |
|
781
|
+ glCallList(GT_NodesList); |
|
782
|
+ Smooth_Shader.EndProgram(); |
|
783
|
+ break; |
|
784
|
+ case DISPLAY_T_GRAPH: |
|
785
|
+ glColor3f(1.0, 1.0, 1.0); |
|
786
|
+ Smooth_Shader.UpdateGlobalUniforms(); |
|
787
|
+ Smooth_Shader.BeginProgram(); |
|
788
|
+ glCallList(T_PathList); |
|
789
|
+ glColor3f(1.0, 1.0, 1.0); |
|
790
|
+ glCallList(T_FibersList); |
|
791
|
+ glCallList(T_NodesList); |
|
792
|
+ Smooth_Shader.EndProgram(); |
|
793
|
+ break; |
|
794
|
+ case DISPLAY_GT_SELECTED: |
|
795
|
+ glColor3f(1.0, 1.0, 1.0); |
|
796
|
+ Smooth_Shader.UpdateGlobalUniforms(); |
|
797
|
+ Smooth_Shader.BeginProgram(); |
|
798
|
+ glCallList(GT_FibersList); |
|
799
|
+ glCallList(GT_NodesList); |
|
800
|
+ |
|
801
|
+ glClear(GL_DEPTH_BUFFER_BIT); |
|
802
|
+ glColor3f(1.0, 0.0, 1.0); |
|
803
|
+ DrawFiberSequence(goldNetwork, coreGraph[current_sequence].second, fiber_radius_factor*sigmaG, node_radius_factor*sigmaG); |
|
804
|
+ Smooth_Shader.EndProgram(); |
|
805
|
+ break; |
|
806
|
+ case DISPLAY_T_SELECTED: |
|
807
|
+ glColor3f(1.0, 1.0, 1.0); |
|
808
|
+ Smooth_Shader.UpdateGlobalUniforms(); |
|
809
|
+ Smooth_Shader.BeginProgram(); |
|
810
|
+ glCallList(T_FibersList); |
|
811
|
+ glCallList(T_NodesList); |
|
812
|
+ |
|
813
|
+ glClear(GL_DEPTH_BUFFER_BIT); |
|
814
|
+ glColor3f(1.0, 0.0, 1.0); |
|
815
|
+ DrawFiberSequence(testNetwork, coreGraph[current_sequence].first, fiber_radius_factor*sigmaG, node_radius_factor*sigmaG); |
|
816
|
+ Smooth_Shader.EndProgram(); |
|
817
|
+ break; |
|
818
|
+ default: |
|
819
|
+ break; |
|
820
|
+ } |
|
821
|
+ |
|
822
|
+} |
|
823
|
+ |
|
824
|
+ |
|
825
|
+ |
|
826
|
+ |
|
827
|
+void MyDisplayFunction() |
|
828
|
+{ |
|
829
|
+ //glClearColor(0.95, 1.0, 0.95, 1.0); |
|
830
|
+ glClearColor(1.0, 1.0, 1.0, 1.0); |
|
831
|
+ glClear(GL_COLOR_BUFFER_BIT); |
|
832
|
+ glClear(GL_DEPTH_BUFFER_BIT); |
|
833
|
+ |
|
834
|
+ //set left viewport |
|
835
|
+ glMatrixMode(GL_PROJECTION); |
|
836
|
+ glLoadIdentity(); |
|
837
|
+ glViewport(0, 0, glutGet(GLUT_WINDOW_WIDTH)/2, glutGet(GLUT_WINDOW_HEIGHT)); |
|
838
|
+ |
|
839
|
+ RenderViewCamera(); |
|
840
|
+ |
|
841
|
+ |
|
842
|
+ if(DisplayMode == DISPLAY_NETWORK) |
|
843
|
+ DrawNetwork(DISPLAY_GT_NETWORK); |
|
844
|
+ else if(DisplayMode == DISPLAY_GRAPH) |
|
845
|
+ DrawNetwork(DISPLAY_GT_GRAPH); |
|
846
|
+ else if(DisplayMode == DISPLAY_SELECTED) |
|
847
|
+ DrawNetwork(DISPLAY_GT_SELECTED); |
|
848
|
+ |
|
849
|
+ //set right viewport |
|
850
|
+ glMatrixMode(GL_PROJECTION); |
|
851
|
+ glLoadIdentity(); |
|
852
|
+ glViewport(glutGet(GLUT_WINDOW_WIDTH)/2, 0, glutGet(GLUT_WINDOW_WIDTH)/2, glutGet(GLUT_WINDOW_HEIGHT)); |
|
853
|
+ |
|
854
|
+ RenderViewCamera(); |
|
855
|
+ //glClear(GL_COLOR_BUFFER_BIT); |
|
856
|
+ //glClear(GL_DEPTH_BUFFER_BIT); |
|
857
|
+ |
|
858
|
+ if(DisplayMode == DISPLAY_NETWORK) |
|
859
|
+ DrawNetwork(DISPLAY_T_NETWORK); |
|
860
|
+ else if(DisplayMode == DISPLAY_GRAPH) |
|
861
|
+ DrawNetwork(DISPLAY_T_GRAPH); |
|
862
|
+ else if(DisplayMode == DISPLAY_SELECTED) |
|
863
|
+ DrawNetwork(DISPLAY_T_SELECTED); |
|
864
|
+ |
|
865
|
+ |
|
866
|
+ |
|
867
|
+ //glutSwapBuffers(); |
|
868
|
+} |
|
869
|
+ |
|
870
|
+void GlutMenuCallback(int option) |
|
871
|
+{ |
|
872
|
+ if(option == NETCOMP_EXIT) |
|
873
|
+ exit(1); |
|
874
|
+ if(option >= DISPLAY_NETWORK && option <= DISPLAY_SELECTED) |
|
875
|
+ DisplayMode = option; |
|
876
|
+ if(option >= COLORMAP_ISOLUMINANT && option <= COLORMAP_RAINBOW) |
|
877
|
+ makeColormap(option); |
|
878
|
+ if(option == CULL_TEST_CASE) |
|
879
|
+ { |
|
880
|
+ //get the new threshold |
|
881
|
+ cout<<"Enter new test case fiber threshold [0 1]: "; |
|
882
|
+ float cull_value; |
|
883
|
+ cin>>cull_value; |
|
884
|
+ testNetwork->setCullValue(cull_value); |
|
885
|
+ |
|
886
|
+ //re-create the display lists |
|
887
|
+ ComputeNetMets(); |
|
888
|
+ CreateDisplayLists(); |
|
889
|
+ |
|
890
|
+ } |
|
891
|
+ if(option == RECOMPUTE_METRIC) |
|
892
|
+ { |
|
893
|
+ cout<<"Please enter a sigma value: "; |
|
894
|
+ cin>>sigmaG; |
|
895
|
+ sigmaC = sigmaG; |
|
896
|
+ |
|
897
|
+ ComputeNetMets(); |
|
898
|
+ CreateDisplayLists(); |
|
899
|
+ } |
|
900
|
+ |
|
901
|
+ |
|
902
|
+ |
|
903
|
+ /* |
|
904
|
+ switch(option) |
|
905
|
+ { |
|
906
|
+ case NETCOMP_EXIT: |
|
907
|
+ exit(1); |
|
908
|
+ break; |
|
909
|
+ case NETCOMP_VIEW_GT: |
|
910
|
+ DisplayMode = DISPLAY_GT_NETWORK; |
|
911
|
+ break; |
|
912
|
+ case NETCOMP_VIEW_T: |
|
913
|
+ DisplayMode = DISPLAY_T_NETWORK; |
|
914
|
+ break; |
|
915
|
+ default: |
|
916
|
+ break; |
|
917
|
+ }*/ |
|
918
|
+ |
|
919
|
+} |
0
|
920
|
\ No newline at end of file |
...
|
...
|
|