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 1.19 by greg, Thu Mar 1 08:19:01 1990 UTC vs.
Revision 1.26 by greg, Tue Jun 18 10:27:16 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 24 | Line 24 | static char SCCSid[] = "$SunId$ LBL";
24  
25   #include  "random.h"
26  
27 + int  dimlist[MAXDIM];                   /* sampling dimensions */
28 + int  ndims = 0;                         /* number of sampling dimensions */
29 + int  samplendx;                         /* sample index number */
30 +
31   VIEW  ourview = STDVIEW;                /* view parameters */
32   int  hresolu = 512;                     /* horizontal resolution */
33   int  vresolu = 512;                     /* vertical resolution */
# Line 53 | Line 57 | int  ralrm = 0;                                /* seconds between reports */
57  
58   double  pctdone = 0.0;                  /* percentage done */
59  
60 + long  tlastrept = 0L;                   /* time at last report */
61 +
62 + extern long  time();
63 + extern long  tstart;                    /* starting time */
64 +
65   extern long  nrays;                     /* number of rays traced */
66  
67 < #define  MAXDIV         32              /* maximum sample size */
67 > #define  MAXDIV         15              /* maximum sample size */
68  
69   #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
70  
# Line 72 | Line 81 | int  code;
81   }
82  
83  
84 + #ifdef BSD
85   report()                /* report progress */
86   {
77 #ifdef BSD
87          struct rusage  rubuf;
88          double  t;
89  
# Line 87 | Line 96 | report()               /* report progress */
96  
97          sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n",
98                          nrays, pctdone, t/3600.0);
99 +        eputs(errmsg);
100 +        tlastrept = time((long *)0);
101 + }
102   #else
103 + report()                /* report progress */
104 + {
105          signal(SIGALRM, report);
106 <        sprintf(errmsg, "%ld rays, %4.2f%% done\n", nrays, pctdone);
107 < #endif
106 >        tlastrept = time((long *)0);
107 >        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n",
108 >                        nrays, pctdone, (tlastrept-tstart)/3600.0);
109          eputs(errmsg);
95
96        if (ralrm > 0)
97                alarm(ralrm);
110   }
111 + #endif
112  
113  
114   render(zfile, oldfile)                          /* render the scene */
# Line 113 | Line 126 | char  *zfile, *oldfile;
126                                          /* check sampling */
127          if (psample < 1)
128                  psample = 1;
129 <        else if (psample > MAXDIV)
129 >        else if (psample > MAXDIV) {
130 >                sprintf(errmsg, "pixel sampling reduced from %d to %d",
131 >                                psample, MAXDIV);
132 >                error(WARNING, errmsg);
133                  psample = MAXDIV;
134 +        }
135                                          /* allocate scanlines */
136          for (i = 0; i <= psample; i++) {
137                  scanbar[i] = (COLOR *)malloc(hresolu*sizeof(COLOR));
# Line 141 | Line 158 | char  *zfile, *oldfile;
158          fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
159                                          /* recover file and compute first */
160          i = salvage(oldfile);
161 <        if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
161 >        if (zfd != -1 && i > 0 &&
162 >                        lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
163                  error(SYSTEM, "z file seek error in render");
164 +        pctdone = 100.0*i/vresolu;
165 +        if (ralrm > 0)                  /* report init stats */
166 +                report();
167          ypos = vresolu-1 - i;
168          fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
169          ystep = psample;
170                                                  /* compute scanlines */
171          for (ypos -= ystep; ypos > -ystep; ypos -= ystep) {
151                                                        /* record progress */
152                pctdone = 100.0*(vresolu-1-ypos-ystep)/vresolu;
172                                                          /* bottom adjust? */
173                  if (ypos < 0) {
174                          ystep += ypos;
# Line 176 | Line 195 | char  *zfile, *oldfile;
195                  }
196                  if (fflush(stdout) == EOF)
197                          goto writerr;
198 +                                                        /* record progress */
199 +                pctdone = 100.0*(vresolu-1-ypos)/vresolu;
200 +                if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
201 +                        report();
202          }
203                                                  /* clean up */
204          if (zfd != -1) {
205                  if (write(zfd, (char *)zbar[0], hresolu*sizeof(float))
206                                  < hresolu*sizeof(float))
207                          goto writerr;
208 <                close(zfd);
208 >                if (close(zfd) == -1)
209 >                        goto writerr;
210                  for (i = 0; i <= psample; i++)
211                          free((char *)zbar[i]);
212          }
# Line 234 | Line 258 | int  xres, y, ysize;
258          COLOR  vline[MAXDIV+1];
259          float  zline[MAXDIV+1];
260          int  b = ysize;
237        double  z;
261          register int  i, j;
262          
263          for (i = 0; i < xres; i++) {
# Line 318 | Line 341 | pixvalue(col, x, y)            /* compute pixel value */
341   COLOR  col;                     /* returned color */
342   int  x, y;                      /* pixel position */
343   {
344 <        static RAY  thisray;    /* our ray for this pixel */
344 >        static RAY  thisray;
345  
346 <        viewray(thisray.rorg, thisray.rdir, &ourview,
347 <                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu);
346 >        if (viewray(thisray.rorg, thisray.rdir, &ourview,
347 >                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) {
348 >                setcolor(col, 0.0, 0.0, 0.0);
349 >                return(0.0);
350 >        }
351  
352          rayorigin(&thisray, NULL, PRIMARY, 1.0);
353 <        
353 >
354 >        samplendx = 3*y + x;                    /* set pixel index */
355 >
356          rayvalue(&thisray);                     /* trace ray */
357  
358          copycolor(col, thisray.rcol);           /* return color */
359          
360 <        return(thisray.rot);                    /* return distance */
360 >        return(thisray.rt);                     /* return distance */
361   }
362  
363  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines