--- ray/src/util/rmtxop.c 2019/12/28 18:05:14 2.17 +++ ray/src/util/rmtxop.c 2023/11/21 01:30:20 2.21 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rmtxop.c,v 2.17 2019/12/28 18:05:14 greg Exp $"; +static const char RCSid[] = "$Id: rmtxop.c,v 2.21 2023/11/21 01:30:20 greg Exp $"; #endif /* * General component matrix operations. @@ -14,8 +14,6 @@ static const char RCSid[] = "$Id: rmtxop.c,v 2.17 2019 #define MAXCOMP 16 /* #components we support */ -static const char stdin_name[] = ""; - /* unary matrix operation(s) */ typedef struct { double sca[MAXCOMP]; /* scalar coefficients */ @@ -28,6 +26,7 @@ typedef struct { /* matrix input source and requested operation(s) */ typedef struct { const char *inspec; /* input specification */ + RMPref rmp; /* matrix preference */ RUNARYOP preop; /* unary operation(s) */ RMATRIX *mtx; /* original matrix if loaded */ int binop; /* binary op with next (or 0) */ @@ -39,11 +38,10 @@ int verbose = 0; /* verbose reporting? */ static int loadmatrix(ROPMAT *rop) { - if (rop->mtx != NULL) + if (rop->mtx != NULL) /* already loaded? */ return(0); - rop->mtx = rmx_load(rop->inspec == stdin_name ? - (const char *)NULL : rop->inspec); + rop->mtx = rmx_load(rop->inspec, rop->rmp); if (rop->mtx == NULL) { fputs(rop->inspec, stderr); fputs(": cannot load matrix\n", stderr); @@ -241,7 +239,7 @@ op_right2left(ROPMAT *mop) while (rpos-- > 0) { if (mright == NULL) break; - mright = binaryop(mop[rpos].inspec, + mright = binaryop(mop[rpos+1].inspec, loadop(mop+rpos), mop[rpos].binop, mright); } return(mright); @@ -382,6 +380,14 @@ main(int argc, char *argv[]) get_factors(mop[nmats].preop.cmat, n, argv+i+1); break; + case 'r': + if (argv[i][2] == 'f') + mop[nmats].rmp = RMPreflF; + else if (argv[i][2] == 'b') + mop[nmats].rmp = RMPreflB; + else + goto userr; + break; default: fprintf(stderr, "%s: unknown operation '%s'\n", argv[0], argv[i]); @@ -412,6 +418,8 @@ main(int argc, char *argv[]) /* write result to stdout */ if (outfmt == DTfromHeader) outfmt = mres->dtype; + if ((outfmt == DTrgbe) & (mres->ncomp > 3)) + outfmt = DTspec; if (outfmt != DTascii) SET_FILE_BINARY(stdout); newheader("RADIANCE", stdout); @@ -424,7 +432,7 @@ main(int argc, char *argv[]) return(0); userr: fprintf(stderr, - "Usage: %s [-v][-f[adfc][-t][-s sf .. | -c ce ..] m1 [.+*/] .. > mres\n", + "Usage: %s [-v][-f[adfc][-t][-s sf .. | -c ce ..][-rf|-rb] m1 [.+*/] .. > mres\n", argv[0]); return(1); }