68 |
|
|
69 |
|
static void trace_contrib(RAY *r); /* our trace callback */ |
70 |
|
|
71 |
< |
static void mcfree(void *p) { epfree((*(MODCONT *)p).binv); free(p); } |
71 |
> |
static void mcfree(void *p) { epfree((*(MODCONT *)p).binv,1); free(p); } |
72 |
|
|
73 |
|
LUTAB modconttab = LU_SINIT(NULL,mcfree); /* modifier lookup table */ |
74 |
|
|
75 |
|
/************************** INITIALIZATION ROUTINES ***********************/ |
76 |
|
|
77 |
< |
char * |
77 |
> |
const char * |
78 |
|
formstr( /* return format identifier */ |
79 |
|
int f |
80 |
|
) |
83 |
|
case 'a': return("ascii"); |
84 |
|
case 'f': return("float"); |
85 |
|
case 'd': return("double"); |
86 |
< |
case 'c': return(COLRFMT); |
86 |
> |
case 'c': return(NCSAMP==3 ? COLRFMT : SPECFMT); |
87 |
|
} |
88 |
|
return("unknown"); |
89 |
|
} |
107 |
|
error(USER, errmsg); |
108 |
|
} |
109 |
|
if (nmods >= modasiz) { /* need bigger modifier array */ |
110 |
< |
modasiz += modasiz/3 + 64; |
110 |
> |
modasiz += modasiz/2 + 64; |
111 |
|
if (modname == NULL) |
112 |
|
modname = (char **)malloc(modasiz*sizeof(char *)); |
113 |
|
else |
134 |
|
error(USER, errmsg); |
135 |
|
} |
136 |
|
/* initialize results holder */ |
137 |
< |
mp = (MODCONT *)malloc(sizeof(MODCONT)+sizeof(DCOLOR)*(bincnt-1)); |
137 |
> |
mp = (MODCONT *)malloc(mcsize(bincnt)); |
138 |
|
if (mp == NULL) |
139 |
|
error(SYSTEM, "out of memory in addmodifier"); |
140 |
|
mp->outspec = outf; /* XXX assumes static string */ |
143 |
|
mp->binv = ebinv; |
144 |
|
mp->bin0 = 0; |
145 |
|
mp->nbins = bincnt; |
146 |
< |
memset(mp->cbin, 0, sizeof(DCOLOR)*bincnt); |
146 |
> |
memset(mp->cbin, 0, DCOLORSIZ*bincnt); |
147 |
|
/* figure out starting bin */ |
148 |
|
while (!getostream(mp->outspec, mp->modname, mp->bin0, 1)) |
149 |
|
mp->bin0++; |
164 |
|
FILE *fp; |
165 |
|
|
166 |
|
if (path == NULL || (fp = fopen(path, "r")) == NULL) { |
167 |
< |
sprintf(errmsg, "cannot load modifier file '%s'", |
168 |
< |
path != NULL ? path : fname); |
167 |
> |
if (path == NULL) |
168 |
> |
sprintf(errmsg, "cannot find modifier file '%s'", fname); |
169 |
> |
else |
170 |
> |
sprintf(errmsg, "cannot load modifier file '%s'", path); |
171 |
|
error(SYSTEM, errmsg); |
172 |
|
} |
173 |
|
while (fgetword(mod, sizeof(mod), fp) != NULL) |
174 |
< |
addmodifier(mod, outf, prms, binv, bincnt); |
174 |
> |
addmodifier(savqstr(mod), outf, prms, binv, bincnt); |
175 |
|
fclose(fp); |
176 |
|
} |
177 |
|
|
273 |
|
MODCONT *mp; |
274 |
|
double bval; |
275 |
|
int bn; |
276 |
< |
RREAL contr[3]; |
276 |
> |
SCOLOR contr; |
277 |
> |
DCOLORV *dvp; |
278 |
> |
int i; |
279 |
|
|
280 |
|
if (r->ro == NULL || r->ro->omod == OVOID) |
281 |
|
return; |
299 |
|
} |
300 |
|
raycontrib(contr, r, PRIMARY); /* compute coefficient */ |
301 |
|
if (contrib) |
302 |
< |
multcolor(contr, r->rcol); /* -> contribution */ |
303 |
< |
addcolor(mp->cbin[bn], contr); |
302 |
> |
smultscolor(contr, r->rcol); /* -> contribution */ |
303 |
> |
dvp = mcbin(mp, bn); |
304 |
> |
for (i = 0; i < NCSAMP; i++) /* add it in */ |
305 |
> |
*dvp++ += contr[i]; |
306 |
|
} |
307 |
|
|
308 |
|
|
356 |
|
for (i = 0; i < nmods; i++) { /* output records & clear */ |
357 |
|
mp = (MODCONT *)lu_find(&modconttab,modname[i])->data; |
358 |
|
mod_output(mp); |
359 |
< |
memset(mp->cbin, 0, sizeof(DCOLOR)*mp->nbins); |
359 |
> |
memset(mp->cbin, 0, DCOLORSIZ*mp->nbins); |
360 |
|
} |
361 |
|
end_record(); /* end lines & flush if time */ |
362 |
|
|