1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
30 |
|
|
31 |
|
#include "otypes.h" |
32 |
|
|
33 |
+ |
#include "resolu.h" |
34 |
+ |
|
35 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
36 |
|
int ndims = 0; /* number of sampling dimensions */ |
37 |
|
int samplendx = 0; /* index for this sample */ |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
+ |
char * |
94 |
+ |
formstr(f) /* return format identifier */ |
95 |
+ |
int f; |
96 |
+ |
{ |
97 |
+ |
switch (f) { |
98 |
+ |
case 'a': return("ascii"); |
99 |
+ |
case 'f': return("float"); |
100 |
+ |
case 'd': return("double"); |
101 |
+ |
case 'c': return(COLRFMT); |
102 |
+ |
} |
103 |
+ |
return("unknown"); |
104 |
+ |
} |
105 |
+ |
|
106 |
+ |
|
107 |
|
rtrace(fname) /* trace rays from file */ |
108 |
|
char *fname; |
109 |
|
{ |
118 |
|
sprintf(errmsg, "cannot open input file \"%s\"", fname); |
119 |
|
error(SYSTEM, errmsg); |
120 |
|
} |
121 |
+ |
#ifdef MSDOS |
122 |
+ |
if (inform != 'a') |
123 |
+ |
setmode(fileno(fp), O_BINARY); |
124 |
+ |
#endif |
125 |
|
/* set up output */ |
126 |
|
setoutput(outvals); |
127 |
|
switch (outform) { |
128 |
|
case 'a': putreal = puta; break; |
129 |
|
case 'f': putreal = putf; break; |
130 |
|
case 'd': putreal = putd; break; |
131 |
+ |
case 'c': |
132 |
+ |
if (strcmp(outvals, "v")) |
133 |
+ |
error(USER, "color format with value output only"); |
134 |
+ |
break; |
135 |
+ |
default: |
136 |
+ |
error(CONSISTENCY, "botched output format"); |
137 |
|
} |
138 |
+ |
if (hresolu > 0 && vresolu > 0) |
139 |
+ |
fprtresolu(hresolu, vresolu, stdout); |
140 |
|
/* process file */ |
141 |
|
while (getvec(orig, inform, fp) == 0 && |
142 |
|
getvec(direc, inform, fp) == 0) { |
295 |
|
return(-1); |
296 |
|
vec[0] = vd[0]; vec[1] = vd[1]; vec[2] = vd[2]; |
297 |
|
break; |
298 |
+ |
default: |
299 |
+ |
error(CONSISTENCY, "botched input format"); |
300 |
|
} |
301 |
|
return(0); |
302 |
|
} |
352 |
|
oputv(r) /* print value */ |
353 |
|
register RAY *r; |
354 |
|
{ |
355 |
+ |
COLR cout; |
356 |
+ |
|
357 |
+ |
if (outform == 'c') { |
358 |
+ |
setcolr(cout, colval(r->rcol,RED), |
359 |
+ |
colval(r->rcol,GRN), |
360 |
+ |
colval(r->rcol,BLU)); |
361 |
+ |
fwrite((char *)cout, sizeof(cout), 1, stdout); |
362 |
+ |
return; |
363 |
+ |
} |
364 |
|
(*putreal)(colval(r->rcol,RED)); |
365 |
|
(*putreal)(colval(r->rcol,GRN)); |
366 |
|
(*putreal)(colval(r->rcol,BLU)); |