Simple test for asyncio.library.
[AROS-Contrib.git] / gfx / povray / optout.c
blob86e13b274902c79b5893b4fb5e49b280e5edc903
1 /****************************************************************************
2 * optout.c
4 * This module contains functions for credit, usage, options and stats.
6 * from Persistence of Vision(tm) Ray Tracer
7 * Copyright 1996,1999 Persistence of Vision Team
8 *---------------------------------------------------------------------------
9 * NOTICE: This source code file is provided so that users may experiment
10 * with enhancements to POV-Ray and to port the software to platforms other
11 * than those supported by the POV-Ray Team. There are strict rules under
12 * which you are permitted to use this file. The rules are in the file
13 * named POVLEGAL.DOC which should be distributed with this file.
14 * If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
15 * Team Coordinator by email to team-coord@povray.org or visit us on the web at
16 * http://www.povray.org. The latest version of POV-Ray may be found at this site.
18 * This program is based on the popular DKB raytracer version 2.12.
19 * DKBTrace was originally written by David K. Buck.
20 * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
22 *****************************************************************************/
24 #include <ctype.h>
25 #include <time.h>
26 #include "frame.h"
27 #include "vector.h"
28 #include "povproto.h"
29 #include "atmosph.h"
30 #include "bezier.h"
31 #include "blob.h"
32 #include "bbox.h"
33 #include "cones.h"
34 #include "csg.h"
35 #include "discs.h"
36 #include "fractal.h"
37 #include "hfield.h"
38 #include "lathe.h"
39 #include "lighting.h"
40 #include "mesh.h"
41 #include "polysolv.h"
42 #include "objects.h"
43 #include "parse.h"
44 #include "point.h"
45 #include "poly.h"
46 #include "polygon.h"
47 #include "octree.h"
48 #include "quadrics.h"
49 #include "pgm.h"
50 #include "ppm.h"
51 #include "prism.h"
52 #include "radiosit.h"
53 #include "render.h"
54 #include "sor.h"
55 #include "spheres.h"
56 #include "super.h"
57 #include "targa.h"
58 #include "texture.h"
59 #include "torus.h"
60 #include "triangle.h"
61 #include "truetype.h"
62 #include "userio.h"
63 #include "lbuffer.h"
64 #include "vbuffer.h"
65 #include "povray.h"
66 #include "optin.h"
67 #include "optout.h"
71 /*****************************************************************************
72 * Local preprocessor defines
73 ******************************************************************************/
75 #define NUMBER_LENGTH 19
76 #define OUTPUT_LENGTH 15
78 #define NUMBER_OF_AUTHORS_ACROSS 4
81 /*****************************************************************************
82 * Local typedefs
83 ******************************************************************************/
87 /*****************************************************************************
88 * Local variables
89 ******************************************************************************/
91 static char numbers[64][20] =
93 "0000000000000000001",
94 "0000000000000000002",
95 "0000000000000000004",
96 "0000000000000000008",
97 "0000000000000000016",
98 "0000000000000000032",
99 "0000000000000000064",
100 "0000000000000000128",
101 "0000000000000000256",
102 "0000000000000000512",
103 "0000000000000001024",
104 "0000000000000002048",
105 "0000000000000004096",
106 "0000000000000008192",
107 "0000000000000016384",
108 "0000000000000032768",
109 "0000000000000065536",
110 "0000000000000131072",
111 "0000000000000262144",
112 "0000000000000524288",
113 "0000000000001048576",
114 "0000000000002097152",
115 "0000000000004194304",
116 "0000000000008388608",
117 "0000000000016777216",
118 "0000000000033554432",
119 "0000000000067108864",
120 "0000000000134217728",
121 "0000000000268435456",
122 "0000000000536870912",
123 "0000000001073741824",
124 "0000000002147483648",
125 "0000000004294967296",
126 "0000000008589934592",
127 "0000000017179869184",
128 "0000000034359738368",
129 "0000000068719476736",
130 "0000000137438953472",
131 "0000000274877906944",
132 "0000000549755813888",
133 "0000001099511627776",
134 "0000002199023255552",
135 "0000004398046511104",
136 "0000008796093022208",
137 "0000017592186044416",
138 "0000035184372088832",
139 "0000070368744177664",
140 "0000140737488355328",
141 "0000281474976710656",
142 "0000562949953421312",
143 "0001125899906842624",
144 "0002251799813685248",
145 "0004503599627370496",
146 "0009007199254740992",
147 "0018014398509481984",
148 "0036028797018963968",
149 "0072057594037927936",
150 "0144115188075855872",
151 "0288230376151711744",
152 "0576460752303423488",
153 "1152921504606846976",
154 "2305843009213693952",
155 "4611686018427387904",
156 "9223372036854775808"
159 static char s1[OUTPUT_LENGTH], s2[OUTPUT_LENGTH];
161 char *Primary_Developers[] =
163 "Steve Anger",
164 "Dieter Bayer",
165 "Chris Cason",
166 "Chris Dailey",
167 "Andreas Dilger",
168 "Steve Demlow",
169 "Alexander Enzmann",
170 "Dan Farmer",
171 "Timothy Wegner",
172 "Chris Young",
173 NULL /* NULL flags the end of the list */
176 char *Contributing_Authors[] =
178 "Steve A. Bennett",
179 "David K. Buck",
180 "Aaron A. Collins",
181 "Pascal Massimino",
182 "Jim McElhiney",
183 "Douglas Muir",
184 "Bill Pulver",
185 "Robert Skinner",
186 "Zsolt Szalavari",
187 "Scott Taylor",
188 "Drew Wells",
189 NULL /* NULL flags the end of the list */
193 /*****************************************************************************
194 * Static functions
195 ******************************************************************************/
197 static void rinfo_on (char *string, unsigned value);
198 static void add_numbers (char *result, char *c1, char *c2);
199 static void counter_to_string (COUNTER *counter, char *string, int len);
200 static void print_intersection_stats (char *text, COUNTER *tests, COUNTER *succeeded);
204 /*****************************************************************************
206 * FUNCTION
208 * add_numbers
210 * INPUT
212 * OUTPUT
214 * RETURNS
216 * AUTHOR
218 * Dieter Bayer
220 * DESCRIPTION
222 * Add two decimal numbers stored in ASCII strings.
224 * CHANGES
226 * Mar 1995 : Creation
228 ******************************************************************************/
230 static void add_numbers(char *result, char *c1, char *c2)
232 int i;
233 char carry, x;
235 carry = '0';
237 for (i = NUMBER_LENGTH-1; i >= 0; i--)
239 x = c1[i] + c2[i] + carry - '0' - '0';
241 if (x > '9')
243 carry = '1';
245 result[i] = x - 10;
247 else
249 carry = '0';
251 result[i] = x;
258 /*****************************************************************************
260 * FUNCTION
262 * counter_to_string
264 * INPUT
266 * OUTPUT
268 * RETURNS
270 * AUTHOR
272 * Dieter Bayer
274 * DESCRIPTION
276 * Convert a low/high precision counter into a decimal number.
278 * CHANGES
280 * Mar 1995 : Creation
282 ******************************************************************************/
284 static void counter_to_string(COUNTER *counter, char *string, int len)
286 char n[NUMBER_LENGTH+1];
287 int i, j;
288 COUNTER c;
290 c = *counter;
292 for (i = 0; i < NUMBER_LENGTH; i++)
294 n[i] = '0';
297 n[NUMBER_LENGTH] = '\0';
299 #if COUNTER_RESOLUTION == HIGH_RESOLUTION
301 for (i = 0; i < 32; i++)
303 if (c.low & 1)
305 add_numbers(n, n, numbers[i]);
308 c.low >>= 1;
311 for (i = 32; i < 64; i++)
313 if (c.high & 1)
315 add_numbers(n, n, numbers[i]);
318 c.high >>= 1;
321 #else
323 for (i = 0; i < 32; i++)
325 if (c & 1)
327 add_numbers(n, n, numbers[i]);
330 c >>= 1;
333 #endif
335 /* Replace leading zeros. */
337 for (i = 0; i < NUMBER_LENGTH-1; i++)
339 if (n[i] == '0')
341 n[i] = ' ';
343 else
345 break;
349 /* Copy number into result string. */
351 if (i >= NUMBER_LENGTH-len)
353 for (j = 0; j < i-NUMBER_LENGTH+len-1; j++)
355 string[j] = ' ';
358 string[j] = '\0';
360 string = strcat(string, &n[i]);
362 else
364 /* Print numbers that don't fit into output string in million units. */
366 string = "";
368 n[NUMBER_LENGTH-6] = 'm';
369 n[NUMBER_LENGTH-5] = '\0';
371 string = strcat(string, &n[NUMBER_LENGTH-len+1-6]);
377 /*****************************************************************************
379 * FUNCTION
381 * print_intersections_stats
383 * INPUT
385 * OUTPUT
387 * RETURNS
389 * AUTHOR
391 * Dieter Bayer
393 * DESCRIPTION
397 * CHANGES
399 * Mar 1995 : Creation
401 ******************************************************************************/
403 static void print_intersection_stats(char *text, COUNTER *tests, COUNTER *succeeded)
405 DBL t, s, p;
407 if (!Test_Zero_Counter(*tests))
409 t = DBL_Counter(*tests);
410 s = DBL_Counter(*succeeded);
412 p = 100.0 * s / t;
414 counter_to_string(tests, s1, OUTPUT_LENGTH);
415 counter_to_string(succeeded, s2, OUTPUT_LENGTH);
417 Statistics("%-22s %s %s %8.2f\n", text, s1, s2, p);
423 /*****************************************************************************
425 * FUNCTION
427 * rinfo_on
429 * INPUT
431 * OUTPUT
433 * RETURNS
435 * AUTHOR
437 * POV-Ray Team
439 * DESCRIPTION
443 * CHANGES
447 ******************************************************************************/
449 static void rinfo_on(char *string, unsigned value)
451 if (value)
453 Render_Info("%s.On",(string));
455 else
457 Render_Info("%sOff",(string));
463 /*****************************************************************************
465 * FUNCTION
467 * Print_Credits
469 * INPUT
471 * OUTPUT
473 * RETURNS
475 * AUTHOR
477 * POV-Ray Team
479 * DESCRIPTION
483 * CHANGES
487 ******************************************************************************/
489 void Print_Credits()
491 Banner ("Persistence of Vision(tm) Ray Tracer Version %s%s\n", POV_RAY_VERSION, COMPILER_VER);
492 Banner (" %s\n", DISTRIBUTION_MESSAGE_1);
493 Banner (" %s\n", DISTRIBUTION_MESSAGE_2);
494 Banner (" %s\n", DISTRIBUTION_MESSAGE_3);
495 Banner ("Copyright 1999 POV-Ray Team(tm)\n");
500 /*****************************************************************************
502 * FUNCTION
504 * Print_Help_Screens
506 * INPUT
508 * OUTPUT
510 * RETURNS
512 * AUTHOR
514 * Dieter Bayer
516 * DESCRIPTION
518 * Print all help screens. Use an interactive menu if GET_KEY exists.
520 * CHANGES
522 * Apr 1995 : Creation.
524 ******************************************************************************/
526 void Print_Help_Screens()
528 #ifdef GET_KEY_EXISTS
529 char c;
530 int n, x, ok;
532 Usage(-1, FALSE);
534 for (n = 0; ; )
536 Banner("\n");
537 Banner("[ Press 0 for general help, 1 to %d for help screen. Press 'q' to quit. ]", MAX_HELP_PAGE);
541 ok = FALSE;
543 GET_KEY(x);
545 c = (char)x;
547 if ((c >= '0') && (c <= '0' + MAX_HELP_PAGE))
549 ok = TRUE;
551 n = (int)c - (int)'0';
553 else
555 if ((c == 'q') || (c == 'Q'))
557 ok = TRUE;
561 while(!ok);
563 Banner("\n");
565 if ((c == 'q') || (c == 'Q'))
567 break;
570 Usage(n, FALSE);
573 #else
574 int n;
576 for (n = -1; n <= MAX_HELP_PAGE; n++)
578 Usage(n, (n == MAX_HELP_PAGE));
580 #endif
581 Terminate_POV(0);
586 /*****************************************************************************
588 * FUNCTION
590 * Usage
592 * INPUT
594 * n - Number of usage screen
595 * f - Flag to terminate
597 * OUTPUT
599 * RETURNS
601 * AUTHOR
603 * POV-Ray Team
605 * DESCRIPTION
607 * Print out usage messages.
609 * CHANGES
611 * Dec 1994 : Changed to show options depending on parameter n. [DB]
613 * Feb 1995 : Changed to terminate only if f != 0. [DB]
615 ******************************************************************************/
617 void Usage(int n, int f)
619 switch (n)
621 /* Help screen. */
623 case 0:
625 Banner("\n");
626 Banner("Usage: POVRAY [+/-]Option1 [+/-]Option2 ... (-h or -? for help)\n");
627 Banner("\n");
628 Banner(" Example: POVRAY scene.ini +Iscene.pov +Oscene.tga +W320 +H200\n");
629 Banner(" Example: POVRAY +Iscene.pov +Oscene.tga +W160 +H200 +V -D +X\n");
630 Banner("\n");
631 Banner("The help screen is divided into several parts. To access one part\n");
632 Banner("just enter the number of the screen after the -h or -? option.\n");
633 Banner("\n");
634 Banner("E.g. use -h5 to see the help screen about the tracing options.\n");
635 Banner("\n");
636 Banner(" Number Part\n");
637 Banner(" 1 Parsing Options\n");
638 Banner(" 2 Output Options\n");
639 Banner(" 3 Output Options - display related\n");
640 Banner(" 4 Output Options - file related\n");
641 Banner(" 5 Tracing Options\n");
642 Banner(" 6 Animation Options\n");
643 Banner(" 7 Redirecting Options\n");
645 break;
647 /* Parsing options. */
649 case 1:
651 Banner("\n");
652 Banner("Parsing options\n");
653 Banner("\n");
654 Banner(" I<name> = input file name\n");
655 Banner(" L<name> = library path prefix\n");
656 Banner(" MVn.n = set compability to version n.n\n");
657 Banner(" SU = split bounded unions if children are finite\n");
658 Banner(" UR = remove unnecessary bounding objects\n");
660 break;
662 /* Output options. */
664 case 2:
666 Banner("\n");
667 Banner("Output options\n");
668 Banner("\n");
669 Banner(" Hnnn = image height\n");
670 Banner(" Wnnn = image width\n");
671 Banner("\n");
672 Banner(" SRnn = start at row nn | SR0.nn start row at nn percent of screen\n");
673 Banner(" ERnn = end at row nn | ER0.nn end row at nn percent of screen\n");
674 Banner(" SCnn = start at col nn | SC0.nn start col at nn percent of screen\n");
675 Banner(" ECnn = end at col nn | EC0.nn end col at nn percent of screen\n");
676 Banner("\n");
677 Banner(" C = continue aborted trace\n");
678 Banner(" P = pause before exit\n");
679 Banner(" V = verbose messages on\n");
680 Banner(" Xnnn = enable early exit by key hit (every nnn pixels)\n");
682 break;
684 case 3:
686 Banner("\n");
687 Banner("Output options - display related\n");
688 Banner("\n");
689 Banner(" Dxy = display in format x, using palette option y\n");
690 Banner(" SPnnn = Mosaic Preview display, Start grid size = 2, 4, 8, 16, ...\n");
691 Banner(" EPnnn = Mosaic Preview display, End grid size = 2, 4, 8, 16, ...\n");
692 Banner(" UD = draw vista rectangles\n");
694 break;
696 /* Output options - file related. */
698 case 4:
700 Banner("\n");
701 Banner("Output options - file related\n");
702 Banner("\n");
703 Banner(" Bnnn = Use nnn KB for output file buffer\n");
704 Banner(" Fx = write output file in format x\n");
705 Banner(" FC - Compressed Targa with 24 or 32 bpp\n");
706 Banner(" FNn - PNG (n bits/color, n = 5 to 16, default is 8)\n");
707 Banner(" FP - PPM\n");
708 Banner(" FS - System specific\n");
709 Banner(" FT - Uncompressed Targa with 24 or 32 bpp\n");
710 Banner(" O<name> = output file name\n");
711 #if PRECISION_TIMER_AVAILABLE
712 Banner("\n");
713 Banner(" HTx = write CPU utilization histogram in format x\n");
714 Banner(" HTC - Comma separated values (CSV - spreadsheet)\n");
715 Banner(" HTN - PNG grayscale\n");
716 Banner(" HTP - PPM heightfield\n");
717 Banner(" HTS - System specific\n");
718 Banner(" HTT - Uncompressed TGA heightfield\n");
719 Banner(" HTX - No histogram output\n");
720 Banner(" HN<name>= histogram filename\n");
721 Banner(" HSx.y = histogram grid number of x, y divisions\n");
722 #endif
724 break;
726 /* Tracing options. */
728 case 5:
730 Banner("\n");
731 Banner("Tracing options\n");
732 Banner("\n");
733 Banner(" MBnnn = use slabs if more than nnn objects\n");
734 Banner(" Qn = image quality (0 = rough, 9 = full, R = radiosity)\n");
735 Banner(" QR = enable radiosity calculations for ambient light\n");
736 Banner("\n");
737 Banner(" A0.n = perform antialiasing\n");
738 Banner(" AMn = use non-adaptive (n=1) or adaptive (n=2) supersampling\n");
739 Banner(" Jn.n = set antialiasing-jitter amount\n");
740 Banner(" Rn = set antialiasing-depth (use n X n rays/pixel)\n");
741 Banner("\n");
742 Banner(" UL = use light buffer\n");
743 Banner(" UV = use vista buffer\n");
745 break;
747 /* Animation options. */
749 case 6:
751 Banner("\n");
752 Banner("Animation options\n");
753 Banner("\n");
754 Banner(" Kn.n = set frame clock to n.n\n");
755 Banner(" KFInnn = Initial frame number\n");
756 Banner(" KFFnnn = Final frame number\n");
757 Banner(" KInnn.nn = Initial clock value\n");
758 Banner(" KFnnn.nn = Final clock value\n");
759 Banner(" SFnn = Start subset at frame nn\n");
760 Banner(" SF0.nn = Start subset nn percent into sequence\n");
761 Banner(" EFnn = End subset at frame nn\n");
762 Banner(" EF0.n = End subset nn percent into sequence\n");
763 Banner(" KC = Calculate clock value for cyclic animation\n");
764 Banner("\n");
765 Banner(" UF = use field rendering\n");
766 Banner(" UO = use odd lines in odd frames\n");
768 break;
770 /* Redirecting options. */
772 case 7:
774 Banner("\n");
775 Banner("Redirecting options\n");
776 Banner("\n");
777 Banner(" GI<name>= write all .INI parameters to file name\n");
778 Banner(" Gx<name>= write stream x to console and/or file name\n");
779 Banner(" GA - All streams (except status)\n");
780 Banner(" GD - Debug stream\n");
781 Banner(" GF - Fatal stream\n");
782 Banner(" GR - Render stream\n");
783 Banner(" GS - Statistics stream\n");
784 Banner(" GW - Warning stream\n");
786 break;
788 /* Usage ... */
790 default:
792 Print_Authors();
795 #if defined(WAIT_FOR_KEYPRESS_EXISTS) && !defined(GET_KEY_EXISTS)
796 Banner("\n");
797 Banner("[ Paused for keypress... ]");
799 WAIT_FOR_KEYPRESS;
801 Banner("\n");
802 #endif
804 if (f)
806 Terminate_POV(0);
811 void Print_Authors()
813 int h, i, j;
815 Banner("\n");
816 Banner("POV-Ray is based on DKBTrace 2.12 by David K. Buck & Aaron A. Collins.\n");
817 Banner("\n");
818 Banner("Primary POV-Ray 3 Developers: (Alphabetically)\n");
820 for (i = h = 0; Primary_Developers[h] != NULL; i++)
822 for (j = 0; (j < NUMBER_OF_AUTHORS_ACROSS) && (Primary_Developers[h] != NULL); j++)
824 Banner(" %-18s", Primary_Developers[h++]);
827 Banner("\n");
830 Banner("\n");
831 Banner("Major Contributing Authors: (Alphabetically)\n");
833 for (i = h = 0; Contributing_Authors[h] != NULL; i++)
835 for (j = 0; (j < NUMBER_OF_AUTHORS_ACROSS) && (Contributing_Authors[h] != NULL); j++)
837 Banner(" %-18s", Contributing_Authors[h++]);
840 Banner("\n");
843 Banner("\n");
844 Banner("Other contributors listed in the documentation.\n");
848 /*****************************************************************************
850 * FUNCTION
852 * Print_Options
854 * INPUT
856 * OUTPUT
858 * RETURNS
860 * AUTHOR
862 * POV-Ray Team
864 * DESCRIPTION
868 * CHANGES
872 ******************************************************************************/
874 void Print_Options()
876 int i, j;
878 /* Print parsing options. */
880 Render_Info("Parsing Options\n");
882 Render_Info(" Input file: %s", opts.Input_File_Name);
883 Render_Info(" (compatible to version %.1f)\n", opts.Language_Version);
885 rinfo_on (" Remove bounds.......", (opts.Options & REMOVE_BOUNDS));
886 rinfo_on (" Split unions........", (opts.Options & SPLIT_UNION));
887 Render_Info("\n");
889 j = 17;
891 Render_Info(" Library paths:");
893 for (i = 0; i < opts.Library_Path_Index; i++)
895 j += strlen(opts.Library_Paths[i])+2;
897 if (j > 77)
899 Render_Info("\n ", j);
901 j = strlen(opts.Library_Paths[i]) + 5;
904 Render_Info(" %s", opts.Library_Paths[i]);
907 Render_Info("\n");
909 /* Print output options. */
911 Render_Info("Output Options\n");
913 Render_Info(" Image resolution %d by %d",
914 Frame.Screen_Width, Frame.Screen_Height);
915 Render_Info(" (rows %d to %d, columns %d to %d).\n",
916 opts.First_Line+1, opts.Last_Line,
917 opts.First_Column+1, opts.Last_Column);
919 if (opts.Options & DISKWRITE)
921 Render_Info(" Output file: %s%s, ", opts.Output_Path, opts.Output_File_Name);
923 if (toupper(opts.OutputFormat) == 'N' && opts.Options & HF_GRAY_16)
925 Render_Info("%d bpp ", opts.OutputQuality);
927 else
929 Render_Info("%d bpp ", ((opts.Options & OUTPUT_ALPHA) ? 4 : 3) * opts.OutputQuality);
932 switch (toupper(opts.OutputFormat))
934 case 'C': Render_Info("RLE Targa"); break;
935 case 'N': Render_Info("PNG"); break;
936 case 'P': Render_Info("PPM"); break;
937 case 'S': Render_Info("(system format)"); break;
938 case 'T': Render_Info("Targa"); break;
941 if (opts.Options & HF_GRAY_16)
943 if (toupper(opts.OutputFormat) == 'N')
945 Render_Info(" grayscale");
947 else if (opts.Options & HF_GRAY_16)
949 Render_Info(" POV heightfield");
953 if (opts.Options & OUTPUT_ALPHA)
955 Render_Info(" with alpha");
958 if ((opts.Options & BUFFERED_OUTPUT) && (opts.File_Buffer_Size != 0))
960 Render_Info(", %d KByte buffer\n", opts.File_Buffer_Size/1024);
962 else
964 Render_Info("\n");
967 else if (opts.Options & DISPLAY)
969 if (opts.histogram_on == TRUE)
971 Warning(0.0, " Rendering to screen and histogram file only.\n");
973 else
975 Warning(0.0, " Rendering to screen only. No file output.\n");
978 else if (opts.histogram_on == TRUE)
980 Warning(0.0, " Rendering to histogram file only.\n");
982 else
984 Warning(0.0, " Rendering to nothing! No screen or file output.\n");
987 rinfo_on (" Graphic display.....", (opts.Options & DISPLAY));
988 if (opts.Options & DISPLAY)
990 Render_Info(" (type: %c, palette: %c, gamma: %4.2g)",
991 toupper(opts.DisplayFormat), toupper(opts.PaletteOption),
992 opts.DisplayGamma);
994 Render_Info("\n");
996 rinfo_on (" Mosaic preview......", (opts.Options & PREVIEW));
997 if (opts.Options & PREVIEW)
999 Render_Info(" (pixel sizes %d to %d)",
1000 opts.PreviewGridSize_Start, opts.PreviewGridSize_End);
1002 Render_Info("\n");
1004 #if PRECISION_TIMER_AVAILABLE
1005 rinfo_on (" CPU usage histogram.", opts.histogram_on);
1006 if (opts.histogram_on)
1008 char *type;
1010 switch (opts.histogram_type)
1012 case CSV: type = "CSV"; break;
1013 case TARGA: type = "TGA"; break;
1014 case PNG: type = "PNG"; break;
1015 case PPM: type = "PPM"; break;
1016 case SYS: type = "(system format)"; break;
1017 case NONE: /* Just to stop warning messages */
1018 default: type = "None"; break;
1021 Render_Info(" (name: %s type: %s, grid: %dx%d)",
1022 opts.Histogram_File_Name,type,opts.histogram_x,opts.histogram_y);
1024 Render_Info("\n");
1025 #endif /* PRECISION_TIMER_AVAILABLE */
1027 rinfo_on (" Continued trace.....", (opts.Options & CONTINUE_TRACE));
1028 rinfo_on (" Allow interruption..", (opts.Options & EXITENABLE));
1029 rinfo_on (" Pause when done.....", (opts.Options & PROMPTEXIT));
1030 Render_Info("\n");
1032 rinfo_on (" Verbose messages....", (opts.Options & VERBOSE));
1034 Render_Info("\n");
1036 /* Print tracing options. */
1038 Render_Info("Tracing Options\n");
1040 Render_Info(" Quality: %2d\n", opts.Quality);
1042 rinfo_on (" Bounding boxes......", opts.Use_Slabs);
1043 if (opts.Use_Slabs)
1045 Render_Info(" Bounding threshold: %d ", opts.BBox_Threshold);
1047 Render_Info("\n");
1049 rinfo_on(" Light Buffer........", (opts.Options & USE_LIGHT_BUFFER));
1050 rinfo_on(" Vista Buffer........", (opts.Options & USE_VISTA_BUFFER));
1051 if (opts.Options & USE_VISTA_BUFFER && opts.Options & DISPLAY)
1053 rinfo_on(" Draw Vista Buffer...", (opts.Options & USE_VISTA_DRAW));
1055 Render_Info("\n");
1057 rinfo_on (" Antialiasing........", (opts.Options & ANTIALIAS));
1058 if (opts.Options & ANTIALIAS)
1060 Render_Info(" (Method %d, ", opts.Tracing_Method);
1061 Render_Info("Threshold %.3f, ", opts.Antialias_Threshold);
1062 Render_Info("Depth %ld, ", opts.AntialiasDepth);
1063 Render_Info("Jitter %.2f)", opts.JitterScale);
1065 Render_Info("\n");
1067 rinfo_on (" Radiosity...........", (opts.Options & RADIOSITY));
1069 Render_Info("\n");
1071 /* Print animation options. */
1073 Render_Info("Animation Options\n");
1075 if (opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME)
1077 Render_Info(" Initial Frame..%8d", opts.FrameSeq.InitialFrame);
1078 Render_Info(" Final Frame....%8d\n", opts.FrameSeq.FinalFrame);
1079 Render_Info(" Initial Clock..%8.3f", opts.FrameSeq.InitialClock);
1080 Render_Info(" Final Clock....%8.3f\n", opts.FrameSeq.FinalClock);
1081 rinfo_on (" Cyclic Animation....", (opts.Options & CYCLIC_ANIMATION));
1082 rinfo_on (" Field render........", (opts.FrameSeq.Field_Render_Flag));
1083 rinfo_on (" Odd lines/frames....", (opts.FrameSeq.Odd_Field_Flag));
1085 else
1087 Render_Info(" Clock value....%8.3f", opts.FrameSeq.Clock_Value);
1088 Render_Info(" (Animation off)");
1091 Render_Info("\n");
1093 /* Print redirecting options. */
1095 Render_Info("Redirecting Options\n");
1097 rinfo_on (" All Streams to console.........", Stream_Info[ALL_STREAM].do_console);
1098 if (Stream_Info[ALL_STREAM].name == NULL)
1100 Render_Info("\n");
1102 else
1104 Render_Info(" and file %s\n", Stream_Info[ALL_STREAM].name);
1107 rinfo_on (" Debug Stream to console........", Stream_Info[DEBUG_STREAM].do_console);
1108 if (Stream_Info[DEBUG_STREAM].name == NULL)
1110 Render_Info("\n");
1112 else
1114 Render_Info(" and file %s\n", Stream_Info[DEBUG_STREAM].name);
1117 rinfo_on (" Fatal Stream to console........", Stream_Info[FATAL_STREAM].do_console);
1118 if (Stream_Info[FATAL_STREAM].name == NULL)
1120 Render_Info("\n");
1122 else
1124 Render_Info(" and file %s\n", Stream_Info[FATAL_STREAM].name);
1127 rinfo_on (" Render Stream to console.......", Stream_Info[RENDER_STREAM].do_console);
1128 if (Stream_Info[RENDER_STREAM].name == NULL)
1130 Render_Info("\n");
1132 else
1134 Render_Info(" and file %s\n", Stream_Info[RENDER_STREAM].name);
1137 rinfo_on (" Statistics Stream to console...", Stream_Info[STATISTIC_STREAM].do_console);
1138 if (Stream_Info[STATISTIC_STREAM].name == NULL)
1140 Render_Info("\n");
1142 else
1144 Render_Info(" and file %s\n", Stream_Info[STATISTIC_STREAM].name);
1147 rinfo_on (" Warning Stream to console......", Stream_Info[WARNING_STREAM].do_console);
1148 if (Stream_Info[WARNING_STREAM].name == NULL)
1150 Render_Info("\n");
1152 else
1154 Render_Info(" and file %s\n", Stream_Info[WARNING_STREAM].name);
1160 /*****************************************************************************
1162 * FUNCTION
1164 * Print_Stats
1166 * INPUT
1168 * OUTPUT
1170 * RETURNS
1172 * AUTHOR
1174 * POV-Ray Team
1176 * DESCRIPTION
1180 * CHANGES
1184 ******************************************************************************/
1186 void Print_Stats(COUNTER *pstats)
1188 unsigned long hours, minutes;
1189 DBL seconds, taverage, ttotal;
1190 long Pixels_In_Image;
1192 Pixels_In_Image = (long)Frame.Screen_Width * (long)Frame.Screen_Height;
1194 Statistics ("\n%s Statistics", opts.Input_File_Name);
1196 if ( Pixels_In_Image > DBL_Counter(pstats[Number_Of_Pixels]) )
1197 Statistics (" (Partial Image Rendered)");
1199 Statistics (", Resolution %d x %d\n", Frame.Screen_Width, Frame.Screen_Height);
1201 Statistics ("----------------------------------------------------------------------------\n");
1203 Statistics ("Pixels: %15.0f Samples: %15.0f Smpls/Pxl: ",
1204 DBL_Counter(pstats[Number_Of_Pixels]),
1205 DBL_Counter(pstats[Number_Of_Samples]));
1207 if (!Test_Zero_Counter(pstats[Number_Of_Pixels]))
1209 Statistics ("%.2f\n",
1210 DBL_Counter(pstats[Number_Of_Samples]) /
1211 DBL_Counter(pstats[Number_Of_Pixels]));
1213 else
1215 Statistics ("-\n");
1218 counter_to_string(&pstats[Number_Of_Rays], s1, OUTPUT_LENGTH);
1219 counter_to_string(&pstats[ADC_Saves], s2, OUTPUT_LENGTH);
1221 Statistics ("Rays: %s Saved: %s Max Level: %d/%d\n",
1222 s1, s2, Highest_Trace_Level, Max_Trace_Level);
1224 Statistics ("----------------------------------------------------------------------------\n");
1226 Statistics ("Ray->Shape Intersection Tests Succeeded Percentage\n");
1227 Statistics ("----------------------------------------------------------------------------\n");
1229 print_intersection_stats("Bezier Patch", &pstats[Ray_Bicubic_Tests],
1230 &pstats[Ray_Bicubic_Tests_Succeeded]);
1232 print_intersection_stats("Blob", &pstats[Ray_Blob_Tests],
1233 &pstats[Ray_Blob_Tests_Succeeded]);
1234 #ifdef BLOB_EXTRA_STATS
1235 print_intersection_stats("Blob Component", &pstats[Blob_Element_Tests],
1236 &pstats[Blob_Element_Tests_Succeeded]);
1237 print_intersection_stats("Blob Bound", &pstats[Blob_Bound_Tests],
1238 &pstats[Blob_Bound_Tests_Succeeded]);
1239 #endif
1241 print_intersection_stats("Box", &pstats[Ray_Box_Tests],
1242 &pstats[Ray_Box_Tests_Succeeded]);
1243 print_intersection_stats("Cone/Cylinder", &pstats[Ray_Cone_Tests],
1244 &pstats[Ray_Cone_Tests_Succeeded]);
1245 print_intersection_stats("CSG Intersection", &pstats[Ray_CSG_Intersection_Tests],
1246 &pstats[Ray_CSG_Intersection_Tests_Succeeded]);
1247 print_intersection_stats("CSG Merge", &pstats[Ray_CSG_Merge_Tests],
1248 &pstats[Ray_CSG_Merge_Tests_Succeeded]);
1249 print_intersection_stats("CSG Union", &pstats[Ray_CSG_Union_Tests],
1250 &pstats[Ray_CSG_Union_Tests_Succeeded]);
1251 print_intersection_stats("Disc", &pstats[Ray_Disc_Tests],
1252 &pstats[Ray_Disc_Tests_Succeeded]);
1253 print_intersection_stats("Fractal", &pstats[Ray_Fractal_Tests],
1254 &pstats[Ray_Fractal_Tests_Succeeded]);
1256 print_intersection_stats("Height Field", &pstats[Ray_HField_Tests],
1257 &pstats[Ray_HField_Tests_Succeeded]);
1258 #ifdef HFIELD_EXTRA_STATS
1259 print_intersection_stats("Height Field Box", &pstats[Ray_HField_Box_Tests],
1260 &pstats[Ray_HField_Box_Tests_Succeeded]);
1261 print_intersection_stats("Height Field Triangle", &pstats[Ray_HField_Triangle_Tests],
1262 &pstats[Ray_HField_Triangle_Tests_Succeeded]);
1263 print_intersection_stats("Height Field Block", &pstats[Ray_HField_Block_Tests],
1264 &pstats[Ray_HField_Block_Tests_Succeeded]);
1265 print_intersection_stats("Height Field Cell", &pstats[Ray_HField_Cell_Tests],
1266 &pstats[Ray_HField_Cell_Tests_Succeeded]);
1267 #endif
1269 print_intersection_stats("Lathe", &pstats[Ray_Lathe_Tests],
1270 &pstats[Ray_Lathe_Tests_Succeeded]);
1271 #ifdef LATHE_EXTRA_STATS
1272 print_intersection_stats("Lathe Bound", &pstats[Lathe_Bound_Tests],
1273 &pstats[Lathe_Bound_Tests_Succeeded]);
1274 #endif
1276 print_intersection_stats("Mesh", &pstats[Ray_Mesh_Tests],
1277 &pstats[Ray_Mesh_Tests_Succeeded]);
1278 print_intersection_stats("Plane", &pstats[Ray_Plane_Tests],
1279 &pstats[Ray_Plane_Tests_Succeeded]);
1280 print_intersection_stats("Polygon", &pstats[Ray_Polygon_Tests],
1281 &pstats[Ray_Polygon_Tests_Succeeded]);
1283 print_intersection_stats("Prism", &pstats[Ray_Prism_Tests],
1284 &pstats[Ray_Prism_Tests_Succeeded]);
1285 #ifdef PRISM_EXTRA_STATS
1286 print_intersection_stats("Prism Bound", &pstats[Prism_Bound_Tests],
1287 &pstats[Prism_Bound_Tests_Succeeded]);
1288 #endif
1290 print_intersection_stats("Quadric", &pstats[Ray_Quadric_Tests],
1291 &pstats[Ray_Quadric_Tests_Succeeded]);
1292 print_intersection_stats("Quartic/Poly", &pstats[Ray_Poly_Tests],
1293 &pstats[Ray_Poly_Tests_Succeeded]);
1294 print_intersection_stats("Sphere", &pstats[Ray_Sphere_Tests],
1295 &pstats[Ray_Sphere_Tests_Succeeded]);
1296 print_intersection_stats("Superellipsoid", &pstats[Ray_Superellipsoid_Tests],
1297 &pstats[Ray_Superellipsoid_Tests_Succeeded]);
1299 print_intersection_stats("Surface of Revolution", &pstats[Ray_Sor_Tests],
1300 &pstats[Ray_Sor_Tests_Succeeded]);
1301 #ifdef SOR_EXTRA_STATS
1302 print_intersection_stats("Surface of Rev. Bound", &pstats[Sor_Bound_Tests],
1303 &pstats[Sor_Bound_Tests_Succeeded]);
1304 #endif
1306 print_intersection_stats("Torus", &pstats[Ray_Torus_Tests],
1307 &pstats[Ray_Torus_Tests_Succeeded]);
1308 #ifdef TORUS_EXTRA_STATS
1309 print_intersection_stats("Torus Bound", &pstats[Torus_Bound_Tests],
1310 &pstats[Torus_Bound_Tests_Succeeded]);
1311 #endif
1313 print_intersection_stats("Triangle", &pstats[Ray_Triangle_Tests],
1314 &pstats[Ray_Triangle_Tests_Succeeded]);
1315 print_intersection_stats("True Type Font", &pstats[Ray_TTF_Tests],
1316 &pstats[Ray_TTF_Tests_Succeeded]);
1318 print_intersection_stats("Bounding Object", &pstats[Bounding_Region_Tests],
1319 &pstats[Bounding_Region_Tests_Succeeded]);
1320 print_intersection_stats("Clipping Object", &pstats[Clipping_Region_Tests],
1321 &pstats[Clipping_Region_Tests_Succeeded]);
1322 print_intersection_stats("Bounding Box", &pstats[nChecked],
1323 &pstats[nEnqueued]);
1324 print_intersection_stats("Light Buffer", &pstats[LBuffer_Tests],
1325 &pstats[LBuffer_Tests_Succeeded]);
1326 print_intersection_stats("Vista Buffer", &pstats[VBuffer_Tests],
1327 &pstats[VBuffer_Tests_Succeeded]);
1329 Statistics ("----------------------------------------------------------------------------\n");
1331 if (!Test_Zero_Counter(pstats[Polynomials_Tested]))
1333 counter_to_string(&pstats[Polynomials_Tested], s1, OUTPUT_LENGTH);
1334 counter_to_string(&pstats[Roots_Eliminated], s2, OUTPUT_LENGTH);
1336 Statistics ("Roots tested: %s eliminated: %s\n", s1, s2);
1339 counter_to_string(&pstats[Calls_To_Noise], s1, OUTPUT_LENGTH);
1340 counter_to_string(&pstats[Calls_To_DNoise], s2, OUTPUT_LENGTH);
1342 Statistics ("Calls to Noise: %s Calls to DNoise: %s\n", s1, s2);
1344 Statistics ("----------------------------------------------------------------------------\n");
1346 /* Print media samples. */
1348 if (!Test_Zero_Counter(pstats[Media_Intervals]))
1350 counter_to_string(&pstats[Media_Intervals], s1, OUTPUT_LENGTH);
1351 counter_to_string(&pstats[Media_Samples], s2, OUTPUT_LENGTH);
1353 Statistics ("Media Intervals: %s Media Samples: %s (%4.2f)\n", s1, s2,
1354 DBL_Counter(pstats[Media_Samples]) / DBL_Counter(pstats[Media_Intervals]));
1357 if (!Test_Zero_Counter(pstats[Shadow_Ray_Tests]))
1359 counter_to_string(&pstats[Shadow_Ray_Tests], s1, OUTPUT_LENGTH);
1360 counter_to_string(&pstats[Shadow_Rays_Succeeded], s2, OUTPUT_LENGTH);
1362 Statistics ("Shadow Ray Tests: %s Succeeded: %s\n", s1, s2);
1365 if (!Test_Zero_Counter(pstats[Reflected_Rays_Traced]))
1367 counter_to_string(&pstats[Reflected_Rays_Traced], s1, OUTPUT_LENGTH);
1369 Statistics ("Reflected Rays: %s", s1);
1371 if (!Test_Zero_Counter(pstats[Internal_Reflected_Rays_Traced]))
1373 counter_to_string(&pstats[Internal_Reflected_Rays_Traced], s1, OUTPUT_LENGTH);
1375 Statistics (" Total Internal: %s", s1);
1378 Statistics ("\n");
1381 if (!Test_Zero_Counter(pstats[Refracted_Rays_Traced]))
1383 counter_to_string(&pstats[Refracted_Rays_Traced], s1, OUTPUT_LENGTH);
1385 Statistics ("Refracted Rays: %s\n", s1);
1388 if (!Test_Zero_Counter(pstats[Transmitted_Rays_Traced]))
1390 counter_to_string(&pstats[Transmitted_Rays_Traced], s1, OUTPUT_LENGTH);
1392 Statistics ("Transmitted Rays: %s\n", s1);
1395 if (!Test_Zero_Counter(pstats[Istack_overflows]))
1397 counter_to_string(&pstats[Istack_overflows], s1, OUTPUT_LENGTH);
1399 Statistics ("I-Stack overflows: %s\n", s1);
1402 if ( ra_reuse_count || ra_gather_count )
1404 Statistics ("----------------------------------------------------------------------------\n");
1405 Statistics ("Radiosity samples calculated: %9ld (%.2f percent)\n", ra_gather_count,
1406 100.*(DBL) ra_gather_count / ((DBL)(ra_gather_count + ra_reuse_count)));
1407 /* Note: don't try to put in a percent sign. There is basically no way to do this
1408 which is completely portable using va_start */
1409 Statistics ("Radiosity samples reused: %9ld\n", ra_reuse_count);
1412 #if defined(MEM_STATS)
1413 Statistics ("----------------------------------------------------------------------------\n");
1415 Long_To_Counter(mem_stats_smallest_alloc(), pstats[MemStat_Smallest_Alloc]);
1416 counter_to_string(&pstats[MemStat_Smallest_Alloc], s1, OUTPUT_LENGTH);
1418 Long_To_Counter(mem_stats_largest_alloc(), pstats[MemStat_Largest_Alloc]);
1419 counter_to_string(&pstats[MemStat_Largest_Alloc], s2, OUTPUT_LENGTH);
1421 #if (MEM_STATS==1)
1422 Statistics ("Smallest Alloc: %s bytes Largest: %s\n", s1, s2);
1423 #elif (MEM_STATS>=2)
1424 Statistics ("Smallest Alloc: %s bytes @ %s:%d\n", s1, mem_stats_smallest_file(), mem_stats_smallest_line());
1425 Statistics ("Largest Alloc: %s bytes @ %s:%d\n", s2, mem_stats_largest_file(), mem_stats_largest_line());
1427 Long_To_Counter(mem_stats_total_allocs(), pstats[MemStat_Total_Allocs]);
1428 counter_to_string(&pstats[MemStat_Total_Allocs], s1, OUTPUT_LENGTH);
1429 Long_To_Counter(mem_stats_total_frees(), pstats[MemStat_Total_Frees]);
1430 counter_to_string(&pstats[MemStat_Total_Frees], s2, OUTPUT_LENGTH);
1431 Statistics ("Total Alloc calls: %s Free calls:%s\n", s1, s2);
1432 #endif
1434 Long_To_Counter(mem_stats_largest_mem_usage(), pstats[MemStat_Largest_Mem_Usage]);
1435 counter_to_string(&pstats[MemStat_Largest_Mem_Usage], s1, OUTPUT_LENGTH);
1436 Statistics ("Peak memory used: %s bytes\n", s1);
1438 #endif
1440 Statistics ("----------------------------------------------------------------------------\n");
1442 /* Get time in case the trace was aborted. */
1444 if (trender == 0.0)
1446 STOP_TIME
1448 trender = TIME_ELAPSED
1451 if (opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME)
1453 if (tparse_total != 0.0)
1455 taverage = tparse_total /
1456 (DBL)(opts.FrameSeq.FrameNumber - opts.FrameSeq.InitialFrame + 1);
1458 SPLIT_TIME(taverage,&hours,&minutes,&seconds);
1459 Statistics ("Time For Parse/Frame: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
1460 hours, minutes, seconds, (long)taverage);
1462 SPLIT_TIME(tparse_total,&hours,&minutes,&seconds);
1463 Statistics ("Time For Parse Total: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
1464 hours, minutes, seconds, (long)tparse_total);
1467 if (trender_total != 0.0)
1469 taverage = trender_total /
1470 (DBL)(opts.FrameSeq.FrameNumber - opts.FrameSeq.InitialFrame + 1);
1472 SPLIT_TIME(taverage,&hours,&minutes,&seconds);
1473 Statistics ("Time For Trace/Frame: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
1474 hours, minutes, seconds, (long)taverage);
1476 SPLIT_TIME(trender_total,&hours,&minutes,&seconds);
1477 Statistics ("Time For Trace Total: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
1478 hours, minutes, seconds, (long)trender_total);
1481 ttotal = tparse_total + trender_total;
1483 if (ttotal != 0.0)
1485 SPLIT_TIME(ttotal,&hours,&minutes,&seconds);
1487 Statistics (" Total Time: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
1488 hours, minutes, seconds, (long)ttotal);
1491 else
1493 if (tparse != 0.0)
1495 SPLIT_TIME(tparse,&hours,&minutes,&seconds);
1497 Statistics ("Time For Parse: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
1498 hours, minutes, seconds, (long)tparse);
1501 if (trender != 0.0)
1503 SPLIT_TIME(trender,&hours,&minutes,&seconds);
1505 Statistics ("Time For Trace: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
1506 hours, minutes, seconds, (long)trender);
1509 ttotal = tparse + trender;
1511 if (ttotal != 0.0)
1513 SPLIT_TIME(ttotal,&hours,&minutes,&seconds);
1515 Statistics (" Total Time: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
1516 hours, minutes, seconds, (long)ttotal);