|
@ -40,14 +40,12 @@ void render(Attractor & myAttractor, Canvas2D & canvas, unsigned int iterations) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) { |
|
|
int main(int argc, char* argv[]) try { |
|
|
std::string attractorFile; |
|
|
std::string attractorFile, output_path; |
|
|
std::string output_path; |
|
|
|
|
|
bool generate_random = false; |
|
|
|
|
|
unsigned int iterations, width, height; |
|
|
unsigned int iterations, width, height; |
|
|
srand(time(0)); |
|
|
srand(time(0)); |
|
|
|
|
|
|
|
|
po::options_description desc("Usage"); |
|
|
po::options_description desc("Options"); |
|
|
desc.add_options() |
|
|
desc.add_options() |
|
|
("help,h", "produce help message") |
|
|
("help,h", "produce help message") |
|
|
("iterations,I", po::value<unsigned int>(&iterations)->default_value(DEFAULT_ITERATIONS), "set number of iterations (in milions)") |
|
|
("iterations,I", po::value<unsigned int>(&iterations)->default_value(DEFAULT_ITERATIONS), "set number of iterations (in milions)") |
|
@ -55,55 +53,33 @@ int main(int argc, char* argv[]) { |
|
|
("height,H", po::value<unsigned int>(&height)->default_value(DEFAULT_HEIGHT), "height of output image") |
|
|
("height,H", po::value<unsigned int>(&height)->default_value(DEFAULT_HEIGHT), "height of output image") |
|
|
("input-file,f", po::value<std::string>(&attractorFile)->default_value(""), "attractor file to read") |
|
|
("input-file,f", po::value<std::string>(&attractorFile)->default_value(""), "attractor file to read") |
|
|
("output-path,P", po::value<std::string>(&output_path)->default_value("render/"), "path to output image") |
|
|
("output-path,P", po::value<std::string>(&output_path)->default_value("render/"), "path to output image") |
|
|
("random,R", "use random parameters") |
|
|
|
|
|
; |
|
|
; |
|
|
|
|
|
|
|
|
po::variables_map vm; |
|
|
po::variables_map vm; |
|
|
try { |
|
|
|
|
|
po::store(po::parse_command_line(argc, argv, desc), vm); |
|
|
po::store(po::parse_command_line(argc, argv, desc), vm); |
|
|
po::notify(vm); |
|
|
po::notify(vm); |
|
|
} catch(std::exception & e) { |
|
|
|
|
|
std::cout << "Failed to read commandline: " << e.what() << std::endl; |
|
|
|
|
|
std::cout << desc << std::endl; |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (vm.count("help") || argc <= 1) { |
|
|
if (vm.count("help") || argc <= 1) { |
|
|
std::cout << desc << std::endl; |
|
|
std::cout << desc << std::endl; |
|
|
return 1; |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(vm.count("random")) generate_random = true; |
|
|
|
|
|
|
|
|
|
|
|
std::string filename = output_path + generate_filename(); |
|
|
std::string filename = output_path + generate_filename(); |
|
|
|
|
|
|
|
|
Logger logger(LOG_VERBOSE, std::cout); |
|
|
Logger logger(LOG_VERBOSE, std::cout); |
|
|
Canvas2D canvas(width, height); |
|
|
Canvas2D canvas(width, height); |
|
|
{ |
|
|
{ |
|
|
Attractor* my_attractor_ptr = 0; |
|
|
Attractor my_attractor(attractorFile); |
|
|
if(attractorFile != "") |
|
|
|
|
|
my_attractor_ptr = new Attractor(attractorFile); |
|
|
|
|
|
else if(generate_random) |
|
|
|
|
|
my_attractor_ptr = new Attractor(); |
|
|
|
|
|
|
|
|
|
|
|
if(my_attractor_ptr == 0){ |
|
|
|
|
|
LogError("Nothing todo\n"); |
|
|
|
|
|
exit(0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
my_attractor_ptr->init_range(); |
|
|
my_attractor.init_range(); |
|
|
|
|
|
|
|
|
logger.start("rendering"); |
|
|
logger.start("rendering"); |
|
|
render(*my_attractor_ptr, canvas, iterations); |
|
|
render(my_attractor, canvas, iterations); |
|
|
logger.stop(); |
|
|
logger.stop(); |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
std::string path(filename + ".stf"); |
|
|
std::string path(filename + ".stf"); |
|
|
std::ofstream file(path.c_str()); |
|
|
std::ofstream file(path.c_str()); |
|
|
file << my_attractor_ptr->stf_output() << std::endl; |
|
|
file << my_attractor.stf_output() << std::endl; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
delete my_attractor_ptr; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
@ -115,6 +91,8 @@ int main(int argc, char* argv[]) { |
|
|
tonemapper.process(canvas, image); |
|
|
tonemapper.process(canvas, image); |
|
|
logger.stop(); |
|
|
logger.stop(); |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (std::exception & e) { |
|
|
|
|
|
std::cout << "Terminated because of: " << e.what() << std::endl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|