#include #include #include #include #include #include namespace po = boost::program_options; #include "stf.hpp" #include "Logger.hpp" #include "defines.hpp" #include "AwesomeAttractorConfig.h" #include "Random.hpp" #include "Canvas.hpp" #include "output.hpp" #include "render.hpp" int verbose = LOG_DEBUG; Logger logger(std::cout, LOG_VERBOSE); std::string generate_filename(){ char filename[64]; time_t t = time(0); struct tm* lt = localtime(&t); sprintf(filename, "attractor_%04d-%02d-%02d_%02d-%02d-%02d", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec); return std::string(filename); } void save_stf(stfu::node & stf_output, std::string const & filename){ stf_output.addValue("version") = __DATE__" "__TIME__; stf_output.addValue("notes") = "This is the version with somewhat better blur (circle) and random colours"; std::string path(filename + ".stf"); std::ofstream file(path.c_str()); file << stf_output << std::endl; } int main(int argc, char* argv[]) try { std::string attractorFile, output_path; unsigned int iterations, width, height; srand(time(0)); po::options_description desc("Options"); desc.add_options() ("help,h", "produce help message") ("iterations,I", po::value(&iterations)->default_value(DEFAULT_ITERATIONS), "set number of iterations (in milions)") ("width,W", po::value(&width)->default_value(DEFAULT_WIDTH), "width of output image") ("height,H", po::value(&height)->default_value(DEFAULT_HEIGHT), "height of output image") ("input-file,f", po::value(&attractorFile)->default_value(""), "attractor file to read") ("output-path,P", po::value(&output_path)->default_value("render/"), "path to output image") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if (vm.count("help") || argc <= 1) { //std::cout << desc << std::endl; return 1; } stfu::node stf_input, stf_output; stf_input.read(attractorFile); std::string filename = output_path + generate_filename(); LayeredCanvas > canvas(width, height, 2); render(canvas, attractorFile, stf_output, iterations); if(stf_input.childExists("tonemapper")) output(canvas, stf_input.getChild("tonemapper"), filename, stf_output); else output(canvas, Random::parameters(), filename, stf_output); save_stf(stf_output, filename); } catch (std::exception & e) { std::cout << "Terminated because of: " << e.what() << std::endl; }