| 32 | #include <iterator> |
| 33 | |
| 34 | int main(int argc, char** argv) { |
| 35 | bool valid_command_line = false; |
| 36 | bool random_color = false; |
| 37 | double eps = 1.e-5; |
| 38 | boost::optional<std::string> class_name; |
| 39 | |
| 40 | std::vector<std::string> flags; |
| 41 | std::vector<std::string> args; |
| 42 | svgfill::solver s = svgfill::FILTERED_CARTESIAN_QUOTIENT; |
| 43 | std::map<std::string, svgfill::solver> solver_mapping { |
| 44 | {"cartesian_double", svgfill::CARTESIAN_DOUBLE}, |
| 45 | {"cartesian_quotient", svgfill::CARTESIAN_QUOTIENT}, |
| 46 | {"filtered_cartesian_quotient", svgfill::FILTERED_CARTESIAN_QUOTIENT}, |
| 47 | {"exact_predicates", svgfill::EXACT_PREDICATES}, |
| 48 | {"exact_constructions", svgfill::EXACT_CONSTRUCTIONS}, |
| 49 | }; |
| 50 | progress_bar::style progress_style = progress_bar::BAR; |
| 51 | |
| 52 | for (int i = 1; i < argc; ++i) { |
| 53 | std::string a = argv[i]; |
| 54 | if (boost::starts_with(a, "-")) { |
| 55 | flags.push_back(a); |
| 56 | } |
| 57 | else { |
| 58 | args.push_back(a); |
| 59 | } |
| 60 | } |
| 61 | std::string fn, ofn; |
| 62 | |
| 63 | if (args.size() == 2) { |
| 64 | fn = args[0]; |
| 65 | ofn = args[1]; |
| 66 | valid_command_line = true; |
| 67 | } |
| 68 | |
| 69 | for (auto& f : flags) { |
| 70 | if (f == "--random-color") { |
| 71 | random_color = true; |
| 72 | } |
| 73 | else if (f == "-q") { |
| 74 | progress_style = progress_bar::DOTS; |
| 75 | } |
| 76 | else if (boost::starts_with(f, "--class=")) { |
| 77 | class_name = f.substr(strlen("--class=")); |
| 78 | } |
| 79 | else if (boost::starts_with(f, "--solver=")) { |
| 80 | std::string solver_str = f.substr(strlen("--solver=")); |
| 81 | auto it = solver_mapping.find(solver_str); |
| 82 | if (it == solver_mapping.end()) { |
| 83 | valid_command_line = false; |
| 84 | } |
| 85 | else { |
| 86 | s = it->second; |
| 87 | } |
| 88 | } |
| 89 | else if (boost::starts_with(f, "--eps=")) { |
| 90 | std::string eps_str = f.substr(strlen("--eps=")); |
| 91 | eps = boost::lexical_cast<double>(eps_str); |