52 |
|
uint32 ac; // accumulation count |
53 |
|
}; |
54 |
|
|
55 |
+ |
// Get format identifier |
56 |
+ |
const char * |
57 |
+ |
formstr(int f) |
58 |
+ |
{ |
59 |
+ |
switch (f) { |
60 |
+ |
case 'a': return("ascii"); |
61 |
+ |
case 'f': return("float"); |
62 |
+ |
case 'd': return("double"); |
63 |
+ |
case 'c': return(NCSAMP==3 ? COLRFMT : SPECFMT); |
64 |
+ |
} |
65 |
+ |
return("unknown"); |
66 |
+ |
} |
67 |
+ |
|
68 |
|
// Our default data share function |
69 |
|
RdataShare * |
70 |
|
defDataShare(const char *name, RCOutputOp op, size_t siz) |
77 |
|
NewRcMod(const char *prms, const char *binexpr, int ncbins) |
78 |
|
{ |
79 |
|
if (!prms) prms = ""; |
80 |
< |
if (!binexpr & (ncbins > 1)) { |
80 |
> |
if ((ncbins > 1) & !binexpr) { |
81 |
|
error(USER, "missing bin expression"); |
82 |
|
return NULL; |
83 |
|
} |
84 |
< |
if (ncbins <= 1) { // shouldn't have bin expression? |
85 |
< |
if (binexpr && strcmp(binexpr, "0")) |
73 |
< |
error(WARNING, "ignoring non-zero expression for single bin"); |
74 |
< |
prms = ""; |
75 |
< |
binexpr = NULL; |
76 |
< |
ncbins = 1; |
77 |
< |
} |
84 |
> |
if (ncbins < 1) ncbins = 1; |
85 |
> |
|
86 |
|
RcontribMod * mp = (RcontribMod *)ecalloc(1, sizeof(RcontribMod) + |
87 |
|
sizeof(DCOLORV)*(NCSAMP*ncbins-1) + |
88 |
|
strlen(prms)+1); |
89 |
|
|
90 |
< |
mp->params = strcpy((char *)(mp->cbin + ncbins*NCSAMP), prms); |
83 |
< |
if (binexpr) { |
90 |
> |
if (binexpr) { // get/check bin expression |
91 |
|
mp->binv = eparse(const_cast<char *>(binexpr)); |
92 |
< |
CHECK(mp->binv->type==NUM, WARNING, "constant bin expression"); |
92 |
> |
if (mp->binv->type == NUM) { // constant expression (0)? |
93 |
> |
if ((int)evalue(mp->binv) != 0) { |
94 |
> |
sprintf(errmsg, "illegal non-zero constant for bin (%s)", |
95 |
> |
binexpr); |
96 |
> |
error(USER, errmsg); |
97 |
> |
} |
98 |
> |
if (ncbins > 1) { |
99 |
> |
sprintf(errmsg, "bad bin count (%d should be 1)", ncbins); |
100 |
> |
error(USER, errmsg); |
101 |
> |
} |
102 |
> |
epfree(mp->binv, true); |
103 |
> |
mp->binv = NULL; |
104 |
> |
prms = ""; |
105 |
> |
ncbins = 1; |
106 |
> |
} |
107 |
|
} |
108 |
+ |
mp->params = strcpy((char *)(mp->cbin + ncbins*NCSAMP), prms); |
109 |
|
mp->nbins = ncbins; |
110 |
|
return mp; |
111 |
|
} |
182 |
|
raycontrib(contr, r, PRIMARY); // compute coefficient |
183 |
|
if (rcp->HasFlag(RCcontrib)) |
184 |
|
smultscolor(contr, r->rcol); // -> value contribution |
185 |
+ |
|
186 |
|
for (int i = 0; i < NCSAMP; i++) |
187 |
|
*dvp++ += contr[i]; // accumulate color/spectrum |
188 |
|
return 1; |
224 |
|
return false; |
225 |
|
nChan = NCSAMP; |
226 |
|
} else if (nChan != NCSAMP) { |
227 |
< |
error(USER, "number of spectral channels must be fixed"); |
227 |
> |
error(USER, "# spectral channels must be fixed in AddModifier()"); |
228 |
|
return false; |
229 |
|
} |
230 |
|
if (Ready()) { |
320 |
|
} |
321 |
|
char mod[MAXSTR]; |
322 |
|
while (fgetword(mod, sizeof(mod), fp)) |
323 |
< |
if (!AddModifier(mod, outspec, prms, binval, bincnt)) |
323 |
> |
if (!AddModifier(mod, outspec, prms, binval, bincnt)) { |
324 |
> |
fclose(fp); |
325 |
|
return false; |
326 |
+ |
} |
327 |
|
fclose(fp); |
328 |
|
return true; |
329 |
|
} |
332 |
|
static int |
333 |
|
checkModExists(const LUENT *lp, void *p) |
334 |
|
{ |
335 |
< |
if (modifier(lp->key) != OVOID) |
335 |
> |
OBJECT mod = modifier(lp->key); |
336 |
> |
|
337 |
> |
if ((mod != OVOID) & (mod < nsceneobjs)) |
338 |
|
return 1; |
339 |
|
|
340 |
|
sprintf(errmsg, "tracked modifier '%s' not found in main scene", lp->key); |
347 |
|
RcontribSimulManager::PrepOutput() |
348 |
|
{ |
349 |
|
if (!outList || !RtraceSimulManager::Ready()) { |
350 |
< |
error(INTERNAL, "PrepOutput() called before octree & modifiers assigned"); |
350 |
> |
error(INTERNAL, "PrepOutput() called before octree & modifiers set"); |
351 |
|
return -1; |
352 |
|
} |
353 |
|
if (!cdsF) { |
354 |
< |
error(INTERNAL, "missing RdataShare constructor call (*cdsF)"); |
354 |
> |
error(INTERNAL, "missing RdataShare constructor call (cdsF)"); |
355 |
|
return -1; |
356 |
|
} |
357 |
|
if (lu_doall(&modLUT, checkModExists, NULL) < 0) |
358 |
|
return -1; |
359 |
|
|
360 |
+ |
outList->nRows = yres * (xres + !xres); // all outputs have same #rows |
361 |
|
int remWarnings = 20; |
362 |
|
for (RcontribOutput *op = outList; op; op = op->next) { |
363 |
|
if (op->rData) { |
364 |
|
error(INTERNAL, "output channel already open in PrepOutput()"); |
365 |
|
return -1; |
366 |
|
} |
367 |
< |
op->nRows = yres * (xres + !xres); |
367 |
> |
op->nRows = outList->nRows; |
368 |
|
op->rData = (*cdsF)(op->ofname, outOp, |
369 |
|
GetHeadLen()+1024 + op->nRows*op->rowBytes); |
370 |
|
freeqstr(op->ofname); op->ofname = NULL; |
374 |
|
return -1; |
375 |
|
if (rd >= op->nRows) { |
376 |
|
if (remWarnings >= 0) { |
377 |
< |
sprintf(errmsg, "recovered output '%s' already done", |
377 |
> |
sprintf(errmsg, "recovered output '%s' is complete", |
378 |
|
op->GetName()); |
379 |
< |
error(WARNING, remWarnings ? errmsg : "etc..."); |
352 |
< |
remWarnings--; |
379 |
> |
error(WARNING, --remWarnings ? errmsg : "etc..."); |
380 |
|
} |
381 |
|
rd = op->nRows; |
382 |
|
} |