| 7 |
|
* G. Ward February 2015 |
| 8 |
|
*/ |
| 9 |
|
|
| 10 |
+ |
#include "platform.h" |
| 11 |
|
#include <ctype.h> |
| 12 |
|
#include "rtio.h" |
| 13 |
|
#include "paths.h" |
| 166 |
|
fprintf(stderr, "%s: cannot open\n", inpspec); |
| 167 |
|
return ""; |
| 168 |
|
} |
| 169 |
< |
#ifndef _WIN32 /* XXX somehow broken on Windows */ |
| 169 |
> |
#if !defined(_WIN32) && !defined(_WIN64) |
| 170 |
> |
/* XXX somehow broken on Windows */ |
| 171 |
|
len = lseek(fd, 0L, SEEK_END); |
| 172 |
|
if (len > 0) { |
| 173 |
|
lseek(fd, 0L, SEEK_SET); |
| 395 |
|
static int |
| 396 |
|
filter_klems_matrix(FILE *fp) |
| 397 |
|
{ |
| 396 |
– |
#define MAX_COLUMNS 145 |
| 398 |
|
const char *bn = klems_basis_name[angle_basis]; |
| 398 |
– |
float col_corr[MAX_COLUMNS]; |
| 399 |
|
int i, j, n = nabases; |
| 400 |
|
/* get angle basis */ |
| 401 |
|
while (n-- > 0) |
| 403 |
|
break; |
| 404 |
|
if (n < 0) |
| 405 |
|
return 0; |
| 406 |
– |
if (abase_list[n].nangles > MAX_COLUMNS) { |
| 407 |
– |
fputs("Internal error - too many Klems columns!\n", stderr); |
| 408 |
– |
return 0; |
| 409 |
– |
} |
| 410 |
– |
/* get correction factors */ |
| 411 |
– |
for (j = abase_list[n].nangles; j--; ) |
| 412 |
– |
col_corr[j] = 1.f / io_getohm(j, &abase_list[n]); |
| 406 |
|
/* read/correct/write matrix */ |
| 407 |
|
for (i = 0; i < abase_list[n].nangles; i++) { |
| 408 |
+ |
const double corr = 1./io_getohm(i, &abase_list[n]); |
| 409 |
|
for (j = 0; j < abase_list[n].nangles; j++) { |
| 410 |
|
double d; |
| 411 |
|
if (fscanf(fp, "%lf", &d) != 1) |
| 414 |
|
fputs("Negative BSDF data!\n", stderr); |
| 415 |
|
return 0; |
| 416 |
|
} |
| 417 |
< |
printf(" %.3e", d*col_corr[j]*(d > 0)); |
| 417 |
> |
printf(" %.3e", d*corr*(d > 0)); |
| 418 |
|
} |
| 419 |
|
fputc('\n', stdout); |
| 420 |
|
} |
| 424 |
|
return 0; |
| 425 |
|
} |
| 426 |
|
return 1; /* all is good */ |
| 433 |
– |
#undef MAX_COLUMNS |
| 427 |
|
} |
| 428 |
|
|
| 429 |
|
/* Write out BSDF data block with surrounding tags */ |
| 606 |
|
if (data_file[i].fname != stdin_name && |
| 607 |
|
data_file[i].fname[0] != '!') |
| 608 |
|
unlink(data_file[i].fname); |
| 609 |
+ |
if (unlink_datafiles > 1 && mgf_geometry != NULL && |
| 610 |
+ |
mgf_geometry != stdin_name && |
| 611 |
+ |
mgf_geometry[0] != '!') |
| 612 |
+ |
unlink(mgf_geometry); |
| 613 |
|
return 1; |
| 614 |
|
} |
| 615 |
|
|
| 775 |
|
attr_unit = argv[i]; |
| 776 |
|
continue; |
| 777 |
|
case 'U': /* unlink data files when done */ |
| 778 |
< |
unlink_datafiles = 1; |
| 778 |
> |
unlink_datafiles = 1 + (argv[i][2] == 'U'); |
| 779 |
|
continue; |
| 780 |
|
case 'a': /* angle basis */ |
| 781 |
|
if (++i >= argc) |