ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rpict.c
(Generate patch)

Comparing ray/src/rt/rpict.c (file contents):
Revision 2.51 by gwlarson, Wed Jun 17 13:29:55 1998 UTC vs.
Revision 2.53 by greg, Tue Feb 25 02:47:23 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1996 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  rpict.c - routines and variables for picture generation.
6   */
7  
8 + #include "copyright.h"
9 +
10   #include  "ray.h"
11  
12   #include  <sys/types.h>
# Line 28 | Line 27 | extern time_t  time();
27  
28   #include  "view.h"
29  
31 #include  "resolu.h"
32
30   #include  "random.h"
31  
32   #include  "paths.h"
# Line 40 | Line 37 | extern time_t  time();
37   #define SIGCONT         SIGIO
38   #endif
39  
40 + CUBE  thescene;                         /* our scene */
41 + OBJECT  nsceneobjs;                     /* number of objects in our scene */
42 +
43   int  dimlist[MAXDIM];                   /* sampling dimensions */
44   int  ndims = 0;                         /* number of sampling dimensions */
45   int  samplendx;                         /* sample index number */
46  
47 + extern void  ambnotify();
48 + void  (*addobjnotify[])() = {ambnotify, NULL};
49 +
50   VIEW  ourview = STDVIEW;                /* view parameters */
51   int  hresolu = 512;                     /* horizontal resolution */
52   int  vresolu = 512;                     /* vertical resolution */
# Line 55 | Line 58 | double dstrpix = 0.67;                 /* square pixel distribution
58  
59   double  mblur = 0.;                     /* motion blur parameter */
60  
61 + void  (*trace)() = NULL;                /* trace call */
62 +
63 + int  do_irrad = 0;                      /* compute irradiance? */
64 +
65   double  dstrsrc = 0.0;                  /* square source distribution */
66   double  shadthresh = .05;               /* shadow threshold */
67   double  shadcert = .5;                  /* shadow certainty */
# Line 76 | Line 83 | int  backvis = 1;                      /* back face visibility */
83   int  maxdepth = 6;                      /* maximum recursion depth */
84   double  minweight = 5e-3;               /* minimum ray weight */
85  
86 + char  *ambfile = NULL;                  /* ambient file name */
87   COLOR  ambval = BLKCOLOR;               /* ambient value */
88   int  ambvwt = 0;                        /* initial weight for ambient value */
89   double  ambacc = 0.2;                   /* ambient accuracy */
# Line 86 | Line 94 | int  ambounce = 0;                     /* ambient bounces */
94   char  *amblist[128];                    /* ambient include/exclude list */
95   int  ambincl = -1;                      /* include == 1, exclude == 0 */
96  
89 #ifdef MSDOS
90 int  ralrm = 60;                        /* seconds between reports */
91 #else
97   int  ralrm = 0;                         /* seconds between reports */
93 #endif
98  
99   double  pctdone = 0.0;                  /* percentage done */
96
100   time_t  tlastrept = 0L;                 /* time at last report */
101 + time_t  tstart;                         /* starting time */
102  
99 extern time_t  tstart;                  /* starting time */
100
101 extern unsigned long  nrays;            /* number of rays traced */
102
103   #define  MAXDIV         16              /* maximum sample size */
104  
105   #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
# Line 110 | Line 110 | static VIEW    lastview;               /* the previous view input */
110  
111   extern char  *mktemp();
112  
113 + void  report();
114 +
115   double  pixvalue();
116  
117   #ifdef NIX
# Line 128 | Line 130 | char  *fname;
130   #endif
131  
132  
133 + void
134   quit(code)                      /* quit program */
135   int  code;
136   {
137          if (code)                       /* report status */
138                  report();
139 + #ifndef NIX
140          headclean();                    /* delete header file */
141          pfclean();                      /* clean up persist files */
142 + #endif
143          exit(code);
144   }
145  
146  
147   #ifndef NIX
148 + void
149   report()                /* report progress */
150   {
151          extern char  *myhostname();
# Line 180 | Line 186 | report()               /* report progress */
186   #endif
187   }
188   #else
189 + void
190   report()                /* report progress */
191   {
192          tlastrept = time((time_t *)NULL);
# Line 190 | Line 197 | report()               /* report progress */
197   #endif
198  
199  
200 + void
201   rpict(seq, pout, zout, prvr)                    /* generate image(s) */
202   int  seq;
203   char  *pout, *zout, *prvr;
# Line 290 | Line 298 | char  *pout, *zout, *prvr;
298                  hres = hresolu; vres = vresolu; pa = pixaspect;
299                  if (prvr != NULL)
300                          if (viewfile(prvr, &ourview, &rs) <= 0
301 <                                        || rs.or != PIXSTANDARD) {
301 >                                        || rs.rt != PIXSTANDARD) {
302                                  sprintf(errmsg,
303                          "cannot recover view parameters from \"%s\"", prvr);
304                                  error(WARNING, errmsg);
# Line 358 | Line 366 | char  *zfile, *oldfile;
366          COLOR  *colptr;
367          float  *zptr;
368          register int  i;
369 +                                        /* check for empty image */
370 +        if (hres <= 0 || vres <= 0) {
371 +                error(WARNING, "empty output picture");
372 +                fprtresolu(0, 0, stdout);
373 +                return;
374 +        }
375                                          /* allocate scanlines */
376          for (i = 0; i <= psample; i++) {
377                  scanbar[i] = (COLOR *)malloc(hres*sizeof(COLOR));
# Line 368 | Line 382 | char  *zfile, *oldfile;
382          ystep = (psample*99+70)/140;
383          if (hstep > 2) {
384                  i = hres/hstep + 2;
385 <                if ((sampdens = malloc(i)) == NULL)
385 >                if ((sampdens = (char *)malloc(i)) == NULL)
386                          goto memerr;
387                  while (i--)
388                          sampdens[i] = hstep;
# Line 400 | Line 414 | char  *zfile, *oldfile;
414          if (i >= vres)
415                  goto alldone;
416          if (zfd != -1 && i > 0 &&
417 <                        lseek(zfd, (long)i*hres*sizeof(float), 0) < 0)
417 >                        lseek(zfd, (off_t)i*hres*sizeof(float), 0) < 0)
418                  error(SYSTEM, "z-file seek error in render");
419          pctdone = 100.0*i/vres;
420          if (ralrm > 0)                  /* report init stats */
# Line 469 | Line 483 | alldone:
483                  if (close(zfd) == -1)
484                          goto writerr;
485                  for (i = 0; i <= psample; i++)
486 <                        free((char *)zbar[i]);
486 >                        free((void *)zbar[i]);
487          }
488          for (i = 0; i <= psample; i++)
489 <                free((char *)scanbar[i]);
489 >                free((void *)scanbar[i]);
490          if (sampdens != NULL)
491                  free(sampdens);
492          pctdone = 100.0;
# Line 695 | Line 709 | char  *oldfile;
709          }
710          if (fflush(stdout) == EOF)
711                  goto writerr;
712 <        free((char *)scanline);
712 >        free((void *)scanline);
713          fclose(fp);
714          unlink(oldfile);
715          return(y);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines