--- ray/src/px/pfilt.c 1995/10/16 12:04:36 2.15 +++ ray/src/px/pfilt.c 1998/10/27 09:08:26 2.20 @@ -1,4 +1,4 @@ -/* Copyright (c) 1992 Regents of the University of California */ +/* Copyright (c) 1996 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -17,6 +17,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" +#include "view.h" + #include "resolu.h" #include "paths.h" @@ -64,6 +66,12 @@ int correctaspect = 0; /* aspect ratio correction? * int wrongformat = 0; +VIEW ourview = STDVIEW; +int gotview = 0; +int wrapfilt = 0; /* wrap filter horizontally? */ + +int estatus = 0; /* exit status (for non-fatal errors) */ + int xrad; /* x search radius */ int yrad; /* y search radius */ int xbrad; /* x box size */ @@ -147,7 +155,7 @@ char **argv; fprintf(stderr, "%s: exposure out of range\n", argv[0]); - exit(1); + quit(1); } switch (argv[i][2]) { case '\0': @@ -267,6 +275,9 @@ char **argv; } if (!(order & YMAJOR)) inpaspect = 1.0/inpaspect; + /* wrap around for cylindrical view? */ + wrapfilt = gotview && ourview.type == VT_CYL && + ourview.horiz >= 360.-FTINY && order & YMAJOR; /* compute output resolution */ if (ncols <= 0) ncols = x_c*xres + .5; @@ -298,7 +309,7 @@ char **argv; } pass2(fin); - quit(0); + quit(estatus); } @@ -321,6 +332,7 @@ COLOR clr; double (*ourbright)() = rgb_bright; +int headline(s) /* process line from header */ char *s; { @@ -339,7 +351,9 @@ char *s; ourbright = xyz_bright; else wrongformat = !globmatch(PICFMT, fmt); - } + } else if (isview(s) && sscanview(&ourview, s) > 0) + gotview++; + return(0); } @@ -382,6 +396,7 @@ FILE *in; progname, (int)(100L*i/yres)); yres = i; y_r = (double)nrows/yres; + estatus++; break; } pass1scan(scan, i); @@ -401,7 +416,7 @@ FILE *in; scan2init(); yread = 0; for (r = 0; r < nrows; r++) { - ycent = (long)r*yres/nrows; + ycent = (r+.5)*yres/nrows; while (yread <= ycent+yrad) { if (yread < yres) { if (freadscan(scanin[yread%barsize], @@ -418,7 +433,7 @@ FILE *in; if (obarsize > 0) scan2sync(r); for (c = 0; c < ncols; c++) { - xcent = (long)c*xres/ncols; + xcent = (c+.5)*xres/ncols; if (thresh > FTINY) dothresh(xcent, ycent, c, r); else if (rad > FTINY) @@ -454,9 +469,9 @@ scan2init() /* prepare scanline arrays */ rad *= (y_r + x_c)/2.0; if (thresh > FTINY) { - xrad = CHECKRAD*THRESHRAD*rad/x_c + xbrad; - yrad = CHECKRAD*THRESHRAD*rad/y_r + ybrad; orad = CHECKRAD*THRESHRAD*rad + 1; + xrad = orad/x_c + xbrad; + yrad = orad/y_r + ybrad; obarsize = 2*orad + 1; } else { xrad = CHECKRAD*rad/x_c + 1; @@ -526,10 +541,10 @@ int r; int ybot; register int c; /* average input scanlines */ - while (nextrow < r+orad && nextrow < nrows) { - ybot = (long)nextrow*yres/nrows; + while (nextrow <= r+orad && nextrow < nrows) { + ybot = (nextrow+.5)*yres/nrows; for (c = 0; c < ncols; c++) { - dobox(ctmp, (int)((long)c*xres/ncols),ybot, c,nextrow); + dobox(ctmp, (int)((c+.5)*xres/ncols),ybot, c,nextrow); greybar[nextrow%obarsize][c] = (*ourbright)(ctmp); } /* and zero output scanline */ @@ -553,7 +568,7 @@ scan2flush() /* flush output buffer */ break; if (fflush(stdout) < 0) { fprintf(stderr, "%s: write error at end of pass2\n", progname); - exit(1); + quit(1); } }