40 |
|
struct RcontribMod { |
41 |
|
RcontribOutput * opl; // pointer to first output channel |
42 |
|
char * params; // parameters string |
43 |
< |
EPNODE * binv; // bin expression |
43 |
> |
EPNODE * binv; // bin expression (NULL if 1 bin) |
44 |
|
int nbins; // bin count this modifier |
45 |
|
int coffset; // column offset in bytes |
46 |
|
DCOLORV cbin[1]; // bin accumulator (extends struct) |
70 |
|
{ |
71 |
|
if (ncbins <= 0) return NULL; |
72 |
|
if (!prms) prms = ""; |
73 |
< |
if (!binexpr | (ncbins == 1)) |
74 |
< |
binexpr = "0"; |
75 |
< |
|
73 |
> |
if (!binexpr & (ncbins > 1)) { |
74 |
> |
error(INTERNAL, "missing bin expression"); |
75 |
> |
return NULL; |
76 |
> |
} |
77 |
> |
if (ncbins == 1) { // shouldn't have bin expression? |
78 |
> |
if (binexpr && strcmp(binexpr, "0")) |
79 |
> |
error(WARNING, "ignoring non-zero expression for single bin"); |
80 |
> |
prms = ""; |
81 |
> |
binexpr = NULL; |
82 |
> |
} |
83 |
|
RcontribMod * mp = (RcontribMod *)ecalloc(1, sizeof(RcontribMod) + |
84 |
|
sizeof(DCOLORV)*(NCSAMP*ncbins-1) + |
85 |
|
strlen(prms)+1); |
86 |
|
|
87 |
|
mp->params = strcpy((char *)(mp->cbin + ncbins*NCSAMP), prms); |
88 |
< |
mp->binv = eparse(const_cast<char *>(binexpr)); |
88 |
> |
if (binexpr) { |
89 |
> |
mp->binv = eparse(const_cast<char *>(binexpr)); |
90 |
> |
CHECK(mp->binv->type==NUM, WARNING, "constant bin expression"); |
91 |
> |
} |
92 |
|
mp->nbins = ncbins; |
93 |
|
return mp; |
94 |
|
} |
98 |
|
FreeRcMod(void *p) |
99 |
|
{ |
100 |
|
if (!p) return; |
101 |
< |
epfree((*(RcontribMod *)p).binv, true); |
101 |
> |
EPNODE * bep = (*(RcontribMod *)p).binv; |
102 |
> |
if (bep) epfree(bep, true); |
103 |
|
efree(p); |
104 |
|
} |
105 |
|
|
146 |
|
if (!mp) |
147 |
|
return 0; // not in our modifier list |
148 |
|
|
149 |
< |
worldfunc(RCCONTEXT, r); // compute bin # |
150 |
< |
set_eparams(mp->params); |
151 |
< |
double bval = evalue(mp->binv); |
152 |
< |
if (bval <= -.5) |
153 |
< |
return 0; // silently ignore negative bin index |
154 |
< |
DCOLORV * dvp = (*mp)[int(bval + .5)]; |
149 |
> |
int bi = 0; // get bin index |
150 |
> |
if (mp->binv) { |
151 |
> |
worldfunc(RCCONTEXT, r); |
152 |
> |
set_eparams(mp->params); |
153 |
> |
double bval = evalue(mp->binv); |
154 |
> |
if (bval <= -.5) |
155 |
> |
return 0; // silently ignore negative bin index |
156 |
> |
bi = int(bval + .5); |
157 |
> |
} |
158 |
> |
DCOLORV * dvp = (*mp)[bi]; |
159 |
|
if (!dvp) { |
160 |
< |
sprintf(errmsg, "bad bin number for '%s' (%.1f ignored)", mname, bval); |
160 |
> |
sprintf(errmsg, "bad bin number for '%s' (%d ignored)", mname, bi); |
161 |
|
error(WARNING, errmsg); |
162 |
|
return 0; |
163 |
|
} |
304 |
|
return true; |
305 |
|
} |
306 |
|
|
307 |
+ |
// call-back to check if modifier has been loaded |
308 |
+ |
static int |
309 |
+ |
checkModExists(const LUENT *lp, void *p) |
310 |
+ |
{ |
311 |
+ |
if (modifier(lp->key) != OVOID) |
312 |
+ |
return 1; |
313 |
+ |
|
314 |
+ |
sprintf(errmsg, "tracked modifier '%s' not found in main scene", lp->key); |
315 |
+ |
error(WARNING, errmsg); |
316 |
+ |
return 0; |
317 |
+ |
} |
318 |
+ |
|
319 |
|
// Prepare output channels and return # completed rows |
320 |
|
int |
321 |
|
RcontribSimulManager::PrepOutput() |
324 |
|
error(INTERNAL, "PrepOutput() called before octree & modifiers assigned"); |
325 |
|
return -1; |
326 |
|
} |
327 |
+ |
if (!cdsF) { |
328 |
+ |
error(INTERNAL, "missing RdataShare constructor call (*cdsF)"); |
329 |
+ |
return -1; |
330 |
+ |
} |
331 |
+ |
if (lu_doall(&modLUT, checkModExists, NULL) < 0) |
332 |
+ |
return -1; |
333 |
+ |
|
334 |
|
int remWarnings = 20; |
335 |
|
for (RcontribOutput *op = outList; op; op = op->next) { |
336 |
|
if (op->rData) { |
477 |
|
return -1; |
478 |
|
} |
479 |
|
// check format |
480 |
< |
if (!(cp = findArgs(hdr, FMTSTR, begData)) || strcmp(cp, formstr(etyp))) { |
480 |
> |
if (!(cp = findArgs(hdr, FMTSTR, begData)) || |
481 |
> |
strncmp(cp, formstr(etyp), strlen(formstr(etyp)))) { |
482 |
|
sprintf(errmsg, "expected %s%s in '%s'", FMTSTR, formstr(etyp), GetName()); |
483 |
|
error(USER, errmsg); |
484 |
|
return -1; |
667 |
|
FD_ISSET(kid[n].w, &writeset) | |
668 |
|
FD_ISSET(kid[n].w, &errset)) { |
669 |
|
// update output row counts |
670 |
< |
UpdateRowsDone(kidRow[n]); |
670 |
> |
if (!FD_ISSET(kid[n].w, &errset)) |
671 |
> |
UpdateRowsDone(kidRow[n]); |
672 |
|
kidRow[n] = -1; // flag it available |
673 |
|
pn = n; |
674 |
|
} |
752 |
|
close(kid[nkids].w); |
753 |
|
free(kid); free(kidRow); |
754 |
|
kid = NULL; kidRow = NULL; |
719 |
– |
rowsDone.NewBitMap(0); |
755 |
|
RunChild(); // should never return |
756 |
|
_exit(1); |
757 |
|
} |