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.15 by greg, Fri Jan 12 09:27:11 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 97 | Line 103 | char  *zfile, *oldfile;
103          COLOR  *scanbar[MAXDIV+1];      /* scanline arrays of pixel values */
104          float  *zbar[MAXDIV+1];         /* z values */
105          int  ypos;                      /* current scanline */
106 +        int  ystep;                     /* current y step size */
107          FILE  *zfp;
108          COLOR  *colptr;
109          float  *zptr;
# Line 108 | Line 115 | char  *zfile, *oldfile;
115                  psample = MAXDIV;
116                                          /* allocate scanlines */
117          for (i = 0; i <= psample; i++) {
118 <                scanbar[i] = (COLOR *)malloc(ourview.hresolu*sizeof(COLOR));
118 >                scanbar[i] = (COLOR *)malloc(hresolu*sizeof(COLOR));
119                  if (scanbar[i] == NULL)
120                          goto memerr;
121          }
# Line 119 | Line 126 | char  *zfile, *oldfile;
126                          error(SYSTEM, errmsg);
127                  }
128                  for (i = 0; i <= psample; i++) {
129 <                        zbar[i] = (float *)malloc(ourview.hresolu*sizeof(float));
129 >                        zbar[i] = (float *)malloc(hresolu*sizeof(float));
130                          if (zbar[i] == NULL)
131                                  goto memerr;
132                  }
# Line 129 | Line 136 | char  *zfile, *oldfile;
136                          zbar[i] = NULL;
137          }
138                                          /* write out boundaries */
139 <        fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, stdout);
139 >        fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
140                                          /* recover file and compute first */
141          i = salvage(oldfile);
142 <        if (zfp != NULL && fseek(zfp, (long)i*ourview.hresolu*sizeof(float), 0) == EOF)
142 >        if (zfp != NULL && fseek(zfp, (long)i*hresolu*sizeof(float), 0) == EOF)
143                  error(SYSTEM, "z file seek error in render");
144 <        ypos = ourview.vresolu-1 - i;
145 <        fillscanline(scanbar[0], zbar[0], ourview.hresolu, ypos, psample);
144 >        ypos = vresolu-1 - i;
145 >        fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
146 >        ystep = psample;
147                                                  /* compute scanlines */
148 <        for (ypos -= psample; ypos >= 0; ypos -= psample) {
149 <        
150 <                pctdone = 100.0*(ourview.vresolu-ypos-psample)/ourview.vresolu;
151 <
152 <                colptr = scanbar[psample];              /* move base to top */
153 <                scanbar[psample] = scanbar[0];
148 >        for (ypos -= ystep; ypos > -ystep; ypos -= ystep) {
149 >                                                        /* record progress */
150 >                pctdone = 100.0*(vresolu-ypos-ystep)/vresolu;
151 >                                                        /* bottom adjust? */
152 >                if (ypos < 0) {
153 >                        ystep += ypos;
154 >                        ypos = 0;
155 >                }
156 >                colptr = scanbar[ystep];                /* move base to top */
157 >                scanbar[ystep] = scanbar[0];
158                  scanbar[0] = colptr;
159 <                zptr = zbar[psample];
160 <                zbar[psample] = zbar[0];
159 >                zptr = zbar[ystep];
160 >                zbar[ystep] = zbar[0];
161                  zbar[0] = zptr;
162                                                          /* fill base line */
163 <                fillscanline(scanbar[0], zbar[0], ourview.hresolu, ypos, psample);
163 >                fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
164                                                          /* fill bar */
165 <                fillscanbar(scanbar, zbar, ourview.hresolu, ypos, psample);
165 >                fillscanbar(scanbar, zbar, hresolu, ypos, ystep);
166                                                          /* write it out */
167 <                for (i = psample; i > 0; i--) {
168 <                        if (zfp != NULL && fwrite(zbar[i],sizeof(float),ourview.hresolu,zfp) != ourview.hresolu)
167 >                for (i = ystep; i > 0; i--) {
168 >                        if (zfp != NULL && fwrite(zbar[i],sizeof(float),hresolu,zfp) != hresolu)
169                                  goto writerr;
170 <                        if (fwritescan(scanbar[i],ourview.hresolu,stdout) < 0)
170 >                        if (fwritescan(scanbar[i],hresolu,stdout) < 0)
171                                  goto writerr;
172                  }
173                  if (zfp != NULL && fflush(zfp) == EOF)
# Line 163 | Line 175 | char  *zfile, *oldfile;
175                  if (fflush(stdout) == EOF)
176                          goto writerr;
177          }
166                                                /* compute residual */
167        colptr = scanbar[psample];
168        scanbar[psample] = scanbar[0];
169        scanbar[0] = colptr;
170        zptr = zbar[psample];
171        zbar[psample] = zbar[0];
172        zbar[0] = zptr;
173        if (ypos > -psample) {
174                fillscanline(scanbar[-ypos], zbar[-ypos], ourview.hresolu,
175                                0, psample);
176                fillscanbar(scanbar-ypos, zbar-ypos, ourview.hresolu,
177                                0, psample+ypos);
178        }
179        for (i = psample; i+ypos >= 0; i--) {
180                if (zfp != NULL && fwrite(zbar[i],sizeof(float),ourview.hresolu,zfp) != ourview.hresolu)
181                        goto writerr;
182                if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0)
183                        goto writerr;
184        }
178                                                  /* clean up */
179          if (zfp != NULL) {
180 +                fwrite(zbar[0], sizeof(float), hresolu, zfp);
181                  if (fclose(zfp) == EOF)
182                          goto writerr;
183                  for (i = 0; i <= psample; i++)
184                          free((char *)zbar[i]);
185          }
186 +        fwritescan(scanbar[0], hresolu, stdout);
187          if (fflush(stdout) == EOF)
188                  goto writerr;
189          for (i = 0; i <= psample; i++)
# Line 214 | Line 209 | int  xres, y, xstep;
209          z = pixvalue(scanline[0], 0, y);
210          if (zline) zline[0] = z;
211  
212 <        for (i = xstep; i < xres; i += xstep) {
213 <        
212 >        for (i = xstep; i < xres-1+xstep; i += xstep) {
213 >                if (i >= xres) {
214 >                        xstep += xres-1-i;
215 >                        i = xres-1;
216 >                }
217                  z = pixvalue(scanline[i], i, y);
218                  if (zline) zline[i] = z;
219                  
220                  b = fillsample(scanline+i-xstep, zline ? zline+i-xstep : NULL,
221                                  i-xstep, y, xstep, 0, b/2);
222          }
225        if (i-xstep < xres-1) {
226                z = pixvalue(scanline[xres-1], xres-1, y);
227                if (zline) zline[xres-1] = z;
228                fillsample(scanline+i-xstep, zline ? zline+i-xstep : NULL,
229                                i-xstep, y, xres-1-(i-xstep), 0, b/2);
230        }
223   }
224  
225  
# Line 325 | Line 317 | int  x, y;                     /* pixel position */
317   {
318          static RAY  thisray;    /* our ray for this pixel */
319  
320 <        rayview(thisray.rorg, thisray.rdir, &ourview,
321 <                        x + pixjitter(), y + pixjitter());
320 >        viewray(thisray.rorg, thisray.rdir, &ourview,
321 >                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu);
322  
323          rayorigin(&thisray, NULL, PRIMARY, 1.0);
324          
# Line 364 | Line 356 | char  *oldfile;
356                  return(0);
357          }
358  
359 <        if (x != ourview.hresolu || y != ourview.vresolu) {
359 >        if (x != hresolu || y != vresolu) {
360                  sprintf(errmsg, "resolution mismatch in recover file \"%s\"",
361                                  oldfile);
362                  error(USER, errmsg);
363          }
364  
365 <        scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));
365 >        scanline = (COLR *)malloc(hresolu*sizeof(COLR));
366          if (scanline == NULL)
367                  error(SYSTEM, "out of memory in salvage");
368 <        for (y = 0; y < ourview.vresolu; y++) {
369 <                if (freadcolrs(scanline, ourview.hresolu, fp) < 0)
368 >        for (y = 0; y < vresolu; y++) {
369 >                if (freadcolrs(scanline, hresolu, fp) < 0)
370                          break;
371 <                if (fwritecolrs(scanline, ourview.hresolu, stdout) < 0)
371 >                if (fwritecolrs(scanline, hresolu, stdout) < 0)
372                          goto writerr;
373          }
374          if (fflush(stdout) == EOF)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines