Commit 4d23da9ca2b95fdebeabba2152faccd0025b6d78
1 parent
5c83f00e
add 00_GT.swc,now everything is good
Showing
2 changed files
with
86 additions
and
42 deletions
Show diff stats
data/00_GT.swc
1 | +# converted from 00_GT.obj | |
2 | +1 1 99 677 0 0.5 -1 | |
3 | +2 1 88 563 0 0.5 1 | |
4 | +3 1 229 510 0 0.5 2 | |
5 | +4 1 181 372 0 0.5 3 | |
6 | +5 1 57 347 0 0.5 4 | |
7 | +6 1 316 596 0 0.5 3 | |
8 | +7 1 344 724 0 0.5 6 | |
9 | +8 1 385 425 0 0.5 3 | |
10 | +9 1 581 361 0 0.5 8 | |
11 | +10 1 574 223 0 0.5 9 | |
12 | +11 1 481 165 0 0.5 10 | |
13 | +12 1 341 199 0 0.5 11 | |
14 | +13 1 757 377 0 0.5 9 | |
15 | +14 1 818 229 0 0.5 13 | |
16 | +15 1 981 152 0 0.5 14 | |
17 | +16 1 793 508 0 0.5 13 | |
18 | +17 1 941 600 0 0.5 16 | |
19 | +18 1 679 601 0 0.5 16 | |
20 | +19 1 647 738 0 0.5 18 | ... | ... |
main.cu
... | ... | @@ -47,7 +47,8 @@ std::vector<unsigned> _t_gt; // store indices of nearest edge points in _ |
47 | 47 | float resample_rate = 0.5f; //sample rate for the network (fraction of sigma used as the maximum sample rate) |
48 | 48 | float camera_factor = 1.2f; //start point of the camera as a function of X and Y size |
49 | 49 | float orbit_factor = 0.01f; //degrees per pixel used to orbit the camera |
50 | -float zoom_factor = 10.0; | |
50 | +float zoom_factor = 10.0f; | |
51 | +float radius_factor = 0.5f; | |
51 | 52 | |
52 | 53 | //mouse click |
53 | 54 | bool LButtonDown = false; // true when left button down |
... | ... | @@ -74,7 +75,9 @@ GLuint dlist2; |
74 | 75 | //OpenGL objects |
75 | 76 | GLuint cmap_tex = 0; //texture name for the color map |
76 | 77 | |
78 | +float delta; | |
77 | 79 | float sigma = 3; //default sigma |
80 | +float radius = 3; //equals to radius | |
78 | 81 | |
79 | 82 | //sets an OpenGL viewport taking up the entire window |
80 | 83 | void glut_render_single_projection(){ |
... | ... | @@ -146,11 +149,12 @@ void glut_render(void) { |
146 | 149 | glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color |
147 | 150 | glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map |
148 | 151 | |
149 | - GT.glCylinder(sigma); //render the GT network | |
152 | + GT.glCylinder(sigma, radius); //render the GT network | |
150 | 153 | |
151 | 154 | glut_render_right_projection(); //set up a projection for the right half of the window |
152 | 155 | glut_render_modelview(); //set up the modelview matrix using camera details |
153 | - T.glCylinder(sigma); //render the T network | |
156 | + T.glCylinder(sigma, radius); //render the T network | |
157 | + sigma = radius; // set sigma equal to radius | |
154 | 158 | } |
155 | 159 | } |
156 | 160 | |
... | ... | @@ -171,12 +175,12 @@ void glut_render(void) { |
171 | 175 | glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color |
172 | 176 | glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map |
173 | 177 | |
174 | - _GT.glCylinder(sigma); //render the GT network | |
178 | + _GT.glCylinder(sigma, radius); //render the GT network | |
175 | 179 | |
176 | 180 | glut_render_right_projection(); //set up a projection for the right half of the window |
177 | 181 | glut_render_modelview(); //set up the modelview matrix using camera details |
178 | - _T.glCylinder(sigma); //render the T network | |
179 | - | |
182 | + _T.glCylinder(sigma, radius); //render the T network | |
183 | + sigma = radius; //set sigma equal to radius | |
180 | 184 | } |
181 | 185 | else { |
182 | 186 | glEnable(GL_DEPTH_TEST); //enable depth |
... | ... | @@ -185,12 +189,13 @@ void glut_render(void) { |
185 | 189 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen |
186 | 190 | |
187 | 191 | //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap); |
188 | - _GT.glRandColorCylinder1(dlist1, _gt_t, colormap, sigma); | |
192 | + _GT.glRandColorCylinder1(dlist1, _gt_t, colormap, sigma, radius); | |
189 | 193 | |
190 | 194 | glut_render_right_projection(); //set up a projection for the right half of the window |
191 | 195 | glut_render_modelview(); //set up the modelview matrix using camera details |
192 | 196 | //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap); |
193 | - _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma); | |
197 | + _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma, radius); | |
198 | + sigma = radius; //set sigma equal to radius | |
194 | 199 | } |
195 | 200 | } |
196 | 201 | } |
... | ... | @@ -310,20 +315,10 @@ void glut_mouse(int button, int state, int x, int y){ |
310 | 315 | |
311 | 316 | // define camera move based on mouse wheel move(actually we can combine this with glut_mouse) |
312 | 317 | void glut_wheel(int wheel, int direction, int x, int y) { |
313 | - /*float cam_move_fac; // camera move unit length | |
314 | - stim::vec3<float> eye = cam.getPosition(); // get the camera position (eye point) | |
315 | - stim::vec3<float> focus = cam.getLookAt(); // get the camera focal point | |
316 | - cam_move_fac = fabs(focus[2] - eye[2]) / 50; // divided by 50 | |
317 | - | |
318 | - if (direction > 0) // if it is button 3(up) | |
319 | - des -= cam_move_fac; | |
320 | - else // if it is button 4(down) | |
321 | - des += cam_move_fac;*/ | |
322 | - float delta; | |
323 | 318 | |
324 | - if (direction > 0) // if it is button 3(up) | |
319 | + if (direction > 0) // if it is button 3(up), move closer | |
325 | 320 | delta = zoom_factor; |
326 | - else // if it is button 4(down) | |
321 | + else // if it is button 4(down), leave farther | |
327 | 322 | delta = -zoom_factor; |
328 | 323 | |
329 | 324 | cam.Push(delta); |
... | ... | @@ -332,19 +327,46 @@ void glut_wheel(int wheel, int direction, int x, int y) { |
332 | 327 | |
333 | 328 | // define keyboard inputs |
334 | 329 | void glut_keyboard(unsigned char key, int x, int y){ |
335 | - if(key == 'm') // if keyboard 'm' is pressed | |
336 | - { | |
337 | - if(compareMode && !mappingMode){ // if it is in compare mode | |
338 | - compareMode = false; | |
339 | - mappingMode = true; | |
340 | - } | |
341 | - else{ // if it is in mapping mode | |
342 | - compareMode = true; | |
343 | - mappingMode = false; | |
344 | - } | |
345 | - } | |
346 | - if (key == 27) { // if keyboard "ESC" is pressed | |
347 | - exit(0); // exit | |
330 | + | |
331 | + // register different keyboard operation | |
332 | + switch (key) { | |
333 | + | |
334 | + // change render mode | |
335 | + case 'm': // if keyboard 'm' is pressed, then change render mode | |
336 | + if (compareMode && !mappingMode && ind) { // if current mode is comparing mode | |
337 | + compareMode = false; | |
338 | + mappingMode = true; | |
339 | + } | |
340 | + else if (!compareMode && mappingMode && ind) { // if current mode is mapping mode | |
341 | + compareMode = true; | |
342 | + mappingMode = false; | |
343 | + } | |
344 | + break; | |
345 | + | |
346 | + // zooming | |
347 | + case 'w': // if keyboard 'w' is pressed, then move closer | |
348 | + delta = zoom_factor; | |
349 | + cam.Push(delta); | |
350 | + break; | |
351 | + case 's': // if keyboard 's' is pressed, then leave farther | |
352 | + delta = -zoom_factor; | |
353 | + cam.Push(delta); | |
354 | + break; | |
355 | + | |
356 | + // resample and re-render the cylinder in different radius | |
357 | + case 'd': // if keyboard 'd' is pressed, then increase radius by radius_factor | |
358 | + radius += radius_factor; | |
359 | + break; | |
360 | + case 'a': // if keyboard 'a' is pressed, then decrease radius by radius_factor | |
361 | + radius -= radius_factor; | |
362 | + // get rid of the degenerated case when radius decrease below 0 | |
363 | + if (radius < 0.001f) | |
364 | + radius = 0.2; | |
365 | + break; | |
366 | + | |
367 | + // close window and exit application | |
368 | + case 27: // if keyboard 'ESC' is pressed, then exit | |
369 | + exit(0); | |
348 | 370 | } |
349 | 371 | glutPostRedisplay(); |
350 | 372 | } |
... | ... | @@ -396,13 +418,13 @@ void glut_initialize(){ |
396 | 418 | glutMouseFunc(glut_mouse); //executed on a mouse click - sets starting mouse positions for rotations |
397 | 419 | glutMotionFunc(glut_motion); //executed when the mouse is moved while a button is pressed |
398 | 420 | if (ind == 1) { //only in mapping mode, keyboard will be used |
399 | - glutKeyboardFunc(glut_keyboard); //register keyboard callback | |
400 | 421 | glutCreateMenu(glut_menu); //register menu option callback |
401 | - glutAddMenuEntry("Comparing Mode", 1);//register menu 1 as comparing mode | |
402 | - glutAddMenuEntry("Mapping Mode", 2); //register menu 2 as mapping mode | |
403 | - glutAddMenuEntry("Exit", 3); //register menu 3 as exiting | |
404 | - glutAttachMenu(GLUT_RIGHT_BUTTON); //register right mouse to open menu option | |
405 | - } | |
422 | + glutAddMenuEntry("Comparing Mode", 1); //register menu 1 as comparing mode | |
423 | + glutAddMenuEntry("Mapping Mode", 2); //register menu 2 as mapping mode | |
424 | + glutAddMenuEntry("Exit", 3); //register menu 3 as exiting | |
425 | + glutAttachMenu(GLUT_RIGHT_BUTTON); //register right mouse to open menu option | |
426 | + } | |
427 | + glutKeyboardFunc(glut_keyboard); //register keyboard callback | |
406 | 428 | glutMouseWheelFunc(glut_wheel); |
407 | 429 | |
408 | 430 | texture_initialize(); //set up texture mapping (create texture maps, enable features) |
... | ... | @@ -579,13 +601,14 @@ int main(int argc, char* argv[]) |
579 | 601 | if (1 == swc_ind) { //loading swc files |
580 | 602 | int device = args["device"].as_int(); //get the device value from the user |
581 | 603 | num_nets = 2; //set the number of networks to two |
582 | - //does it need to be resampled?? | |
583 | 604 | sigma = args["sigma"].as_float(); //get the sigma value from the user |
605 | + radius = sigma; | |
584 | 606 | T.load_swc(args.arg(1)); //load the second (test) network |
585 | 607 | if (args["features"].is_set()) //if the user wants to save features |
586 | 608 | features(args["features"].as_string()); |
587 | - GT = GT.resample(resample_rate * sigma); //resample both networks based on the sigma value | |
588 | - T = T.resample(resample_rate * sigma); | |
609 | + //does it need to be resampled?? | |
610 | + //GT = GT.resample(resample_rate * sigma); //resample both networks based on the sigma value | |
611 | + //T = T.resample(resample_rate * sigma); | |
589 | 612 | if (args["mapping"].is_set()) { |
590 | 613 | float threshold = args["mapping"].as_float(); |
591 | 614 | map_swc(sigma, device, threshold); |
... | ... | @@ -599,6 +622,7 @@ int main(int argc, char* argv[]) |
599 | 622 | int device = args["device"].as_int(); //get the device value from the user |
600 | 623 | num_nets = 2; //set the number of networks to two |
601 | 624 | sigma = args["sigma"].as_float(); //get the sigma value from the user |
625 | + radius = sigma; | |
602 | 626 | T.load_obj(args.arg(1)); //load the second (test) network |
603 | 627 | if (args["features"].is_set()) //if the user wants to save features |
604 | 628 | features(args["features"].as_string()); | ... | ... |