diff --git a/CMakeLists.txt b/CMakeLists.txt index d2bea50..c959f24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,3 +84,4 @@ configure_file(data/04_Ta.obj ${CMAKE_CURRENT_BINARY_DIR}/04_Ta.obj @ONLY) configure_file(data/04_Tb.obj ${CMAKE_CURRENT_BINARY_DIR}/04_Tb.obj @ONLY) configure_file(data/1.swc ${CMAKE_CURRENT_BINARY_DIR}/1.swc @ONLY) configure_file(data/2.swc ${CMAKE_CURRENT_BINARY_DIR}/2.swc @ONLY) +configure_file(data/00_GT.swc ${CMAKE_CURRENT_BINARY_DIR}/00_GT.swc @ONLY) diff --git a/main.cu b/main.cu index 9f4bbd3..5204a56 100644 --- a/main.cu +++ b/main.cu @@ -1,8 +1,4 @@ -#ifndef GL_MULTISAMPLE -#define GL_MULTISAMPLE 0x809D -#endif - -#include +#include #include #include #include @@ -51,7 +47,7 @@ std::vector _t_gt; // store indices of nearest edge points in _ float resample_rate = 0.5f; //sample rate for the network (fraction of sigma used as the maximum sample rate) float camera_factor = 1.2f; //start point of the camera as a function of X and Y size float orbit_factor = 0.01f; //degrees per pixel used to orbit the camera -float zoom_factor = 5.0; +float zoom_factor = 10.0; //mouse click bool LButtonDown = false; // true when left button down @@ -78,6 +74,8 @@ GLuint dlist2; //OpenGL objects GLuint cmap_tex = 0; //texture name for the color map +float sigma = 3; //default sigma + //sets an OpenGL viewport taking up the entire window void glut_render_single_projection(){ @@ -130,17 +128,40 @@ void glut_render(void) { //no mapping, just comparing if (ind == 0) { - //-----working with obj files----- - if (swc_ind == 0) { - if (num_nets == 1) { //if a single network is loaded - glEnable(GL_DEPTH_TEST); //enable depth - glut_render_single_projection(); //fill the entire viewport - glut_render_modelview(); //set up the modelview matrix with camera details - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen - GT.glCenterline0(); //render the GT network (the only one loaded) - } + if (num_nets == 1) { //if a single network is loaded + glEnable(GL_DEPTH_TEST); //enable depth + glut_render_single_projection(); //fill the entire viewport + glut_render_modelview(); //set up the modelview matrix with camera details + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen + GT.glCenterline0(); //render the GT network (the only one loaded) + } + + if (num_nets == 2) { //if two networks are loaded + glEnable(GL_DEPTH_TEST); //enable depth + glut_render_left_projection(); //set up a projection for the left half of the window + glut_render_modelview(); //set up the modelview matrix using camera details + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen + + glEnable(GL_TEXTURE_1D); //enable texture mapping + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color + glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map + + GT.glCylinder(sigma); //render the GT network + + glut_render_right_projection(); //set up a projection for the right half of the window + glut_render_modelview(); //set up the modelview matrix using camera details + T.glCylinder(sigma); //render the T network + } + } - if (num_nets == 2) { //if two networks are loaded + //do comparing and mapping + else { + if (num_nets == 1) { //if a single network is loaded + std::cout << "You should have at least two networks to do mapping." << std::endl; //exit program because there isn't enough network + exit(1); + } + if (num_nets == 2) { //if two networks are loaded + if (compareMode) { glEnable(GL_DEPTH_TEST); //enable depth glut_render_left_projection(); //set up a projection for the left half of the window glut_render_modelview(); //set up the modelview matrix using camera details @@ -150,124 +171,26 @@ void glut_render(void) { glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map - GT.glCylinder(); //render the GT network + _GT.glCylinder(sigma); //render the GT network glut_render_right_projection(); //set up a projection for the right half of the window glut_render_modelview(); //set up the modelview matrix using camera details - T.glCylinder(); //render the T network - } - } - //-----working with swc files----- - else { - if (num_nets == 1) { //if a single network is loaded - glEnable(GL_DEPTH_TEST); //enable depth - glut_render_single_projection(); //fill the entire viewport - glut_render_modelview(); //set up the modelview matrix with camera details - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen - GT.glCenterline0_swc(); //render the GT network (the only one loaded) - } + _T.glCylinder(sigma); //render the T network - if (num_nets == 2) { //if two networks are loaded + } + else { glEnable(GL_DEPTH_TEST); //enable depth glut_render_left_projection(); //set up a projection for the left half of the window glut_render_modelview(); //set up the modelview matrix using camera details glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen - glEnable(GL_TEXTURE_1D); //enable texture mapping - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color - glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map - - GT.glCenterline(); //render the GT network + //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap); + _GT.glRandColorCylinder1(dlist1, _gt_t, colormap, sigma); glut_render_right_projection(); //set up a projection for the right half of the window glut_render_modelview(); //set up the modelview matrix using camera details - T.glCenterline(); //render the T network - } - } - } - - //do comparing and mapping - else { - //-----working with obj files----- - if (swc_ind == 0) { - if (num_nets == 1) { //if a single network is loaded - std::cout << "You should have at least two networks to do mapping." << std::endl; //exit program because there isn't enough network - exit(1); - } - if (num_nets == 2) { //if two networks are loaded - if (compareMode) { - glEnable(GL_DEPTH_TEST); //enable depth - glut_render_left_projection(); //set up a projection for the left half of the window - glut_render_modelview(); //set up the modelview matrix using camera details - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen - - glEnable(GL_TEXTURE_1D); //enable texture mapping - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color - glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map - - _GT.glCylinder(); //render the GT network - - glut_render_right_projection(); //set up a projection for the right half of the window - glut_render_modelview(); //set up the modelview matrix using camera details - _T.glCylinder(); //render the T network - - } - else { - glEnable(GL_DEPTH_TEST); //enable depth - glut_render_left_projection(); //set up a projection for the left half of the window - glut_render_modelview(); //set up the modelview matrix using camera details - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen - - //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap); - _GT.glRandColorCylinder1(dlist1, _gt_t, colormap); - - glut_render_right_projection(); //set up a projection for the right half of the window - glut_render_modelview(); //set up the modelview matrix using camera details - //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap); - _T.glRandColorCylinder2(dlist2, _t_gt, colormap); - } - } - } - //-----working with swc files----- - else { - if (num_nets == 1) { //if a single network is loaded - std::cout << "You should have at least two networks to do mapping." << std::endl; //exit program because there isn't enough network - exit(1); - } - if (num_nets == 2) { //if two networks are loaded - //in compare mode - if (compareMode) { - glEnable(GL_DEPTH_TEST); //enable depth - glut_render_left_projection(); //set up a projection for the left half of the window - glut_render_modelview(); //set up the modelview matrix using camera details - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen - - glEnable(GL_TEXTURE_1D); //enable texture mapping - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); //texture map will be used as the network color - glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map - - _GT.glCenterline(); //render the GT network - - glut_render_right_projection(); //set up a projection for the right half of the window - glut_render_modelview(); //set up the modelview matrix using camera details - _T.glCenterline(); //render the T network - - } - //in mapping mode - else { - glEnable(GL_DEPTH_TEST); //enable depth - glut_render_left_projection(); //set up a projection for the left half of the window - glut_render_modelview(); //set up the modelview matrix using camera details - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen - - //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap); - _GT.glRandColorCylinder1_swc(dlist1, _gt_t, colormap); - - glut_render_right_projection(); //set up a projection for the right half of the window - glut_render_modelview(); //set up the modelview matrix using camera details - //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap); - _T.glRandColorCylinder2_swc(dlist2, _t_gt, colormap); - } + //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap); + _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma); } } } @@ -399,9 +322,9 @@ void glut_wheel(int wheel, int direction, int x, int y) { float delta; if (direction > 0) // if it is button 3(up) - delta = -zoom_factor; - else // if it is button 4(down) delta = zoom_factor; + else // if it is button 4(down) + delta = -zoom_factor; cam.Push(delta); glutPostRedisplay(); @@ -463,12 +386,11 @@ void glut_initialize(){ glutInit(&myargc, myargv); //pass bogus arguments to glutInit() glutSetOption(GLUT_MULTISAMPLE, 8); - glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_MULTISAMPLE); //generate a color buffer, depth buffer, and enable double buffering + glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); //generate a color buffer, depth buffer, and enable double buffering glutInitWindowPosition(100,100); //set the initial window position glutInitWindowSize(320, 320); //set the initial window size glutCreateWindow("NetMets - STIM Lab, UH"); //set the dialog box title - glEnable(GL_MULTISAMPLE); // register callback functions glutDisplayFunc(glut_render); //function executed for rendering - renders networks glutMouseFunc(glut_mouse); //executed on a mouse click - sets starting mouse positions for rotations @@ -653,12 +575,12 @@ int main(int argc, char* argv[]) } } - if (args.nargs() == 2) { //if two files are specified, they will be displayed in neighboring viewports and compared - if (1 == swc_ind) { //loading swc files + if (args.nargs() == 2) { //if two files are specified, they will be displayed in neighboring viewports and compared + if (1 == swc_ind) { //loading swc files int device = args["device"].as_int(); //get the device value from the user num_nets = 2; //set the number of networks to two //does it need to be resampled?? - float sigma = args["sigma"].as_float(); //get the sigma value from the user + sigma = args["sigma"].as_float(); //get the sigma value from the user T.load_swc(args.arg(1)); //load the second (test) network if (args["features"].is_set()) //if the user wants to save features features(args["features"].as_string()); @@ -676,7 +598,7 @@ int main(int argc, char* argv[]) else { int device = args["device"].as_int(); //get the device value from the user num_nets = 2; //set the number of networks to two - float sigma = args["sigma"].as_float(); //get the sigma value from the user + sigma = args["sigma"].as_float(); //get the sigma value from the user T.load_obj(args.arg(1)); //load the second (test) network if (args["features"].is_set()) //if the user wants to save features features(args["features"].as_string()); -- libgit2 0.21.4