291 |
|
error(WARNING, "binary data past end of expected input"); |
292 |
|
} |
293 |
|
|
294 |
+ |
/* Enforce reciprocity by averaging data values */ |
295 |
+ |
static void |
296 |
+ |
do_reciprocity() |
297 |
+ |
{ |
298 |
+ |
const int siz = 1<<log2g; |
299 |
+ |
float *v1p, *v2p; |
300 |
+ |
|
301 |
+ |
if (ttrank == 3) { |
302 |
+ |
int ix, ox, oy; |
303 |
+ |
for (ix = 0; ix < siz>>1; ix++) |
304 |
+ |
for (ox = 0; ox < siz; ox++) |
305 |
+ |
for (oy = 0; oy < siz>>1; oy++) { |
306 |
+ |
v1p = &dval3(ix,ox,oy); |
307 |
+ |
v2p = &dval3(ix,ox,siz-1-oy); |
308 |
+ |
*v1p = *v2p = .5f*( *v1p + *v2p ); |
309 |
+ |
} |
310 |
+ |
} else /* ttrank == 4 */ { |
311 |
+ |
int ix, iy, ox, oy; |
312 |
+ |
for (ix = 1; ix < siz; ix++) |
313 |
+ |
for (iy = 1; iy < siz; iy++) |
314 |
+ |
for (ox = 0; ox < ix; ox++) |
315 |
+ |
for (oy = 0; oy < iy; oy++) { |
316 |
+ |
v1p = &dval4(siz-1-ix,siz-1-iy,ox,oy); |
317 |
+ |
v2p = &dval4(siz-1-ox,siz-1-oy,ix,iy); |
318 |
+ |
*v1p = *v2p = .5f*( *v1p + *v2p ); |
319 |
+ |
} |
320 |
+ |
} |
321 |
+ |
} |
322 |
+ |
|
323 |
|
/* Load BSDF array, coalesce uniform regions and format as tensor tree */ |
324 |
|
int |
325 |
|
main(int argc, char *argv[]) |
326 |
|
{ |
327 |
|
int doheader = 1; |
328 |
+ |
int recipavg = 0; |
329 |
|
int bmin[4]; |
330 |
|
TNODE gtree; |
331 |
|
int i; |
332 |
|
/* get options and parameters */ |
333 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
334 |
|
switch (argv[i][1]) { |
335 |
+ |
case 'a': |
336 |
+ |
recipavg = !recipavg; |
337 |
+ |
break; |
338 |
|
case 'h': |
339 |
|
doheader = !doheader; |
340 |
|
break; |
371 |
|
if (infmt != 'a') |
372 |
|
SET_FILE_BINARY(stdin); |
373 |
|
load_data(); |
374 |
+ |
if (recipavg) |
375 |
+ |
do_reciprocity(); |
376 |
|
if (doheader) { |
377 |
|
for (i = 0; i < argc; i++) { |
378 |
|
fputs(argv[i], stdout); |
394 |
|
*/ |
395 |
|
return(0); |
396 |
|
userr: |
397 |
< |
fprintf(stderr, "Usage: %s [-h][-f{a|f|d}][-r {3|4}][-g log2grid][-t trim%%] [input]\n", |
397 |
> |
fprintf(stderr, "Usage: %s [-h][-a][-f{a|f|d}][-r {3|4}][-g log2grid][-t trim%%] [input]\n", |
398 |
|
argv[0]); |
399 |
|
return(1); |
400 |
|
} |