--- ray/src/px/pcomb.c 2004/03/28 20:33:14 2.32 +++ ray/src/px/pcomb.c 2006/09/08 21:38:25 2.39 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pcomb.c,v 2.32 2004/03/28 20:33:14 schorsch Exp $"; +static const char RCSid[] = "$Id: pcomb.c,v 2.39 2006/09/08 21:38:25 greg Exp $"; #endif /* * Combine picture files according to calcomp functions. @@ -8,14 +8,13 @@ static const char RCSid[] = "$Id: pcomb.c,v 2.32 2004/ */ #include "platform.h" +#include "standard.h" #include "rtprocess.h" -#include "rterror.h" -#include "rtmisc.h" #include "color.h" #include "calcomp.h" #include "view.h" -#define MAXINP 32 /* maximum number of input files */ +#define MAXINP 512 /* maximum number of input files */ #define WINSIZ 64 /* scanline window size */ #define MIDSCN ((WINSIZ-1)/2+1) @@ -69,11 +68,12 @@ int xpos, ypos; /* output position */ char *progname; /* global argv[0] */ +int echoheader = 1; int wrongformat = 0; int gotview; -static gethfunc tabputs; +static gethfunc headline; static void checkfile(void); static double rgb_bright(COLOR clr); static double xyz_bright(COLOR clr); @@ -111,6 +111,9 @@ main( case 'w': nowarn = !nowarn; continue; + case 'h': + echoheader = !echoheader; + continue; case 'f': case 'e': a++; @@ -229,14 +232,14 @@ usage: eputs("Usage: "); eputs(argv[0]); eputs( -" [-w][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); +" [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); quit(1); return 1; /* pro forma return */ } static int -tabputs( /* put out string preceded by a tab */ +headline( /* check header line & echo if requested */ char *s, void *p ) @@ -265,9 +268,12 @@ tabputs( /* put out string preceded by a tab */ input[nfiles].pa *= aspectval(s); else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0) gotview++; - /* echo line */ - putchar('\t'); - return(fputs(s, stdout)); + + if (echoheader) { /* echo line */ + putchar('\t'); + return(fputs(s, stdout)); + } + return(0); } @@ -277,9 +283,11 @@ checkfile(void) /* ready a file */ register int i; /* process header */ gotview = 0; - fputs(input[nfiles].name, stdout); - fputs(":\n", stdout); - getheader(input[nfiles].fp, tabputs, NULL); + if (echoheader) { + fputs(input[nfiles].name, stdout); + fputs(":\n", stdout); + } + getheader(input[nfiles].fp, headline, NULL); if (wrongformat < 0) { eputs(input[nfiles].name); eputs(": not a Radiance picture\n"); @@ -335,8 +343,6 @@ double (*ourbright)() = rgb_bright; static void init(void) /* perform final setup */ { - double l_colin(char *), l_expos(char *), l_pixaspect(char *), - l_ray(char *), l_psize(char *); register int i; /* define constants */ varset("PI", ':', PI); @@ -442,11 +448,8 @@ advance(void) /* read in data for next scanline */ eputs(": read error\n"); quit(1); } - if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 || - fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 || - fabs(colval(input[i].coef,BLU)-1.0) > 1e-3) - for (j = 0; j < xmax; j++) /* adjust color */ - multcolor(st[j], input[i].coef); + for (j = 0; j < xmax; j++) /* adjust color */ + multcolor(st[j], input[i].coef); } } @@ -604,22 +607,22 @@ l_psize(char *nm) /* compute pixel size in steradians if (input[fn].vw.type == 0) errno = EDOM; else if (input[fn].vw.type != VT_PAR && - funvalue(vray[6], 1, &d) >= 0) { + funvalue(vray[6], 1, &d) >= -FTINY) { for (i = 0; i < 3; i++) dir0[i] = funvalue(vray[3+i], 1, &d); pix2loc(locx, &input[fn].rs, xscan+1, ymax-1-yscan); pix2loc(locy, &input[fn].rs, xscan, ymax-yscan); if (viewray(org, dirx, &input[fn].vw, - locx[0], locx[1]) >= 0 && + locx[0], locx[1]) >= -FTINY && viewray(org, diry, &input[fn].vw, - locy[0], locy[1]) >= 0) { + locy[0], locy[1]) >= -FTINY) { /* approximate solid angle */ for (i = 0; i < 3; i++) { dirx[i] -= dir0[i]; diry[i] -= dir0[i]; } fcross(dir0, dirx, diry); - psize[fn] = sqrt(DOT(dir0,dir0)); + psize[fn] = VLEN(dir0); } } ltick[fn] = eclock;