--- ray/src/px/pinterp.c 1995/09/14 13:40:17 2.24 +++ ray/src/px/pinterp.c 1998/10/27 09:08:26 2.31 @@ -39,7 +39,7 @@ static char SCCSid[] = "$SunId$ LBL"; #define PACKSIZ 256 /* max. calculation packet size */ -#define RTCOM "rtrace -h- -ovl -fff " +#define RTCOM "rtrace -h- -ovl -fff -ld- -i- -I- " #define ABS(x) ((x)>0?(x):-(x)) @@ -61,7 +61,7 @@ COLR *ourpict; /* output picture (COLR's) */ COLOR *ourspict; /* output pixel sums (averaging) */ float *ourweigh = NULL; /* output pixel weights (averaging) */ float *ourzbuf; /* corresponding z-buffer */ -COLOR *ourbpict = NULL; /* blurred picture */ +COLOR *ourbpict = NULL; /* blurred picture (view averaging) */ VIEW avgview; /* average view for -B option */ int nvavg; /* number of views averaged */ @@ -76,6 +76,7 @@ COLR backcolr = BLKCOLR; /* background color */ COLOR backcolor = BLKCOLOR; /* background color (float) */ double backz = 0.0; /* background z value */ int normdist = 1; /* i/o normalized distance? */ +char ourfmt[LPICFMT+1] = PICFMT; /* original picture format */ double ourexp = -1; /* original picture exposure */ int expadj = 0; /* exposure adjustment (f-stops) */ double rexpadj = 1; /* real exposure adjustment */ @@ -92,7 +93,7 @@ int PDesc[3] = {-1,-1,-1}; /* rtrace process descript #define childpid (PDesc[2]) unsigned short queue[PACKSIZ][2]; /* pending pixels */ int packsiz; /* actual packet size */ -int queuesiz; /* number of pixels pending */ +int queuesiz = 0; /* number of pixels pending */ extern double movepixel(); @@ -251,7 +252,7 @@ char *argv[]; rexpadj = pow(2.0, (double)expadj); } /* set view */ - if (nextview(doblur ? stdin : NULL) == EOF) { + if (nextview(doblur ? stdin : (FILE *)NULL) == EOF) { fprintf(stderr, "%s: no view on standard input!\n", progname); exit(1); @@ -308,7 +309,8 @@ char *argv[]; ourexp = rexpadj; if (ourexp < .995 | ourexp > 1.005) fputexpos(ourexp, stdout); - fputformat(COLRFMT, stdout); + if (strcmp(ourfmt, PICFMT)) /* print format if known */ + fputformat(ourfmt, stdout); putc('\n', stdout); /* write picture */ writepicture(); @@ -326,16 +328,21 @@ userr: } +int headline(s) /* process header string */ char *s; { char fmt[32]; if (isheadid(s)) - return; + return(0); if (formatval(fmt, s)) { - wrongformat = strcmp(fmt, COLRFMT); - return; + if (globmatch(ourfmt, fmt)) { + wrongformat = 0; + strcpy(ourfmt, fmt); + } else + wrongformat = 1; + return(0); } if (nvavg < 2) { putc('\t', stdout); @@ -343,10 +350,11 @@ char *s; } if (isexpos(s)) { theirexp *= exposval(s); - return; + return(0); } if (isview(s) && sscanview(&theirview, s) > 0) gotview++; + return(0); } @@ -516,9 +524,9 @@ register VIEW *vw1, *vw2; { double m4t[4][4]; - if (vw1->type != VT_PER && vw1->type != VT_PAR) + if (vw1->type != VT_PER & vw1->type != VT_PAR) return(0); - if (vw2->type != VT_PER && vw2->type != VT_PAR) + if (vw2->type != VT_PER & vw2->type != VT_PAR) return(0); setident4(xfmat); xfmat[0][0] = vw1->hvec[0]; @@ -635,10 +643,10 @@ double z; y1 = p0->y + c1*s1y/l1; for (c2 = l2; c2-- > 0; ) { x = x1 + c2*s2x/l2; - if (x < 0 || x >= hresolu) + if (x < 0 | x >= hresolu) continue; y = y1 + c2*s2y/l2; - if (y < 0 || y >= vresolu) + if (y < 0 | y >= vresolu) continue; if (averaging) { if (zscan(y)[x] <= 0 || zscan(y)[x]-z @@ -673,7 +681,7 @@ register FVECT pos; if (usematrix) { pos[0] += theirview.hoff - .5; pos[1] += theirview.voff - .5; - if (normdist && theirview.type == VT_PER) + if (normdist & theirview.type == VT_PER) d = sqrt(1. + pos[0]*pos[0]*theirview.hn2 + pos[1]*pos[1]*theirview.vn2); else @@ -707,7 +715,7 @@ register FVECT pos; if (pos[2] <= 0) return(0); } - if (pos[0] < 0 || pos[0] >= 1-FTINY || pos[1] < 0 || pos[1] >= 1-FTINY) + if (pos[0] < 0 | pos[0] >= 1-FTINY | pos[1] < 0 | pos[1] >= 1-FTINY) return(0); if (!averaging) return(1); @@ -924,6 +932,8 @@ int (*fill)(); for (x = 0; x < hresolu; x++) if (zscan(y)[x] <= 0) (*fill)(x,y); + if (fill == rcalfill) + clearqueue(); } @@ -1161,9 +1171,9 @@ clearqueue() /* process queue */ } /* mark end and get results */ bzero((char *)fbp, 6*sizeof(float)); - if (process(PDesc, fbuf, fbuf, 4*sizeof(float)*queuesiz, + if (process(PDesc, fbuf, fbuf, 4*sizeof(float)*(queuesiz+1), 6*sizeof(float)*(queuesiz+1)) != - 4*sizeof(float)*queuesiz) { + 4*sizeof(float)*(queuesiz+1)) { fprintf(stderr, "%s: error reading from rtrace process\n", progname); exit(1);