Blame view

main.cu 18.1 KB
db598823   David Mayerich   fixed GCC errors ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  #include <stdlib.h>
  #include <string>
  #include <fstream>
  #include <algorithm>
  
  //OpenGL includes
  #include <GL/glut.h>
  #include <GL/freeglut.h>
  
  //STIM includes
  #include <stim/visualization/gl_network.h>
  #include <stim/biomodels/network.h>
  #include <stim/visualization/gl_aaboundingbox.h>
  #include <stim/parser/arguments.h>
  #include <stim/visualization/camera.h>
  
f86a38d3   Jiaming Guo   add device choice...
17
18
19
20
21
  #ifdef __CUDACC__
  //CUDA includes
  #include <cuda.h>
  #endif
  
db598823   David Mayerich   fixed GCC errors ...
22
23
24
25
26
27
28
29
30
31
32
33
34
  //ANN includes
  //#include <ANN/ANN.h>
  
  //BOOST includes
  #include <boost/tuple/tuple.hpp>
  
  //visualization objects
  stim::gl_aaboundingbox<float> bb;			//axis-aligned bounding box object
  stim::camera cam;					//camera object
  
  unsigned num_nets = 0;
  stim::gl_network<float> GT;			//ground truth network
  stim::gl_network<float> T;			//test network
9627c6e6   Jiaming Guo   add splitting and...
35
36
37
38
39
40
41
  stim::gl_network<float> _GT;		//splitted GT
  stim::gl_network<float> _T;			//splitted T
  
  unsigned ind = 0;						//indicator of mapping
  
  std::vector<unsigned> _gt_t;								// store indices of nearest edge points in _T for _GT
  std::vector<unsigned> _t_gt;								// store indices of nearest edge points in _GT for _T
db598823   David Mayerich   fixed GCC errors ...
42
43
  
  //hard-coded parameters
f86a38d3   Jiaming Guo   add device choice...
44
45
46
  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
db598823   David Mayerich   fixed GCC errors ...
47
  
9627c6e6   Jiaming Guo   add splitting and...
48
49
50
51
  //mouse click
  bool LButtonDown = false;			// true when left button down
  bool RButtonDown = false;
  
db598823   David Mayerich   fixed GCC errors ...
52
53
54
55
  //mouse position tracking
  int mouse_x;
  int mouse_y;
  
9627c6e6   Jiaming Guo   add splitting and...
56
57
58
59
60
61
62
63
64
65
  bool compareMode = true;			// default mode is compare mode
  bool mappingMode = false;
  
  // random color map
  std::vector<float> colormap;
  
  // create display lists
  GLuint dlist1;
  GLuint dlist2;
  
db598823   David Mayerich   fixed GCC errors ...
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  //OpenGL objects
  GLuint cmap_tex = 0;				//texture name for the color map
  
  //sets an OpenGL viewport taking up the entire window
  void glut_render_single_projection(){
  
  	glMatrixMode(GL_PROJECTION);					//load the projection matrix for editing
  	glLoadIdentity();								//start with the identity matrix
  	int X = glutGet(GLUT_WINDOW_WIDTH);				//use the whole screen for rendering
  	int Y = glutGet(GLUT_WINDOW_HEIGHT);
  	glViewport(0, 0, X, Y);							//specify a viewport for the entire window
  	float aspect = (float)X / (float)Y;				//calculate the aspect ratio
  	gluPerspective(60, aspect, 0.1, 1000000);		//set up a perspective projection
  }
  
  //sets an OpenGL viewport taking up the left half of the window
  void glut_render_left_projection(){
  
  	glMatrixMode(GL_PROJECTION);					//load the projection matrix for editing
  	glLoadIdentity();								//start with the identity matrix
  	int X = glutGet(GLUT_WINDOW_WIDTH) / 2;			//only use half of the screen for the viewport
  	int Y = glutGet(GLUT_WINDOW_HEIGHT);
  	glViewport(0, 0, X, Y);							//specify the viewport on the left
  	float aspect = (float)X / (float)Y;				//calculate the aspect ratio
  	gluPerspective(60, aspect, 0.1, 1000000);		//set up a perspective projection
  }
  
  //sets an OpenGL viewport taking up the right half of the window
  void glut_render_right_projection(){
  
  	glMatrixMode(GL_PROJECTION);					//load the projection matrix for editing
  	glLoadIdentity();								//start with the identity matrix
  	int X = glutGet(GLUT_WINDOW_WIDTH) / 2;			//only use half of the screen for the viewport
  	int Y = glutGet(GLUT_WINDOW_HEIGHT);
  	glViewport(X, 0, X, Y);							//specify the viewport on the right
  	float aspect = (float)X / (float)Y;				//calculate the aspect ratio
  	gluPerspective(60, aspect, 0.1, 1000000);		//set up a perspective projection
  }
  
  void glut_render_modelview(){
  
  	glMatrixMode(GL_MODELVIEW);						//load the modelview matrix for editing
  	glLoadIdentity();								//start with the identity matrix
  	stim::vec3<float> eye = cam.getPosition();		//get the camera position (eye point)
  	stim::vec3<float> focus = cam.getLookAt();		//get the camera focal point
  	stim::vec3<float> up = cam.getUp();				//get the camera "up" orientation
  
  	gluLookAt(eye[0], eye[1], eye[2], focus[0], focus[1], focus[2], up[0], up[1], up[2]);	//set up the OpenGL camera
  }
  
9627c6e6   Jiaming Guo   add splitting and...
116
  
db598823   David Mayerich   fixed GCC errors ...
117
118
119
  //draws the network(s)
  void glut_render(void) {
  
9627c6e6   Jiaming Guo   add splitting and...
120
121
122
123
124
125
126
  	if(ind == 0){
  		if(num_nets == 1){											//if a single network is loaded
  			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.glCenterline(GT.nmags() - 1);						//render the GT network (the only one loaded)
  		}
db598823   David Mayerich   fixed GCC errors ...
127
  
9627c6e6   Jiaming Guo   add splitting and...
128
  		if(num_nets == 2){											//if two networks are loaded	
db598823   David Mayerich   fixed GCC errors ...
129
  
9627c6e6   Jiaming Guo   add splitting and...
130
131
132
  			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
db598823   David Mayerich   fixed GCC errors ...
133
  
9627c6e6   Jiaming Guo   add splitting and...
134
135
136
  			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
db598823   David Mayerich   fixed GCC errors ...
137
  
9627c6e6   Jiaming Guo   add splitting and...
138
  			GT.glCenterline(GT.nmags() - 1);						//render the GT network
db598823   David Mayerich   fixed GCC errors ...
139
  
9627c6e6   Jiaming Guo   add splitting and...
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
  			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(T.nmags() - 1);							//render the T network
  		}
  	}
  	else{
  		if(num_nets == 1){											//if a single network is loaded
  			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.glCenterline(_GT.nmags() - 1);						//render the GT network (the only one loaded)
  		}
  		if(num_nets == 2){											//if two networks are loaded
  			if(compareMode){
  				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(_GT.nmags() - 1);						//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(_T.nmags() - 1);							//render the T network
  
  			}
  			else{
  				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);
  
  				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);
  			}
  		}
db598823   David Mayerich   fixed GCC errors ...
181
182
  	}
  
9627c6e6   Jiaming Guo   add splitting and...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
  	std::ostringstream ss;
  	if(mappingMode)											// if it is in mapping mode
  		ss<< "Mapping Mode";
  	else									
  		ss<< "Compare Mode";								// default mode is compare mode
  
  	glDisable(GL_TEXTURE_1D);
  	glMatrixMode(GL_PROJECTION);										//Set up the 2d viewport for text printing
  	glPushMatrix();
  	glLoadIdentity();
  	int X = glutGet(GLUT_WINDOW_WIDTH);							
  	int Y = glutGet(GLUT_WINDOW_HEIGHT);
  	glViewport(0, 0, X/2, Y);
  	gluOrtho2D(0, X, 0, Y);
  	glColor3f(0.0, 1.0, 0.0);											// using green to show mode
  	
  	glMatrixMode(GL_MODELVIEW);
  	glPushMatrix();
  	glLoadIdentity();
  
  		glRasterPos2f(0, 5);											//print text in the bottom left corner
  		glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, (const unsigned char*) (ss.str().c_str()));	
  
  	glPopMatrix();
  	glMatrixMode(GL_PROJECTION);
  	glPopMatrix();
  
db598823   David Mayerich   fixed GCC errors ...
210
211
212
213
214
215
  	glutSwapBuffers();
  }
  
  // defines camera motion based on mouse dragging
  void glut_motion(int x, int y){
  	
9627c6e6   Jiaming Guo   add splitting and...
216
  	if(LButtonDown == true && RButtonDown == false){
db598823   David Mayerich   fixed GCC errors ...
217
218
219
220
221
222
223
224
225
226
  
  	float theta = orbit_factor * (mouse_x - x);		//determine the number of degrees along the x-axis to rotate
  	float phi = orbit_factor * (y - mouse_y);		//number of degrees along the y-axis to rotate
  
  	cam.OrbitFocus(theta, phi);						//rotate the camera around the focal point
  
  	mouse_x = x;									//update the mouse position
  	mouse_y = y;
  		
  	glutPostRedisplay();							//re-draw the visualization
9627c6e6   Jiaming Guo   add splitting and...
227
  	}
db598823   David Mayerich   fixed GCC errors ...
228
229
230
231
  }
  
  // sets the mouse position when clicked
  void glut_mouse(int button, int state, int x, int y){
9627c6e6   Jiaming Guo   add splitting and...
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
  	
  	if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN){
  		mouse_x = x;
  		mouse_y = y;
  		LButtonDown = true;
  	}
  	else if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN){
  		mouse_x = x;
  		mouse_y = y;
  		RButtonDown = true;
  	}
  	else if(button == GLUT_LEFT_BUTTON && state == GLUT_UP){
  		mouse_x = x;
  		mouse_y = y;
  		LButtonDown = false;
  	}
  	else if(button == GLUT_RIGHT_BUTTON && state == GLUT_UP){
  		mouse_x = x;
  		mouse_y = y;
  		RButtonDown = false;
  	}
  }
  
  void glut_keyboard(unsigned char key, int x, int y){
  	if(key == 'm')											// press m to change mode
  	{
  		if(compareMode && !mappingMode){					// if it is in compare mode
  			compareMode = false;
  			mappingMode = true;
  		}
  		else{												// if it is in mapping mode
  			compareMode = true;
  			mappingMode = false;
  		}
  	}
  	glutPostRedisplay();
db598823   David Mayerich   fixed GCC errors ...
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
  }
  
  #define BREWER_CTRL_PTS 11							//number of control points in the Brewer map
  void texture_initialize(){
  
  	//define the colormap
  	static float  brewer_map[BREWER_CTRL_PTS][3] = {			//generate a Brewer color map (blue to red)
  		{0.192157f, 0.211765f, 0.584314f},
  		{0.270588f, 0.458824f, 0.705882f},
  		{0.454902f, 0.678431f, 0.819608f},
  		{0.670588f, 0.85098f, 0.913725f},
  		{0.878431f, 0.952941f, 0.972549f},
  		{1.0f, 1.0f, 0.74902f},
  		{0.996078f, 0.878431f, 0.564706f},
  		{0.992157f, 0.682353f, 0.380392f},
  		{0.956863f, 0.427451f, 0.262745f},
  		{0.843137f, 0.188235f, 0.152941f},
  		{0.647059f, 0.0f, 0.14902f}
  	};
  
  	glGenTextures(1, &cmap_tex);								//generate a texture map name
  	glBindTexture(GL_TEXTURE_1D, cmap_tex);						//bind the texture map
  
  	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);		//enable linear interpolation
  	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);			//clamp the values at the minimum and maximum
  	glTexImage1D(GL_TEXTURE_1D, 0, 3, BREWER_CTRL_PTS, 0, GL_RGB, GL_FLOAT,	//upload the texture map to the GPU
  					brewer_map);
  }
  
  //Initialize the OpenGL (GLUT) window, including starting resolution, callbacks, texture maps, and camera
  void glut_initialize(){
  	
  	int myargc = 1;					//GLUT requires arguments, so create some bogus ones
  	char* myargv[1];
  	myargv [0]=strdup ("netmets");
  
  	glutInit(&myargc, myargv);									//pass bogus arguments to glutInit()
  	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
  
  	
  	// 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
  	glutMotionFunc(glut_motion);			//executed when the mouse is moved while a button is pressed
9627c6e6   Jiaming Guo   add splitting and...
316
317
  	if(ind == 1)							//only in mapping mode, keyboard will be used
  		glutKeyboardFunc(glut_keyboard);
db598823   David Mayerich   fixed GCC errors ...
318
  
9627c6e6   Jiaming Guo   add splitting and...
319
  	texture_initialize();									//set up texture mapping (create texture maps, enable features)
db598823   David Mayerich   fixed GCC errors ...
320
321
322
323
324
325
  
  	stim::vec3<float> c = bb.center();		//get the center of the network bounding box
  
  	//place the camera along the z-axis at a distance determined by the network size along x and y
  	cam.setPosition(c + stim::vec<float>(0, 0, camera_factor * std::max(bb.size()[0], bb.size()[1])));
  	cam.LookAt(c[0], c[1], c[2]);						//look at the center of the network
db598823   David Mayerich   fixed GCC errors ...
326
327
  }
  
f86a38d3   Jiaming Guo   add device choice...
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
  #ifdef __CUDACC__
  void setdevice(int &device){
  	int count;
  	cudaGetDeviceCount(&count);				// numbers of device that are available
  	if(count < device + 1){
  	std::cout<<"No such device available, please set another device"<<std::endl;
  	exit(1);
  	}
  }
  #else
  void setdevice(int &device){
  	device = -1;
  }
  #endif
  
db598823   David Mayerich   fixed GCC errors ...
343
  //compare both networks and fill the networks with error information
f86a38d3   Jiaming Guo   add device choice...
344
  void compare(float sigma, int device){
db598823   David Mayerich   fixed GCC errors ...
345
  
f86a38d3   Jiaming Guo   add device choice...
346
347
  	GT = GT.compare(T, sigma, device);						//compare the ground truth to the test case - store errors in GT
      T = T.compare(GT, sigma, device);						//compare the test case to the ground truth - store errors in T
db598823   David Mayerich   fixed GCC errors ...
348
349
  
  	//calculate the metrics
35c77a3e   David Mayerich   updated netmets t...
350
351
  	float FPR = GT.average(0);						//calculate the metrics
  	float FNR = T.average(0);
db598823   David Mayerich   fixed GCC errors ...
352
353
354
355
356
  	
  	std::cout << "FNR: " << FPR << std::endl;		//print false alarms and misses
  	std::cout << "FPR: " << FNR << std::endl;
  }
  
9627c6e6   Jiaming Guo   add splitting and...
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
  void map(float sigma, int device){
  
  	_GT.split(GT, T, sigma, device);
  	_T.split(T, GT, sigma, device);
  
  	_GT.mapping(_T, _gt_t, device);
  	_T.mapping(_GT, _t_gt, device);
  
  	size_t num = _gt_t.size();							// also create random color for unmapping edge, but won't be used though
  	colormap.resize(3*num);
  	for(int i = 0; i < 3*num; i++)
  		colormap[i] = rand()/(float)RAND_MAX;
  	
  	//calculate the metrics
  	float FPR = _GT.average(0);						//calculate the metrics
  	float FNR = _T.average(0);
  	
  	std::cout << "FNR: " << FPR << std::endl;		//print false alarms and misses
  	std::cout << "FPR: " << FNR << std::endl;
  }
  
db598823   David Mayerich   fixed GCC errors ...
378
379
380
  // writes features of the networks i.e average segment length, tortuosity, branching index, contraction, fractal dimension, number of end and branch points to a csv file
  // Pranathi wrote this - saves network features to a CSV file
  void features(std::string filename){
f86a38d3   Jiaming Guo   add device choice...
381
  		double avgL_t, avgL_gt, avgT_t, avgT_gt, avgB_t, avgB_gt, avgC_t, avgC_gt, avgFD_t, avgFD_gt;
db598823   David Mayerich   fixed GCC errors ...
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
  		unsigned int e_t, e_gt, b_gt, b_t;
  		avgL_gt = GT.Lengths();
  		avgT_gt = GT.Tortuosities();
  		avgL_t = T.Lengths();
  		avgT_t = T.Tortuosities();
  		avgB_gt = GT.BranchingIndex();
  		avgB_t = T.BranchingIndex();
  		avgC_gt = GT.Contractions();
  		avgFD_gt = GT.FractalDimensions();
  		avgC_t = T.Contractions();
  		avgFD_t = T.FractalDimensions();
  		e_gt = GT.EndP();
  		e_t = T.EndP();
  		b_gt = GT.BranchP();
  		b_t = T.BranchP();
  		std::ofstream myfile;
  		myfile.open (filename.c_str());
  		myfile << "Length, Tortuosity, Contraction, Fractal Dimension, Branch Points, End points, Branching Index, \n";
  		myfile << avgL_gt << "," << avgT_gt << "," << avgC_gt << "," << avgFD_gt << "," << b_gt << "," << e_gt << "," << avgB_gt <<std::endl;
  		myfile << avgL_t << "," << avgT_t << "," << avgC_t << "," << avgFD_t << "," << b_t << "," << e_t << "," << avgB_t <<std::endl;
  		myfile.close();
  }
  
  // Output an advertisement for the lab, authors, and usage information
  void advertise(){
  	std::cout<<std::endl<<std::endl;
  	std::cout<<"========================================================================="<<std::endl;
  	std::cout<<"Thank you for using the NetMets network comparison tool!"<<std::endl;
  	std::cout<<"Scalable Tissue Imaging and Modeling (STIM) Lab, University of Houston"<<std::endl;
  	std::cout<<"Developers: Pranathi Vemuri, David Mayerich"<<std::endl;
9627c6e6   Jiaming Guo   add splitting and...
412
  	std::cout<<"Source: https://git.stim.ee.uh.edu/segmentation/netmets" <<std::endl;
db598823   David Mayerich   fixed GCC errors ...
413
414
  	std::cout<<"========================================================================="<<std::endl<<std::endl;
  
f86a38d3   Jiaming Guo   add device choice...
415
416
417
418
419
420
  	std::cout<<"usage: netmets file1 file2 --sigma 3"<<std::endl;
  	std::cout<<"            compare two files with a tolerance of 3 (units defined by the network)"<<std::endl<<std::endl;
  	std::cout<<"       netmets file1 --gui"<<std::endl;
  	std::cout<<"            load a file and display it using OpenGL"<<std::endl<<std::endl;
  	std::cout<<"       netmets file1 file2 --device 0"<<std::endl;
  	std::cout<<"            compare two files using device 0 (if there isn't a gpu, use cpu)"<<std::endl<<std::endl;
db598823   David Mayerich   fixed GCC errors ...
421
422
423
424
425
426
427
428
  }
  
  int main(int argc, char* argv[])
  {
  	stim::arglist args;						//create an instance of arglist
  
  	//add arguments
  	args.add("help", "prints this help");
f86a38d3   Jiaming Guo   add device choice...
429
  	args.add("sigma", "force a sigma value to specify the tolerance of the network comparison", "3");
db598823   David Mayerich   fixed GCC errors ...
430
  	args.add("gui", "display the network or network comparison using OpenGL");
f86a38d3   Jiaming Guo   add device choice...
431
  	args.add("device", "choose specific device to run", "0");
db598823   David Mayerich   fixed GCC errors ...
432
  	args.add("features", "save features to a CSV file, specify file name");
9627c6e6   Jiaming Guo   add splitting and...
433
  	args.add("mapping", "mapping input according to similarity");
db598823   David Mayerich   fixed GCC errors ...
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
  
  	args.parse(argc, argv);					//parse the user arguments
  
  	if(args["help"].is_set() || args.nargs() == 0){			//test for help
  		advertise();										//output the advertisement
  		std::cout<<args.str();								//output arguments
  		exit(1);											//exit
  	}
  	
  	if(args.nargs() >= 1){					//if at least one network file is specified
  		num_nets = 1;						//set the number of networks to one
  		GT.load_obj(args.arg(0));			//load the specified file as the ground truth
  		/*GT.to_txt("Graph.txt");*/
  	}
  	
  	if(args.nargs() == 2){			//if two files are specified, they will be displayed in neighboring viewports and compared
f86a38d3   Jiaming Guo   add device choice...
450
  		int device = args["device"].as_int();				//get the device value from the user
db598823   David Mayerich   fixed GCC errors ...
451
452
453
454
455
456
457
  		num_nets = 2;										//set the number of networks to two
  		float 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());
  		GT = GT.resample(resample_rate * sigma);			//resample both networks based on the sigma value
  		T = T.resample(resample_rate * sigma);
9627c6e6   Jiaming Guo   add splitting and...
458
459
460
461
462
  		if(args["mapping"].is_set()){
  			map(sigma, device);
  		}
  		else
  			compare(sigma, device);										//run the comparison algorithm
db598823   David Mayerich   fixed GCC errors ...
463
464
465
  	}
  
  	//if a GUI is requested, display the network using OpenGL
9627c6e6   Jiaming Guo   add splitting and...
466
467
468
469
470
471
472
473
474
475
476
477
478
  	if(args["gui"].is_set()){
  		if(args["mapping"].is_set()){
  			ind = 1;
  			bb = _GT.boundingbox();					//generate a bounding volume		
  			glut_initialize();						//create the GLUT window and set callback functions		
  			glutMainLoop();							// enter GLUT event processing cycle
  		}
  		else{
  			bb = GT.boundingbox();					//generate a bounding volume		
  			glut_initialize();						//create the GLUT window and set callback functions		
  			glutMainLoop();							// enter GLUT event processing cycle
  		}
  	}
db598823   David Mayerich   fixed GCC errors ...
479
  }