home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / povsrc31.zip / optout.c < prev    next >
C/C++ Source or Header  |  2001-01-23  |  50KB  |  1,759 lines

  1. /****************************************************************************
  2. *                   optout.c
  3. *
  4. *  ---------------------------------------------------------
  5. *  ATTENTION:
  6. *  This is an unofficial version of optout.c modified by
  7. *  Ryoichi Suzuki, rsuzuki@etl.go.jp, for use  with 
  8. *  "isosurface" shape type.
  9. *  ---------------------------------------------------------
  10. *  This module contains functions for credit, usage, options and stats.
  11. *
  12. *  from Persistence of Vision(tm) Ray Tracer
  13. *  Copyright 1996,1999 Persistence of Vision Team
  14. *---------------------------------------------------------------------------
  15. *  NOTICE: This source code file is provided so that users may experiment
  16. *  with enhancements to POV-Ray and to port the software to platforms other
  17. *  than those supported by the POV-Ray Team.  There are strict rules under
  18. *  which you are permitted to use this file.  The rules are in the file
  19. *  named POVLEGAL.DOC which should be distributed with this file.
  20. *  If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  21. *  Team Coordinator by email to team-coord@povray.org or visit us on the web at
  22. *  http://www.povray.org. The latest version of POV-Ray may be found at this site.
  23. *
  24. * This program is based on the popular DKB raytracer version 2.12.
  25. * DKBTrace was originally written by David K. Buck.
  26. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  27. *
  28. *****************************************************************************/
  29.  
  30. #include <ctype.h>
  31. #include <time.h>
  32. #include "frame.h"
  33. #include "vector.h"
  34. #include "povproto.h"
  35. #include "atmosph.h"
  36. #include "bezier.h"
  37. #include "blob.h"
  38. #include "bbox.h"
  39. #include "cones.h"
  40. #include "csg.h"
  41. #include "discs.h"
  42. #include "fractal.h"
  43. #include "hfield.h"
  44. #include "lathe.h"
  45. #include "lighting.h"
  46. #include "mesh.h"
  47. #include "polysolv.h"
  48. #include "objects.h"
  49. #include "parse.h"
  50. #include "point.h"
  51. #include "poly.h"
  52. #include "polygon.h"
  53. #include "octree.h"
  54. #include "quadrics.h"
  55. #include "pgm.h"
  56. #include "ppm.h"
  57. #include "prism.h"
  58. #include "radiosit.h"
  59. #include "render.h"
  60. #include "sor.h"
  61. #include "spheres.h"
  62. #include "super.h"
  63. #include "targa.h"
  64. #include "texture.h"
  65. #include "torus.h"
  66. #include "triangle.h"
  67. #include "truetype.h"
  68. #include "userio.h"
  69. #include "lbuffer.h"
  70. #include "vbuffer.h"
  71. #include "povray.h"
  72. #include "optin.h"
  73. #include "optout.h"
  74.  
  75. /** poviso: July 19 '96  R.S. **/
  76. #ifdef POVISO
  77. #include "isosrf.h"
  78. extern FUNCTION *First_Func, *Last_Func;
  79. #endif
  80. /** --- **/
  81.  
  82. #ifdef UseMediaAndLightCache
  83.     extern long TotalMallocCacheSize;
  84.     #ifdef AccumulateCacheStatistics
  85.         extern long MaxAppColourRecCntr;
  86.         extern long MaxSimMediatRecCntr;
  87.         extern long MaxShadowTextRecCntr;
  88.         extern long MaxLightedTexture;
  89.     #endif
  90. #endif
  91.  
  92.  
  93. /*****************************************************************************
  94. * Local preprocessor defines
  95. ******************************************************************************/
  96.  
  97. #define NUMBER_LENGTH 19
  98. #define OUTPUT_LENGTH 15
  99.  
  100. #define NUMBER_OF_AUTHORS_ACROSS  4
  101.  
  102.  
  103. /*****************************************************************************
  104. * Local typedefs
  105. ******************************************************************************/
  106.  
  107.  
  108.  
  109. /*****************************************************************************
  110. * Local variables
  111. ******************************************************************************/
  112.  
  113. static char numbers[64][20] =
  114. {
  115. "0000000000000000001",
  116. "0000000000000000002",
  117. "0000000000000000004",
  118. "0000000000000000008",
  119. "0000000000000000016",
  120. "0000000000000000032",
  121. "0000000000000000064",
  122. "0000000000000000128",
  123. "0000000000000000256",
  124. "0000000000000000512",
  125. "0000000000000001024",
  126. "0000000000000002048",
  127. "0000000000000004096",
  128. "0000000000000008192",
  129. "0000000000000016384",
  130. "0000000000000032768",
  131. "0000000000000065536",
  132. "0000000000000131072",
  133. "0000000000000262144",
  134. "0000000000000524288",
  135. "0000000000001048576",
  136. "0000000000002097152",
  137. "0000000000004194304",
  138. "0000000000008388608",
  139. "0000000000016777216",
  140. "0000000000033554432",
  141. "0000000000067108864",
  142. "0000000000134217728",
  143. "0000000000268435456",
  144. "0000000000536870912",
  145. "0000000001073741824",
  146. "0000000002147483648",
  147. "0000000004294967296",
  148. "0000000008589934592",
  149. "0000000017179869184",
  150. "0000000034359738368",
  151. "0000000068719476736",
  152. "0000000137438953472",
  153. "0000000274877906944",
  154. "0000000549755813888",
  155. "0000001099511627776",
  156. "0000002199023255552",
  157. "0000004398046511104",
  158. "0000008796093022208",
  159. "0000017592186044416",
  160. "0000035184372088832",
  161. "0000070368744177664",
  162. "0000140737488355328",
  163. "0000281474976710656",
  164. "0000562949953421312",
  165. "0001125899906842624",
  166. "0002251799813685248",
  167. "0004503599627370496",
  168. "0009007199254740992",
  169. "0018014398509481984",
  170. "0036028797018963968",
  171. "0072057594037927936",
  172. "0144115188075855872",
  173. "0288230376151711744",
  174. "0576460752303423488",
  175. "1152921504606846976",
  176. "2305843009213693952",
  177. "4611686018427387904",
  178. "9223372036854775808"
  179. };
  180.  
  181. static char s1[OUTPUT_LENGTH], s2[OUTPUT_LENGTH];
  182.  
  183. char *Primary_Developers[] =
  184. {
  185.   "Steve Anger",
  186.   "Dieter Bayer",
  187.   "Chris Cason",
  188.   "Chris Dailey",
  189.   "Andreas Dilger",
  190.   "Steve Demlow",
  191.   "Alexander Enzmann",
  192.   "Dan Farmer",
  193.   "Timothy Wegner",
  194.   "Chris Young",
  195.   NULL   /* NULL flags the end of the list */
  196. };
  197.  
  198. char *Contributing_Authors[] =
  199. {
  200.   "Steve A. Bennett",
  201.   "Tomas Bily", 
  202.   "Eric Brown",
  203.   "Matthew C. Brown",
  204.   "David K. Buck",
  205.   "Phil Carrig (PoD)",
  206.   "Kochin Chang",
  207.   "Aaron A. Collins",
  208.   "Jon A. Cruz",
  209.   "Daniel Fenner",
  210.   "Hans-Detlev Fink",
  211.   "Jerome Grimbert",
  212.   "Mike Hough",
  213.   "Chris Huff",
  214.   "Nathan Kopp",
  215.   "Jochen Lippert",
  216.   "Lummox, Jr.",
  217.   "Pascal Massimino",
  218.   "Jim McElhiney",
  219.   "Douglas Muir",
  220.   "Wolfgang Ortmann",
  221.   "Ron Parker",
  222.   "Mike Paul",
  223.   "Ansgar Philippsen",
  224.   "Bill Pulver",
  225.   "David Sharp",
  226.   "Rene Smellenbergh",
  227.   "Yvo Smellenbergh",
  228.   "Daniel Skarda",
  229.   "Robert Skinner",
  230.   "Ryoichi Suzuki",
  231.   "Zsolt Szalavari",
  232.   "Scott Taylor",
  233.   "John VanSickle",
  234.   "Mark Wagner",
  235.   "Drew Wells",
  236.   "Daren Wilson",
  237.   NULL   /* NULL flags the end of the list */
  238. };
  239.  
  240.  
  241. /*****************************************************************************
  242. * Static functions
  243. ******************************************************************************/
  244.  
  245. static void rinfo_on (char *string, unsigned value);
  246. static void add_numbers (char *result, char *c1, char *c2);
  247. static void counter_to_string (COUNTER *counter, char *string, int len);
  248. static void print_intersection_stats (char *text, COUNTER *tests, COUNTER *succeeded);
  249.  
  250.  
  251.  
  252. /*****************************************************************************
  253. *
  254. * FUNCTION
  255. *
  256. *   add_numbers
  257. *
  258. * INPUT
  259. *   
  260. * OUTPUT
  261. *   
  262. * RETURNS
  263. *   
  264. * AUTHOR
  265. *
  266. *   Dieter Bayer
  267. *   
  268. * DESCRIPTION
  269. *
  270. *   Add two decimal numbers stored in ASCII strings.
  271. *
  272. * CHANGES
  273. *
  274. *   Mar 1995 : Creation
  275. *
  276. ******************************************************************************/
  277.  
  278. static void add_numbers(char *result, char  *c1, char  *c2)
  279. {
  280.   int i;
  281.   char carry, x;
  282.  
  283.   carry = '0';
  284.  
  285.   for (i = NUMBER_LENGTH-1; i >= 0; i--)
  286.   {
  287.     x = c1[i] + c2[i] + carry - '0' - '0';
  288.  
  289.     if (x > '9')
  290.     {
  291.       carry = '1';
  292.  
  293.       result[i] = x - 10;
  294.     }
  295.     else
  296.     {
  297.       carry = '0';
  298.  
  299.       result[i] = x;
  300.     }
  301.   }
  302. }
  303.  
  304.  
  305.  
  306. /*****************************************************************************
  307. *
  308. * FUNCTION
  309. *
  310. *   counter_to_string
  311. *
  312. * INPUT
  313. *   
  314. * OUTPUT
  315. *   
  316. * RETURNS
  317. *   
  318. * AUTHOR
  319. *
  320. *   Dieter Bayer
  321. *   
  322. * DESCRIPTION
  323. *
  324. *   Convert a low/high precision counter into a decimal number.
  325. *
  326. * CHANGES
  327. *
  328. *   Mar 1995 : Creation
  329. *
  330. ******************************************************************************/
  331.  
  332. static void counter_to_string(COUNTER *counter, char *string, int len)
  333. {
  334.   char n[NUMBER_LENGTH+1];
  335.   int i, j;
  336.   COUNTER c;
  337.  
  338.   c = *counter;
  339.  
  340.   for (i = 0; i < NUMBER_LENGTH; i++)
  341.   {
  342.     n[i] = '0';
  343.   }
  344.  
  345.   n[NUMBER_LENGTH] = '\0';
  346.  
  347. #if COUNTER_RESOLUTION == HIGH_RESOLUTION
  348.  
  349.   for (i = 0; i < 32; i++)
  350.   {
  351.     if (c.low & 1)
  352.     {
  353.       add_numbers(n, n, numbers[i]);
  354.     }
  355.  
  356.     c.low >>= 1;
  357.   }
  358.  
  359.   for (i = 32; i < 64; i++)
  360.   {
  361.     if (c.high & 1)
  362.     {
  363.       add_numbers(n, n, numbers[i]);
  364.     }
  365.  
  366.     c.high >>= 1;
  367.   }
  368.  
  369. #else
  370.  
  371.   for (i = 0; i < 32; i++)
  372.   {
  373.     if (c & 1)
  374.     {
  375.       add_numbers(n, n, numbers[i]);
  376.     }
  377.  
  378.     c >>= 1;
  379.   }
  380.  
  381. #endif
  382.  
  383.   /* Replace leading zeros. */
  384.  
  385.   for (i = 0; i < NUMBER_LENGTH-1; i++)
  386.   {
  387.     if (n[i] == '0')
  388.     {
  389.       n[i] = ' ';
  390.     }
  391.     else
  392.     {
  393.       break;
  394.     }
  395.   }
  396.  
  397.   /* Copy number into result string. */
  398.  
  399.   if (i >= NUMBER_LENGTH-len)
  400.   {
  401.     for (j = 0; j < i-NUMBER_LENGTH+len-1; j++)
  402.     {
  403.       string[j] = ' ';
  404.     }
  405.  
  406.     string[j] = '\0';
  407.  
  408.     string = strcat(string, &n[i]);
  409.   }
  410.   else
  411.   {
  412.     /* Print numbers that don't fit into output string in million units. */
  413.  
  414.     string = "";
  415.  
  416.     n[NUMBER_LENGTH-6] = 'm';
  417.     n[NUMBER_LENGTH-5] = '\0';
  418.  
  419.     string = strcat(string, &n[NUMBER_LENGTH-len+1-6]);
  420.   }
  421. }
  422.  
  423.  
  424.  
  425. /*****************************************************************************
  426. *
  427. * FUNCTION
  428. *
  429. *   print_intersections_stats
  430. *
  431. * INPUT
  432. *   
  433. * OUTPUT
  434. *   
  435. * RETURNS
  436. *   
  437. * AUTHOR
  438. *
  439. *   Dieter Bayer
  440. *   
  441. * DESCRIPTION
  442. *
  443. *   -
  444. *
  445. * CHANGES
  446. *
  447. *   Mar 1995 : Creation
  448. *
  449. ******************************************************************************/
  450.  
  451. static void print_intersection_stats(char *text, COUNTER *tests, COUNTER  *succeeded)
  452. {
  453.   DBL t, s, p;
  454.  
  455.   if (!Test_Zero_Counter(*tests))
  456.   {
  457.     t = DBL_Counter(*tests);
  458.     s = DBL_Counter(*succeeded);
  459.  
  460.     p = 100.0 * s / t;
  461.  
  462.     counter_to_string(tests, s1, OUTPUT_LENGTH);
  463.     counter_to_string(succeeded, s2, OUTPUT_LENGTH);
  464.  
  465.     Statistics("%-22s  %s  %s  %8.2f\n", text, s1, s2, p);
  466.   }
  467. }
  468.  
  469.  
  470.  
  471. /*****************************************************************************
  472. *
  473. * FUNCTION
  474. *
  475. *   rinfo_on
  476. *
  477. * INPUT
  478. *
  479. * OUTPUT
  480. *
  481. * RETURNS
  482. *
  483. * AUTHOR
  484. *
  485. *   POV-Ray Team
  486. *
  487. * DESCRIPTION
  488. *
  489. *   -
  490. *
  491. * CHANGES
  492. *
  493. *   -
  494. *
  495. ******************************************************************************/
  496.  
  497. static void rinfo_on(char *string, unsigned value)
  498. {
  499.   if (value)
  500.   {
  501.     Render_Info("%s.On",(string));
  502.   }
  503.   else
  504.   {
  505.     Render_Info("%sOff",(string));
  506.   }
  507. }
  508.  
  509.  
  510.  
  511. /*****************************************************************************
  512. *
  513. * FUNCTION
  514. *
  515. *   Print_Credits
  516. *
  517. * INPUT
  518. *   
  519. * OUTPUT
  520. *   
  521. * RETURNS
  522. *   
  523. * AUTHOR
  524. *
  525. *   POV-Ray Team
  526. *   
  527. * DESCRIPTION
  528. *
  529. *   -
  530. *
  531. * CHANGES
  532. *
  533. *   -
  534. *
  535. ******************************************************************************/
  536.  
  537. void Print_Credits()
  538. {
  539.   Banner ("Persistence of Vision(tm) Ray Tracer Version %s%s\n", POV_RAY_VERSION, COMPILER_VER);
  540.   Banner ("  %s\n", DISTRIBUTION_MESSAGE_1);
  541.   Banner ("  %s\n", DISTRIBUTION_MESSAGE_2);
  542.   Banner ("  %s\n", DISTRIBUTION_MESSAGE_3);
  543.   Banner ("Copyright 1999 POV-Ray Team(tm)\n");
  544. }
  545.  
  546.  
  547.  
  548. /*****************************************************************************
  549. *
  550. * FUNCTION
  551. *
  552. *   Print_Help_Screens
  553. *
  554. * INPUT
  555. *   
  556. * OUTPUT
  557. *   
  558. * RETURNS
  559. *   
  560. * AUTHOR
  561. *
  562. *   Dieter Bayer
  563. *   
  564. * DESCRIPTION
  565. *
  566. *   Print all help screens. Use an interactive menu if GET_KEY exists.
  567. *
  568. * CHANGES
  569. *
  570. *   Apr 1995 : Creation.
  571. *
  572. ******************************************************************************/
  573.  
  574. void Print_Help_Screens()
  575. {
  576. #ifdef GET_KEY_EXISTS
  577.   char c;
  578.   int n, x, ok;
  579.  
  580.   Usage(-1, FALSE);
  581.  
  582.   for (n = 0; ; )
  583.   {
  584.     Banner("\n");
  585.     Banner("[ Press 0 for general help, 1 to %d for help screen. Press 'q' to quit. ]", MAX_HELP_PAGE);
  586.  
  587.     do
  588.     {
  589.       ok = FALSE;
  590.  
  591.       GET_KEY(x);
  592.  
  593.       c = (char)x;
  594.  
  595.       if ((c >= '0') && (c <= '0' + MAX_HELP_PAGE))
  596.       {
  597.         ok = TRUE;
  598.  
  599.         n = (int)c - (int)'0';
  600.       }
  601.       else
  602.       {
  603.         if ((c == 'q') || (c == 'Q'))
  604.         {
  605.           ok = TRUE;
  606.         }
  607.       }
  608.     }
  609.     while(!ok);
  610.  
  611.     Banner("\n");
  612.  
  613.     if ((c == 'q') || (c == 'Q'))
  614.     {
  615.       break;
  616.     }
  617.  
  618.     Usage(n, FALSE);
  619.   }
  620.  
  621. #else
  622.   int n;
  623.  
  624.   for (n = -1; n <= MAX_HELP_PAGE; n++)
  625.   {
  626.     Usage(n, (n == MAX_HELP_PAGE));
  627.   }
  628. #endif
  629.   Terminate_POV(0);
  630. }
  631.  
  632.  
  633.  
  634. /*****************************************************************************
  635. *
  636. * FUNCTION
  637. *
  638. *   Usage
  639. *
  640. * INPUT
  641. *
  642. *   n - Number of usage screen
  643. *   f - Flag to terminate
  644. *   
  645. * OUTPUT
  646. *   
  647. * RETURNS
  648. *   
  649. * AUTHOR
  650. *
  651. *   POV-Ray Team
  652. *   
  653. * DESCRIPTION
  654. *
  655. *   Print out usage messages.
  656. *
  657. * CHANGES
  658. *
  659. *   Dec 1994 : Changed to show options depending on parameter n. [DB]
  660. *
  661. *   Feb 1995 : Changed to terminate only if f != 0. [DB]
  662. *
  663. ******************************************************************************/
  664.  
  665. void Usage(int n, int  f)
  666. {
  667.   switch (n)
  668.   {
  669.     /* Help screen. */
  670.  
  671.     case 0:
  672.  
  673.       Banner("\n");
  674.       Banner("Usage: POVRAY [+/-]Option1 [+/-]Option2 ... (-h or -? for help)\n");
  675.       Banner("\n");
  676.       Banner("  Example: POVRAY scene.ini +Iscene.pov +Oscene.tga +W320 +H200\n");
  677.       Banner("  Example: POVRAY +Iscene.pov +Oscene.tga +W160 +H200 +V -D +X\n");
  678.       Banner("\n");
  679.       Banner("The help screen is divided into several parts. To access one part\n");
  680.       Banner("just enter the number of the screen after the -h or -? option.\n");
  681.       Banner("\n");
  682.       Banner("E.g. use -h5 to see the help screen about the tracing options.\n");
  683.       Banner("\n");
  684.       Banner("  Number  Part\n");
  685.       Banner("    1     Parsing Options\n");
  686.       Banner("    2     Output Options\n");
  687.       Banner("    3     Output Options - display related\n");
  688.       Banner("    4     Output Options - file related\n");
  689.       Banner("    5     Tracing Options\n");
  690.       Banner("    6     Animation Options\n");
  691.       Banner("    7     Redirecting Options\n");
  692.  
  693.       break;
  694.  
  695.     /* Parsing options. */
  696.  
  697.     case 1:
  698.  
  699.       Banner("\n");
  700.       Banner("Parsing options\n");
  701.       Banner("\n");
  702.       Banner("  I<name> = input file name\n");
  703.       Banner("  L<name> = library path prefix\n");
  704.       Banner("  MVn.n   = set compability to version n.n\n");
  705.       Banner("  SU      = split bounded unions if children are finite\n");
  706.       Banner("  UR      = remove unnecessary bounding objects\n");
  707.  
  708.       break;
  709.  
  710.     /* Output options. */
  711.  
  712.     case 2:
  713.  
  714.       Banner("\n");
  715.       Banner("Output options\n");
  716.       Banner("\n");
  717.       Banner("  Hnnn    = image height\n");
  718.       Banner("  Wnnn    = image width\n");
  719.       Banner("\n");
  720.       Banner("  SRnn    = start at row nn | SR0.nn start row at nn percent of screen\n");
  721.       Banner("  ERnn    = end   at row nn | ER0.nn end   row at nn percent of screen\n");
  722.       Banner("  SCnn    = start at col nn | SC0.nn start col at nn percent of screen\n");
  723.       Banner("  ECnn    = end   at col nn | EC0.nn end   col at nn percent of screen\n");
  724.       Banner("\n");
  725.       Banner("  C       = continue aborted trace\n");
  726.       Banner("  P       = pause before exit\n");
  727.       Banner("  V       = verbose messages on\n");
  728.       Banner("  Xnnn    = enable early exit by key hit (every nnn pixels)\n");
  729.  
  730.       break;
  731.  
  732.     case 3:
  733.  
  734.       Banner("\n");
  735.       Banner("Output options - display related\n");
  736.       Banner("\n");
  737.       Banner("  Dxy     = display in format x, using palette option y\n");
  738.       Banner("  SPnnn   = Mosaic Preview display, Start grid size = 2, 4, 8, 16, ...\n");
  739.       Banner("  EPnnn   = Mosaic Preview display, End grid size   = 2, 4, 8, 16, ...\n");
  740.       Banner("  UD      = draw vista rectangles\n");
  741.  
  742.       break;
  743.  
  744.     /* Output options - file related. */
  745.  
  746.     case 4:
  747.  
  748.       Banner("\n");
  749.       Banner("Output options - file related\n");
  750.       Banner("\n");
  751.       Banner("  Bnnn    = Use nnn KB for output file buffer\n");
  752.       Banner("  Fx      = write output file in format x\n");
  753.       Banner("            FC  - Compressed Targa with 24 or 32 bpp\n");
  754.       Banner("            FNn - PNG (n bits/color, n = 5 to 16, default is 8)\n");
  755.       Banner("            FP  - PPM\n");
  756.       Banner("            FS  - System specific\n");
  757.       Banner("            FT  - Uncompressed Targa with 24 or 32 bpp\n");
  758.       Banner("  O<name> = output file name\n");
  759. #if PRECISION_TIMER_AVAILABLE
  760.       Banner("\n");
  761.       Banner("  HTx     = write CPU utilization histogram in format x\n");
  762.       Banner("            HTC - Comma separated values (CSV - spreadsheet)\n");
  763.       Banner("            HTN - PNG grayscale\n");
  764.       Banner("            HTP - PPM heightfield\n");
  765.       Banner("            HTS - System specific\n");
  766.       Banner("            HTT - Uncompressed TGA heightfield\n");
  767.       Banner("            HTX - No histogram output\n");
  768.       Banner("  HN<name>= histogram filename\n");
  769.       Banner("  HSx.y   = histogram grid number of x, y divisions\n");
  770. #endif
  771.  
  772.       break;
  773.  
  774.     /* Tracing options. */
  775.  
  776.     case 5:
  777.  
  778.       Banner("\n");
  779.       Banner("Tracing options\n");
  780.       Banner("\n");
  781.       Banner("  MBnnn   = use slabs if more than nnn objects\n");
  782.       Banner("  Qn      = image quality (0 = rough, 9 = full, R = radiosity)\n");
  783.       Banner("  QR      = enable radiosity calculations for ambient light\n");
  784.       Banner("\n");
  785.       Banner("  A0.n    = perform antialiasing\n");
  786.       Banner("  AMn     = use non-adaptive (n=1) or adaptive (n=2) supersampling\n");
  787.       Banner("  Jn.n    = set antialiasing-jitter amount\n");
  788.       Banner("  Rn      = set antialiasing-depth (use n X n rays/pixel)\n");
  789.       Banner("\n");
  790.       Banner("  UL      = use light buffer\n");
  791.       Banner("  UV      = use vista buffer\n");
  792.  
  793.       break;
  794.  
  795.     /* Animation options. */
  796.  
  797.     case 6:
  798.  
  799.       Banner("\n");
  800.       Banner("Animation options\n");
  801.       Banner("\n");
  802.       Banner("  Kn.n      = set frame clock to n.n\n");
  803.       Banner("  KFInnn    = Initial frame number\n");
  804.       Banner("  KFFnnn    = Final frame number\n");
  805.       Banner("  KInnn.nn  = Initial clock value\n");
  806.       Banner("  KFnnn.nn  = Final clock value\n");
  807.       Banner("  SFnn      = Start subset at frame nn\n");
  808.       Banner("  SF0.nn    = Start subset nn percent into sequence\n");
  809.       Banner("  EFnn      = End subset at frame nn\n");
  810.       Banner("  EF0.n     = End subset nn percent into sequence\n");
  811.       Banner("  KC        = Calculate clock value for cyclic animation\n");
  812.       Banner("\n");
  813.       Banner("  UF        = use field rendering\n");
  814.       Banner("  UO        = use odd lines in odd frames\n");
  815.  
  816.       break;
  817.  
  818.     /* Redirecting options. */
  819.  
  820.     case 7:
  821.  
  822.       Banner("\n");
  823.       Banner("Redirecting options\n");
  824.       Banner("\n");
  825.       Banner("  GI<name>= write all .INI parameters to file name\n");
  826.       Banner("  Gx<name>= write stream x to console and/or file name\n");
  827.       Banner("            GA - All streams (except status)\n");
  828.       Banner("            GD - Debug stream\n");
  829.       Banner("            GF - Fatal stream\n");
  830.       Banner("            GR - Render stream\n");
  831.       Banner("            GS - Statistics stream\n");
  832.       Banner("            GW - Warning stream\n");
  833.  
  834.       break;
  835.  
  836.     /* Usage ... */
  837.  
  838.     default:
  839.  
  840.       Print_Authors();
  841.   }
  842.  
  843. #if defined(WAIT_FOR_KEYPRESS_EXISTS) && !defined(GET_KEY_EXISTS)
  844.   Banner("\n");
  845.   Banner("[ Paused for keypress... ]");
  846.  
  847.   WAIT_FOR_KEYPRESS;
  848.  
  849.   Banner("\n");
  850. #endif
  851.  
  852.   if (f)
  853.   {
  854.     Terminate_POV(0);
  855.   }
  856. }
  857.  
  858.  
  859. void Print_Authors()
  860. {
  861.   int h, i, j;
  862.  
  863.   Banner("\n");
  864.   Banner("POV-Ray is based on DKBTrace 2.12 by David K. Buck & Aaron A. Collins.\n");
  865.   Banner("\n");
  866.   Banner("Primary POV-Ray 3 Developers: (Alphabetically)\n");
  867.  
  868.   for (i = h = 0; Primary_Developers[h] != NULL; i++)
  869.   {
  870.     for (j = 0; (j < NUMBER_OF_AUTHORS_ACROSS) && (Primary_Developers[h] != NULL); j++)
  871.     {
  872.         Banner(" %-18s", Primary_Developers[h++]);
  873.     }
  874.  
  875.     Banner("\n");
  876.   }
  877.  
  878.   Banner("\n");
  879.   Banner("Major Contributing Authors: (in no particular order)\n");
  880.  
  881.   for (i = h = 0; Contributing_Authors[h] != NULL; i++)
  882.   {
  883.     for (j = 0; (j < NUMBER_OF_AUTHORS_ACROSS) && (Contributing_Authors[h] != NULL); j++)
  884.     {
  885.         Banner(" %-18s", Contributing_Authors[h++]);
  886.     }
  887.  
  888.     Banner("\n");
  889.   }
  890.  
  891.   Banner("\n");
  892.   Banner("Other contributors listed in the documentation.\n");
  893. }
  894.  
  895.  
  896. /*****************************************************************************
  897. *
  898. * FUNCTION
  899. *
  900. *   Print_Options
  901. *
  902. * INPUT
  903. *   
  904. * OUTPUT
  905. *   
  906. * RETURNS
  907. *   
  908. * AUTHOR
  909. *
  910. *   POV-Ray Team
  911. *   
  912. * DESCRIPTION
  913. *
  914. *   -
  915. *
  916. * CHANGES
  917. *
  918. *   -
  919. *
  920. ******************************************************************************/
  921.  
  922. void Print_Options()
  923. {
  924.   int i, j;
  925.  
  926.   /* Print parsing options. */
  927.  
  928.   Render_Info("Parsing Options\n");
  929.  
  930.   Render_Info("  Input file: %s", opts.Input_File_Name);
  931.   /* NK 1999 changed this to %g instead of %.1f */
  932.   Render_Info(" (compatible to version %g)\n", opts.Language_Version/100.0);
  933.  
  934.   rinfo_on   ("  Remove bounds.......", (opts.Options & REMOVE_BOUNDS));
  935.   rinfo_on   ("  Split unions........", (opts.Options & SPLIT_UNION));
  936.   Render_Info("\n");
  937.  
  938.   j = 17;
  939.  
  940.   Render_Info("  Library paths:");
  941.   for (i = 0; i < opts.Library_Path_Index; i++)
  942.   {
  943.     j += strlen(opts.Library_Paths[i])+2;
  944.  
  945.     if (j > 77)
  946.     {
  947.       Render_Info("\n   ", j);
  948.  
  949.       j = strlen(opts.Library_Paths[i]) + 5;
  950.     }
  951.  
  952.     Render_Info(" %s", opts.Library_Paths[i]);
  953.   }
  954.  
  955.   Render_Info("\n");
  956.  
  957.   /* Print output options. */
  958.  
  959.   Render_Info("Output Options\n");
  960.  
  961.   Render_Info("  Image resolution %d by %d",
  962.                                     Frame.Screen_Width, Frame.Screen_Height);
  963.   Render_Info(" (rows %d to %d, columns %d to %d).\n",
  964.                        opts.First_Line, opts.Last_Line,
  965.                        opts.First_Column, opts.Last_Column);
  966.  
  967.   if (opts.Options & DISKWRITE)
  968.   {
  969.     Render_Info("  Output file: %s%s, ", opts.Output_Path, opts.Output_File_Name);
  970.  
  971.     if (toupper(opts.OutputFormat) == 'N' && opts.Options & HF_GRAY_16)
  972.     {
  973.        Render_Info("%d bpp ", opts.OutputQuality);
  974.     }
  975.     else
  976.     {
  977.       Render_Info("%d bpp ", ((opts.Options & OUTPUT_ALPHA) ? 4 : 3) * opts.OutputQuality);
  978.     }
  979.  
  980.     switch (toupper(opts.OutputFormat))
  981.     {
  982.       case 'C': Render_Info("RLE Targa");       break;
  983.       case 'N': Render_Info("PNG");             break;
  984.       case 'P': Render_Info("PPM");             break;
  985.       case 'S': Render_Info("(system format)"); break;
  986.       case 'T': Render_Info("Targa");           break;
  987. #ifdef df3OuputPatch
  988.        case 'D': Render_Info("Density file");    break;
  989. #endif
  990.     }
  991.  
  992.     if (opts.Options & HF_GRAY_16)
  993.     {
  994.       if (toupper(opts.OutputFormat) == 'N')
  995.       {
  996.         Render_Info(" grayscale");
  997.       }
  998.       else if (opts.Options & HF_GRAY_16)
  999.       {
  1000.         Render_Info(" POV heightfield");
  1001.       }
  1002.     }
  1003.  
  1004.     if (opts.Options & OUTPUT_ALPHA)
  1005.     {
  1006.       Render_Info(" with alpha");
  1007.     }
  1008.  
  1009.     if ((opts.Options & BUFFERED_OUTPUT) && (opts.File_Buffer_Size != 0))
  1010.     {
  1011.       Render_Info(", %d KByte buffer\n", opts.File_Buffer_Size/1024);
  1012.     }
  1013.     else
  1014.     {
  1015.       Render_Info("\n");
  1016.     }
  1017.   }
  1018.   else if (opts.Options & DISPLAY)
  1019.   {
  1020.     if (opts.histogram_on == TRUE)
  1021.     {
  1022.       Warning(0, "  Rendering to screen and histogram file only.\n");
  1023.     }
  1024.     else
  1025.     {
  1026.       Warning(0, "  Rendering to screen only. No file output.\n");
  1027.     }
  1028.   }
  1029.   else if (opts.histogram_on == TRUE)
  1030.   {
  1031.     Warning(0, "  Rendering to histogram file only.\n");
  1032.   }
  1033.   else
  1034.   {
  1035.     Warning(0, "  Rendering to nothing! No screen or file output.\n");
  1036.   }
  1037.  
  1038.   rinfo_on   ("  Graphic display.....", (opts.Options & DISPLAY));
  1039.   if (opts.Options & DISPLAY)
  1040.   {
  1041.     Render_Info("  (type: %c, palette: %c, gamma: %4.2g)",
  1042.                toupper(opts.DisplayFormat), toupper(opts.PaletteOption),
  1043.                opts.DisplayGamma);
  1044.   }
  1045.   Render_Info("\n");
  1046.  
  1047.   rinfo_on   ("  Mosaic preview......", (opts.Options & PREVIEW));
  1048.   if (opts.Options & PREVIEW)
  1049.   {
  1050.     Render_Info("  (pixel sizes %d to %d)",
  1051.                opts.PreviewGridSize_Start, opts.PreviewGridSize_End);
  1052.   }
  1053.   Render_Info("\n");
  1054.  
  1055. #if PRECISION_TIMER_AVAILABLE
  1056.   rinfo_on ("  CPU usage histogram.", opts.histogram_on);
  1057.   if (opts.histogram_on)
  1058.   {
  1059.     char *type;
  1060.  
  1061.     switch (opts.histogram_type)
  1062.     {
  1063.       case CSV:   type = "CSV"; break;
  1064.       case TARGA: type = "TGA"; break;
  1065.       case PNG:   type = "PNG"; break;
  1066.       case PPM:   type = "PPM"; break;
  1067.       case SYS:   type = "(system format)"; break;
  1068.       case NONE:                     /* Just to stop warning messages */
  1069.       default:    type = "None"; break;
  1070.     }
  1071.  
  1072.     Render_Info("  (name: %s type: %s, grid: %dx%d)",
  1073.              opts.Histogram_File_Name,type,opts.histogram_x,opts.histogram_y);
  1074.   }
  1075.   Render_Info("\n");
  1076. #endif /* PRECISION_TIMER_AVAILABLE */
  1077.  
  1078.   rinfo_on   ("  Continued trace.....", (opts.Options & CONTINUE_TRACE));
  1079.   rinfo_on   ("  Allow interruption..", (opts.Options & EXITENABLE));
  1080.   rinfo_on   ("  Pause when done.....", (opts.Options & PROMPTEXIT));
  1081.   Render_Info("\n");
  1082.  
  1083.   rinfo_on   ("  Verbose messages....", (opts.Options & VERBOSE));
  1084.  
  1085.   Render_Info("\n");
  1086.  
  1087.   /* Print tracing options. */
  1088.  
  1089.   Render_Info("Tracing Options\n");
  1090.  
  1091.   Render_Info("  Quality: %2d\n", opts.Quality);
  1092.  
  1093.   rinfo_on   ("  Bounding boxes......", opts.Use_Slabs);
  1094.   if (opts.Use_Slabs)
  1095.   {
  1096.     Render_Info("  Bounding threshold: %d ", opts.BBox_Threshold);
  1097.   }
  1098.   Render_Info("\n");
  1099.  
  1100.   rinfo_on("  Light Buffer........", (opts.Options & USE_LIGHT_BUFFER));
  1101.   rinfo_on("  Vista Buffer........", (opts.Options & USE_VISTA_BUFFER));
  1102.   if (opts.Options & USE_VISTA_BUFFER && opts.Options & DISPLAY)
  1103.   {
  1104.     rinfo_on("  Draw Vista Buffer...", (opts.Options & USE_VISTA_DRAW));
  1105.   }
  1106.   Render_Info("\n");
  1107.  
  1108.   rinfo_on   ("  Antialiasing........", (opts.Options & ANTIALIAS));
  1109.   if (opts.Options & ANTIALIAS)
  1110.   {
  1111.     Render_Info("  (Method %d, ", opts.Tracing_Method);
  1112.     Render_Info("Threshold %.3f, ", opts.Antialias_Threshold);
  1113.     Render_Info("Depth %ld, ", opts.AntialiasDepth);
  1114.     Render_Info("Jitter %.2f)", opts.JitterScale);
  1115.   }
  1116.   Render_Info("\n");
  1117.  
  1118.   rinfo_on   ("  Radiosity...........", (opts.Options & RADIOSITY));
  1119.  
  1120.   Render_Info("\n");
  1121.  
  1122.   /* Print animation options. */
  1123.  
  1124.   Render_Info("Animation Options\n");
  1125.  
  1126.   if (opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME)
  1127.   {
  1128.     Render_Info("  Initial Frame..%8d", opts.FrameSeq.InitialFrame);
  1129.     Render_Info("  Final Frame....%8d\n", opts.FrameSeq.FinalFrame);
  1130.     Render_Info("  Initial Clock..%8.3f", opts.FrameSeq.InitialClock);
  1131.     Render_Info("  Final Clock....%8.3f\n", opts.FrameSeq.FinalClock);
  1132.     rinfo_on   ("  Cyclic Animation....", (opts.Options & CYCLIC_ANIMATION));
  1133.     rinfo_on   ("  Field render........", (opts.FrameSeq.Field_Render_Flag));
  1134.     rinfo_on   ("  Odd lines/frames....", (opts.FrameSeq.Odd_Field_Flag));
  1135.   }
  1136.   else
  1137.   {
  1138.     Render_Info("  Clock value....%8.3f", opts.FrameSeq.Clock_Value);
  1139.     Render_Info("  (Animation off)");
  1140.   }
  1141.  
  1142.   Render_Info("\n");
  1143.  
  1144.   /* Print redirecting options. */
  1145.  
  1146.   Render_Info("Redirecting Options\n");
  1147.  
  1148.   rinfo_on   ("  All Streams to console.........", Stream_Info[ALL_STREAM].do_console);
  1149.   if (Stream_Info[ALL_STREAM].name == NULL)
  1150.   {
  1151.     Render_Info("\n");
  1152.   }
  1153.   else
  1154.   {
  1155.     Render_Info("  and file %s\n", Stream_Info[ALL_STREAM].name);
  1156.   }
  1157.  
  1158.   rinfo_on   ("  Debug Stream to console........", Stream_Info[DEBUG_STREAM].do_console);
  1159.   if (Stream_Info[DEBUG_STREAM].name == NULL)
  1160.   {
  1161.     Render_Info("\n");
  1162.   }
  1163.   else
  1164.   {
  1165.     Render_Info("  and file %s\n", Stream_Info[DEBUG_STREAM].name);
  1166.   }
  1167.  
  1168.   rinfo_on   ("  Fatal Stream to console........", Stream_Info[FATAL_STREAM].do_console);
  1169.   if (Stream_Info[FATAL_STREAM].name == NULL)
  1170.   {
  1171.     Render_Info("\n");
  1172.   }
  1173.   else
  1174.   {
  1175.     Render_Info("  and file %s\n", Stream_Info[FATAL_STREAM].name);
  1176.   }
  1177.  
  1178.   rinfo_on   ("  Render Stream to console.......", Stream_Info[RENDER_STREAM].do_console);
  1179.   if (Stream_Info[RENDER_STREAM].name == NULL)
  1180.   {
  1181.     Render_Info("\n");
  1182.   }
  1183.   else
  1184.   {
  1185.     Render_Info("  and file %s\n", Stream_Info[RENDER_STREAM].name);
  1186.   }
  1187.  
  1188.   rinfo_on   ("  Statistics Stream to console...", Stream_Info[STATISTIC_STREAM].do_console);
  1189.   if (Stream_Info[STATISTIC_STREAM].name == NULL)
  1190.   {
  1191.     Render_Info("\n");
  1192.   }
  1193.   else
  1194.   {
  1195.     Render_Info("  and file %s\n", Stream_Info[STATISTIC_STREAM].name);
  1196.   }
  1197.  
  1198.   rinfo_on   ("  Warning Stream to console......", Stream_Info[WARNING_STREAM].do_console);
  1199.   if (Stream_Info[WARNING_STREAM].name == NULL)
  1200.   {
  1201.     Render_Info("\n");
  1202.   }
  1203.   else
  1204.   {
  1205.     Render_Info("  and file %s\n", Stream_Info[WARNING_STREAM].name);
  1206.   }
  1207. }
  1208.  
  1209.  
  1210.  
  1211. /*****************************************************************************
  1212. *
  1213. * FUNCTION
  1214. *
  1215. *   Print_Stats
  1216. *
  1217. * INPUT
  1218. *   
  1219. * OUTPUT
  1220. *   
  1221. * RETURNS
  1222. *   
  1223. * AUTHOR
  1224. *
  1225. *   POV-Ray Team
  1226. *
  1227. * DESCRIPTION
  1228. *
  1229. *   -
  1230. *
  1231. * CHANGES
  1232. *
  1233. *   -
  1234. *
  1235. ******************************************************************************/
  1236.  
  1237. void Print_Stats(COUNTER *pstats)
  1238. {
  1239.   unsigned long hours, minutes;
  1240.   DBL seconds, taverage, ttotal;
  1241.   long Pixels_In_Image;
  1242. /** poviso: July 23 '96  R.S. **/
  1243. #ifdef POVISO
  1244.   FUNCTION *TFunc;
  1245.   int i;
  1246. #endif
  1247. /** --- **/
  1248.  
  1249.   Pixels_In_Image = (long)Frame.Screen_Width * (long)Frame.Screen_Height;
  1250.  
  1251.   Statistics ("\n%s Statistics", opts.Input_File_Name);
  1252.  
  1253.   if ( Pixels_In_Image > DBL_Counter(pstats[Number_Of_Pixels]) )
  1254.     Statistics (" (Partial Image Rendered)");
  1255.  
  1256.   Statistics (", Resolution %d x %d\n", Frame.Screen_Width, Frame.Screen_Height);
  1257.  
  1258.   Statistics ("----------------------------------------------------------------------------\n");
  1259.  
  1260.   Statistics ("Pixels: %15.0f   Samples: %15.0f   Smpls/Pxl: ",
  1261.               DBL_Counter(pstats[Number_Of_Pixels]),
  1262.               DBL_Counter(pstats[Number_Of_Samples]));
  1263.  
  1264.   if (!Test_Zero_Counter(pstats[Number_Of_Pixels]))
  1265.   {
  1266.     Statistics ("%.2f\n",
  1267.               DBL_Counter(pstats[Number_Of_Samples]) /
  1268.               DBL_Counter(pstats[Number_Of_Pixels]));
  1269.   }
  1270.   else
  1271.   {
  1272.     Statistics ("-\n");
  1273.   }
  1274.  
  1275.   counter_to_string(&pstats[Number_Of_Rays], s1, OUTPUT_LENGTH);
  1276.   counter_to_string(&pstats[ADC_Saves], s2, OUTPUT_LENGTH);
  1277.  
  1278.   Statistics ("Rays:    %s   Saved:    %s   Max Level: %d/%d\n",
  1279.               s1, s2, Highest_Trace_Level, Max_Trace_Level);
  1280.  
  1281.   Statistics ("----------------------------------------------------------------------------\n");
  1282.  
  1283.   Statistics ("Ray->Shape Intersection          Tests       Succeeded  Percentage\n");
  1284.   Statistics ("----------------------------------------------------------------------------\n");
  1285. #ifdef RBezierPatch
  1286.   print_intersection_stats("Bicubic Patch",          &pstats[Ray_Bicubic_Tests],
  1287.        &pstats[Ray_Bicubic_Tests_Succeeded]);
  1288. #endif
  1289.   print_intersection_stats("Bezier Patch",          &pstats[Ray_Bicubic_Tests],
  1290.        &pstats[Ray_Bicubic_Tests_Succeeded]);
  1291.  
  1292.   print_intersection_stats("Blob",                  &pstats[Ray_Blob_Tests],
  1293.        &pstats[Ray_Blob_Tests_Succeeded]);
  1294. #ifdef BLOB_EXTRA_STATS
  1295.   print_intersection_stats("Blob Component",        &pstats[Blob_Element_Tests],
  1296.        &pstats[Blob_Element_Tests_Succeeded]);
  1297.   print_intersection_stats("Blob Bound",            &pstats[Blob_Bound_Tests],
  1298.        &pstats[Blob_Bound_Tests_Succeeded]);
  1299. #endif
  1300. #ifdef IsoBlobPatch
  1301. /* Added by Lummox JR, July 1999 */
  1302.   print_intersection_stats("Isoblob",               &pstats[Ray_Isoblob_Tests],
  1303.        &pstats[Ray_Isoblob_Tests_Succeeded]);
  1304. #ifdef BLOB_EXTRA_STATS
  1305.   print_intersection_stats("Isoblob Component",     &pstats[Isoblob_Element_Tests],
  1306.        &pstats[Isoblob_Element_Tests_Succeeded]);
  1307.   print_intersection_stats("Isoblob Bound",         &pstats[Isoblob_Bound_Tests],
  1308.        &pstats[Isoblob_Bound_Tests_Succeeded]);
  1309. #endif
  1310. /* end Lummox JR's additions */
  1311.  
  1312. #endif
  1313. #ifdef MotionBlurPatch
  1314.   print_intersection_stats("Motion Blur",          &pstats[Ray_Motion_Blur_Tests],
  1315.        &pstats[Ray_Motion_Blur_Tests_Succeeded]);
  1316. #endif
  1317.  
  1318.   print_intersection_stats("Box",                   &pstats[Ray_Box_Tests],
  1319.        &pstats[Ray_Box_Tests_Succeeded]);
  1320.   print_intersection_stats("Cone/Cylinder",         &pstats[Ray_Cone_Tests],
  1321.        &pstats[Ray_Cone_Tests_Succeeded]);
  1322.   print_intersection_stats("CSG Intersection",      &pstats[Ray_CSG_Intersection_Tests],
  1323.        &pstats[Ray_CSG_Intersection_Tests_Succeeded]);
  1324.   print_intersection_stats("CSG Merge",             &pstats[Ray_CSG_Merge_Tests],
  1325.        &pstats[Ray_CSG_Merge_Tests_Succeeded]);
  1326.   print_intersection_stats("CSG Union",             &pstats[Ray_CSG_Union_Tests],
  1327.        &pstats[Ray_CSG_Union_Tests_Succeeded]);
  1328.  
  1329.   print_intersection_stats("Disc",                  &pstats[Ray_Disc_Tests],
  1330.        &pstats[Ray_Disc_Tests_Succeeded]);
  1331.   print_intersection_stats("Fractal",               &pstats[Ray_Fractal_Tests],
  1332.        &pstats[Ray_Fractal_Tests_Succeeded]);
  1333.  
  1334.   print_intersection_stats("Height Field",          &pstats[Ray_HField_Tests],
  1335.        &pstats[Ray_HField_Tests_Succeeded]);
  1336. #ifdef HFIELD_EXTRA_STATS
  1337.   print_intersection_stats("Height Field Box",      &pstats[Ray_HField_Box_Tests],
  1338.        &pstats[Ray_HField_Box_Tests_Succeeded]);
  1339.   print_intersection_stats("Height Field Triangle", &pstats[Ray_HField_Triangle_Tests],
  1340.        &pstats[Ray_HField_Triangle_Tests_Succeeded]);
  1341.   print_intersection_stats("Height Field Block",    &pstats[Ray_HField_Block_Tests],
  1342.        &pstats[Ray_HField_Block_Tests_Succeeded]);
  1343.   print_intersection_stats("Height Field Cell",     &pstats[Ray_HField_Cell_Tests],
  1344.        &pstats[Ray_HField_Cell_Tests_Succeeded]);
  1345. #endif
  1346.  
  1347.   print_intersection_stats("Lathe",                 &pstats[Ray_Lathe_Tests],
  1348.        &pstats[Ray_Lathe_Tests_Succeeded]);
  1349. #ifdef LATHE_EXTRA_STATS
  1350.   print_intersection_stats("Lathe Bound",           &pstats[Lathe_Bound_Tests],
  1351.        &pstats[Lathe_Bound_Tests_Succeeded]);
  1352. #endif
  1353.  
  1354.   print_intersection_stats("Mesh",                  &pstats[Ray_Mesh_Tests],
  1355.        &pstats[Ray_Mesh_Tests_Succeeded]);
  1356.   print_intersection_stats("Plane",                 &pstats[Ray_Plane_Tests],
  1357.        &pstats[Ray_Plane_Tests_Succeeded]);
  1358.   print_intersection_stats("Polygon",               &pstats[Ray_Polygon_Tests],
  1359.        &pstats[Ray_Polygon_Tests_Succeeded]);
  1360.  
  1361.   print_intersection_stats("Prism",                 &pstats[Ray_Prism_Tests],
  1362.        &pstats[Ray_Prism_Tests_Succeeded]);
  1363. #ifdef PRISM_EXTRA_STATS
  1364.   print_intersection_stats("Prism Bound",           &pstats[Prism_Bound_Tests],
  1365.        &pstats[Prism_Bound_Tests_Succeeded]);
  1366. #endif
  1367.  
  1368.   print_intersection_stats("Quadric",               &pstats[Ray_Quadric_Tests],
  1369.        &pstats[Ray_Quadric_Tests_Succeeded]);
  1370.   print_intersection_stats("Quartic/Poly",          &pstats[Ray_Poly_Tests],
  1371.        &pstats[Ray_Poly_Tests_Succeeded]);
  1372.   print_intersection_stats("Sphere",                &pstats[Ray_Sphere_Tests],
  1373.        &pstats[Ray_Sphere_Tests_Succeeded]);
  1374.       /* Sphere  [Sweep supportJL] */
  1375.   print_intersection_stats("Sphere Sweep",          &pstats[Ray_Sphere_Sweep_Tests],
  1376.        &pstats[Ray_Sphere_Sweep_Tests_Succeeded]);
  1377.   print_intersection_stats("Superellipsoid",        &pstats[Ray_Superellipsoid_Tests],
  1378.        &pstats[Ray_Superellipsoid_Tests_Succeeded]);
  1379.  
  1380.   print_intersection_stats("Surface of Revolution", &pstats[Ray_Sor_Tests],
  1381.        &pstats[Ray_Sor_Tests_Succeeded]);
  1382. #ifdef SOR_EXTRA_STATS
  1383.   print_intersection_stats("Surface of Rev. Bound", &pstats[Sor_Bound_Tests],
  1384.        &pstats[Sor_Bound_Tests_Succeeded]);
  1385. #endif
  1386.  
  1387.   print_intersection_stats("Torus",                 &pstats[Ray_Torus_Tests],
  1388.        &pstats[Ray_Torus_Tests_Succeeded]);
  1389. #ifdef TORUS_EXTRA_STATS
  1390.   print_intersection_stats("Torus Bound",           &pstats[Torus_Bound_Tests],
  1391.        &pstats[Torus_Bound_Tests_Succeeded]);
  1392. #endif
  1393.  
  1394.   print_intersection_stats("Triangle",              &pstats[Ray_Triangle_Tests],
  1395.        &pstats[Ray_Triangle_Tests_Succeeded]);
  1396.   print_intersection_stats("True Type Font",        &pstats[Ray_TTF_Tests],
  1397.        &pstats[Ray_TTF_Tests_Succeeded]);
  1398. /** poviso: July 15, '96 R.S. **/
  1399. #ifdef POVISO
  1400.   print_intersection_stats("Isosurface Bound",        &pstats[Ray_IsoSurface_Bound_Tests],
  1401.        &pstats[Ray_IsoSurface_Bound_Tests_Succeeded]);
  1402.   print_intersection_stats("Isosurface",        &pstats[Ray_IsoSurface_Tests],
  1403.        &pstats[Ray_IsoSurface_Tests_Succeeded]);
  1404.   print_intersection_stats("Isosurface Cache",        &pstats[Ray_IsoSurface_Cache],
  1405.        &pstats[Ray_IsoSurface_Cache_Succeeded]);
  1406.   print_intersection_stats("Parametric Box",        &pstats[Ray_Par_Box_Tests],
  1407.        &pstats[Ray_Par_Box_Tests_Succeeded]);
  1408.   print_intersection_stats("Parametric",        &pstats[Ray_Parametric_Tests],
  1409.        &pstats[Ray_Parametric_Tests_Succeeded]);
  1410. #endif
  1411. /** --- **/
  1412.  
  1413.   print_intersection_stats("Bounding Object", &pstats[Bounding_Region_Tests],
  1414.        &pstats[Bounding_Region_Tests_Succeeded]);
  1415.   print_intersection_stats("Clipping Object", &pstats[Clipping_Region_Tests],
  1416.        &pstats[Clipping_Region_Tests_Succeeded]);
  1417.   print_intersection_stats("Bounding Box",    &pstats[nChecked],
  1418.        &pstats[nEnqueued]);
  1419.   print_intersection_stats("Light Buffer",    &pstats[LBuffer_Tests],
  1420.        &pstats[LBuffer_Tests_Succeeded]);
  1421.   print_intersection_stats("Vista Buffer",    &pstats[VBuffer_Tests],
  1422.        &pstats[VBuffer_Tests_Succeeded]);
  1423.  
  1424.   Statistics ("----------------------------------------------------------------------------\n");
  1425. /** poviso: July 15, '96 R.S. **/
  1426. #ifdef POVISO
  1427.    i=0;
  1428.    if (First_Func)
  1429.     {
  1430.       TFunc=First_Func;
  1431.       while (TFunc)
  1432.       {
  1433.           if (TFunc->gradient!=0.0)
  1434.           {
  1435.               i++;
  1436.               Statistics ("  function%4d :%15s              max_gradient: %9.3f\n",
  1437.                   i, TFunc->func_name, TFunc->gradient);
  1438.           }
  1439.           TFunc=TFunc->next;
  1440.       }
  1441.     }
  1442.     if (i>0) Statistics ("----------------------------------------------------------------------------\n");
  1443. #endif
  1444. /** --- **/
  1445.  
  1446.   if (!Test_Zero_Counter(pstats[Polynomials_Tested]))
  1447.   {
  1448.     counter_to_string(&pstats[Polynomials_Tested], s1, OUTPUT_LENGTH);
  1449.     counter_to_string(&pstats[Roots_Eliminated], s2, OUTPUT_LENGTH);
  1450.  
  1451.     Statistics ("Roots tested:       %s   eliminated:      %s\n", s1, s2);
  1452.   }
  1453.  
  1454.   counter_to_string(&pstats[Calls_To_Noise], s1, OUTPUT_LENGTH);
  1455.   counter_to_string(&pstats[Calls_To_DNoise], s2, OUTPUT_LENGTH);
  1456.  
  1457.   Statistics ("Calls to Noise:     %s   Calls to DNoise: %s\n", s1, s2);
  1458.  
  1459.   Statistics ("----------------------------------------------------------------------------\n");
  1460.  
  1461.   /* Print media samples. */
  1462.  
  1463.   if (!Test_Zero_Counter(pstats[Media_Intervals]))
  1464.   {
  1465.     counter_to_string(&pstats[Media_Intervals], s1, OUTPUT_LENGTH);
  1466.     counter_to_string(&pstats[Media_Samples], s2, OUTPUT_LENGTH);
  1467.  
  1468.     Statistics ("Media Intervals:    %s   Media Samples:   %s (%4.2f)\n", s1, s2,
  1469.       DBL_Counter(pstats[Media_Samples]) / DBL_Counter(pstats[Media_Intervals]));
  1470.   }
  1471.  
  1472.   if (!Test_Zero_Counter(pstats[Shadow_Ray_Tests]))
  1473.   {
  1474.     counter_to_string(&pstats[Shadow_Ray_Tests], s1, OUTPUT_LENGTH);
  1475.     counter_to_string(&pstats[Shadow_Rays_Succeeded], s2, OUTPUT_LENGTH);
  1476.  
  1477.     Statistics ("Shadow Ray Tests:   %s   Succeeded:       %s\n", s1, s2);
  1478.   }
  1479.  
  1480.   if (!Test_Zero_Counter(pstats[Reflected_Rays_Traced]))
  1481.   {
  1482.     counter_to_string(&pstats[Reflected_Rays_Traced], s1, OUTPUT_LENGTH);
  1483.  
  1484.     Statistics ("Reflected Rays:     %s", s1);
  1485.  
  1486.     if (!Test_Zero_Counter(pstats[Internal_Reflected_Rays_Traced]))
  1487.     {
  1488.       counter_to_string(&pstats[Internal_Reflected_Rays_Traced], s1, OUTPUT_LENGTH);
  1489.  
  1490.       Statistics ("   Total Internal:  %s", s1);
  1491.     }
  1492.  
  1493.     Statistics ("\n");
  1494.   }
  1495.  
  1496.   if (!Test_Zero_Counter(pstats[Refracted_Rays_Traced]))
  1497.   {
  1498.     counter_to_string(&pstats[Refracted_Rays_Traced], s1, OUTPUT_LENGTH);
  1499.  
  1500.     Statistics ("Refracted Rays:     %s\n", s1);
  1501.   }
  1502.  
  1503.   if (!Test_Zero_Counter(pstats[Transmitted_Rays_Traced]))
  1504.   {
  1505.     counter_to_string(&pstats[Transmitted_Rays_Traced], s1, OUTPUT_LENGTH);
  1506.  
  1507.     Statistics ("Transmitted Rays:   %s\n", s1);
  1508.   }
  1509.  
  1510.   if (!Test_Zero_Counter(pstats[Istack_overflows]))
  1511.   {
  1512.     counter_to_string(&pstats[Istack_overflows], s1, OUTPUT_LENGTH);
  1513.  
  1514.     Statistics ("I-Stack overflows:  %s\n", s1);
  1515.   }
  1516.  
  1517.   /* NK phmap - regular & testing stats */
  1518.   if (!Test_Zero_Counter(pstats[Number_Of_Photons_Shot]))
  1519.   {
  1520.     counter_to_string(&pstats[Number_Of_Photons_Shot], s1, OUTPUT_LENGTH);
  1521.     Statistics ("Number of photons shot: %s\n", s1);
  1522.   }
  1523.   if (!Test_Zero_Counter(pstats[Number_Of_Photons_Stored]))
  1524.   {
  1525.     counter_to_string(&pstats[Number_Of_Photons_Stored], s1, OUTPUT_LENGTH);
  1526.     Statistics ("Surface photons stored: %s\n", s1);
  1527.   }
  1528.   if (!Test_Zero_Counter(pstats[Number_Of_Media_Photons_Stored]))
  1529.   {
  1530.     counter_to_string(&pstats[Number_Of_Media_Photons_Stored], s1, OUTPUT_LENGTH);
  1531.     Statistics ("Media photons stored:   %s\n", s1);
  1532.   }
  1533.   if (!Test_Zero_Counter(pstats[Number_Of_Global_Photons_Stored]))
  1534.   {
  1535.     counter_to_string(&pstats[Number_Of_Global_Photons_Stored], s1, OUTPUT_LENGTH);
  1536.     Statistics ("Global photons stored:  %s\n", s1);
  1537.   }
  1538.   if (!Test_Zero_Counter(pstats[Priority_Queue_Insert]))
  1539.   {
  1540.     counter_to_string(&pstats[Priority_Queue_Insert], s1, OUTPUT_LENGTH);
  1541.     Statistics ("Priority queue insert:  %s\n", s1);
  1542.   }
  1543.   if (!Test_Zero_Counter(pstats[Priority_Queue_Remove]))
  1544.   {
  1545.     counter_to_string(&pstats[Priority_Queue_Remove], s1, OUTPUT_LENGTH);
  1546.     Statistics ("Priority queue remove:  %s\n", s1);
  1547.   }
  1548.   if (!Test_Zero_Counter(pstats[Gather_Performed_Count]))
  1549.   {
  1550.     counter_to_string(&pstats[Gather_Performed_Count], s1, OUTPUT_LENGTH);
  1551.     Statistics ("Gather function called: %s\n", s1);
  1552.   }
  1553.   if (!Test_Zero_Counter(pstats[Gather_Expanded_Count]))
  1554.   {
  1555.     counter_to_string(&pstats[Gather_Expanded_Count], s1, OUTPUT_LENGTH);
  1556.     Statistics ("Gather radius expanded: %s\n", s1);
  1557.   }
  1558.   /* NK ---- */
  1559.  
  1560.   if ( ra_reuse_count || ra_gather_count )
  1561.   {
  1562.     Statistics ("----------------------------------------------------------------------------\n");
  1563.     Statistics ("Radiosity samples calculated:  %9ld (%.2f percent)\n", ra_gather_count,
  1564.                 100.*(DBL) ra_gather_count / ((DBL)(ra_gather_count + ra_reuse_count)));
  1565.     /* Note:  don't try to put in a percent sign.  There is basically no way to do this
  1566.        which is completely portable using va_start */
  1567.     Statistics ("Radiosity samples reused:      %9ld\n", ra_reuse_count);
  1568.   }
  1569.  
  1570. #if defined(MEM_STATS)
  1571.   Statistics ("----------------------------------------------------------------------------\n");
  1572.  
  1573.   Long_To_Counter(mem_stats_smallest_alloc(), pstats[MemStat_Smallest_Alloc]);
  1574.   counter_to_string(&pstats[MemStat_Smallest_Alloc], s1, OUTPUT_LENGTH);
  1575.  
  1576.   Long_To_Counter(mem_stats_largest_alloc(), pstats[MemStat_Largest_Alloc]);
  1577.   counter_to_string(&pstats[MemStat_Largest_Alloc],  s2, OUTPUT_LENGTH);
  1578.  
  1579. #if (MEM_STATS==1)
  1580.   Statistics ("Smallest Alloc:     %s bytes   Largest:   %s\n", s1, s2);
  1581. #elif (MEM_STATS>=2)
  1582.   Statistics ("Smallest Alloc:     %s bytes @ %s:%d\n", s1, mem_stats_smallest_file(), mem_stats_smallest_line());
  1583.   Statistics ("Largest  Alloc:     %s bytes @ %s:%d\n", s2, mem_stats_largest_file(), mem_stats_largest_line());
  1584.  
  1585.   Long_To_Counter(mem_stats_total_allocs(), pstats[MemStat_Total_Allocs]);
  1586.   counter_to_string(&pstats[MemStat_Total_Allocs], s1, OUTPUT_LENGTH);
  1587.   Long_To_Counter(mem_stats_total_frees(), pstats[MemStat_Total_Frees]);
  1588.   counter_to_string(&pstats[MemStat_Total_Frees], s2, OUTPUT_LENGTH);
  1589.   Statistics ("Total Alloc calls:  %s         Free calls:%s\n", s1, s2);
  1590. #endif
  1591.  
  1592.   Long_To_Counter(mem_stats_largest_mem_usage(), pstats[MemStat_Largest_Mem_Usage]);
  1593.   counter_to_string(&pstats[MemStat_Largest_Mem_Usage], s1, OUTPUT_LENGTH);
  1594.   Statistics ("Peak memory used:   %s bytes\n", s1);
  1595.  
  1596. #endif
  1597.  
  1598.   Statistics ("----------------------------------------------------------------------------\n");
  1599.  
  1600.   /* Get time in case the trace was aborted. */
  1601.  
  1602.   if (trender == 0.0)
  1603.   {
  1604.     STOP_TIME
  1605.  
  1606. #ifdef PostProcessPatch
  1607.     if (Stage == STAGE_POST_PROCESS)
  1608.       tpost = TIME_ELAPSED
  1609.     else
  1610. #endif
  1611.     trender = TIME_ELAPSED
  1612.   }
  1613.  
  1614.   if (opts.FrameSeq.FrameType == FT_MULTIPLE_FRAME)
  1615.   {
  1616.     if (tparse_total != 0.0)
  1617.     {
  1618.       taverage = tparse_total /
  1619.           (DBL)(opts.FrameSeq.FrameNumber - opts.FrameSeq.InitialFrame + 1);
  1620.  
  1621.       SPLIT_TIME(taverage,&hours,&minutes,&seconds);
  1622.       Statistics ("Time For Parse/Frame:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1623.           hours, minutes, seconds, (long)taverage);
  1624.  
  1625.       SPLIT_TIME(tparse_total,&hours,&minutes,&seconds);
  1626.       Statistics ("Time For Parse Total:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1627.           hours, minutes, seconds, (long)tparse_total);
  1628.     }
  1629.  
  1630.     /* NK photons */
  1631.     if (tphoton_total != 0.0)
  1632.     {
  1633.       taverage = tphoton_total /
  1634.           (DBL)(opts.FrameSeq.FrameNumber - opts.FrameSeq.InitialFrame + 1);
  1635.  
  1636.       SPLIT_TIME(taverage,&hours,&minutes,&seconds);
  1637.       Statistics ("Time For Photon/Frame: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1638.           hours, minutes, seconds, (long)taverage);
  1639.  
  1640.       SPLIT_TIME(tphoton_total,&hours,&minutes,&seconds);
  1641.       Statistics ("Time For Photon Total: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1642.           hours, minutes, seconds, (long)tphoton_total);
  1643.     }
  1644.     /* NK ---- */
  1645.  
  1646.     if (trender_total != 0.0)
  1647.     {
  1648.       taverage = trender_total /
  1649.           (DBL)(opts.FrameSeq.FrameNumber - opts.FrameSeq.InitialFrame + 1);
  1650.  
  1651.       SPLIT_TIME(taverage,&hours,&minutes,&seconds);
  1652.       Statistics ("Time For Trace/Frame:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1653.           hours, minutes, seconds, (long)taverage);
  1654.  
  1655.       SPLIT_TIME(trender_total,&hours,&minutes,&seconds);
  1656.       Statistics ("Time For Trace Total:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1657.           hours, minutes, seconds, (long)trender_total);
  1658.     }
  1659.  
  1660. #ifdef PostProcessPatch
  1661.     if (tpost_total != 0.0)
  1662.     {
  1663.       taverage = tpost_total /
  1664.           (DBL)(opts.FrameSeq.FrameNumber - opts.FrameSeq.InitialFrame + 1);
  1665.  
  1666.       SPLIT_TIME(taverage,&hours,&minutes,&seconds);
  1667.       Statistics ("Time For Post/Frame:   %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1668.           hours, minutes, seconds, (long)taverage);
  1669.  
  1670.       SPLIT_TIME(tpost_total,&hours,&minutes,&seconds);
  1671.       Statistics ("Time For Post Total:   %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1672.           hours, minutes, seconds, (long)tpost_total);
  1673.     }
  1674. #endif
  1675.  
  1676. #ifdef PostProcessPatch
  1677.     ttotal = tparse_total + tphoton_total + trender_total + tpost_total;
  1678. #else
  1679.     ttotal = tparse_total + tphoton_total + trender_total;
  1680. #endif
  1681.  
  1682.     if (ttotal != 0.0)
  1683.     {
  1684.       SPLIT_TIME(ttotal,&hours,&minutes,&seconds);
  1685.  
  1686.       Statistics ("          Total Time:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1687.           hours, minutes, seconds, (long)ttotal);
  1688.     }
  1689.   }
  1690.   else
  1691.   {
  1692.     if (tparse != 0.0)
  1693.     {
  1694.       SPLIT_TIME(tparse,&hours,&minutes,&seconds);
  1695.  
  1696.       Statistics ("Time For Parse:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1697.           hours, minutes, seconds, (long)tparse);
  1698.     }
  1699.  
  1700.     /* NK photons */
  1701.     if (tphoton != 0.0)
  1702.     {
  1703.       SPLIT_TIME(tphoton,&hours,&minutes,&seconds);
  1704.  
  1705.       Statistics ("Time For Photon: %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1706.           hours, minutes, seconds, (long)tphoton);
  1707.     }
  1708.     /* NK ---- */
  1709.  
  1710.     if (trender != 0.0)
  1711.     {
  1712.       SPLIT_TIME(trender,&hours,&minutes,&seconds);
  1713.  
  1714.       Statistics ("Time For Trace:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1715.           hours, minutes, seconds, (long)trender);
  1716.     }
  1717.  
  1718. #ifdef PostProcessPatch
  1719.     if (tpost != 0.0)
  1720.     {
  1721.       SPLIT_TIME(tpost,&hours,&minutes,&seconds);
  1722.  
  1723.       Statistics ("Time For Post:   %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1724.           hours, minutes, seconds, (long)tpost);
  1725.     }
  1726. #endif
  1727.  
  1728. #ifdef PostProcessPatch
  1729.     ttotal = tparse + tphoton + trender + tpost;
  1730. #else
  1731.     ttotal = tparse + tphoton + trender;
  1732. #endif
  1733.  
  1734.     if (ttotal != 0.0)
  1735.     {
  1736.       SPLIT_TIME(ttotal,&hours,&minutes,&seconds);
  1737.  
  1738.       Statistics ("    Total Time:  %3ld hours %2ld minutes %5.1f seconds (%ld seconds)\n",
  1739.           hours, minutes, seconds, (long)ttotal);
  1740.     }
  1741.   }
  1742.  
  1743. #ifdef UseMediaAndLightCache
  1744.   Statistics("Total cache size: %ld\n",TotalMallocCacheSize);
  1745.  
  1746.   #ifdef AccumulateCacheStatistics
  1747.      if ( MaxAppColourRecCntr > -1)
  1748.       Statistics("Determine_Apparent_Colour Depth: %ld\n",MaxAppColourRecCntr+1);
  1749.      if ( MaxSimMediatRecCntr > -1)
  1750.      Statistics("           Simulate_Media Depth:  %ld\n",MaxSimMediatRecCntr+1);
  1751.      if ( MaxShadowTextRecCntr > -1)
  1752.       Statistics("   compute_shadow_texture Depth: %ld\n",MaxShadowTextRecCntr+1);
  1753.       if ( MaxLightedTexture > -1)
  1754.        Statistics("  compute_lighted_texture Depth:%ld\n",MaxLightedTexture+1);
  1755.    #endif
  1756. #endif
  1757.  
  1758. }
  1759.