24 |
|
extern const char BIGEND[]; |
25 |
|
extern const char FMTSTR[]; |
26 |
|
|
27 |
< |
extern int contrib; /* computing contributions? */ |
28 |
< |
extern int lim_dist; /* limit distance? */ |
27 |
> |
int contrib = 0; // computing contributions? |
28 |
|
|
29 |
+ |
int xres = 0; // horizontal (scan) size |
30 |
+ |
int yres = 0; // vertical resolution |
31 |
+ |
|
32 |
|
// new/exclusive, overwrite if exists, or recover data |
33 |
|
int RSDOflags[] = {RDSwrite|RDSexcl|RDSextend, RDSwrite|RDSextend, |
34 |
|
RDSread|RDSwrite}; |
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) |
51 |
|
} |
52 |
|
}; |
53 |
|
|
54 |
< |
// used to assign record calc to child |
54 |
> |
// Struct used to assign record calculation to child |
55 |
|
struct RowAssignment { |
56 |
|
uint32 row; // row to do |
57 |
|
uint32 ac; // accumulation count |
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); // compute bin # |
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 |
< |
// Run through current list of output struct's |
308 |
< |
int |
309 |
< |
RcontribSimulManager::GetOutputs(RoutputShareF *osF, void *cd) const |
307 |
> |
// call-back to check if modifier has been loaded |
308 |
> |
static int |
309 |
> |
checkModExists(const LUENT *lp, void *p) |
310 |
|
{ |
311 |
< |
int cnt = 0; |
311 |
> |
if (modifier(lp->key) != OVOID) |
312 |
> |
return 1; |
313 |
|
|
314 |
< |
for (const RcontribOutput *op = outList; op; op = op->next) { |
315 |
< |
int rv = 1; |
316 |
< |
if (osF && (rv = (*osF)(op, cd)) < 0) |
299 |
< |
return rv; |
300 |
< |
cnt += rv; |
301 |
< |
} |
302 |
< |
return cnt; |
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 |
324 |
|
error(INTERNAL, "PrepOutput() called before octree & modifiers assigned"); |
325 |
|
return -1; |
326 |
|
} |
327 |
+ |
if (lu_doall(&modLUT, checkModExists, NULL) < 0) |
328 |
+ |
return -1; |
329 |
+ |
|
330 |
|
int remWarnings = 20; |
331 |
|
for (RcontribOutput *op = outList; op; op = op->next) { |
332 |
|
if (op->rData) { |
358 |
|
!op->rData->Resize(op->begData + op->nRows*op->rowBytes)) |
359 |
|
return -1; // calls error() for us |
360 |
|
} |
344 |
– |
if (lim_dist) // XXX where else to put this? |
345 |
– |
rtFlags |= RTlimDist; |
346 |
– |
else |
347 |
– |
rtFlags &= ~RTlimDist; |
348 |
– |
|
361 |
|
rowsDone.NewBitMap(outList->nRows); // create row completion map |
362 |
|
rowsDone.ClearBits(0, rInPos, true); |
363 |
|
return rInPos; |
473 |
|
return -1; |
474 |
|
} |
475 |
|
// check format |
476 |
< |
if (!(cp = findArgs(hdr, FMTSTR, begData)) || strcmp(cp, formstr(etyp))) { |
476 |
> |
if (!(cp = findArgs(hdr, FMTSTR, begData)) || |
477 |
> |
strncmp(cp, formstr(etyp), strlen(formstr(etyp)))) { |
478 |
|
sprintf(errmsg, "expected %s%s in '%s'", FMTSTR, formstr(etyp), GetName()); |
479 |
|
error(USER, errmsg); |
480 |
|
return -1; |
663 |
|
FD_ISSET(kid[n].w, &writeset) | |
664 |
|
FD_ISSET(kid[n].w, &errset)) { |
665 |
|
// update output row counts |
666 |
< |
UpdateRowsDone(kidRow[n]); |
666 |
> |
if (!FD_ISSET(kid[n].w, &errset)) |
667 |
> |
UpdateRowsDone(kidRow[n]); |
668 |
|
kidRow[n] = -1; // flag it available |
669 |
|
pn = n; |
670 |
|
} |
748 |
|
close(kid[nkids].w); |
749 |
|
free(kid); free(kidRow); |
750 |
|
kid = NULL; kidRow = NULL; |
737 |
– |
rowsDone.NewBitMap(0); |
751 |
|
RunChild(); // should never return |
752 |
|
_exit(1); |
753 |
|
} |