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.11 by greg, Sun Dec 10 13:42:45 1989 UTC vs.
Revision 1.14 by greg, Thu Jan 11 08:30:42 1990 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #ifdef BSD
16   #include  <sys/time.h>
17   #include  <sys/resource.h>
18 + #else
19 + #include  <signal.h>
20   #endif
21  
22   #include  "view.h"
23  
24   #include  "random.h"
25  
26 < VIEW  ourview = STDVIEW(512);           /* view parameters */
26 > VIEW  ourview = STDVIEW;                /* view parameters */
27 > int  hresolu = 512;                     /* horizontal resolution */
28 > int  vresolu = 512;                     /* vertical resolution */
29 > double  pixaspect = 1.0;                /* pixel aspect ratio */
30  
31   int  psample = 4;                       /* pixel sample size */
32   double  maxdiff = .05;                  /* max. difference for interpolation */
# Line 82 | Line 87 | report()               /* report progress */
87          sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n",
88                          nrays, pctdone, t/3600.0);
89   #else
90 +        signal(SIGALRM, report);
91          sprintf(errmsg, "%ld rays, %4.2f%% done\n", nrays, pctdone);
92   #endif
93          eputs(errmsg);
# Line 108 | Line 114 | char  *zfile, *oldfile;
114                  psample = MAXDIV;
115                                          /* allocate scanlines */
116          for (i = 0; i <= psample; i++) {
117 <                scanbar[i] = (COLOR *)malloc(ourview.hresolu*sizeof(COLOR));
117 >                scanbar[i] = (COLOR *)malloc(hresolu*sizeof(COLOR));
118                  if (scanbar[i] == NULL)
119                          goto memerr;
120          }
# Line 119 | Line 125 | char  *zfile, *oldfile;
125                          error(SYSTEM, errmsg);
126                  }
127                  for (i = 0; i <= psample; i++) {
128 <                        zbar[i] = (float *)malloc(ourview.hresolu*sizeof(float));
128 >                        zbar[i] = (float *)malloc(hresolu*sizeof(float));
129                          if (zbar[i] == NULL)
130                                  goto memerr;
131                  }
# Line 129 | Line 135 | char  *zfile, *oldfile;
135                          zbar[i] = NULL;
136          }
137                                          /* write out boundaries */
138 <        fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, stdout);
138 >        fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
139                                          /* recover file and compute first */
140          i = salvage(oldfile);
141 <        if (zfp != NULL && fseek(zfp, (long)i*ourview.hresolu*sizeof(float), 0) == EOF)
141 >        if (zfp != NULL && fseek(zfp, (long)i*hresolu*sizeof(float), 0) == EOF)
142                  error(SYSTEM, "z file seek error in render");
143 <        ypos = ourview.vresolu-1 - i;
144 <        fillscanline(scanbar[0], zbar[0], ourview.hresolu, ypos, psample);
143 >        ypos = vresolu-1 - i;
144 >        fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
145                                                  /* compute scanlines */
146          for (ypos -= psample; ypos >= 0; ypos -= psample) {
147          
148 <                pctdone = 100.0*(ourview.vresolu-ypos-psample)/ourview.vresolu;
148 >                pctdone = 100.0*(vresolu-ypos-psample)/vresolu;
149  
150                  colptr = scanbar[psample];              /* move base to top */
151                  scanbar[psample] = scanbar[0];
# Line 148 | Line 154 | char  *zfile, *oldfile;
154                  zbar[psample] = zbar[0];
155                  zbar[0] = zptr;
156                                                          /* fill base line */
157 <                fillscanline(scanbar[0], zbar[0], ourview.hresolu, ypos, psample);
157 >                fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
158                                                          /* fill bar */
159 <                fillscanbar(scanbar, zbar, ourview.hresolu, ypos, psample);
159 >                fillscanbar(scanbar, zbar, hresolu, ypos, psample);
160                                                          /* write it out */
161                  for (i = psample; i > 0; i--) {
162 <                        if (zfp != NULL && fwrite(zbar[i],sizeof(float),ourview.hresolu,zfp) != ourview.hresolu)
162 >                        if (zfp != NULL && fwrite(zbar[i],sizeof(float),hresolu,zfp) != hresolu)
163                                  goto writerr;
164 <                        if (fwritescan(scanbar[i],ourview.hresolu,stdout) < 0)
164 >                        if (fwritescan(scanbar[i],hresolu,stdout) < 0)
165                                  goto writerr;
166                  }
167                  if (zfp != NULL && fflush(zfp) == EOF)
# Line 171 | Line 177 | char  *zfile, *oldfile;
177          zbar[psample] = zbar[0];
178          zbar[0] = zptr;
179          if (ypos > -psample) {
180 <                fillscanline(scanbar[-ypos], zbar[-ypos], ourview.hresolu,
181 <                                0, psample);
176 <                fillscanbar(scanbar-ypos, zbar-ypos, ourview.hresolu,
177 <                                0, psample+ypos);
180 >                fillscanline(scanbar[-ypos], zbar[-ypos], hresolu, 0, psample);
181 >                fillscanbar(scanbar-ypos, zbar-ypos, hresolu, 0, psample+ypos);
182          }
183          for (i = psample; i+ypos >= 0; i--) {
184 <                if (zfp != NULL && fwrite(zbar[i],sizeof(float),ourview.hresolu,zfp) != ourview.hresolu)
184 >                if (zfp != NULL && fwrite(zbar[i],sizeof(float),hresolu,zfp) != hresolu)
185                          goto writerr;
186 <                if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0)
186 >                if (fwritescan(scanbar[i], hresolu, stdout) < 0)
187                          goto writerr;
188          }
189                                                  /* clean up */
# Line 325 | Line 329 | int  x, y;                     /* pixel position */
329   {
330          static RAY  thisray;    /* our ray for this pixel */
331  
332 <        rayview(thisray.rorg, thisray.rdir, &ourview,
333 <                        x + pixjitter(), y + pixjitter());
332 >        viewray(thisray.rorg, thisray.rdir, &ourview,
333 >                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu);
334  
335          rayorigin(&thisray, NULL, PRIMARY, 1.0);
336          
# Line 364 | Line 368 | char  *oldfile;
368                  return(0);
369          }
370  
371 <        if (x != ourview.hresolu || y != ourview.vresolu) {
371 >        if (x != hresolu || y != vresolu) {
372                  sprintf(errmsg, "resolution mismatch in recover file \"%s\"",
373                                  oldfile);
374                  error(USER, errmsg);
375          }
376  
377 <        scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));
377 >        scanline = (COLR *)malloc(hresolu*sizeof(COLR));
378          if (scanline == NULL)
379                  error(SYSTEM, "out of memory in salvage");
380 <        for (y = 0; y < ourview.vresolu; y++) {
381 <                if (freadcolrs(scanline, ourview.hresolu, fp) < 0)
380 >        for (y = 0; y < vresolu; y++) {
381 >                if (freadcolrs(scanline, hresolu, fp) < 0)
382                          break;
383 <                if (fwritecolrs(scanline, ourview.hresolu, stdout) < 0)
383 >                if (fwritecolrs(scanline, hresolu, stdout) < 0)
384                          goto writerr;
385          }
386          if (fflush(stdout) == EOF)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines