Commit 5c83f00e12e33b450f62f36eb314e464d6e6d182

Authored by David Mayerich
2 parents b31bfd7d 7c1b82bc

Merge branch 'JACK' into 'master'

test for 00_GT.swc

See merge request !8
Showing 2 changed files with 53 additions and 130 deletions   Show diff stats
@@ -84,3 +84,4 @@ configure_file(data/04_Ta.obj ${CMAKE_CURRENT_BINARY_DIR}/04_Ta.obj @ONLY) @@ -84,3 +84,4 @@ configure_file(data/04_Ta.obj ${CMAKE_CURRENT_BINARY_DIR}/04_Ta.obj @ONLY)
84 configure_file(data/04_Tb.obj ${CMAKE_CURRENT_BINARY_DIR}/04_Tb.obj @ONLY) 84 configure_file(data/04_Tb.obj ${CMAKE_CURRENT_BINARY_DIR}/04_Tb.obj @ONLY)
85 configure_file(data/1.swc ${CMAKE_CURRENT_BINARY_DIR}/1.swc @ONLY) 85 configure_file(data/1.swc ${CMAKE_CURRENT_BINARY_DIR}/1.swc @ONLY)
86 configure_file(data/2.swc ${CMAKE_CURRENT_BINARY_DIR}/2.swc @ONLY) 86 configure_file(data/2.swc ${CMAKE_CURRENT_BINARY_DIR}/2.swc @ONLY)
  87 +configure_file(data/00_GT.swc ${CMAKE_CURRENT_BINARY_DIR}/00_GT.swc @ONLY)
1 -#ifndef GL_MULTISAMPLE  
2 -#define GL_MULTISAMPLE 0x809D  
3 -#endif  
4 -  
5 -#include <stdlib.h> 1 +#include <stdlib.h>
6 #include <string> 2 #include <string>
7 #include <fstream> 3 #include <fstream>
8 #include <algorithm> 4 #include <algorithm>
@@ -51,7 +47,7 @@ std::vector&lt;unsigned&gt; _t_gt; // store indices of nearest edge points in _ @@ -51,7 +47,7 @@ std::vector&lt;unsigned&gt; _t_gt; // store indices of nearest edge points in _
51 float resample_rate = 0.5f; //sample rate for the network (fraction of sigma used as the maximum sample rate) 47 float resample_rate = 0.5f; //sample rate for the network (fraction of sigma used as the maximum sample rate)
52 float camera_factor = 1.2f; //start point of the camera as a function of X and Y size 48 float camera_factor = 1.2f; //start point of the camera as a function of X and Y size
53 float orbit_factor = 0.01f; //degrees per pixel used to orbit the camera 49 float orbit_factor = 0.01f; //degrees per pixel used to orbit the camera
54 -float zoom_factor = 5.0; 50 +float zoom_factor = 10.0;
55 51
56 //mouse click 52 //mouse click
57 bool LButtonDown = false; // true when left button down 53 bool LButtonDown = false; // true when left button down
@@ -78,6 +74,8 @@ GLuint dlist2; @@ -78,6 +74,8 @@ GLuint dlist2;
78 //OpenGL objects 74 //OpenGL objects
79 GLuint cmap_tex = 0; //texture name for the color map 75 GLuint cmap_tex = 0; //texture name for the color map
80 76
  77 +float sigma = 3; //default sigma
  78 +
81 //sets an OpenGL viewport taking up the entire window 79 //sets an OpenGL viewport taking up the entire window
82 void glut_render_single_projection(){ 80 void glut_render_single_projection(){
83 81
@@ -130,17 +128,40 @@ void glut_render(void) { @@ -130,17 +128,40 @@ void glut_render(void) {
130 128
131 //no mapping, just comparing 129 //no mapping, just comparing
132 if (ind == 0) { 130 if (ind == 0) {
133 - //-----working with obj files-----  
134 - if (swc_ind == 0) {  
135 - if (num_nets == 1) { //if a single network is loaded  
136 - glEnable(GL_DEPTH_TEST); //enable depth  
137 - glut_render_single_projection(); //fill the entire viewport  
138 - glut_render_modelview(); //set up the modelview matrix with camera details  
139 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen  
140 - GT.glCenterline0(); //render the GT network (the only one loaded)  
141 - } 131 + if (num_nets == 1) { //if a single network is loaded
  132 + glEnable(GL_DEPTH_TEST); //enable depth
  133 + glut_render_single_projection(); //fill the entire viewport
  134 + glut_render_modelview(); //set up the modelview matrix with camera details
  135 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen
  136 + GT.glCenterline0(); //render the GT network (the only one loaded)
  137 + }
  138 +
  139 + if (num_nets == 2) { //if two networks are loaded
  140 + glEnable(GL_DEPTH_TEST); //enable depth
  141 + glut_render_left_projection(); //set up a projection for the left half of the window
  142 + glut_render_modelview(); //set up the modelview matrix using camera details
  143 + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen
  144 +
  145 + glEnable(GL_TEXTURE_1D); //enable texture mapping
  146 + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color
  147 + glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map
  148 +
  149 + GT.glCylinder(sigma); //render the GT network
  150 +
  151 + glut_render_right_projection(); //set up a projection for the right half of the window
  152 + glut_render_modelview(); //set up the modelview matrix using camera details
  153 + T.glCylinder(sigma); //render the T network
  154 + }
  155 + }
142 156
143 - if (num_nets == 2) { //if two networks are loaded 157 + //do comparing and mapping
  158 + else {
  159 + if (num_nets == 1) { //if a single network is loaded
  160 + std::cout << "You should have at least two networks to do mapping." << std::endl; //exit program because there isn't enough network
  161 + exit(1);
  162 + }
  163 + if (num_nets == 2) { //if two networks are loaded
  164 + if (compareMode) {
144 glEnable(GL_DEPTH_TEST); //enable depth 165 glEnable(GL_DEPTH_TEST); //enable depth
145 glut_render_left_projection(); //set up a projection for the left half of the window 166 glut_render_left_projection(); //set up a projection for the left half of the window
146 glut_render_modelview(); //set up the modelview matrix using camera details 167 glut_render_modelview(); //set up the modelview matrix using camera details
@@ -150,124 +171,26 @@ void glut_render(void) { @@ -150,124 +171,26 @@ void glut_render(void) {
150 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color 171 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color
151 glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map 172 glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map
152 173
153 - GT.glCylinder(); //render the GT network 174 + _GT.glCylinder(sigma); //render the GT network
154 175
155 glut_render_right_projection(); //set up a projection for the right half of the window 176 glut_render_right_projection(); //set up a projection for the right half of the window
156 glut_render_modelview(); //set up the modelview matrix using camera details 177 glut_render_modelview(); //set up the modelview matrix using camera details
157 - T.glCylinder(); //render the T network  
158 - }  
159 - }  
160 - //-----working with swc files-----  
161 - else {  
162 - if (num_nets == 1) { //if a single network is loaded  
163 - glEnable(GL_DEPTH_TEST); //enable depth  
164 - glut_render_single_projection(); //fill the entire viewport  
165 - glut_render_modelview(); //set up the modelview matrix with camera details  
166 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen  
167 - GT.glCenterline0_swc(); //render the GT network (the only one loaded)  
168 - } 178 + _T.glCylinder(sigma); //render the T network
169 179
170 - if (num_nets == 2) { //if two networks are loaded 180 + }
  181 + else {
171 glEnable(GL_DEPTH_TEST); //enable depth 182 glEnable(GL_DEPTH_TEST); //enable depth
172 glut_render_left_projection(); //set up a projection for the left half of the window 183 glut_render_left_projection(); //set up a projection for the left half of the window
173 glut_render_modelview(); //set up the modelview matrix using camera details 184 glut_render_modelview(); //set up the modelview matrix using camera details
174 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen 185 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen
175 186
176 - glEnable(GL_TEXTURE_1D); //enable texture mapping  
177 - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color  
178 - glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map  
179 -  
180 - GT.glCenterline(); //render the GT network 187 + //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap);
  188 + _GT.glRandColorCylinder1(dlist1, _gt_t, colormap, sigma);
181 189
182 glut_render_right_projection(); //set up a projection for the right half of the window 190 glut_render_right_projection(); //set up a projection for the right half of the window
183 glut_render_modelview(); //set up the modelview matrix using camera details 191 glut_render_modelview(); //set up the modelview matrix using camera details
184 - T.glCenterline(); //render the T network  
185 - }  
186 - }  
187 - }  
188 -  
189 - //do comparing and mapping  
190 - else {  
191 - //-----working with obj files-----  
192 - if (swc_ind == 0) {  
193 - if (num_nets == 1) { //if a single network is loaded  
194 - std::cout << "You should have at least two networks to do mapping." << std::endl; //exit program because there isn't enough network  
195 - exit(1);  
196 - }  
197 - if (num_nets == 2) { //if two networks are loaded  
198 - if (compareMode) {  
199 - glEnable(GL_DEPTH_TEST); //enable depth  
200 - glut_render_left_projection(); //set up a projection for the left half of the window  
201 - glut_render_modelview(); //set up the modelview matrix using camera details  
202 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen  
203 -  
204 - glEnable(GL_TEXTURE_1D); //enable texture mapping  
205 - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color  
206 - glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map  
207 -  
208 - _GT.glCylinder(); //render the GT network  
209 -  
210 - glut_render_right_projection(); //set up a projection for the right half of the window  
211 - glut_render_modelview(); //set up the modelview matrix using camera details  
212 - _T.glCylinder(); //render the T network  
213 -  
214 - }  
215 - else {  
216 - glEnable(GL_DEPTH_TEST); //enable depth  
217 - glut_render_left_projection(); //set up a projection for the left half of the window  
218 - glut_render_modelview(); //set up the modelview matrix using camera details  
219 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen  
220 -  
221 - //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap);  
222 - _GT.glRandColorCylinder1(dlist1, _gt_t, colormap);  
223 -  
224 - glut_render_right_projection(); //set up a projection for the right half of the window  
225 - glut_render_modelview(); //set up the modelview matrix using camera details  
226 - //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap);  
227 - _T.glRandColorCylinder2(dlist2, _t_gt, colormap);  
228 - }  
229 - }  
230 - }  
231 - //-----working with swc files-----  
232 - else {  
233 - if (num_nets == 1) { //if a single network is loaded  
234 - std::cout << "You should have at least two networks to do mapping." << std::endl; //exit program because there isn't enough network  
235 - exit(1);  
236 - }  
237 - if (num_nets == 2) { //if two networks are loaded  
238 - //in compare mode  
239 - if (compareMode) {  
240 - glEnable(GL_DEPTH_TEST); //enable depth  
241 - glut_render_left_projection(); //set up a projection for the left half of the window  
242 - glut_render_modelview(); //set up the modelview matrix using camera details  
243 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen  
244 -  
245 - glEnable(GL_TEXTURE_1D); //enable texture mapping  
246 - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color  
247 - glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map  
248 -  
249 - _GT.glCenterline(); //render the GT network  
250 -  
251 - glut_render_right_projection(); //set up a projection for the right half of the window  
252 - glut_render_modelview(); //set up the modelview matrix using camera details  
253 - _T.glCenterline(); //render the T network  
254 -  
255 - }  
256 - //in mapping mode  
257 - else {  
258 - glEnable(GL_DEPTH_TEST); //enable depth  
259 - glut_render_left_projection(); //set up a projection for the left half of the window  
260 - glut_render_modelview(); //set up the modelview matrix using camera details  
261 - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen  
262 -  
263 - //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap);  
264 - _GT.glRandColorCylinder1_swc(dlist1, _gt_t, colormap);  
265 -  
266 - glut_render_right_projection(); //set up a projection for the right half of the window  
267 - glut_render_modelview(); //set up the modelview matrix using camera details  
268 - //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap);  
269 - _T.glRandColorCylinder2_swc(dlist2, _t_gt, colormap);  
270 - } 192 + //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap);
  193 + _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma);
271 } 194 }
272 } 195 }
273 } 196 }
@@ -399,9 +322,9 @@ void glut_wheel(int wheel, int direction, int x, int y) { @@ -399,9 +322,9 @@ void glut_wheel(int wheel, int direction, int x, int y) {
399 float delta; 322 float delta;
400 323
401 if (direction > 0) // if it is button 3(up) 324 if (direction > 0) // if it is button 3(up)
402 - delta = -zoom_factor;  
403 - else // if it is button 4(down)  
404 delta = zoom_factor; 325 delta = zoom_factor;
  326 + else // if it is button 4(down)
  327 + delta = -zoom_factor;
405 328
406 cam.Push(delta); 329 cam.Push(delta);
407 glutPostRedisplay(); 330 glutPostRedisplay();
@@ -463,12 +386,11 @@ void glut_initialize(){ @@ -463,12 +386,11 @@ void glut_initialize(){
463 386
464 glutInit(&myargc, myargv); //pass bogus arguments to glutInit() 387 glutInit(&myargc, myargv); //pass bogus arguments to glutInit()
465 glutSetOption(GLUT_MULTISAMPLE, 8); 388 glutSetOption(GLUT_MULTISAMPLE, 8);
466 - glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_MULTISAMPLE); //generate a color buffer, depth buffer, and enable double buffering 389 + glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); //generate a color buffer, depth buffer, and enable double buffering
467 glutInitWindowPosition(100,100); //set the initial window position 390 glutInitWindowPosition(100,100); //set the initial window position
468 glutInitWindowSize(320, 320); //set the initial window size 391 glutInitWindowSize(320, 320); //set the initial window size
469 glutCreateWindow("NetMets - STIM Lab, UH"); //set the dialog box title 392 glutCreateWindow("NetMets - STIM Lab, UH"); //set the dialog box title
470 393
471 - glEnable(GL_MULTISAMPLE);  
472 // register callback functions 394 // register callback functions
473 glutDisplayFunc(glut_render); //function executed for rendering - renders networks 395 glutDisplayFunc(glut_render); //function executed for rendering - renders networks
474 glutMouseFunc(glut_mouse); //executed on a mouse click - sets starting mouse positions for rotations 396 glutMouseFunc(glut_mouse); //executed on a mouse click - sets starting mouse positions for rotations
@@ -653,12 +575,12 @@ int main(int argc, char* argv[]) @@ -653,12 +575,12 @@ int main(int argc, char* argv[])
653 } 575 }
654 } 576 }
655 577
656 - if (args.nargs() == 2) { //if two files are specified, they will be displayed in neighboring viewports and compared  
657 - if (1 == swc_ind) { //loading swc files 578 + if (args.nargs() == 2) { //if two files are specified, they will be displayed in neighboring viewports and compared
  579 + if (1 == swc_ind) { //loading swc files
658 int device = args["device"].as_int(); //get the device value from the user 580 int device = args["device"].as_int(); //get the device value from the user
659 num_nets = 2; //set the number of networks to two 581 num_nets = 2; //set the number of networks to two
660 //does it need to be resampled?? 582 //does it need to be resampled??
661 - float sigma = args["sigma"].as_float(); //get the sigma value from the user 583 + sigma = args["sigma"].as_float(); //get the sigma value from the user
662 T.load_swc(args.arg(1)); //load the second (test) network 584 T.load_swc(args.arg(1)); //load the second (test) network
663 if (args["features"].is_set()) //if the user wants to save features 585 if (args["features"].is_set()) //if the user wants to save features
664 features(args["features"].as_string()); 586 features(args["features"].as_string());
@@ -676,7 +598,7 @@ int main(int argc, char* argv[]) @@ -676,7 +598,7 @@ int main(int argc, char* argv[])
676 else { 598 else {
677 int device = args["device"].as_int(); //get the device value from the user 599 int device = args["device"].as_int(); //get the device value from the user
678 num_nets = 2; //set the number of networks to two 600 num_nets = 2; //set the number of networks to two
679 - float sigma = args["sigma"].as_float(); //get the sigma value from the user 601 + sigma = args["sigma"].as_float(); //get the sigma value from the user
680 T.load_obj(args.arg(1)); //load the second (test) network 602 T.load_obj(args.arg(1)); //load the second (test) network
681 if (args["features"].is_set()) //if the user wants to save features 603 if (args["features"].is_set()) //if the user wants to save features
682 features(args["features"].as_string()); 604 features(args["features"].as_string());