1 /****************************************************************************
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 *****************************************************************************/
71 /*****************************************************************************
72 * Local preprocessor defines
73 ******************************************************************************/
75 #define NUMBER_LENGTH 19
76 #define OUTPUT_LENGTH 15
78 #define NUMBER_OF_AUTHORS_ACROSS 4
81 /*****************************************************************************
83 ******************************************************************************/
87 /*****************************************************************************
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
[] =
173 NULL
/* NULL flags the end of the list */
176 char *Contributing_Authors
[] =
189 NULL
/* NULL flags the end of the list */
193 /*****************************************************************************
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 /*****************************************************************************
222 * Add two decimal numbers stored in ASCII strings.
226 * Mar 1995 : Creation
228 ******************************************************************************/
230 static void add_numbers(char *result
, char *c1
, char *c2
)
237 for (i
= NUMBER_LENGTH
-1; i
>= 0; i
--)
239 x
= c1
[i
] + c2
[i
] + carry
- '0' - '0';
258 /*****************************************************************************
276 * Convert a low/high precision counter into a decimal number.
280 * Mar 1995 : Creation
282 ******************************************************************************/
284 static void counter_to_string(COUNTER
*counter
, char *string
, int len
)
286 char n
[NUMBER_LENGTH
+1];
292 for (i
= 0; i
< NUMBER_LENGTH
; i
++)
297 n
[NUMBER_LENGTH
] = '\0';
299 #if COUNTER_RESOLUTION == HIGH_RESOLUTION
301 for (i
= 0; i
< 32; i
++)
305 add_numbers(n
, n
, numbers
[i
]);
311 for (i
= 32; i
< 64; i
++)
315 add_numbers(n
, n
, numbers
[i
]);
323 for (i
= 0; i
< 32; i
++)
327 add_numbers(n
, n
, numbers
[i
]);
335 /* Replace leading zeros. */
337 for (i
= 0; i
< NUMBER_LENGTH
-1; i
++)
349 /* Copy number into result string. */
351 if (i
>= NUMBER_LENGTH
-len
)
353 for (j
= 0; j
< i
-NUMBER_LENGTH
+len
-1; j
++)
360 string
= strcat(string
, &n
[i
]);
364 /* Print numbers that don't fit into output string in million units. */
368 n
[NUMBER_LENGTH
-6] = 'm';
369 n
[NUMBER_LENGTH
-5] = '\0';
371 string
= strcat(string
, &n
[NUMBER_LENGTH
-len
+1-6]);
377 /*****************************************************************************
381 * print_intersections_stats
399 * Mar 1995 : Creation
401 ******************************************************************************/
403 static void print_intersection_stats(char *text
, COUNTER
*tests
, COUNTER
*succeeded
)
407 if (!Test_Zero_Counter(*tests
))
409 t
= DBL_Counter(*tests
);
410 s
= DBL_Counter(*succeeded
);
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 /*****************************************************************************
447 ******************************************************************************/
449 static void rinfo_on(char *string
, unsigned value
)
453 Render_Info("%s.On",(string
));
457 Render_Info("%sOff",(string
));
463 /*****************************************************************************
487 ******************************************************************************/
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 /*****************************************************************************
518 * Print all help screens. Use an interactive menu if GET_KEY exists.
522 * Apr 1995 : Creation.
524 ******************************************************************************/
526 void Print_Help_Screens()
528 #ifdef GET_KEY_EXISTS
537 Banner("[ Press 0 for general help, 1 to %d for help screen. Press 'q' to quit. ]", MAX_HELP_PAGE
);
547 if ((c
>= '0') && (c
<= '0' + MAX_HELP_PAGE
))
551 n
= (int)c
- (int)'0';
555 if ((c
== 'q') || (c
== 'Q'))
565 if ((c
== 'q') || (c
== 'Q'))
576 for (n
= -1; n
<= MAX_HELP_PAGE
; n
++)
578 Usage(n
, (n
== MAX_HELP_PAGE
));
586 /*****************************************************************************
594 * n - Number of usage screen
595 * f - Flag to terminate
607 * Print out usage messages.
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
)
626 Banner("Usage: POVRAY [+/-]Option1 [+/-]Option2 ... (-h or -? for help)\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");
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");
634 Banner("E.g. use -h5 to see the help screen about the tracing options.\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");
647 /* Parsing options. */
652 Banner("Parsing options\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");
662 /* Output options. */
667 Banner("Output options\n");
669 Banner(" Hnnn = image height\n");
670 Banner(" Wnnn = image width\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");
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");
687 Banner("Output options - display related\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");
696 /* Output options - file related. */
701 Banner("Output options - file related\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
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");
726 /* Tracing options. */
731 Banner("Tracing options\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");
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");
742 Banner(" UL = use light buffer\n");
743 Banner(" UV = use vista buffer\n");
747 /* Animation options. */
752 Banner("Animation options\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");
765 Banner(" UF = use field rendering\n");
766 Banner(" UO = use odd lines in odd frames\n");
770 /* Redirecting options. */
775 Banner("Redirecting options\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");
795 #if defined(WAIT_FOR_KEYPRESS_EXISTS) && !defined(GET_KEY_EXISTS)
797 Banner("[ Paused for keypress... ]");
816 Banner("POV-Ray is based on DKBTrace 2.12 by David K. Buck & Aaron A. Collins.\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
++]);
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
++]);
844 Banner("Other contributors listed in the documentation.\n");
848 /*****************************************************************************
872 ******************************************************************************/
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
));
891 Render_Info(" Library paths:");
893 for (i
= 0; i
< opts
.Library_Path_Index
; i
++)
895 j
+= strlen(opts
.Library_Paths
[i
])+2;
899 Render_Info("\n ", j
);
901 j
= strlen(opts
.Library_Paths
[i
]) + 5;
904 Render_Info(" %s", opts
.Library_Paths
[i
]);
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
);
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);
967 else if (opts
.Options
& DISPLAY
)
969 if (opts
.histogram_on
== TRUE
)
971 Warning(0.0, " Rendering to screen and histogram file only.\n");
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");
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
),
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
);
1004 #if PRECISION_TIMER_AVAILABLE
1005 rinfo_on (" CPU usage histogram.", opts
.histogram_on
);
1006 if (opts
.histogram_on
)
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
);
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
));
1032 rinfo_on (" Verbose messages....", (opts
.Options
& VERBOSE
));
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
);
1045 Render_Info(" Bounding threshold: %d ", opts
.BBox_Threshold
);
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
));
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
);
1067 rinfo_on (" Radiosity...........", (opts
.Options
& RADIOSITY
));
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
));
1087 Render_Info(" Clock value....%8.3f", opts
.FrameSeq
.Clock_Value
);
1088 Render_Info(" (Animation off)");
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
)
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
)
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
)
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
)
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
)
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
)
1154 Render_Info(" and file %s\n", Stream_Info
[WARNING_STREAM
].name
);
1160 /*****************************************************************************
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
]));
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
]);
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
]);
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
]);
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
]);
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
]);
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
]);
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
);
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
);
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
);
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
);
1440 Statistics ("----------------------------------------------------------------------------\n");
1442 /* Get time in case the trace was aborted. */
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
;
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
);
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
);
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
;
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
);