#include <Batch.h>
Collaboration diagram for Batch:

Public Types | |
| enum | e_TESTMODE { PCA, STABILITY, ALLTEST, ACCURACY } |
Public Member Functions | |
| Batch () | |
| Batch (bool debug) | |
| ~Batch () | |
| void | Init () |
Private Member Functions | |
| void | import () |
| void | importModel () |
| void | importDir () |
| void | importData () |
| void | analyze () |
| void | analyzeModel () |
| void | getModel () |
| void | getRandomModels () |
| void | Export () |
| void | ExportModel () |
| void | ExportModels () |
| void | Test () |
| void | TestSystem (e_TESTMODE mode, Analyzer::e_PCAMode method) |
| void | TestSystem (e_TESTMODE mode) |
| void | TestAnalyzer (Analyzer::e_PCAMode mode, int size) |
| void | renderTitle (string title, bool sub=false) |
| void | renderOptions (string title, vector< string > options, bool back=false) |
| int | handleInput () |
Private Attributes | |
| bool | m_mainRun |
| bool | m_subRun |
| string | m_mainErr |
| string | m_subErr |
| vector< ExampleModel * > | m_inputModels |
| vector< ReferenceModel > | m_refModels |
| vector< ReferenceModel > | m_generatedModels |
| Analyzer | pca |
|
|
Definition at line 31 of file Batch.h. 00031 { PCA, STABILITY, ALLTEST, ACCURACY };
|
|
|
Definition at line 21 of file Batch.cpp. 00021 {
00022 Batch(false);
00023 }
|
|
|
Definition at line 25 of file Batch.cpp. References log::clear(), m_mainErr, m_subErr, log::setDebug(), and log::write(). 00025 {
00026 m_mainErr = "";
00027 m_subErr = "";
00028 log::clear();
00029 log::setDebug(debug);
00030 log::write("Batch started");
00031 }
|
Here is the call graph for this function:

|
|
Definition at line 64 of file Batch.h. 00064 {};
|
|
|
Definition at line 189 of file Batch.cpp. References analyzeModel(), getModel(), getRandomModels(), handleInput(), m_inputModels, m_subErr, m_subRun, and renderOptions(). Referenced by Init(). 00189 {
00190 m_subRun=true;
00191 vector<string> options;
00192 char tmp[100];
00193 #ifndef __WINDOWS__
00194 sprintf(tmp,"Analyze %d models",m_inputModels.size());
00195 #else
00196 sprintf_s(tmp,"Analyze %d models",m_inputModels.size());
00197 #endif
00198 string s = string(tmp);
00199 options.push_back(s);
00200 options.push_back("Get a Model");
00201 options.push_back("Get random Model");
00202
00203 while(m_subRun) {
00204 renderOptions("Analyze models", options, true);
00205 int o = handleInput();
00206 switch(o) {
00207 case 1: analyzeModel();break;
00208 case 2: getModel();break;
00209 case 3: getRandomModels();break;
00210 default: m_subErr = "Not a valid option!";break;
00211 }
00212 }
00213 }
|
Here is the call graph for this function:

|
|
Definition at line 215 of file Batch.cpp. References model::Analyzer::adjust(), model::Analyzer::computeEnergy(), model::Analyzer::covariance(), model::Analyzer::findComponents(), m_inputModels, m_subErr, model::Analyzer::mean(), model::Analyzer::mergeData(), pca, model::Analyzer::selectComponents(), model::Model::setFaces(), model::Model::setVertexs(), model::Analyzer::transformation(), and log::write(). Referenced by analyze(). 00215 {
00216 //pca = Analyzer();
00217 ReferenceModel refModel = ReferenceModel();
00218 refModel.setVertexs(m_inputModels[0]->getVertexs());
00219 refModel.setFaces(m_inputModels[0]->getFaces());
00220 log::write("*************Starting to Analyze*************");
00221 printf("start\n");
00222 pca.mergeData(refModel,m_inputModels);
00223 printf("mergeData done\n");
00224 log::write("Calculating mean");
00225 pca.mean();
00226 printf("mean done\n");
00227 log::write("Adjusting data");
00228 pca.adjust();
00229 printf("adjust done\n");
00230 log::write("Finding Covariance");
00231 pca.covariance();
00232 printf("covariance done\n");
00233 log::write("Begin EigenVector calculations");
00234 log::write("Timer Started");
00235 clock_t begin = clock();
00236 pca.findComponents();
00237 clock_t end = clock();
00238 log::write("Timer Stopped");
00239 log::write("Time elapsed in seconds:", difftime(end, begin));
00240 log::write("Time elapsed in clock cycles:",(int)(end-begin));
00241 log::write("End EigenVector calculations");
00242 printf("finding done\n");
00243 pca.computeEnergy();
00244 printf("compute energy done\n");
00245 pca.selectComponents();
00246 printf("select components done\n");
00247 pca.transformation();
00248 m_subErr = "Models analyzed";
00249 log::write("*************ANALYSIS ENDED*************");
00250 }
|
Here is the call graph for this function:

|
|
Definition at line 278 of file Batch.cpp. References ExportModel(), ExportModels(), handleInput(), m_generatedModels, m_inputModels, m_refModels, m_subErr, m_subRun, and renderOptions(). Referenced by Init(). 00278 {
00279 m_subRun=true;
00280 vector<string> options;
00281 options.push_back("Export a model");
00282 char* optname = "Export all models";
00283 int count = m_inputModels.size() + m_refModels.size() + m_generatedModels.size();
00284 if(count>0) {
00285 char tmp[100];
00286 #ifndef __WINDOWS__
00287 sprintf(tmp,"%s (%d)",optname,count);
00288 #else
00289 sprintf_s(tmp,"%s (%d)",optname,count);
00290 #endif
00291 optname = tmp;
00292 }
00293 string s = string(optname);
00294 options.push_back(s);
00295
00296 while(m_subRun) {
00297 renderOptions("Export models", options, true);
00298 int o = handleInput();
00299 switch(o) {
00300 case 1: ExportModel();break;
00301 case 2: ExportModels(); break;
00302 default: m_subErr = "Not a valid option!";break;
00303 }
00304 }
00305 }
|
Here is the call graph for this function:

|
|
Definition at line 307 of file Batch.cpp. Referenced by Export(). 00307 {
00308
00309 }
|
|
|
Definition at line 311 of file Batch.cpp. References functions::Exporter::exportModel(), m_generatedModels, m_inputModels, m_refModels, m_subErr, and log::write(). Referenced by Export(). 00311 {
00312 log::write("Batch::ExportModels");
00313 functions::Exporter ex = functions::Exporter();
00314 char tmp[100];
00315 log::write("Export Inputmodels");
00316 for(int i=0; i<m_inputModels.size(); i++) {
00317 #ifndef __WINDOWS__
00318 sprintf(tmp,"inputModel%d.x3d",i);
00319 #else
00320 sprintf_s(tmp,"inputModel%d.x3d",i);
00321 #endif
00322 ex.exportModel(m_inputModels[i],tmp);
00323 }
00324 log::write("Export refModels");
00325 for(int i=0; i<m_refModels.size(); i++) {
00326 #ifndef __WINDOWS__
00327 sprintf(tmp,"referenceModel%d.x3d",i);
00328 #else
00329 sprintf_s(tmp,"referenceModel%d.x3d",i);
00330 #endif
00331
00332 ex.exportModel(&m_refModels[i],tmp);
00333 }
00334 log::write("Export generatedModels");
00335 for(int i=0; i<m_generatedModels.size(); i++) {
00336 #ifndef __WINDOWS__
00337 sprintf(tmp,"generatedModel%d.x3d",i);
00338 #else
00339 sprintf_s(tmp,"generatedModel%d.x3d",i);
00340 #endif
00341 ex.exportModel(&m_generatedModels[i],tmp);
00342 }
00343 m_subErr = "Models exported";
00344 }
|
Here is the call graph for this function:

|
|
Definition at line 252 of file Batch.cpp. References renderTitle(). Referenced by analyze(). 00252 {
00253 renderTitle("Get a model");
00254
00255 }
|
Here is the call graph for this function:

|
|
Definition at line 257 of file Batch.cpp. References model::Analyzer::getInputDimension(), model::Analyzer::getModel(), m_generatedModels, pca, renderTitle(), and log::write(). Referenced by analyze(). 00257 {
00258 renderTitle("Generates 10 random models",true);
00259 int dim = pca.getInputDimension();
00260 Matrix input(1,dim);
00261 int lowest=-10, highest=10;
00262 int range=(highest-lowest)+1;
00263 for(int i=0; i<10;i++) {
00264 if(dim=1) {
00265 input(1,1) = i-5;
00266 } else {
00267 for(int n=0;n<dim;n++) {
00268 input(1,n+1) = lowest+int(range*rand()/(RAND_MAX + 1.0));
00269 }
00270 }
00271 log::write("Batch-Input",input);
00272 ReferenceModel refModel = pca.getModel(input);
00273 log::write("ReferenceModel",refModel);
00274 m_generatedModels.push_back(refModel);
00275 }
00276 }
|
Here is the call graph for this function:

|
|
Definition at line 476 of file Batch.cpp. References m_mainRun, and m_subRun. Referenced by analyze(), Export(), import(), Init(), and Test(). 00476 {
00477 //cout << "handel input\n";
00478 int opt;
00479 char temp[100];
00480 cin.getline(temp, 100);
00481
00482 opt=atoi(temp);
00483 if(opt==9) {
00484 m_mainRun = false;
00485 m_subRun = false;
00486 } else if(opt == 8) {
00487 m_subRun = false;
00488 }
00489 //cout << opt << "\n";
00490 return opt;
00491 }
|
|
|
Definition at line 81 of file Batch.cpp. References handleInput(), importData(), importDir(), importModel(), m_subErr, m_subRun, and renderOptions(). 00081 {
00082 m_subRun=true;
00083 vector<string> options;
00084 options.push_back("Import a model");
00085 options.push_back("Import models");
00086 options.push_back("Import data models");
00087
00088 while(m_subRun) {
00089 renderOptions("Import models", options, true);
00090 int o = handleInput();
00091 switch(o) {
00092 case 1: importModel();break;
00093 case 2: importDir(); break;
00094 case 3: importData(); break;
00095 default: m_subErr = "Not a valid option!";break;
00096 }
00097 }
00098 }
|
Here is the call graph for this function:

|
|
Definition at line 143 of file Batch.cpp. References functions::Importer::importModel(), m_inputModels, m_subErr, and renderTitle(). Referenced by import(). 00143 {
00144 functions::Importer im = functions::Importer();
00145 string path = "";
00146 string name = "";
00147 string ending = "";
00148 int rangeStart = 0;
00149 int rangeEnd = 1;
00150 char temp[100];
00151 bool run = true;
00152 renderTitle("Import data models",true);
00153 while(run) {
00154 cout << "Enter path to the data models (../data/): ";
00155 cin.getline(temp, 100);
00156 path.assign(temp);
00157 cout << "Enter start file name (exportFile): ";
00158 cin.getline(temp, 100);
00159 name.assign(temp);
00160 cout << "Enter file ending (.x3d): ";
00161 cin.getline(temp, 100);
00162 ending.assign(temp);
00163 cout << "Enter start range (1): ";
00164 cin.getline(temp, 100);
00165 rangeStart=atoi(temp);
00166 cout << "Enter end range (99): ";
00167 cin.getline(temp, 100);
00168 rangeEnd=atoi(temp);
00169 for(int i=rangeStart;i<=rangeEnd;i++) {
00170 std::cout << "Importing model " << i << " of " << rangeEnd << " \r" << std::flush;
00171 ExampleModel* em = new ExampleModel();
00172 string filename = path + name;
00173 #ifndef __WINDOWS__
00174 sprintf(temp,"%d",i);
00175 #else
00176 sprintf_s(temp,"%d",i);
00177 #endif
00178 filename.append(string(temp));
00179 filename.append(ending);
00180 run = !im.importModel(filename.c_str(),em);
00181 if(!run) {
00182 m_subErr = "Data Models loaded";
00183 m_inputModels.push_back(em);
00184 }
00185 }
00186 }
00187 }
|
Here is the call graph for this function:

|
|
Definition at line 119 of file Batch.cpp. Referenced by import(). 00119 {
00120 /* DIR *pdir;
00121 struct dirent *pent;
00122 string path = "";
00123
00124 renderTitle("Import a model dir",true);
00125 cout << "Enter path to the model file: ";
00126 cin >> path;
00127
00128 pdir=opendir(path); //"." refers to the current dir
00129 if (!pdir){
00130 printf ("opendir() failure; terminating");
00131 }
00132 errno=0;
00133 while ((pent=readdir(pdir))){
00134 printf("%s", pent->d_name);
00135 }
00136 if (errno){
00137 printf ("readdir() failure; terminating");
00138 exit(1);
00139 }
00140 closedir(pdir);*/
00141 }
|
|
|
Definition at line 100 of file Batch.cpp. References functions::Importer::importModel(), m_inputModels, m_subErr, and renderTitle(). Referenced by import(). 00100 {
00101 ExampleModel* em = new ExampleModel();
00102 functions::Importer im = functions::Importer();
00103 string file = "";
00104 bool run = true;
00105 renderTitle("Import a model",true);
00106 while(run) {
00107 cout << "Enter path to the model file: ";
00108 cin >> file;
00109 char temp[100];
00110 cin.getline(temp, 100);
00111 run = !im.importModel(file.c_str(),em);
00112 if(!run) {
00113 m_subErr = "Model loaded";
00114 m_inputModels.push_back(em);
00115 }
00116 }
00117 }
|
Here is the call graph for this function:

|
|
Definition at line 33 of file Batch.cpp. References analyze(), Export(), handleInput(), m_generatedModels, m_inputModels, m_mainErr, m_mainRun, m_refModels, m_subRun, renderOptions(), and Test(). Referenced by main(). 00033 {
00034 m_mainRun = true;
00035 m_subRun = true;
00036
00037
00038 while(m_mainRun) {
00039 vector<string> options;
00040 options.push_back("Import models");
00041 char* optname = "Analyze models";
00042 int count = m_inputModels.size();
00043 if(count>0) {
00044 char tmp[100];
00045 #ifndef __WINDOWS__
00046 sprintf(tmp,"%s (%d)",optname,count);
00047 #else
00048 sprintf_s(tmp,"%s (%d)",optname,count);
00049 #endif
00050 optname = tmp;
00051 }
00052 string s = string(optname);
00053 options.push_back(s);
00054 optname = "Export models";
00055 count = m_inputModels.size() + m_refModels.size() + m_generatedModels.size();
00056 if(count>0) {
00057 char tmp[100];
00058 #ifndef __WINDOWS__
00059 sprintf(tmp,"%s (%d)",optname,count);
00060 #else
00061 sprintf_s(tmp,"%s (%d)",optname,count);
00062 #endif
00063 optname = tmp;
00064 }
00065 s = string(optname);
00066 options.push_back(s);
00067 options.push_back("Test");
00068
00069 renderOptions("PCG",options);
00070 int o = handleInput();
00071 switch(o) {
00072 case 1: import();break;
00073 case 2: analyze(); break;
00074 case 3: Export(); break;
00075 case 4: Test(); break;
00076 default: m_mainErr = "Not a valid option!";break;
00077 }
00078 }
00079 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 462 of file Batch.cpp. References renderTitle(). Referenced by analyze(), Export(), import(), Init(), and Test(). 00462 {
00463 renderTitle(title,back);
00464 for(int i=0; i<options.size();i++) {
00465 cout << " " << i+1 << ") " << options[i] << "\n";
00466 }
00467 cout << "\n\n";
00468 if(back) {
00469 cout << " 8) Back\n";
00470 }
00471 cout << " 9) Quit\n\n";
00472 cout << " Select a option: ";
00473
00474 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 446 of file Batch.cpp. References m_mainErr, and m_subErr. Referenced by getModel(), getRandomModels(), importData(), importModel(), and renderOptions(). 00446 {
00447 #ifdef __WINDOWS__
00448 system("cls");
00449 #else
00450 system("clear");
00451 #endif
00452 string err = m_mainErr;
00453 if(sub) {
00454 err = m_subErr;
00455 }
00456 cout << err << "\n\n\n";
00457 cout << " " << title << "\n\n";
00458 m_mainErr = "";
00459 m_subErr = "";
00460 }
|
|
|
Definition at line 348 of file Batch.cpp. References ALLTEST, handleInput(), m_subErr, m_subRun, PCA, renderOptions(), STABILITY, and TestSystem(). Referenced by Init(). 00348 {
00349 m_subRun=true;
00350 vector<string> options;
00351 options.push_back("ALL Methods");
00352 options.push_back("JACOBI Method");
00353 options.push_back("HOUSEHOLDER Method");
00354 options.push_back("Time stability");
00355 options.push_back("All tests");
00356
00357 while(m_subRun) {
00358 renderOptions("Test", options, true);
00359 int o = handleInput();
00360 switch(o) {
00361 case 1: TestSystem(PCA,Analyzer::ALL);break;
00362 case 2: TestSystem(PCA,Analyzer::JACOBI); break;
00363 case 3: TestSystem(PCA,Analyzer::HOUSEHOLDER); break;
00364 case 4: TestSystem(STABILITY); break;
00365 case 5: TestSystem(ALLTEST); break;
00366 default: m_subErr = "Not a valid option!";break;
00367 }
00368 }
00369 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 410 of file Batch.cpp. References model::Analyzer::adjust(), model::Analyzer::computeEnergy(), model::Analyzer::covariance(), model::Analyzer::findComponents(), m_inputModels, model::Analyzer::mean(), model::Analyzer::mergeData(), pca, model::Analyzer::selectComponents(), model::Model::setFaces(), model::Model::setVertexs(), model::Analyzer::transformation(), and log::write(). Referenced by TestSystem(). 00410 {
00411 if(mode == Analyzer::JACOBI) {
00412 printf("Running JACOBI with %d models",size);
00413 } else if(mode == Analyzer::HOUSEHOLDER) {
00414 printf("Running HOUSEHOLDER with %d models",size);
00415 }
00416 ReferenceModel refModel = ReferenceModel();
00417 refModel.setVertexs(m_inputModels[0]->getVertexs());
00418 refModel.setFaces(m_inputModels[0]->getFaces());
00419 log::write("*************Starting to Analyze*************");
00420 pca.mergeData(refModel,m_inputModels,size);
00421 log::write("Calculating mean");
00422 pca.mean();
00423 log::write("Adjusting data");
00424 pca.adjust();
00425 log::write("Finding Covariance");
00426 pca.covariance();
00427 log::write("Begin EigenVector calculations");
00428 log::write("Timer Started");
00429 clock_t begin = clock();
00430 pca.findComponents(mode);
00431 clock_t end = clock();
00432 float time = (float)(end - begin)/CLOCKS_PER_SEC;
00433 printf(" - It took %f seconds\n",time);
00434 log::write("Timer Stopped");
00435 log::write("Time elapsed in seconds:", time);
00436 log::write("Time elapsed in clock cycles:",(int)(end-begin));
00437 log::write("End EigenVector calculations");
00438 pca.computeEnergy();
00439 pca.selectComponents();
00440 pca.transformation();
00441 log::write("*************ANALYSIS ENDED*************");
00442 }
|
Here is the call graph for this function:

|
|
Definition at line 371 of file Batch.cpp. References TestSystem(). 00371 {
00372 TestSystem(mode,Analyzer::ALL);
00373 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 375 of file Batch.cpp. References log::clear(), PCA, STABILITY, TestAnalyzer(), and log::write(). Referenced by Test(), and TestSystem(). 00375 {
00376 #ifdef __WINDOWS__
00377 system("cls");
00378 #else
00379 system("clear");
00380 #endif
00381 log::clear();
00382 log::write("TESTING STARTED");
00383 if(mode == PCA || mode == ALLTEST) {
00384 log::write("PCA TEST");
00385 int testRunNumbers[4] = {5,10,50,100};
00386 if(method == Analyzer::ALL) {
00387 for(int i=0; i<4; i++) {
00388 TestAnalyzer(Analyzer::JACOBI, testRunNumbers[i]);
00389 }
00390 for(int i=0; i<4; i++) {
00391 TestAnalyzer(Analyzer::HOUSEHOLDER,testRunNumbers[i]);
00392 }
00393 } else {
00394 for(int i=0; i<4; i++) {
00395 TestAnalyzer(method,testRunNumbers[i]);
00396 }
00397 }
00398 } else if(mode == STABILITY || mode == ALLTEST) {
00399 log::write("TIME STABILITY TEST");
00400 int testRunNumbers[4] = {2,3,4,5};
00401 for(int i=0;i<4;i++) {
00402 for(int n=0;n<100;n++) {
00403 log::write("Run nr:",n+1);
00404 TestAnalyzer(Analyzer::HOUSEHOLDER,testRunNumbers[i]);
00405 }
00406 }
00407 }
00408 }
|
Here is the call graph for this function:

|
|
Definition at line 37 of file Batch.h. Referenced by Export(), ExportModels(), getRandomModels(), and Init(). |
|
|
Definition at line 35 of file Batch.h. Referenced by analyze(), analyzeModel(), Export(), ExportModels(), importData(), importModel(), Init(), and TestAnalyzer(). |
|
|
Definition at line 34 of file Batch.h. Referenced by Batch(), Init(), and renderTitle(). |
|
|
Definition at line 33 of file Batch.h. Referenced by handleInput(), and Init(). |
|
|
Definition at line 36 of file Batch.h. Referenced by Export(), ExportModels(), and Init(). |
|
|
Definition at line 34 of file Batch.h. Referenced by analyze(), analyzeModel(), Batch(), Export(), ExportModels(), import(), importData(), importModel(), renderTitle(), and Test(). |
|
|
Definition at line 33 of file Batch.h. Referenced by analyze(), Export(), handleInput(), import(), Init(), and Test(). |
|
|
Definition at line 38 of file Batch.h. Referenced by analyzeModel(), getRandomModels(), and TestAnalyzer(). |
1.3.9.1