#include #include #include #include //OpenGL includes #include //STIM includes #include #include #include #include //ANN includes #include //BOOST includes #include stim::gl_aabb bb; stim::camera cam; stim::gl_network GT; stim::gl_network T; //hard-coded parameters float resample_rate = 0.5; //mouse position tracking int mouse_x; int mouse_y; void glut_render(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); stim::vec eye = cam.getPosition(); stim::vec focus = cam.getLookAt(); stim::vec up = cam.getUp(); gluLookAt(eye[0], eye[1], eye[2], focus[0], focus[1], focus[2], up[0], up[1], up[2]); // render the bounding box glColor3f(0.0, 0.0, 1.0); glBegin(GL_LINE_LOOP); bb.glPointsCW(); glEnd(); //render the GT network (red) glColor3f(1.0, 0.0, 0.0); GT.glCenterline(); //render the T network (green) glColor3f(0.0, 1.0, 0.0); T.glCenterline(); glutSwapBuffers(); } // defines camera motion based on mouse dragging void glut_motion(int x, int y){ float factor = 0.01; float theta = factor * (mouse_x - x); float phi = factor * (y - mouse_y); cam.OrbitFocus(theta, phi); mouse_x = x; mouse_y = y; glutPostRedisplay(); } // sets the mouse position when clicked void glut_mouse(int button, int state, int x, int y){ mouse_x = x; mouse_y = y; } // re-calculates the projection matrix if the window is reshaped void glut_reshape(int x, int y){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, x, y); float aspect = (float)x / (float)y; gluPerspective(60, aspect, 0.1, 1000000); } void advertise(){ //output advertisement std::cout< cGT = GT.compare(T, sigma); stim::network cT = T.compare(GT, sigma); //calculate the metrics float FPR = cGT.average(1); float FNR = cT.average(1); // print false alarms and misses std::cout << "FNR: " << FPR << std::endl; std::cout << "FPR: " << FNR << std::endl; } void glut_initialize(){ float factor = 1.2; // init GLUT and create Window int myargc = 1; char* myargv[1]; myargv [0]=strdup ("netmets"); glutInit(&myargc, myargv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100,100); glutInitWindowSize(320,320); glutCreateWindow("Lighthouse3D- GLUT Tutorial"); // register callbacks glutDisplayFunc(glut_render); glutMouseFunc(glut_mouse); glutMotionFunc(glut_motion); glutReshapeFunc(glut_reshape); //set up the camera stim::vec c = bb.center(); //place the camera along the z-axis at a distance determined by the network size along x and y cam.setPosition(c + stim::vec(0, 0, factor * std::max(bb.size()[0], bb.size()[1]))); cam.LookAt(c[0], c[1], c[2]); //look at the center } void display(){ //generate a bounding volume bb = GT.boundingbox(); std::cout<= 1){ GT.load_obj(args.arg(0)); } //if two files are provided, compare them if(args.nargs() == 2){ float sigma = args["sigma"].as_float(); //get the sigma value from the user T.load_obj(args.arg(1)); //load the second (test) network GT = GT.resample(resample_rate * sigma); //resample both networks based on the sigma value T = T.resample(resample_rate * sigma); compare(sigma); //run the comparison algorithm } //if a GUI is requested, display the network using OpenGL if(args["gui"].is_set()) display(); }