2 * SPDX-FileCopyrightText: 2021 Jiri Vlasak <jiri.vlasak.2@cvut.cz>
4 * SPDX-License-Identifier: GPL-3.0-only
16 #define INIT_V vector<M> V;
17 #define P(W) V.push_back(M(#W)); V.back().o.W = true;
19 #define A P(CAR) LC = c;
20 //#define A P(CAR_POINT) LC = c;
24 static unsigned int cntr;
29 bcar::BicycleCar::GenPlotOpts o;
33 this->c.gen_gnuplot_to(this->f, this->o);
41 M(std::string fn) : fn(fn)
43 this->fc = std::to_string(this->cntr++);
44 this->f.open(this->fn + this->fc);
47 M(M const& m) : fn(m.fn), c(m.c), o(m.o)
49 this->fc = std::to_string(this->cntr++);
50 this->f.open(this->fn + this->fc);
57 friend void swap(M& f, M& t)
66 f.f.open(f.fn + f.fc);
67 t.f.open(t.fn + t.fc);
74 unsigned int M::cntr = 10;
77 gpl_slot(bcar::ParkingSlot& s, std::string fn = "")
79 if (fn.compare("") == 0) {
90 gen_pl_script(std::vector<M>& ms, std::string with_slot)
95 f << "#!/usr/bin/gnuplot" << endl;
96 f << "set terminal pdf size 16,9 enhance color lw 4" << endl;
97 f << "set output 'out.pdf'" << endl;
98 f << "unset key" << endl;
99 f << "set size ratio -1" << endl;
100 f << "set xrange [-0.5:6.5]" << endl;
101 f << "set yrange [-2.8:1.9]" << endl;
102 if (with_slot.compare("") != 0) {
103 f << "plot '" << with_slot << "' w l lc 'blue',";
108 f << " '" << (m.fn + m.fc) << "'" << " w l lc 'red',";
111 //f << "pause -1" << endl;
116 main(int argc, char **argv)
121 //cerr << "Specify `what_plot` number." << endl;
122 // what_plot values 50 - 72 correspond to OSP
128 //bcar::ParkingSlot s(bcar::Point(0, 0), 0, 2.5, 6); // orig
129 //bcar::ParkingSlot s(bcar::Point(0, 0), 0, 2.2, 6); // less width
130 //bcar::ParkingSlot s(bcar::Point(1, 0), 0, 2.5, 5); // less length
131 bcar::ParkingSlot s(bcar::Point(1, 0), 0, 2.2, 5); // less all
135 s.fe(bcar::BicycleCar());
139 what_plot = atoi(argv[1]);
148 //int len = s._ispaths.size();
149 //auto c = s._ispaths[len / 2].front(); // orig
150 //auto c = s._ispaths[len - 1].front(); // for less width
151 //auto c = s._ispaths[len - len].front(); // for less length
152 auto c = s._ispaths[38].front(); // for less all
160 while (!s.collide(c)) {
170 // 1 cusp: go forward
172 while (!s.collide(c)) {
182 // 2 cusp: go backward
184 while (!s.collide(c)) {
196 cerr << s.parked(c) << endl;
199 #if 0 /* out of slot */
200 if (what_plot > 52) {
203 for (int i = 0; i < 5; i++) {
208 if (what_plot > 54) { // can go anywhere forward
211 while (!s.lf().inside_of(c.ccr(), c.iradi())) {
217 if (what_plot > 55) {
219 for (int i = 0; i < 10; i++) {
224 if (what_plot > 56) {
226 for (int i = 0; i < 10; i++) {
231 if (what_plot > 57) {
233 for (int i = 0; i < 10; i++) {
238 if (what_plot > 58) { // few steps towards -- most up
240 for (int i = 0; i < 10; i++) {
245 if (what_plot > 60) {
248 for (int i = 0; i < 10; i++) {
253 if (what_plot > 61) {
256 for (int i = 0; i < 10; i++) {
261 if (what_plot > 62) { // parallel to ps
264 for (int i = 0; i < 10; i++) {
269 if (what_plot > 66) { // what_plot should be up to 22 (init)
270 int how_much = what_plot - 16 - 50;
273 for (int i = 0; i < 20 * how_much; i++) {
279 if (what_plot > 58) {
283 for (int i = 0; i < 10; i++) {
288 if (what_plot > 62) {
292 for (int i = 0; i < 10; i++) {
297 if (what_plot > 66) {
301 for (int i = 0; i < 10; i++) {
306 if (what_plot > 70) {
309 for (int i = 0; i < 20; i++) {
314 if (what_plot > 72) {
317 for (int i = 0; i < 20; i++) {
322 if (what_plot > 74) {
325 for (int i = 0; i < 10; i++) {
330 if (what_plot > 76) {
333 for (int i = 0; i < 20; i++) {
338 if (what_plot > 78) {
342 for (int i = 0; i < 10; i++) {
347 if (what_plot > 80) { // up to 83 (init)
348 int how_much = what_plot - 80;
351 for (int i = 0; i < 20 * how_much; i++) {
357 if (what_plot > 56) {
360 for (int i = 0; i < 10; i++) {
365 if (what_plot > 58) {
369 for (int i = 0; i < 10; i++) {
374 if (what_plot > 62) {
378 for (int i = 0; i < 10; i++) {
383 if (what_plot > 66) {
386 for (int i = 0; i < 5; i++) {
391 if (what_plot > 68) {
394 for (int i = 0; i < 10; i++) {
399 if (what_plot > 70) {
402 for (int i = 0; i < 20; i++) {
407 if (what_plot > 72) {
410 for (int i = 0; i < 20; i++) {
415 if (what_plot > 73) {
418 for (int i = 0; i < 20; i++) {
423 if (what_plot > 74) {
427 for (int i = 0; i < 5; i++) {
432 if (what_plot > 80) { // up to 83 (init)
433 int how_much = what_plot - 80;
436 for (int i = 0; i < 20 * how_much; i++) {
445 gen_pl_script(V, sn);
446 cout << "mv out.pdf " << ((what_plot < 10)?"0":"");
447 cout << what_plot << ".pdf" << endl;