--- ray/src/rt/rpict.c 1991/07/18 14:42:54 1.30 +++ ray/src/rt/rpict.c 1991/10/10 12:58:13 1.34 @@ -15,9 +15,9 @@ static char SCCSid[] = "$SunId$ LBL"; #ifdef BSD #include #include -#else -#include #endif + +#include #include #include "view.h" @@ -122,6 +122,7 @@ char *zfile, *oldfile; float *zbar[MAXDIV+1]; /* z values */ int ypos; /* current scanline */ int ystep; /* current y step size */ + int hstep; /* h step size */ int zfd; COLOR *colptr; float *zptr; @@ -167,9 +168,14 @@ char *zfile, *oldfile; pctdone = 100.0*i/vresolu; if (ralrm > 0) /* report init stats */ report(); +#ifndef BSD + else +#endif + signal(SIGALRM, report); ypos = vresolu-1 - i; - fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); - ystep = psample; + hstep = (psample*140+49)/99; /* quincunx sampling */ + ystep = (psample*99+70)/140; + fillscanline(scanbar[0], zbar[0], hresolu, ypos, hstep); /* compute scanlines */ for (ypos -= ystep; ypos > -ystep; ypos -= ystep) { /* bottom adjust? */ @@ -184,10 +190,13 @@ char *zfile, *oldfile; zbar[ystep] = zbar[0]; zbar[0] = zptr; /* fill base line */ - fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); + fillscanline(scanbar[0], zbar[0], hresolu, ypos, hstep); /* fill bar */ fillscanbar(scanbar, zbar, hresolu, ypos, ystep); /* write it out */ +#ifndef BSD + signal(SIGALRM, SIG_IGN); /* don't interrupt writes */ +#endif for (i = ystep; i > 0; i--) { if (zfd != -1 && write(zfd, (char *)zbar[i], hresolu*sizeof(float)) @@ -202,6 +211,10 @@ char *zfile, *oldfile; pctdone = 100.0*(vresolu-1-ypos)/vresolu; if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm) report(); +#ifndef BSD + else + signal(SIGALRM, report); +#endif } /* clean up */ if (zfd != -1) { @@ -232,14 +245,15 @@ register COLOR *scanline; register float *zline; int xres, y, xstep; { + static int nc = 0; /* number of calls */ int b = xstep; double z; register int i; z = pixvalue(scanline[0], 0, y); if (zline) zline[0] = z; - - for (i = xstep; i < xres-1+xstep; i += xstep) { + /* zig-zag start for quincunx pattern */ + for (i = nc++ & 1 ? xstep/2 : xstep; i < xres-1+xstep; i += xstep) { if (i >= xres) { xstep += xres-1-i; i = xres-1; @@ -354,7 +368,7 @@ int x, y; /* pixel position */ rayorigin(&thisray, NULL, PRIMARY, 1.0); - samplendx = 3*y + x; /* set pixel index */ + samplendx = pixnumber(x,y,hresolu,vresolu); /* set pixel index */ rayvalue(&thisray); /* trace ray */ @@ -413,4 +427,16 @@ char *oldfile; return(y); writerr: error(SYSTEM, "write error in salvage"); +} + + +int +pixnumber(x, y, xres, yres) /* compute pixel index (brushed) */ +register int x, y; +int xres, yres; +{ + x -= y; + while (x < 0) + x += xres; + return((((x>>2)*yres + y) << 2) + (x & 3)); }