-
Notifications
You must be signed in to change notification settings - Fork 0
/
sudoprint.cpp
144 lines (116 loc) · 2.8 KB
/
sudoprint.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <iostream>
#include <unistd.h>
#include <getopt.h>
#include <plotter.h>
#include "coords.h"
#include "psout.h"
#include "backtrack_common.h"
#include "backtrack_naive_unique.h"
#include "bitmatrix_to_ps.h"
#include "bits.h"
#include "simple_naked_single.h"
#include "naked_single.h"
#include "hidden_single.h"
#include "nh_subset.h"
#include "pointing.h"
#include "boxline.h"
#include "nfish.h"
#include "simple_coloring.h"
#include "pretty_solver.h"
#include "pattern.h"
#include "backtrack_to_bits.h"
#include "permutation.h"
//#include "cairo_out.h"
#include "bits_to_output.h"
#include "strong_link.h"
#include "simple_complete_gen.h"
#include "naive_gen.h"
#include "libplot_out.h"
const int OUT_PS = 0;
const int OUT_SVG = 1;
const int OUT_PNG = 2;
const int OUT_GIF = 3;
Plotter* plotter;
int output_format = 0;
bool show_candidates = false;
std::string resolution = "560x560";
std::string font = "Helvetica";
PlotterParams params;
void init_ps() {
//params.setplparam("PAGESIZE",(char*)"letter");
plotter = new PSPlotter(std::cin, std::cout, std::cerr, params);
}
void init_svg() {
plotter = new SVGPlotter(std::cin, std::cout, std::cerr, params);
}
void init_png() {
std::cout << "WARNING: PNGPlotter will not compile!" << std::endl;
//plotter = new PNGPlotter(std::cin, std::cout, std::cerr, params);
}
void init_gif() {
params.setplparam("BITMAPSIZE",(char*)"560x560");
plotter = new GIFPlotter(std::cin, std::cout, std::cerr, params);
}
int main(int argc, char* argv[]) {
int c;
while(true) {
static struct option long_options[] = {
{"ps", no_argument, 0, 'p'},
{"svg", no_argument, 0, 's'},
{"png", no_argument, 0, 'n'},
{"gif", no_argument, 0, 'g'},
{"candidates", no_argument, 0, 'c'},
{"font", required_argument, 0, 'f'},
{0, 0, 0, 0}
};
int option_index = 0;
c = getopt_long(argc, argv, "psngcf:", long_options, &option_index);
if(c == -1) { break; }
switch(c) {
/*
case 0:
*/
case 'p':
output_format = OUT_PS; break;
case 's':
output_format = OUT_SVG; break;
case 'n':
output_format = OUT_PNG; break;
case 'g':
output_format = OUT_GIF; break;
case 'c':
show_candidates = true; break;
case 'f':
font = std::string(optarg); break;
}
}
if(optind < argc) {
/*
while(optind < argc) {
printf ("%s ", argv[optind++]);
}
*/
}
if(output_format == OUT_PS) {
init_ps();
} else if(output_format == OUT_SVG) {
init_svg();
} else if(output_format == OUT_PNG) {
init_png();
} else if(output_format == OUT_GIF) {
init_gif();
} else {
std::cerr << "Not yet supported" << std::endl;
return 1;
}
Bits bits = Bits();
std::cin >> bits;
LPOut lp = LPOut(plotter);
write_numbers(&bits, &lp);
if(show_candidates) {
write_candidates(&bits, &lp);
}
lp.draw();
delete plotter;
return 0;
}