cleaned up code
This commit is contained in:
parent
ffa47f36cd
commit
68ab1640a3
1 changed files with 63 additions and 63 deletions
126
main.cpp
126
main.cpp
|
@ -15,94 +15,94 @@ int verbose;
|
||||||
|
|
||||||
void showHelpText(){
|
void showHelpText(){
|
||||||
std::cout << "Awesome Attractor, version " << __DATE__ << std::endl;
|
std::cout << "Awesome Attractor, version " << __DATE__ << std::endl;
|
||||||
std::cout << "Usage: AwesomeAttractor [OPTION]... FILE" << std::endl << std::endl;
|
std::cout << "Usage: AwesomeAttractor [OPTION]... FILE" << std::endl << std::endl;
|
||||||
std::cout << "Optons:" << std::endl;
|
std::cout << "Optons:" << std::endl;
|
||||||
std::cout << " --help Shows this help" << std::endl;
|
std::cout << " --help Shows this help" << std::endl;
|
||||||
std::cout << " -q quiet mode" << std::endl;
|
std::cout << " -q quiet mode" << std::endl;
|
||||||
std::cout << " -v verbose mode" << std::endl;
|
std::cout << " -v verbose mode" << std::endl;
|
||||||
std::cout << " -V loud mode" << std::endl;
|
std::cout << " -V loud mode" << std::endl;
|
||||||
std::cout << " -w N Sets width of output image to N" << std::endl;
|
std::cout << " -w N Sets width of output image to N" << std::endl;
|
||||||
std::cout << " -h N Sets height of output image to N" << std::endl;
|
std::cout << " -h N Sets height of output image to N" << std::endl;
|
||||||
std::cout << " -i N Sets number of iterations to N" << std::endl;
|
std::cout << " -i N Sets number of iterations to N" << std::endl;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
verbose = 0;
|
verbose = 0;
|
||||||
std::string attractorFile = DEFAULT_ATTRACTOR_FILE;
|
std::string attractorFile = DEFAULT_ATTRACTOR_FILE;
|
||||||
unsigned int iterations = DEFAULT_ITERATIONS;
|
unsigned int iterations = DEFAULT_ITERATIONS;
|
||||||
unsigned int width = DEFAULT_WIDTH;
|
unsigned int width = DEFAULT_WIDTH;
|
||||||
unsigned int height = DEFAULT_HEIGHT;
|
unsigned int height = DEFAULT_HEIGHT;
|
||||||
|
|
||||||
if ( argc <= 1 ) {
|
if ( argc <= 1 ) {
|
||||||
showHelpText();
|
showHelpText();
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int i = 1; i < argc; ++i ) {
|
for ( int i = 1; i < argc; ++i ) {
|
||||||
if ( strcmp(argv[i], "-v") == 0 ) {
|
if ( strcmp(argv[i], "-v") == 0 ) {
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
} else if ( strcmp(argv[i], "-q") == 0 ) {
|
} else if ( strcmp(argv[i], "-q") == 0 ) {
|
||||||
verbose = -1;
|
verbose = -1;
|
||||||
} else if ( strcmp(argv[i], "--help") == 0 ) {
|
} else if ( strcmp(argv[i], "--help") == 0 ) {
|
||||||
showHelpText();
|
showHelpText();
|
||||||
} else if ( strcmp(argv[i], "-V") == 0 ) {
|
} else if ( strcmp(argv[i], "-V") == 0 ) {
|
||||||
verbose = 3;
|
verbose = 3;
|
||||||
} else if ( strcmp(argv[i], "-w") == 0 ) {
|
} else if ( strcmp(argv[i], "-w") == 0 ) {
|
||||||
width = atoi(argv[++i]);
|
width = atoi(argv[++i]);
|
||||||
} else if ( strcmp(argv[i], "-h") == 0 ) {
|
} else if ( strcmp(argv[i], "-h") == 0 ) {
|
||||||
height = atoi(argv[++i]);
|
height = atoi(argv[++i]);
|
||||||
} else if ( strcmp(argv[i], "-i") == 0 ) {
|
} else if ( strcmp(argv[i], "-i") == 0 ) {
|
||||||
iterations = atoi(argv[++i]);
|
iterations = atoi(argv[++i]);
|
||||||
} else {
|
} else {
|
||||||
attractorFile = argv[i];
|
attractorFile = argv[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInfo("Awesome Attractor, version %s\n", __DATE__);
|
LogInfo("Awesome Attractor, version %s\n", __DATE__);
|
||||||
|
|
||||||
// initialising stuff
|
// initialising stuff
|
||||||
Attractor myAttractor(attractorFile);
|
Attractor myAttractor(attractorFile);
|
||||||
|
|
||||||
Projector projection;
|
Projector projection;
|
||||||
Canvas canvas(width, height, 3);
|
Canvas canvas(width, height, 3);
|
||||||
projection.canvas = &canvas;
|
projection.canvas = &canvas;
|
||||||
|
|
||||||
myAttractor.projectors.push_back(&projection);
|
myAttractor.projectors.push_back(&projection);
|
||||||
myAttractor.init_range();
|
myAttractor.init_range();
|
||||||
|
|
||||||
projection.output();
|
projection.output();
|
||||||
|
|
||||||
LogInfo("\nRendering\n");
|
LogInfo("\nRendering\n");
|
||||||
|
|
||||||
clock_t start, end;
|
clock_t start, end;
|
||||||
start = clock();
|
start = clock();
|
||||||
for ( unsigned int j = 1; j <= 100; ++j ) {
|
for ( unsigned int j = 1; j <= 100; ++j ) {
|
||||||
for ( unsigned int i = 0; i <= iterations; i++ ) {
|
for ( unsigned int i = 0; i <= iterations; i++ ) {
|
||||||
myAttractor.iterate();
|
myAttractor.iterate();
|
||||||
myAttractor.plot();
|
myAttractor.plot();
|
||||||
}
|
}
|
||||||
if ( verbose >= 0 ) {
|
if ( verbose >= 0 ) {
|
||||||
std::cout << "\r" << j << "% done" << std::flush;
|
std::cout << "\r" << j << "% done" << std::flush;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end = clock();
|
end = clock();
|
||||||
|
|
||||||
double totalIterations = 100.0*iterations;
|
double totalIterations = 100.0*iterations;
|
||||||
double totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
|
double totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
|
||||||
LogInfo("\nTotal clock time: %f\n", totalTime);
|
LogInfo("\nTotal clock time: %f\n", totalTime);
|
||||||
LogMoreInfo("Average iterations per second: %f\n\n", totalIterations/totalTime);
|
LogMoreInfo("Average iterations per second: %f\n\n", totalIterations/totalTime);
|
||||||
|
|
||||||
// saving output
|
// saving output
|
||||||
start = clock();
|
start = clock();
|
||||||
canvas.output_file();
|
canvas.output_file();
|
||||||
end = clock();
|
end = clock();
|
||||||
|
|
||||||
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
|
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
|
||||||
|
|
||||||
LogInfo("Total clock time for writing png: %f\n", totalTime);
|
LogInfo("Total clock time for writing png: %f\n", totalTime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue