home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / radiance / simplerd.lha / simplerad / FinalFTP / Light / conv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-21  |  2.0 KB  |  50 lines

  1. /**********************************************************************/
  2. /* conv.c                                                             */
  3. /*                                                                    */
  4. /* For storing points to show converge in radiosity per iteration     */
  5. /* Plot total radiosity left versus iteration. Show data every n      */
  6. /* iterations by default, where n = label_freq variable.              */
  7. /*                                                                    */
  8. /* Copyright (C) 1992, Bernard Kwok                                   */
  9. /* All rights reserved.                                               */
  10. /* Revision 1.0                                                       */
  11. /* May, 1992                                                          */
  12. /**********************************************************************/
  13. #include <stdio.h>
  14. #include <string.h>
  15.  
  16. extern char *ProgName;
  17.  
  18. int label_freq = 1;           /* Label frequency */
  19. FILE *convfile;               /* File of data points of convergence */
  20. char *convfilename =          /* Filename */
  21.   "                              ";
  22.  
  23. /**********************************************************************/
  24. /* Switch log on / off */
  25. /**********************************************************************/
  26. void LogConv(logflag,fname)
  27.      int logflag;
  28. {
  29.   if (logflag) {
  30.     sprintf(convfilename,"%s.conv",fname);   /* Convergence log */
  31.     if (!(convfile = fopen(convfilename, "w"))) {
  32.       fprintf(stderr,"%s: cannot open log file %s\n", ProgName, convfilename);
  33.       exit(1);
  34.     } 
  35.     printf("\n\t*** Print convergence data to %s ***\n",convfilename);
  36.   } else 
  37.     fclose(convfile);
  38. }
  39.  
  40. /**********************************************************************/
  41. /* Log pair of data */
  42. /**********************************************************************/
  43. void LogConv_Pt(iter,value)
  44.      int iter;
  45.      double value;
  46. {
  47.   if ((iter % label_freq) == 0) /* Every n iterations ? */
  48.     fprintf(convfile,"%g %g\n", (float)iter, value);
  49. }
  50.