19 |
|
/* global argv[0] */ |
20 |
|
char *progname; |
21 |
|
/* percentage to cull (<0 to turn off) */ |
22 |
< |
double pctcull = 90.; |
22 |
> |
static double pctcull = 90.; |
23 |
|
/* sampling order */ |
24 |
< |
int samp_order = 6; |
24 |
> |
static int samp_order = 6; |
25 |
|
/* super-sampling threshold */ |
26 |
|
const double ssamp_thresh = 0.35; |
27 |
|
/* number of super-samples */ |
34 |
|
static int do_prog = 79; |
35 |
|
|
36 |
|
|
37 |
+ |
|
38 |
|
/* Start new progress bar */ |
39 |
|
#define prog_start(s) if (do_prog) fprintf(stderr, "%s: %s...\n", progname, s); else |
40 |
|
|
42 |
|
static void |
43 |
|
prog_show(double frac) |
44 |
|
{ |
45 |
< |
char pbar[256]; |
46 |
< |
int nchars; |
45 |
> |
static unsigned call_cnt = 0; |
46 |
> |
static char lastc[] = "-\\|/"; |
47 |
> |
char pbar[256]; |
48 |
> |
int nchars; |
49 |
|
|
50 |
< |
if (do_prog <= 0) return; |
50 |
> |
if (do_prog <= 1) return; |
51 |
|
if (do_prog > sizeof(pbar)-2) |
52 |
|
do_prog = sizeof(pbar)-2; |
53 |
|
if (frac < 0) frac = 0; |
54 |
< |
else if (frac > 1) frac = 1; |
55 |
< |
nchars = do_prog*frac + .5; |
54 |
> |
else if (frac >= 1) frac = .9999; |
55 |
> |
nchars = do_prog*frac; |
56 |
|
pbar[0] = '\r'; |
57 |
|
memset(pbar+1, '*', nchars); |
58 |
< |
memset(pbar+1+nchars, '-', do_prog-nchars); |
58 |
> |
pbar[nchars+1] = lastc[call_cnt++ & 3]; |
59 |
> |
memset(pbar+2+nchars, '-', do_prog-nchars-1); |
60 |
|
pbar[do_prog+1] = '\0'; |
61 |
|
fputs(pbar, stderr); |
62 |
|
} |
74 |
|
fputc('\r', stderr); |
75 |
|
} |
76 |
|
|
73 |
– |
/* Output XML prologue to stdout */ |
74 |
– |
static void |
75 |
– |
xml_prologue(int ac, char *av[]) |
76 |
– |
{ |
77 |
– |
puts("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); |
78 |
– |
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\">"); |
79 |
– |
fputs("<!-- File produced by:", stdout); |
80 |
– |
while (ac-- > 0) { |
81 |
– |
fputc(' ', stdout); |
82 |
– |
fputs(*av++, stdout); |
83 |
– |
} |
84 |
– |
puts(" -->"); |
85 |
– |
puts("<WindowElementType>System</WindowElementType>"); |
86 |
– |
puts("<FileType>BSDF</FileType>"); |
87 |
– |
puts("<Optical>"); |
88 |
– |
puts("<Layer>"); |
89 |
– |
puts("\t<Material>"); |
90 |
– |
printf("\t\t<Name>%s</Name>\n", bsdf_name[0] ? bsdf_name : "Unknown"); |
91 |
– |
printf("\t\t<Manufacturer>%s</Manufacturer>\n", |
92 |
– |
bsdf_manuf[0] ? bsdf_manuf : "Unknown"); |
93 |
– |
puts("\t\t<DeviceType>Other</DeviceType>"); |
94 |
– |
puts("\t</Material>"); |
95 |
– |
puts("\t<DataDefinition>"); |
96 |
– |
printf("\t\t<IncidentDataStructure>TensorTree%c</IncidentDataStructure>\n", |
97 |
– |
single_plane_incident ? '3' : '4'); |
98 |
– |
puts("\t</DataDefinition>"); |
99 |
– |
} |
100 |
– |
|
101 |
– |
/* Output XML data prologue to stdout */ |
102 |
– |
static void |
103 |
– |
data_prologue() |
104 |
– |
{ |
105 |
– |
static const char *bsdf_type[4] = { |
106 |
– |
"Reflection Front", |
107 |
– |
"Transmission Front", |
108 |
– |
"Transmission Back", |
109 |
– |
"Reflection Back" |
110 |
– |
}; |
111 |
– |
|
112 |
– |
puts("\t<WavelengthData>"); |
113 |
– |
puts("\t\t<LayerNumber>System</LayerNumber>"); |
114 |
– |
puts("\t\t<Wavelength unit=\"Integral\">Visible</Wavelength>"); |
115 |
– |
puts("\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>"); |
116 |
– |
puts("\t\t<DetectorSpectrum>ASTM E308 1931 Y.dsp</DetectorSpectrum>"); |
117 |
– |
puts("\t\t<WavelengthDataBlock>"); |
118 |
– |
printf("\t\t\t<WavelengthDataDirection>%s</WavelengthDataDirection>\n", |
119 |
– |
bsdf_type[(input_orient>0)<<1 | (output_orient>0)]); |
120 |
– |
puts("\t\t\t<AngleBasis>LBNL/Shirley-Chiu</AngleBasis>"); |
121 |
– |
puts("\t\t\t<ScatteringDataType>BTDF</ScatteringDataType>"); |
122 |
– |
puts("\t\t\t<ScatteringData>"); |
123 |
– |
} |
124 |
– |
|
125 |
– |
/* Output XML data epilogue to stdout */ |
126 |
– |
static void |
127 |
– |
data_epilogue(void) |
128 |
– |
{ |
129 |
– |
puts("\t\t\t</ScatteringData>"); |
130 |
– |
puts("\t\t</WavelengthDataBlock>"); |
131 |
– |
puts("\t</WavelengthData>"); |
132 |
– |
} |
133 |
– |
|
134 |
– |
/* Output XML epilogue to stdout */ |
135 |
– |
static void |
136 |
– |
xml_epilogue(void) |
137 |
– |
{ |
138 |
– |
puts("</Layer>"); |
139 |
– |
puts("</Optical>"); |
140 |
– |
puts("</WindowElement>"); |
141 |
– |
} |
142 |
– |
|
77 |
|
/* Compute absolute relative difference */ |
78 |
|
static double |
79 |
|
abs_diff(double v1, double v0) |
133 |
|
iovec[5] = output_orient * |
134 |
|
sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]); |
135 |
|
if (funame == NULL) |
136 |
< |
bsdf = eval_rbfrep(rbf, iovec+3) * |
203 |
< |
output_orient/iovec[5]; |
136 |
> |
bsdf = eval_rbfrep(rbf, iovec+3); |
137 |
|
else { |
138 |
|
if (assignD) { |
139 |
|
varset("Dx", '=', -iovec[3]); |
246 |
|
iovec[5] = output_orient * |
247 |
|
sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]); |
248 |
|
if (funame == NULL) |
249 |
< |
bsdf = eval_rbfrep(rbf, iovec+3) * |
317 |
< |
output_orient/iovec[5]; |
249 |
> |
bsdf = eval_rbfrep(rbf, iovec+3); |
250 |
|
else { |
251 |
|
if (assignD) { |
252 |
|
varset("Dx", '=', -iovec[3]); |