60 |
|
SDsquare2disk(ovec, (ox+.5)/sqres, (oy+.5)/sqres); |
61 |
|
ovec[2] = output_orient * |
62 |
|
sqrt(1. - ovec[0]*ovec[0] - ovec[1]*ovec[1]); |
63 |
< |
bsdf = eval_rbfrep(rbf, ovec) / fabs(ovec[2]); |
63 |
> |
bsdf = eval_rbfrep(rbf, ovec) * output_orient/ovec[2]; |
64 |
|
if (pctcull >= 0) |
65 |
|
fwrite(&bsdf, sizeof(bsdf), 1, ofp); |
66 |
|
else |
122 |
|
SDsquare2disk(ovec, (ox+.5)/sqres, (oy+.5)/sqres); |
123 |
|
ovec[2] = output_orient * |
124 |
|
sqrt(1. - ovec[0]*ovec[0] - ovec[1]*ovec[1]); |
125 |
< |
bsdf = eval_rbfrep(rbf, ovec) / fabs(ovec[2]); |
125 |
> |
bsdf = eval_rbfrep(rbf, ovec) * output_orient/ovec[2]; |
126 |
|
if (pctcull >= 0) |
127 |
|
fwrite(&bsdf, sizeof(bsdf), 1, ofp); |
128 |
|
else |
141 |
|
fputs("}\n", stdout); |
142 |
|
} |
143 |
|
|
144 |
+ |
/* Output XML prologue to stdout */ |
145 |
+ |
static void |
146 |
+ |
xml_prologue(int ac, char *av[]) |
147 |
+ |
{ |
148 |
+ |
static const char *bsdf_type[4] = { |
149 |
+ |
"Reflection Back", |
150 |
+ |
"Transmission Back", |
151 |
+ |
"Transmission Front", |
152 |
+ |
"Reflection Front" |
153 |
+ |
}; |
154 |
+ |
|
155 |
+ |
puts("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); |
156 |
+ |
puts("<WindowElement xmlns=\"http://windows.lbl.gov\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://windows.lbl.gov/BSDF-v1.4.xsd\">"); |
157 |
+ |
fputs("<!-- File produced by:", stdout); |
158 |
+ |
while (ac-- > 0) { |
159 |
+ |
fputc(' ', stdout); |
160 |
+ |
fputs(*av++, stdout); |
161 |
+ |
} |
162 |
+ |
puts(" -->"); |
163 |
+ |
puts("<WindowElementType>System</WindowElementType>"); |
164 |
+ |
puts("<FileType>BSDF</FileType>"); |
165 |
+ |
puts("<Optical>"); |
166 |
+ |
puts("<Layer>"); |
167 |
+ |
puts("\t<Material>"); |
168 |
+ |
puts("\t\t<Name>Name</Name>"); |
169 |
+ |
puts("\t\t<Manufacturer>Manufacturer</Manufacturer>"); |
170 |
+ |
puts("\t\t<DeviceType>Other</DeviceType>"); |
171 |
+ |
puts("\t</Material>"); |
172 |
+ |
puts("\t<DataDefinition>"); |
173 |
+ |
printf("\t\t<IncidentDataStructure>TensorTree%c</IncidentDataStructure>\n", |
174 |
+ |
single_plane_incident ? '3' : '4'); |
175 |
+ |
puts("\t</DataDefinition>"); |
176 |
+ |
puts("\t<WavelengthData>"); |
177 |
+ |
puts("\t\t<LayerNumber>System</LayerNumber>"); |
178 |
+ |
puts("\t\t<Wavelength unit=\"Integral\">Visible</Wavelength>"); |
179 |
+ |
puts("\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>"); |
180 |
+ |
puts("\t\t<DetectorSpectrum>ASTM E308 1931 Y.dsp</DetectorSpectrum>"); |
181 |
+ |
puts("\t\t<WavelengthDataBlock>"); |
182 |
+ |
printf("\t\t\t<WavelengthDataDirection>%s</WavelengthDataDirection>\n", |
183 |
+ |
bsdf_type[(input_orient>0)<<1 | (output_orient>0)]); |
184 |
+ |
puts("\t\t\t<AngleBasis>LBNL/Shirley-Chiu</AngleBasis>"); |
185 |
+ |
puts("\t\t\t<ScatteringDataType>BTDF</ScatteringDataType>"); |
186 |
+ |
puts("\t\t\t<ScatteringData>"); |
187 |
+ |
} |
188 |
+ |
|
189 |
+ |
/* Output XML epilogue to stdout */ |
190 |
+ |
static void |
191 |
+ |
xml_epilogue(void) |
192 |
+ |
{ |
193 |
+ |
puts("\t\t\t</ScatteringData>"); |
194 |
+ |
puts("\t\t</WavelengthDataBlock>"); |
195 |
+ |
puts("\t</WavelengthData>"); |
196 |
+ |
puts("</Layer>"); |
197 |
+ |
puts("</Optical>"); |
198 |
+ |
puts("</WindowElement>"); |
199 |
+ |
} |
200 |
+ |
|
201 |
|
/* Read in BSDF and interpolate as tensor tree representation */ |
202 |
|
int |
203 |
|
main(int argc, char *argv[]) |
205 |
|
FILE *fpin = stdin; |
206 |
|
int i; |
207 |
|
|
208 |
< |
progname = argv[0]; /* get options */ |
209 |
< |
while (argc > 2 && argv[1][0] == '-') { |
210 |
< |
switch (argv[1][1]) { |
208 |
> |
progname = argv[0]; |
209 |
> |
for (i = 1; i < argc-1 && argv[i][0] == '-'; i++) |
210 |
> |
switch (argv[i][1]) { /* get option */ |
211 |
|
case 't': |
212 |
< |
pctcull = atoi(argv[2]); |
212 |
> |
pctcull = atoi(argv[++i]); |
213 |
|
break; |
214 |
|
case 'g': |
215 |
< |
samp_order = atoi(argv[2]); |
215 |
> |
samp_order = atoi(argv[++i]); |
216 |
|
break; |
217 |
|
default: |
218 |
|
goto userr; |
219 |
|
} |
220 |
< |
argv += 2; argc -= 2; |
221 |
< |
} |
222 |
< |
if (argc == 2) { /* open input if given */ |
166 |
< |
fpin = fopen(argv[1], "r"); |
220 |
> |
|
221 |
> |
if (i == argc-1) { /* open input if given */ |
222 |
> |
fpin = fopen(argv[i], "r"); |
223 |
|
if (fpin == NULL) { |
224 |
|
fprintf(stderr, "%s: cannot open BSDF interpolant '%s'\n", |
225 |
|
progname, argv[1]); |
226 |
|
return(1); |
227 |
|
} |
228 |
< |
} else if (argc != 1) |
228 |
> |
} else if (i < argc-1) |
229 |
|
goto userr; |
230 |
|
SET_FILE_BINARY(fpin); /* load BSDF interpolant */ |
231 |
|
if (!load_bsdf_rep(fpin)) |
232 |
|
return(1); |
233 |
< |
/* xml_prologue(); /* start XML output */ |
233 |
> |
fclose(fpin); |
234 |
> |
xml_prologue(argc, argv); /* start XML output */ |
235 |
|
if (single_plane_incident) /* resample dist. */ |
236 |
|
interp_isotropic(); |
237 |
|
else |
238 |
|
interp_anisotropic(); |
239 |
< |
/* xml_epilogue(); /* finish XML output */ |
239 |
> |
xml_epilogue(); /* finish XML output */ |
240 |
|
return(0); |
241 |
|
userr: |
242 |
|
fprintf(stderr, |