--- ray/src/rt/rtrace.c 1992/01/16 12:05:20 2.4 +++ ray/src/rt/rtrace.c 1992/07/21 10:36:37 2.7 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1992 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -30,6 +30,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include "otypes.h" +#include "resolu.h" + int dimlist[MAXDIM]; /* sampling dimensions */ int ndims = 0; /* number of sampling dimensions */ int samplendx = 0; /* index for this sample */ @@ -70,7 +72,7 @@ extern OBJREC Lamb; /* a Lambertian surface */ static RAY thisray; /* for our convenience */ -static int oputo(), oputd(), oputv(), oputl(), +static int oputo(), oputd(), oputv(), oputl(), oputL(), oputp(), oputn(), oputs(), oputw(), oputm(); static int (*ray_out[10])(), (*every_out[10])(); @@ -88,6 +90,20 @@ int code; } +char * +formstr(f) /* return format identifier */ +int f; +{ + switch (f) { + case 'a': return("ascii"); + case 'f': return("float"); + case 'd': return("double"); + case 'c': return(COLRFMT); + } + return("unknown"); +} + + rtrace(fname) /* trace rays from file */ char *fname; { @@ -108,7 +124,15 @@ char *fname; case 'a': putreal = puta; break; case 'f': putreal = putf; break; case 'd': putreal = putd; break; + case 'c': + if (strcmp(outvals, "v")) + error(USER, "color format with value output only"); + break; + default: + error(CONSISTENCY, "botched output format"); } + if (hresolu > 0 && vresolu > 0) + fprtresolu(hresolu, vresolu, stdout); /* process file */ while (getvec(orig, inform, fp) == 0 && getvec(direc, inform, fp) == 0) { @@ -164,10 +188,13 @@ register char *vs; *table++ = oputv; castonly = 0; break; - case 'l': /* length */ + case 'l': /* effective distance */ *table++ = oputl; castonly = 0; break; + case 'L': /* single ray length */ + *table++ = oputL; + break; case 'p': /* point */ *table++ = oputp; break; @@ -241,6 +268,7 @@ FILE *fp; { extern char *fgetword(); static float vf[3]; + static double vd[3]; char buf[32]; register int i; @@ -259,9 +287,12 @@ FILE *fp; vec[0] = vf[0]; vec[1] = vf[1]; vec[2] = vf[2]; break; case 'd': /* binary double */ - if (fread((char *)vec, sizeof(double), 3, fp) != 3) + if (fread((char *)vd, sizeof(double), 3, fp) != 3) return(-1); + vec[0] = vd[0]; vec[1] = vd[1]; vec[2] = vd[2]; break; + default: + error(CONSISTENCY, "botched input format"); } return(0); } @@ -317,6 +348,15 @@ static oputv(r) /* print value */ register RAY *r; { + COLR cout; + + if (outform == 'c') { + setcolr(cout, colval(r->rcol,RED), + colval(r->rcol,GRN), + colval(r->rcol,BLU)); + fwrite((char *)cout, sizeof(cout), 1, stdout); + return; + } (*putreal)(colval(r->rcol,RED)); (*putreal)(colval(r->rcol,GRN)); (*putreal)(colval(r->rcol,BLU)); @@ -324,10 +364,18 @@ register RAY *r; static -oputl(r) /* print length */ +oputl(r) /* print effective distance */ register RAY *r; { (*putreal)(r->rt); +} + + +static +oputL(r) /* print single ray length */ +register RAY *r; +{ + (*putreal)(r->rot); }