| 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 |
|
} |
| 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++; |
| 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 |
|
|