| 45 |
|
int |
| 46 |
|
main(int argc, char *argv[]) |
| 47 |
|
{ |
| 48 |
< |
const char *directory = ""; |
| 48 |
> |
const char *directory = NULL; |
| 49 |
|
char inp[512], path[512]; |
| 50 |
|
const SDData *bsdf = NULL; |
| 51 |
|
|
| 56 |
|
if (argc == 2) |
| 57 |
|
directory = argv[1]; |
| 58 |
|
|
| 59 |
< |
SDretainSet = SDretainBSDFs; /* keep BSDFs loaded */ |
| 59 |
> |
SDretainSet = SDretainBSDFs; /* keep BSDFs in memory */ |
| 60 |
|
|
| 61 |
|
/* loop on command */ |
| 62 |
|
while (fgets(inp, sizeof(inp), stdin) != NULL) { |
| 70 |
|
|
| 71 |
|
while (isspace(*cp)) cp++; |
| 72 |
|
|
| 73 |
< |
switch (*cp) { |
| 74 |
< |
case 'l': |
| 73 |
> |
switch (toupper(*cp)) { |
| 74 |
|
case 'L': /* load/activate BSDF input */ |
| 75 |
|
cp2 = cp = sskip2(cp, 1); |
| 76 |
|
if (!*cp) |
| 77 |
|
break; |
| 78 |
|
while (*cp) cp++; |
| 79 |
|
while (isspace(*--cp)) *cp = '\0'; |
| 80 |
< |
if (directory[0]) |
| 80 |
> |
if (directory) |
| 81 |
|
sprintf(path, "%s/%s", directory, cp2); |
| 82 |
|
else |
| 83 |
|
strcpy(path, cp2); |
| 84 |
+ |
if (bsdf) |
| 85 |
+ |
SDfreeCache(bsdf); |
| 86 |
|
bsdf = SDcacheFile(path); |
| 87 |
|
continue; |
| 87 |
– |
case 'q': |
| 88 |
|
case 'Q': /* query BSDF value */ |
| 89 |
|
if (bsdf == NULL) |
| 90 |
|
goto noBSDFerr; |
| 95 |
|
if (!SDreportError(SDevalBSDF(&val, vout, vin, bsdf), stderr)) |
| 96 |
|
printf("%.3e\n", val.cieY); |
| 97 |
|
continue; |
| 98 |
– |
case 's': |
| 98 |
|
case 'S': /* sample BSDF */ |
| 99 |
|
if (bsdf == NULL) |
| 100 |
|
goto noBSDFerr; |
| 110 |
|
printf("%.8f %.8f %.8f\n", vin[0], vin[1], vin[2]); |
| 111 |
|
} |
| 112 |
|
continue; |
| 114 |
– |
case 'h': |
| 113 |
|
case 'H': /* hemispherical totals */ |
| 116 |
– |
case 'r': |
| 114 |
|
case 'R': |
| 118 |
– |
case 't': |
| 115 |
|
case 'T': |
| 116 |
|
if (bsdf == NULL) |
| 117 |
|
goto noBSDFerr; |
| 118 |
|
if (!*sskip2(cp,2)) |
| 119 |
|
break; |
| 120 |
|
if (tolower(*cp) == 'r') |
| 121 |
< |
sflags ^= SDsampT; |
| 121 |
> |
sflags &= ~SDsampT; |
| 122 |
|
else if (tolower(*cp) == 't') |
| 123 |
< |
sflags ^= SDsampR; |
| 123 |
> |
sflags &= ~SDsampR; |
| 124 |
|
vec_from_deg(vin, atof(sskip2(cp,1)), atof(sskip2(cp,2))); |
| 125 |
|
printf("%.4e\n", SDdirectHemi(vin, sflags, bsdf)); |
| 126 |
|
continue; |
| 127 |
< |
case 'a': |
| 132 |
< |
case 'A': /* resolution in degrees */ |
| 127 |
> |
case 'A': /* resolution in proj. steradians */ |
| 128 |
|
if (bsdf == NULL) |
| 129 |
|
goto noBSDFerr; |
| 130 |
|
if (!*sskip2(cp,2)) |