1 // This file is part of the Mussa source distribution.
2 // http://mussa.caltech.edu/
3 // Contact author: Tristan De Buysscher, tristan@caltech.edu
5 // This program and all associated source code files are Copyright (C) 2005
6 // the California Institute of Technology, Pasadena, CA, 91125 USA. It is
7 // under the GNU Public License; please see the included LICENSE.txt
8 // file for more information, or contact Tristan directly.
11 #include "ConnWindow.hh"
16 parse_args(int argc, char **argv, string *a_file_path, int *window,
17 int *threshold, char *ana_mode, float *ent_thres);
20 int main(int argc, char **argv)
25 int window, threshold;
27 char run_mode, ana_mode;
35 // yeah, its horrible to be passing these by reference, but I just don't see
36 // any other way without making parse_args part of MussaClass, which just
37 // seems wrong (args are after all, an io type thing, and the gui only mode
38 // will have it own way as well...
39 run_mode = parse_args(argc, argv, &a_file_path, &window, &threshold,
40 &ana_mode, &ent_thres);
42 cout << "mussa: run mode = " << run_mode;
43 cout << "\tfile_path = "<< a_file_path << endl;
44 cout << "mussa: ent_thres = " << ent_thres << endl;
46 // if no error from parse args (run_mode = 'e', ie error), run in proper mode
49 if ((run_mode == 'f') || (run_mode == 'n'))
51 err_msg = an_analysis.load_mupa_file(a_file_path);
52 err_msg = an_analysis.analyze(window, threshold, ana_mode, ent_thres);
53 //an_overlord.do_analysis();
57 err_msg = an_analysis.load(a_file_path);
58 //an_overlord.get_analysis();
60 // no longer needed, but still semi-useful reality check...
63 cout << "GTV - All Gui, All the Time\n";
68 if ((run_mode == 'f') || (run_mode == 'v') || (run_mode == 'g'))
70 //an_overlord.spawnConnView(1000,500);
71 ConnWindow *a_conn_win = new ConnWindow(x_max, y_max, "Mussa");
73 // we have an analysis already if in these 2 modes
74 if ((run_mode == 'f') || (run_mode == 'v'))
75 a_conn_win->add_ana(&an_analysis);
81 cout << err_msg << endl;
86 // minimal arg reading function, not very robust to errors
88 parse_args(int argc, char **argv, string *a_file_path, int *window,
89 int *threshold, char *ana_mode, float *ent_thres)
95 // initialize these to 0 as flag if they are not changed
99 run_mode = 'e'; //error default if no run mode set implicitly or explicitly
100 *ana_mode = 't'; // default to transitivie analyses mode
104 // no args means gui only mode
107 // 1 arg means its a mupa file and run in full mode
122 // see what alternate mode the user wants to run in
127 if ( (an_arg == "v") || (an_arg == "n") ) //only 2 valid modes so far
128 run_mode = an_arg[0];
131 cout << "Error: \'" << an_arg;
132 cout << "\' is not a valid analysis mode for -a argument" << endl;
135 *a_file_path = * ++argv;
138 // alternate analyses modes
139 else if (an_arg == "-a")
143 // t = transitive, r = radial, e = entropy
144 if ( (an_arg == "t") || (an_arg == "r") || (an_arg == "e") )
145 *ana_mode = an_arg[0];
148 cout << "Error: \'" << an_arg;
149 cout << "\' is not a valid run mode for -m argument" << endl;
154 else if (an_arg == "-w") // alternate window size arg
156 *window = atoi(* ++argv);
159 else if (an_arg == "-t") // alternate threshold arg
161 *threshold = atoi(* ++argv);
164 else if (an_arg == "-et") // alternate entropy threshold arg
166 *ent_thres = atof(* ++argv);
173 *a_file_path = an_arg;
179 //cout << "Error, unknown arg: \'" << an_arg << "\'" << endl;
180 cout << "Error, too many filenames: \'" << an_arg << "\'" << endl;