Orbiter 2022
Combinatorial Objects
video_draw_options.cpp
Go to the documentation of this file.
1/*
2 * video_draw_options.cpp
3 *
4 * Created on: Feb 10, 2019
5 * Author: betten
6 */
7
8
9
10#include "foundations.h"
11
12
13using namespace std;
14
15
16namespace orbiter {
17namespace layer1_foundations {
18namespace graphics {
19
20
21
23{
24
25 f_rotate = TRUE;
27 // 1 = 1,1,1
28 // 2 = 0,0,1
29 // 3 = custom
30 //double rotation_axis_custom[3]
31
32 boundary_type = 1;
33 // 1 = sphere
34 // 2 = box
35 // 3 = no clipping
36
39
41 font_size = 36; // works well for 800 x 600
42
44 stroke_width = 2; // works well for 800 x 600
45
46 f_W = FALSE;
47 W = 0;
48 f_H = FALSE;
49 H = 0;
50
52 default_angle = 22;
53
55 clipping_radius = 2.1;
56
57 nb_clipping = 0;
58 //int clipping_round[1000];
59 //double clipping_value[1000];
60
61 nb_camera = 0;
62 //int camera_round[1000];
63 //const char *camera_sky[1000];
64 //const char *camera_location[1000];
65 //const char *camera_look_at[1000];
66
67 nb_zoom = 0;
68 //int zoom_round[1000];
69 //int zoom_start[1000];
70 //int zoom_end[1000];
71
72
74 //int zoom_sequence_round[1000];
75 //const char *zoom_sequence_text[1000];
76
77 nb_pan = 0;
78 //int pan_round[1000];
79 //int pan_f_reverse[1000];
80 //double pan_from[1000 * 3];
81 //double pan_to[1000 * 3];
82 //double pan_center[1000 * 3];
83
85 //int no_background_round[1000];
86
88 //int no_bottom_plane_round[1000];
89
90 cnt_nb_frames = 0;
91 //int nb_frames_round[1000];
92 //int nb_frames_value[1000];
93
94
95 nb_round_text = 0;
96 //int round_text_round[1000];
97 //int round_text_sustain[1000];
98 //const char *round_text_text[1000];
99
100 nb_label = 0;
101 //int label_round[1000];
102 //int label_start[1000];
103 //int label_sustain[1000];
104 //const char *label_gravity[1000];
105 //const char *label_text[1000];
106
107
108 nb_latex_label = 0;
109 //int latex_label_round[1000];
110 //int latex_label_start[1000];
111 //int latex_label_sustain[1000];
112 //const char *latex_extras_for_praeamble[1000];
113 //const char *latex_label_gravity[1000];
114 //const char *latex_label_text[1000];
115 //int latex_f_label_has_been_prepared[1000];
116 //char *latex_fname_base[1000];
117
118
119 nb_picture = 0;
120 //int picture_round[1000];
121 //double picture_scale[1000];
122 //const char *picture_fname[1000];
123 //const char *picture_options[1000];
124
125
128
129 //sky = "<1,1,1>";
130 //location = "<-3,1,3>";
131 //look_at = "<0,0,0>";
132 sky[0] = 1;
133 sky[1] = 1;
134 sky[2] = 1;
135 location[0] = -3;
136 location[1] = 1;
137 location[2] = 3;
139 look_at[0] = 0;
140 look_at[1] = 0;
141 look_at[2] = 0;
142
144 scale_factor = 1.;
145
147 line_radius = 0.02;
148
149}
150
152{
153}
154
156 int argc, std::string *argv,
157 int verbose_level)
158{
159 int f_v = (verbose_level >= 1);
160 int i;
162
163 if (f_v) {
164 cout << "video_draw_options::read_arguments" << endl;
165 }
166 for (i = 0; i < argc; i++) {
167 if (ST.stringcmp(argv[i], "-v") == 0) {
168 verbose_level = ST.strtoi(argv[++i]);
169 if (f_v) {
170 cout << "-v " << verbose_level << endl;
171 }
172 }
173 else if (ST.stringcmp(argv[i], "-do_not_rotate") == 0) {
174 f_rotate = FALSE;
175 if (f_v) {
176 cout << "video_draw_options::read_arguments -do_not_rotate " << endl;
177 }
178 }
179 else if (ST.stringcmp(argv[i], "-rotate_about_z_axis") == 0) {
180 f_rotate = TRUE;
182 if (f_v) {
183 cout << "-rotate_about_z_axis " << endl;
184 }
185 }
186 else if (ST.stringcmp(argv[i], "-rotate_about_111") == 0) {
187 f_rotate = TRUE;
189 if (f_v) {
190 cout << "-rotate_about_111 " << endl;
191 }
192 }
193 else if (ST.stringcmp(argv[i], "-rotate_about_custom_axis") == 0) {
194 f_rotate = TRUE;
196
198 if (f_v) {
199 cout << "-rotate_about_custom_axis " << endl;
200 }
201 }
202 else if (ST.stringcmp(argv[i], "-boundary_none") == 0) {
203 boundary_type = 3;
204 if (f_v) {
205 cout << "-boundary_none " << endl;
206 }
207 }
208 else if (ST.stringcmp(argv[i], "-boundary_box") == 0) {
209 boundary_type = 2;
210 if (f_v) {
211 cout << "-boundary_box " << endl;
212 }
213 }
214 else if (ST.stringcmp(argv[i], "-boundary_sphere") == 0) {
215 boundary_type = 1;
216 if (f_v) {
217 cout << "-boundary_sphere " << endl;
218 }
219 }
220 else if (ST.stringcmp(argv[i], "-font_size") == 0) {
222 font_size = ST.strtoi(argv[++i]);
223 if (f_v) {
224 cout << "-font_size " << font_size << endl;
225 }
226 }
227 else if (ST.stringcmp(argv[i], "-stroke_width") == 0) {
229 stroke_width = ST.strtoi(argv[++i]);
230 if (f_v) {
231 cout << "-stroke_width " << stroke_width << endl;
232 }
233 }
234 else if (ST.stringcmp(argv[i], "-omit_bottom_plane") == 0) {
236 if (f_v) {
237 cout << "-omit_bottom_plane " << endl;
238 }
239 }
240
241 else if (ST.stringcmp(argv[i], "-W") == 0) {
242 f_W = TRUE;
243 W = ST.strtoi(argv[++i]);
244 if (f_v) {
245 cout << "-W " << W << endl;
246 }
247 }
248 else if (ST.stringcmp(argv[i], "-H") == 0) {
249 f_H = TRUE;
250 H = ST.strtoi(argv[++i]);
251 if (f_v) {
252 cout << "-H " << H << endl;
253 }
254 }
255 else if (ST.stringcmp(argv[i], "-nb_frames") == 0) {
256 nb_frames_round[cnt_nb_frames] = ST.strtoi(argv[++i]);
257 nb_frames_value[cnt_nb_frames] = ST.strtoi(argv[++i]);
258 if (f_v) {
259 cout << "-nb_frames "
261 << nb_frames_value[cnt_nb_frames] << endl;
262 }
264 }
265 else if (ST.stringcmp(argv[i], "-zoom") == 0) {
266 i++;
267 zoom_round[nb_zoom] = ST.strtoi(argv[i]);
268 i++;
269 zoom_start[nb_zoom] = ST.strtoi(argv[i]);
270 i++;
271 zoom_end[nb_zoom] = ST.strtoi(argv[i]);
272 double d;
273 i++;
274 d = ST.strtof(argv[++i]);
276 i++;
277 d = ST.strtof(argv[++i]);
279 if (f_v) {
280 cout << "-zoom "
281 << zoom_round[nb_zoom] << " "
282 << zoom_start[nb_zoom] << " "
283 << zoom_end[nb_zoom] << " "
285 << zoom_clipping_end[nb_zoom] << " "
286 << endl;
287 }
288 nb_zoom++;
289 }
290 else if (ST.stringcmp(argv[i], "-zoom_sequence") == 0) {
292 zoom_sequence_text[nb_zoom_sequence].assign(argv[++i]);
293 if (f_v) {
294 cout << "-zoom_sequence "
297 }
299 }
300 else if (ST.stringcmp(argv[i], "-pan") == 0) {
301 pan_round[nb_pan] = ST.strtoi(argv[++i]);
303 numerics Num;
304
305
306 ST.text_to_three_double(argv[++i], pan_from + nb_pan * 3);
307 ST.text_to_three_double(argv[++i], pan_to + nb_pan * 3);
308 ST.text_to_three_double(argv[++i], pan_center + nb_pan * 3);
309
310 if (f_v) {
311 cout << "video_draw_options::read_arguments -pan "
312 << pan_round[nb_pan];
313 cout << " ";
314 Num.vec_print(pan_from + 3 * nb_pan, 3);
315 cout << " ";
316 Num.vec_print(pan_to + 3 * nb_pan, 3);
317 cout << " ";
318 Num.vec_print(pan_center + 3 * nb_pan, 3);
319 cout << endl;
320 }
321 nb_pan++;
322 }
323 else if (ST.stringcmp(argv[i], "-pan_reverse") == 0) {
324 pan_round[nb_pan] = ST.strtoi(argv[++i]);
326 numerics Num;
327
328
329 ST.text_to_three_double(argv[++i], pan_from + nb_pan * 3);
330 ST.text_to_three_double(argv[++i], pan_to + nb_pan * 3);
331 ST.text_to_three_double(argv[++i], pan_center + nb_pan * 3);
332
333 if (f_v) {
334 cout << "-pan_reverse "
335 << pan_round[nb_pan];
336 cout << " ";
337 Num.vec_print(pan_from + 3 * nb_pan, 3);
338 cout << " ";
339 Num.vec_print(pan_to + 3 * nb_pan, 3);
340 cout << " ";
341 Num.vec_print(pan_center + 3 * nb_pan, 3);
342 cout << endl;
343 }
344 nb_pan++;
345 }
346 else if (ST.stringcmp(argv[i], "-no_background") == 0) {
348 if (f_v) {
349 cout << "-no_background "
351 }
353 }
354 else if (ST.stringcmp(argv[i], "-no_bottom_plane") == 0) {
356 if (f_v) {
357 cout << "-no_bottom_plane "
359 }
361 }
362 else if (ST.stringcmp(argv[i], "-camera") == 0) {
363 camera_round[nb_camera] = ST.strtoi(argv[++i]);
364
365
366
367 ST.text_to_three_double(argv[++i], camera_sky + nb_camera * 3);
369 ST.text_to_three_double(argv[++i], camera_look_at + nb_camera * 3);
370
371 if (f_v) {
372 cout << "-camera "
373 << camera_round[nb_camera] << " "
374 << camera_sky[nb_camera * 3 + 0] << " "
375 << camera_sky[nb_camera * 3 + 1] << " "
376 << camera_sky[nb_camera * 3 + 2] << " "
377 << camera_location[nb_camera * 3 + 0] << " "
378 << camera_location[nb_camera * 3 + 1] << " "
379 << camera_location[nb_camera * 3 + 2] << " "
380 << camera_look_at[nb_camera * 3 + 0] << " "
381 << camera_look_at[nb_camera * 3 + 1] << " "
382 << camera_look_at[nb_camera * 3 + 2] << " "
383 << endl;
384 }
385 nb_camera++;
386
387 //sky <1,1,1>
388 //direction <1,0,0>
389 //right <1,1,0>
390 //location <-3,1,3>
391 //look_at <0,0,0>
392 }
393 else if (ST.stringcmp(argv[i], "-clipping") == 0) {
394 clipping_round[nb_clipping] = ST.strtoi(argv[++i]);
395 double d;
396 d = ST.strtof(argv[++i]);
398 if (f_v) {
399 cout << "-clipping "
400 << clipping_round[nb_clipping] << " "
401 << clipping_value[nb_clipping] << endl;
402 }
403 nb_clipping++;
404 }
405 else if (ST.stringcmp(argv[i], "-text") == 0) {
406 round_text_round[nb_round_text] = ST.strtoi(argv[++i]);
407 round_text_sustain[nb_round_text] = ST.strtoi(argv[++i]);
408 round_text_text[nb_round_text].assign(argv[++i]);
409 if (f_v) {
410 cout << "-text "
413 << round_text_text[nb_round_text] << endl;
414 }
416 }
417 else if (ST.stringcmp(argv[i], "-label") == 0) {
418 label_round[nb_label] = ST.strtoi(argv[++i]);
419 label_start[nb_label] = ST.strtoi(argv[++i]);
420 label_sustain[nb_label] = ST.strtoi(argv[++i]);
421 label_gravity[nb_label].assign(argv[++i]);
422 label_text[nb_label].assign(argv[++i]);
423 if (f_v) {
424 cout << "-label "
425 << label_round[nb_label] << " "
426 << label_start[nb_label] << " "
427 << label_sustain[nb_label] << " "
428 << label_gravity[nb_label] << " "
429 << label_text[nb_label] << " "
430 << endl;
431 }
432 nb_label++;
433 }
434 else if (ST.stringcmp(argv[i], "-latex") == 0) {
435 latex_label_round[nb_latex_label] = ST.strtoi(argv[++i]);
436 latex_label_start[nb_latex_label] = ST.strtoi(argv[++i]);
439 latex_label_gravity[nb_latex_label].assign(argv[++i]);
440 latex_label_text[nb_latex_label].assign(argv[++i]);
442 //latex_fname_base[nb_latex_label] = NEW_char(1000);
443 if (f_v) {
444 cout << "-latex "
451 << endl;
452 }
454 }
455 else if (ST.stringcmp(argv[i], "-global_picture_scale") == 0) {
457 double d;
458 d = ST.strtof(argv[++i]);
460 if (f_v) {
461 cout << "-global_picture_scale " << d << endl;
462 }
463 }
464 else if (ST.stringcmp(argv[i], "-picture") == 0) {
465 picture_round[nb_picture] = ST.strtoi(argv[++i]);
466 double d;
467 d = ST.strtof(argv[++i]);
469 picture_fname[nb_picture].assign(argv[++i]);
470 picture_options[nb_picture].assign(argv[++i]);
471 if (f_v) {
472 cout << "-picture "
473 << picture_round[nb_picture] << " "
474 << picture_scale[nb_picture] << " "
475 << picture_fname[nb_picture] << " "
476 << picture_options[nb_picture] << " "
477 << endl;
478 }
479 nb_picture++;
480 }
481 else if (ST.stringcmp(argv[i], "-look_at") == 0) {
482 //look_at = argv[++i];
483 f_look_at = TRUE;
484
485 ST.text_to_three_double(argv[++i], look_at);
486 if (f_v) {
487 cout << "-look_at "
488 << look_at[0] << " " << look_at[1] << " " << look_at[2] << " " << endl;
489 }
490 }
491
492 else if (ST.stringcmp(argv[i], "-default_angle") == 0) {
494 default_angle = ST.strtoi(argv[++i]);
495 if (f_v) {
496 cout << "-default_angle " << default_angle << endl;
497 }
498 }
499 else if (ST.stringcmp(argv[i], "-clipping_radius") == 0) {
501 clipping_radius = ST.strtof(argv[++i]);
502 if (f_v) {
503 cout << "-clipping_radius " << clipping_radius << endl;
504 }
505 }
506 else if (ST.stringcmp(argv[i], "-scale_factor") == 0) {
508 scale_factor = ST.strtof(argv[++i]);
509 if (f_v) {
510 cout << "-scale_factor " << scale_factor << endl;
511 }
512 }
513 else if (ST.stringcmp(argv[i], "-line_radius") == 0) {
515 line_radius = ST.strtof(argv[++i]);
516 if (f_v) {
517 cout << "-line_radius " << line_radius << endl;
518 }
519 }
520 else if (ST.stringcmp(argv[i], "-end") == 0) {
521 if (f_v) {
522 cout << "-end" << endl;
523 }
524 break;
525 }
526 else {
527 cout << "video_draw_options::read_arguments "
528 "unrecognized option " << argv[i] << endl;
529 exit(1);
530 }
531 }
532 if (f_v) {
533 cout << "video_draw_options::read_arguments done" << endl;
534 }
535 return i + 1;
536}
537
538
540{
541 if (f_rotate == FALSE) {
542 cout << "-do_not_rotate " << endl;
543 }
544 if (f_rotate && rotation_axis_type == 2) {
545 cout << "-rotate_about_z_axis " << endl;
546 }
547 if (f_rotate && rotation_axis_type == 1) {
548 cout << "-rotate_about_111 " << endl;
549 }
550 if (f_rotate && rotation_axis_type == 3) {
551 cout << "-rotate_about_custom_axis " << endl;
552 }
553 if (boundary_type == 3) {
554 cout << "-boundary_none " << endl;
555 }
556 if (boundary_type == 2) {
557 cout << "-boundary_box " << endl;
558 }
559 if (boundary_type == 1) {
560 cout << "-boundary_sphere " << endl;
561 }
562 if (f_has_font_size) {
563 cout << "-font_size " << font_size << endl;
564 }
565 if (f_has_stroke_width) {
566 cout << "-stroke_width " << stroke_width << endl;
567 }
569 cout << "-omit_bottom_plane " << endl;
570 }
571
572 if (f_W) {
573 cout << "-W " << W << endl;
574 }
575 if (f_H) {
576 cout << "-H " << H << endl;
577 }
578 for (int i = 0; i < cnt_nb_frames; i++) {
579 cout << "-nb_frames "
580 << nb_frames_round[i] << " "
581 << nb_frames_value[i] << endl;
582 }
583 for (int i = 0; i < nb_zoom; i++) {
584 cout << "-zoom "
585 << zoom_round[i] << " "
586 << zoom_start[i] << " "
587 << zoom_end[i] << " "
588 << zoom_clipping_start[i] << " "
589 << zoom_clipping_end[i] << " "
590 << endl;
591 }
592 for (int i = 0; i < nb_zoom_sequence; i++) {
593 cout << "-zoom_sequence "
594 << zoom_sequence_round[i] << " "
595 << zoom_sequence_text[i] << endl;
596 }
597 for (int i = 0; i < nb_pan; i++) {
598 if (pan_f_reverse[nb_pan]) {
599 numerics Num;
600 cout << "-pan_reverse "
601 << pan_round[i];
602 cout << " ";
603 Num.vec_print(pan_from + 3 * i, 3);
604 cout << " ";
605 Num.vec_print(pan_to + 3 * i, 3);
606 cout << " ";
607 Num.vec_print(pan_center + 3 * i, 3);
608 cout << endl;
609
610 }
611 else {
612 numerics Num;
613 cout << "-pan "
614 << pan_round[i];
615 cout << " ";
616 Num.vec_print(pan_from + 3 * i, 3);
617 cout << " ";
618 Num.vec_print(pan_to + 3 * i, 3);
619 cout << " ";
620 Num.vec_print(pan_center + 3 * i, 3);
621 cout << endl;
622 }
623 }
624 for (int i = 0; i < nb_no_background; i++) {
625 cout << "-no_background "
626 << no_background_round[i] << endl;
627 }
628 for (int i = 0; i < nb_no_bottom_plane; i++) {
629 cout << "-no_bottom_plane "
630 << no_bottom_plane_round[i] << endl;
631 }
632 for (int i = 0; i < nb_camera; i++) {
633 cout << "-camera "
634 << camera_round[i] << " "
635 << camera_sky[i * 3 + 0] << " "
636 << camera_sky[i * 3 + 1] << " "
637 << camera_sky[i * 3 + 2] << " "
638 << camera_location[i * 3 + 0] << " "
639 << camera_location[i * 3 + 1] << " "
640 << camera_location[i * 3 + 2] << " "
641 << camera_look_at[i * 3 + 0] << " "
642 << camera_look_at[i * 3 + 1] << " "
643 << camera_look_at[i * 3 + 2] << " "
644 << endl;
645 }
646 for (int i = 0; i < nb_clipping; i++) {
647 cout << "-clipping "
648 << clipping_round[i] << " "
649 << clipping_value[i] << endl;
650 }
651 for (int i = 0; i < nb_round_text; i++) {
652 cout << "-text "
653 << round_text_round[i] << " "
654 << round_text_sustain[i] << " "
655 << round_text_text[i] << endl;
656 }
657 for (int i = 0; i < nb_label; i++) {
658 cout << "-label "
659 << label_round[i] << " "
660 << label_start[i] << " "
661 << label_sustain[i] << " "
662 << label_gravity[i] << " "
663 << label_text[i] << " "
664 << endl;
665 }
666 for (int i = 0; i < nb_latex_label; i++) {
667 cout << "-latex "
668 << latex_label_round[i] << " "
669 << latex_label_start[i] << " "
670 << latex_label_sustain[i] << " "
671 << latex_extras_for_praeamble[i] << " "
672 << latex_label_gravity[i] << " "
673 << latex_label_text[i] << " "
674 << endl;
675 }
677 cout << "-global_picture_scale " << global_picture_scale << endl;
678 }
679 for (int i = 0; i < nb_picture; i++) {
680 cout << "-picture "
681 << picture_round[i] << " "
682 << picture_scale[i] << " "
683 << picture_fname[i] << " "
684 << picture_options[i] << " "
685 << endl;
686 }
687 if (f_look_at) {
688 cout << "-look_at "
689 << look_at[0] << " " << look_at[1] << " " << look_at[2] << " " << endl;
690 }
691
692 if (f_default_angle) {
693 cout << "-default_angle " << default_angle << endl;
694 }
695 if (f_clipping_radius) {
696 cout << "-clipping_radius " << clipping_radius << endl;
697 }
698 if (f_scale_factor) {
699 cout << "-scale_factor " << scale_factor << endl;
700 }
701 if (f_line_radius) {
702 cout << "-line_radius " << line_radius << endl;
703 }
704}
705
706
707
708
709}}}
710
711
functions related to strings and character arrays
int read_arguments(int argc, std::string *argv, int verbose_level)
numerical functions, mostly concerned with double
Definition: globals.h:129
void vec_print(double *a, int len)
Definition: numerics.cpp:35
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
the orbiter library for the classification of combinatorial objects