71 |
|
SDretainSet = SDretainBSDFs; /* keep BSDFs in memory */ |
72 |
|
|
73 |
|
/* loop on command */ |
74 |
< |
while (fgets(inp, sizeof(inp), stdin) != NULL) { |
74 |
> |
while (fgets(inp, sizeof(inp), stdin)) { |
75 |
|
int sflags = SDsampAll; |
76 |
|
char *cp = inp; |
77 |
|
char *cp2; |
98 |
|
bsdf = SDcacheFile(path); |
99 |
|
continue; |
100 |
|
case 'I': /* report general info. */ |
101 |
< |
if (bsdf == NULL) |
101 |
> |
if (!bsdf) |
102 |
|
goto noBSDFerr; |
103 |
|
printf("Material: '%s'\n", bsdf->matn); |
104 |
|
printf("Manufacturer: '%s'\n", bsdf->makr); |
105 |
|
printf("Width, Height, Thickness (m): %.4e, %.4e, %.4e\n", |
106 |
|
bsdf->dim[0], bsdf->dim[1], bsdf->dim[2]); |
107 |
< |
printf("Has geometry: %s\n", bsdf->mgf!=NULL ? "yes" : "no"); |
107 |
> |
printf("Has geometry: %s\n", bsdf->mgf ? "yes" : "no"); |
108 |
|
continue; |
109 |
|
case 'C': /* report constant values */ |
110 |
< |
if (bsdf == NULL) |
110 |
> |
if (!bsdf) |
111 |
|
goto noBSDFerr; |
112 |
< |
if (bsdf->rf != NULL) |
112 |
> |
if (bsdf->rf) |
113 |
|
printf("Peak front hemispherical reflectance: %.3e\n", |
114 |
|
bsdf->rLambFront.cieY + |
115 |
|
bsdf->rf->maxHemi); |
116 |
< |
if (bsdf->rb != NULL) |
116 |
> |
if (bsdf->rb) |
117 |
|
printf("Peak back hemispherical reflectance: %.3e\n", |
118 |
|
bsdf->rLambBack.cieY + |
119 |
|
bsdf->rb->maxHemi); |
120 |
< |
if (bsdf->tf != NULL) |
120 |
> |
if (bsdf->tf) |
121 |
|
printf("Peak front hemispherical transmittance: %.3e\n", |
122 |
|
bsdf->tLamb.cieY + bsdf->tf->maxHemi); |
123 |
< |
if (bsdf->tb != NULL) |
123 |
> |
if (bsdf->tb) |
124 |
|
printf("Peak back hemispherical transmittance: %.3e\n", |
125 |
|
bsdf->tLamb.cieY + bsdf->tb->maxHemi); |
126 |
|
printXYZ("Diffuse Front Reflectance: ", &bsdf->rLambFront); |
128 |
|
printXYZ("Diffuse Transmittance: ", &bsdf->tLamb); |
129 |
|
continue; |
130 |
|
case 'Q': /* query BSDF value */ |
131 |
< |
if (bsdf == NULL) |
131 |
> |
if (!bsdf) |
132 |
|
goto noBSDFerr; |
133 |
|
if (!*sskip2(cp,4)) |
134 |
|
break; |
138 |
|
printXYZ("", &val); |
139 |
|
continue; |
140 |
|
case 'S': /* sample BSDF */ |
141 |
< |
if (bsdf == NULL) |
141 |
> |
if (!bsdf) |
142 |
|
goto noBSDFerr; |
143 |
|
if (!*sskip2(cp,3)) |
144 |
|
break; |
155 |
|
case 'H': /* hemispherical totals */ |
156 |
|
case 'R': |
157 |
|
case 'T': |
158 |
< |
if (bsdf == NULL) |
158 |
> |
if (!bsdf) |
159 |
|
goto noBSDFerr; |
160 |
|
if (!*sskip2(cp,2)) |
161 |
|
break; |
167 |
|
printf("%.4e\n", SDdirectHemi(vin, sflags, bsdf)); |
168 |
|
continue; |
169 |
|
case 'A': /* resolution in proj. steradians */ |
170 |
< |
if (bsdf == NULL) |
170 |
> |
if (!bsdf) |
171 |
|
goto noBSDFerr; |
172 |
|
if (!*sskip2(cp,2)) |
173 |
|
break; |