| 10 |
|
|
| 11 |
|
#include "mkillum.h" |
| 12 |
|
|
| 13 |
< |
#define brt(col) (.295*(col)[0] + .636*(col)[1] + .070*(col)[2]) |
| 13 |
> |
#define brt(col) (.263*(col)[0]+.655*(col)[1]+.082*(col)[2]) |
| 14 |
|
|
| 15 |
|
char DATORD[] = "RGB"; /* data ordering */ |
| 16 |
|
char DATSUF[] = ".dat"; /* data file suffix */ |
| 24 |
|
{ |
| 25 |
|
register int i; |
| 26 |
|
|
| 27 |
+ |
if (issurface(obj->otype) && !strcmp(mod, VOIDID)) |
| 28 |
+ |
return; /* don't print void surfaces */ |
| 29 |
|
printf("\n%s %s %s", mod, ofun[obj->otype].funame, obj->oname); |
| 30 |
|
printf("\n%d", obj->oargs.nsargs); |
| 31 |
|
for (i = 0; i < obj->oargs.nsargs; i++) |
| 95 |
|
int n, m; |
| 96 |
|
FVECT u, v, w; |
| 97 |
|
{ |
| 98 |
+ |
float *Ninv; |
| 99 |
|
FILE *dfp; |
| 100 |
|
int i; |
| 101 |
|
|
| 102 |
+ |
if ((Ninv = (float *)malloc(3*m*sizeof(float))) == NULL) |
| 103 |
+ |
error(SYSTEM, "out of memory in flatout"); |
| 104 |
+ |
compinv(Ninv, da, m); |
| 105 |
|
if (il->flags & IL_COLDST) { |
| 106 |
|
printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame, |
| 107 |
|
il->matname, DSTSUF); |
| 108 |
|
printf("\n9 red green blue"); |
| 109 |
|
for (i = 0; i < 3; i++) { |
| 110 |
|
dfp = dfopen(il, DATORD[i]); |
| 111 |
< |
fprintf(dfp, "2\n1 0 %d\n0 %f %d\n", n, 2.*PI, m); |
| 112 |
< |
colorout(i, da, n*m, 1./il->nsamps/il->col[i], dfp); |
| 111 |
> |
fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", |
| 112 |
> |
1.+.5/n, .5/n, n+1, |
| 113 |
> |
0., 2.*PI, m+1); |
| 114 |
> |
colorout(i, Ninv, 1, m, 1./il->nsamps/il->col[i], dfp); |
| 115 |
> |
colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp); |
| 116 |
> |
fputeol(dfp); |
| 117 |
|
fclose(dfp); |
| 118 |
|
printf(" %s", dfname(il, DATORD[i])); |
| 119 |
|
} |
| 120 |
|
} else { |
| 121 |
|
printf("\n%s %s %s%s", VOIDID, ofun[PAT_BDATA].funame, |
| 122 |
|
il->matname, DSTSUF); |
| 123 |
< |
printf("\n5 noop"); |
| 123 |
> |
printf("\n5 noneg"); |
| 124 |
|
dfp = dfopen(il, 0); |
| 125 |
< |
fprintf(dfp, "2\n1 0 %d\n0 %f %d\n", n, 2.*PI, m); |
| 126 |
< |
brightout(da, n*m, 1./il->nsamps/brt(il->col), dfp); |
| 125 |
> |
fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.+.5/n, .5/n, n+1, |
| 126 |
> |
0., 2.*PI, m+1); |
| 127 |
> |
brightout(Ninv, 1, m, 1./il->nsamps/brt(il->col), dfp); |
| 128 |
> |
brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp); |
| 129 |
> |
fputeol(dfp); |
| 130 |
|
fclose(dfp); |
| 131 |
|
printf(" %s", dfname(il, 0)); |
| 132 |
|
} |
| 136 |
|
printf("\t%f\t%f\t%f\n", v[0], v[1], v[2]); |
| 137 |
|
printf("\t%f\t%f\t%f\n", w[0], w[1], w[2]); |
| 138 |
|
il->dfnum++; |
| 139 |
+ |
free((char *)Ninv); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
|
| 145 |
|
float *da; |
| 146 |
|
int n, m; |
| 147 |
|
{ |
| 148 |
+ |
float *Ninv, *Sinv; |
| 149 |
|
FILE *dfp; |
| 150 |
|
int i; |
| 151 |
|
|
| 152 |
+ |
if ((Ninv = (float *)malloc(3*m*sizeof(float))) == NULL || |
| 153 |
+ |
(Sinv = (float *)malloc(3*m*sizeof(float))) == NULL) |
| 154 |
+ |
error(SYSTEM, "out of memory in flatout"); |
| 155 |
+ |
compinv(Ninv, da, m); |
| 156 |
+ |
compinv(Sinv, da+3*m*(n-1), m); |
| 157 |
|
if (il->flags & IL_COLDST) { |
| 158 |
|
printf("\n%s %s %s%s", VOIDID, ofun[PAT_CDATA].funame, |
| 159 |
|
il->matname, DSTSUF); |
| 160 |
|
printf("\n9 red green blue"); |
| 161 |
|
for (i = 0; i < 3; i++) { |
| 162 |
|
dfp = dfopen(il, DATORD[i]); |
| 163 |
< |
fprintf(dfp, "2\n1 -1 %d\n0 %f %d\n", n, 2.*PI, m); |
| 164 |
< |
colorout(i, da, n*m, 1./il->nsamps/il->col[i], dfp); |
| 163 |
> |
fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", |
| 164 |
> |
1.+1./n, -1.-1./n, n+2, |
| 165 |
> |
0., 2.*PI, m+1); |
| 166 |
> |
colorout(i, Ninv, 1, m, 1./il->nsamps/il->col[i], dfp); |
| 167 |
> |
colorout(i, da, n, m, 1./il->nsamps/il->col[i], dfp); |
| 168 |
> |
colorout(i, Sinv, 1, m, 1./il->nsamps/il->col[i], dfp); |
| 169 |
> |
fputeol(dfp); |
| 170 |
|
fclose(dfp); |
| 171 |
|
printf(" %s", dfname(il, DATORD[i])); |
| 172 |
|
} |
| 173 |
|
} else { |
| 174 |
|
printf("\n%s %s %s%s", VOIDID, ofun[PAT_BDATA].funame, |
| 175 |
|
il->matname, DSTSUF); |
| 176 |
< |
printf("\n5 noop"); |
| 176 |
> |
printf("\n5 noneg"); |
| 177 |
|
dfp = dfopen(il, 0); |
| 178 |
< |
fprintf(dfp, "2\n1 -1 %d\n0 %f %d\n", n, 2.*PI, m); |
| 179 |
< |
brightout(da, n*m, 1./il->nsamps/brt(il->col), dfp); |
| 178 |
> |
fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.-1./n, -1.+1./n, n, |
| 179 |
> |
0., 2.*PI, m+1); |
| 180 |
> |
brightout(Ninv, 1, m, 1./il->nsamps/brt(il->col), dfp); |
| 181 |
> |
brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp); |
| 182 |
> |
brightout(Sinv, 1, m, 1./il->nsamps/brt(il->col), dfp); |
| 183 |
> |
fputeol(dfp); |
| 184 |
|
fclose(dfp); |
| 185 |
|
printf(" %s", dfname(il, 0)); |
| 186 |
|
} |
| 187 |
|
printf("\n\t%s il_alt il_azi", FNCFNM); |
| 188 |
|
printf("\n0\n0\n"); |
| 189 |
|
il->dfnum++; |
| 190 |
+ |
free((char *)Ninv); |
| 191 |
+ |
free((char *)Sinv); |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
|
| 221 |
|
} |
| 222 |
|
|
| 223 |
|
|
| 224 |
< |
average(il, da, n) /* compute average value for distribution */ |
| 225 |
< |
register struct illum_args *il; |
| 224 |
> |
compavg(col, da, n) /* compute average for set of data values */ |
| 225 |
> |
float col[3]; |
| 226 |
|
register float *da; |
| 227 |
|
int n; |
| 228 |
|
{ |
| 229 |
|
register int i; |
| 230 |
|
|
| 231 |
< |
il->col[0] = il->col[1] = il->col[2] = 0.; |
| 231 |
> |
col[0] = col[1] = col[2] = 0.; |
| 232 |
|
i = n; |
| 233 |
|
while (i-- > 0) { |
| 234 |
< |
il->col[0] += *da++; |
| 235 |
< |
il->col[1] += *da++; |
| 236 |
< |
il->col[2] += *da++; |
| 234 |
> |
col[0] += *da++; |
| 235 |
> |
col[1] += *da++; |
| 236 |
> |
col[2] += *da++; |
| 237 |
|
} |
| 238 |
|
for (i = 0; i < 3; i++) |
| 239 |
< |
il->col[i] /= (double)n*il->nsamps; |
| 239 |
> |
col[i] /= (double)n; |
| 240 |
|
} |
| 241 |
|
|
| 242 |
|
|
| 243 |
< |
colorout(p, da, n, mult, fp) /* put out color distribution data */ |
| 243 |
> |
compinv(rinv, rp, m) /* compute other side of row average */ |
| 244 |
> |
register float *rinv, *rp; |
| 245 |
> |
int m; |
| 246 |
> |
{ |
| 247 |
> |
float avg[3]; |
| 248 |
> |
|
| 249 |
> |
compavg(avg, rp, m); /* row average */ |
| 250 |
> |
while (m-- > 0) { |
| 251 |
> |
*rinv++ = 2.*avg[0] - *rp++; |
| 252 |
> |
*rinv++ = 2.*avg[1] - *rp++; |
| 253 |
> |
*rinv++ = 2.*avg[2] - *rp++; |
| 254 |
> |
} |
| 255 |
> |
} |
| 256 |
> |
|
| 257 |
> |
|
| 258 |
> |
average(il, da, n) /* evaluate average value for distribution */ |
| 259 |
> |
register struct illum_args *il; |
| 260 |
> |
float *da; |
| 261 |
> |
int n; |
| 262 |
> |
{ |
| 263 |
> |
compavg(il->col, da, n); /* average */ |
| 264 |
> |
if (il->nsamps > 1) { |
| 265 |
> |
il->col[0] /= (double)il->nsamps; |
| 266 |
> |
il->col[1] /= (double)il->nsamps; |
| 267 |
> |
il->col[2] /= (double)il->nsamps; |
| 268 |
> |
} |
| 269 |
> |
/* brighter than minimum? */ |
| 270 |
> |
return(brt(il->col) > il->minbrt+FTINY); |
| 271 |
> |
} |
| 272 |
> |
|
| 273 |
> |
|
| 274 |
> |
static int colmcnt = 0; /* count of columns written */ |
| 275 |
> |
|
| 276 |
> |
fputnum(d, fp) /* put out a number to fp */ |
| 277 |
> |
double d; |
| 278 |
> |
FILE *fp; |
| 279 |
> |
{ |
| 280 |
> |
if (colmcnt++ % 5 == 0) |
| 281 |
> |
putc('\n', fp); |
| 282 |
> |
fprintf(fp, " %11e", d); |
| 283 |
> |
} |
| 284 |
> |
|
| 285 |
> |
|
| 286 |
> |
fputeol(fp) /* write end of line to fp */ |
| 287 |
> |
register FILE *fp; |
| 288 |
> |
{ |
| 289 |
> |
putc('\n', fp); |
| 290 |
> |
colmcnt = 0; |
| 291 |
> |
} |
| 292 |
> |
|
| 293 |
> |
|
| 294 |
> |
colorout(p, da, n, m, mult, fp) /* put out color distribution data */ |
| 295 |
|
int p; |
| 296 |
|
register float *da; |
| 297 |
< |
int n; |
| 297 |
> |
int n, m; |
| 298 |
|
double mult; |
| 299 |
|
FILE *fp; |
| 300 |
|
{ |
| 301 |
< |
register int i; |
| 301 |
> |
register int i, j; |
| 302 |
|
|
| 303 |
|
for (i = 0; i < n; i++) { |
| 304 |
< |
if (i%6 == 0) |
| 305 |
< |
putc('\n', fp); |
| 306 |
< |
fprintf(fp, " %11e", mult*da[p]); |
| 307 |
< |
da += 3; |
| 304 |
> |
for (j = 0; j < m; j++) { |
| 305 |
> |
fputnum(mult*da[p], fp); |
| 306 |
> |
da += 3; |
| 307 |
> |
} |
| 308 |
> |
fputnum(mult*da[p-3*m], fp); /* wrap phi */ |
| 309 |
|
} |
| 227 |
– |
putc('\n', fp); |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
|
| 313 |
< |
brightout(da, n, mult, fp) /* put out brightness distribution data */ |
| 313 |
> |
brightout(da, n, m, mult, fp) /* put out brightness distribution data */ |
| 314 |
|
register float *da; |
| 315 |
< |
int n; |
| 315 |
> |
int n, m; |
| 316 |
|
double mult; |
| 317 |
|
FILE *fp; |
| 318 |
|
{ |
| 319 |
< |
register int i; |
| 319 |
> |
register int i, j; |
| 320 |
|
|
| 321 |
|
for (i = 0; i < n; i++) { |
| 322 |
< |
if (i%6 == 0) |
| 323 |
< |
putc('\n', fp); |
| 324 |
< |
fprintf(fp, " %11e", mult*brt(da)); |
| 325 |
< |
da += 3; |
| 322 |
> |
for (j = 0; j < m; j++) { |
| 323 |
> |
fputnum(mult*brt(da), fp); |
| 324 |
> |
da += 3; |
| 325 |
> |
} |
| 326 |
> |
fputnum(mult*brt(da-3*m), fp); /* wrap phi */ |
| 327 |
|
} |
| 245 |
– |
putc('\n', fp); |
| 328 |
|
} |