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.16 by greg, Tue Jan 16 11:30:09 1990 UTC vs.
Revision 1.25 by greg, Tue May 21 17:41:35 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 18 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18   #else
19   #include  <signal.h>
20   #endif
21 < #include  <sys/fcntl.h>
21 > #include  <fcntl.h>
22  
23   #include  "view.h"
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 32 | Line 36 | double  pixaspect = 1.0;               /* pixel aspect ratio */
36   int  psample = 4;                       /* pixel sample size */
37   double  maxdiff = .05;                  /* max. difference for interpolation */
38   double  dstrpix = 0.67;                 /* square pixel distribution */
39 + int  psuper = 2;                        /* pixel super-sampling rate */
40  
41   double  dstrsrc = 0.0;                  /* square source distribution */
42   double  shadthresh = .05;               /* shadow threshold */
# Line 53 | Line 58 | int  ralrm = 0;                                /* seconds between reports */
58  
59   double  pctdone = 0.0;                  /* percentage done */
60  
61 + long  tlastrept = 0L;                   /* time at last report */
62 +
63 + extern long  time();
64 + extern long  tstart;                    /* starting time */
65 +
66   extern long  nrays;                     /* number of rays traced */
67  
68   #define  MAXDIV         32              /* maximum sample size */
# Line 72 | Line 82 | int  code;
82   }
83  
84  
85 + #ifdef BSD
86   report()                /* report progress */
87   {
77 #ifdef BSD
88          struct rusage  rubuf;
89          double  t;
90  
# Line 87 | Line 97 | report()               /* report progress */
97  
98          sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n",
99                          nrays, pctdone, t/3600.0);
100 +        eputs(errmsg);
101 +        tlastrept = time((long *)0);
102 + }
103   #else
104 + report()                /* report progress */
105 + {
106          signal(SIGALRM, report);
107 <        sprintf(errmsg, "%ld rays, %4.2f%% done\n", nrays, pctdone);
108 < #endif
107 >        tlastrept = time((long *)0);
108 >        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n",
109 >                        nrays, pctdone, (tlastrept-tstart)/3600.0);
110          eputs(errmsg);
95
96        if (ralrm > 0)
97                alarm(ralrm);
111   }
112 + #endif
113  
114  
115   render(zfile, oldfile)                          /* render the scene */
# Line 141 | Line 155 | char  *zfile, *oldfile;
155          fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
156                                          /* recover file and compute first */
157          i = salvage(oldfile);
158 <        if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
158 >        if (zfd != -1 && i > 0 &&
159 >                        lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
160                  error(SYSTEM, "z file seek error in render");
161 +        pctdone = 100.0*i/vresolu;
162 +        if (ralrm > 0)                  /* report init stats */
163 +                report();
164          ypos = vresolu-1 - i;
165          fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
166          ystep = psample;
167                                                  /* compute scanlines */
168          for (ypos -= ystep; ypos > -ystep; ypos -= ystep) {
151                                                        /* record progress */
152                pctdone = 100.0*(vresolu-ypos-ystep)/vresolu;
169                                                          /* bottom adjust? */
170                  if (ypos < 0) {
171                          ystep += ypos;
# Line 167 | Line 183 | char  *zfile, *oldfile;
183                  fillscanbar(scanbar, zbar, hresolu, ypos, ystep);
184                                                          /* write it out */
185                  for (i = ystep; i > 0; i--) {
186 <                        if (zfd!=-1 && write(zfd,zbar[i],hresolu*sizeof(float))
186 >                        if (zfd != -1 && write(zfd, (char *)zbar[i],
187 >                                        hresolu*sizeof(float))
188                                          < hresolu*sizeof(float))
189                                  goto writerr;
190 <                        if (fwritescan(scanbar[i],hresolu,stdout) < 0)
190 >                        if (fwritescan(scanbar[i], hresolu, stdout) < 0)
191                                  goto writerr;
192                  }
193                  if (fflush(stdout) == EOF)
194                          goto writerr;
195 +                                                        /* record progress */
196 +                pctdone = 100.0*(vresolu-1-ypos)/vresolu;
197 +                if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
198 +                        report();
199          }
200                                                  /* clean up */
201          if (zfd != -1) {
202 <                if (write(zfd,zbar[0],hresolu*sizeof(float))
202 >                if (write(zfd, (char *)zbar[0], hresolu*sizeof(float))
203                                  < hresolu*sizeof(float))
204                          goto writerr;
205 <                close(zfd);
205 >                if (close(zfd) == -1)
206 >                        goto writerr;
207                  for (i = 0; i <= psample; i++)
208                          free((char *)zbar[i]);
209          }
# Line 233 | Line 255 | int  xres, y, ysize;
255          COLOR  vline[MAXDIV+1];
256          float  zline[MAXDIV+1];
257          int  b = ysize;
236        double  z;
258          register int  i, j;
259          
260          for (i = 0; i < xres; i++) {
# Line 317 | Line 338 | pixvalue(col, x, y)            /* compute pixel value */
338   COLOR  col;                     /* returned color */
339   int  x, y;                      /* pixel position */
340   {
341 <        static RAY  thisray;    /* our ray for this pixel */
341 >        static RAY  thisray;
342  
343 <        viewray(thisray.rorg, thisray.rdir, &ourview,
344 <                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu);
343 >        if (viewray(thisray.rorg, thisray.rdir, &ourview,
344 >                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu) < 0) {
345 >                setcolor(col, 0.0, 0.0, 0.0);
346 >                return(0.0);
347 >        }
348  
349          rayorigin(&thisray, NULL, PRIMARY, 1.0);
350 <        
350 >
351 >        samplendx = 3*y + x;                    /* set pixel index */
352 >
353          rayvalue(&thisray);                     /* trace ray */
354  
355          copycolor(col, thisray.rcol);           /* return color */
356          
357 <        return(thisray.rot);                    /* return distance */
357 >        return(thisray.rt);                     /* return distance */
358   }
359  
360  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines