62 |
|
inpfile[i].theta = inpfile[i].phi = -10001.; |
63 |
|
/* read header information */ |
64 |
|
while ((c = getc(fp)) == '#' || c == EOF) { |
65 |
+ |
char typ[32]; |
66 |
|
if (fgets(buf, sizeof(buf), fp) == NULL) { |
67 |
|
fputs(fname, stderr); |
68 |
|
fputs(": unexpected EOF\n", stderr); |
69 |
|
fclose(fp); |
70 |
|
return(0); |
71 |
|
} |
72 |
< |
if (!strcmp(buf, "format: theta phi DSF\n")) { |
73 |
< |
inpfile[i].isDSF = 1; |
74 |
< |
continue; |
72 |
> |
if (sscanf(buf, "format: theta phi %s", typ) == 1) { |
73 |
> |
if (!strcasecmp(typ, "DSF")) { |
74 |
> |
inpfile[i].isDSF = 1; |
75 |
> |
continue; |
76 |
> |
} |
77 |
> |
if (!strcasecmp(typ, "BSDF")) { |
78 |
> |
inpfile[i].isDSF = 0; |
79 |
> |
continue; |
80 |
> |
} |
81 |
|
} |
75 |
– |
if (!strcmp(buf, "format: theta phi BSDF\n")) { |
76 |
– |
inpfile[i].isDSF = 0; |
77 |
– |
continue; |
78 |
– |
} |
82 |
|
if (sscanf(buf, "intheta %lf", &inpfile[i].theta) == 1) |
83 |
|
continue; |
84 |
|
if (sscanf(buf, "inphi %lf", &inpfile[i].phi) == 1) |
99 |
|
fputs(": unknown incident angle\n", stderr); |
100 |
|
return(0); |
101 |
|
} |
102 |
+ |
while (inpfile[i].phi < 0) /* normalize phi direction */ |
103 |
+ |
inpfile[i].phi += 360.; |
104 |
|
return(1); |
105 |
|
} |
106 |
|
|
117 |
|
fputs(": cannot open\n", stderr); |
118 |
|
return(0); |
119 |
|
} |
115 |
– |
#ifdef DEBUG |
116 |
– |
fprintf(stderr, "Loading measurements from '%s'...\n", inpfile[i].fname); |
117 |
– |
#endif |
120 |
|
/* prepare input grid */ |
121 |
|
if (!i || cmp_inang(&inpfile[i-1], &inpfile[i])) { |
122 |
|
if (i) /* need to process previous incidence */ |
127 |
|
#endif |
128 |
|
new_bsdf_data(inpfile[i].theta, inpfile[i].phi); |
129 |
|
} |
130 |
+ |
#ifdef DEBUG |
131 |
+ |
fprintf(stderr, "Loading measurements from '%s'...\n", inpfile[i].fname); |
132 |
+ |
#endif |
133 |
|
/* read scattering data */ |
134 |
|
while (fscanf(fp, "%lf %lf %lf\n", &theta_out, &phi_out, &val) == 3) |
135 |
|
add_bsdf_data(theta_out, phi_out, val, inpfile[i].isDSF); |