| 24 |
|
extern const char BIGEND[]; |
| 25 |
|
extern const char FMTSTR[]; |
| 26 |
|
|
| 27 |
– |
int contrib = 0; // computing contributions? |
| 28 |
– |
|
| 29 |
– |
int xres = 0; // horizontal (scan) size |
| 30 |
– |
int yres = 0; // vertical resolution |
| 31 |
– |
|
| 27 |
|
// new/exclusive, overwrite if exists, or recover data |
| 28 |
|
int RSDOflags[] = {RDSwrite|RDSexcl|RDSextend, RDSwrite|RDSextend, |
| 29 |
|
RDSread|RDSwrite}; |
| 63 |
|
RcontribMod * |
| 64 |
|
NewRcMod(const char *prms, const char *binexpr, int ncbins) |
| 65 |
|
{ |
| 71 |
– |
if (ncbins <= 0) return NULL; |
| 66 |
|
if (!prms) prms = ""; |
| 67 |
|
if (!binexpr & (ncbins > 1)) { |
| 68 |
< |
error(INTERNAL, "missing bin expression"); |
| 68 |
> |
error(USER, "missing bin expression"); |
| 69 |
|
return NULL; |
| 70 |
|
} |
| 71 |
< |
if (ncbins == 1) { // shouldn't have bin expression? |
| 71 |
> |
if (ncbins <= 1) { // shouldn't have bin expression? |
| 72 |
|
if (binexpr && strcmp(binexpr, "0")) |
| 73 |
|
error(WARNING, "ignoring non-zero expression for single bin"); |
| 74 |
|
prms = ""; |
| 75 |
|
binexpr = NULL; |
| 76 |
+ |
ncbins = 1; |
| 77 |
|
} |
| 78 |
|
RcontribMod * mp = (RcontribMod *)ecalloc(1, sizeof(RcontribMod) + |
| 79 |
|
sizeof(DCOLORV)*(NCSAMP*ncbins-1) + |
| 143 |
|
|
| 144 |
|
int bi = 0; // get bin index |
| 145 |
|
if (mp->binv) { |
| 146 |
< |
worldfunc(RCCONTEXT, r); // compute bin # |
| 146 |
> |
worldfunc(RCCONTEXT, r); |
| 147 |
|
set_eparams(mp->params); |
| 148 |
|
double bval = evalue(mp->binv); |
| 149 |
|
if (bval <= -.5) |
| 158 |
|
} |
| 159 |
|
SCOLOR contr; |
| 160 |
|
raycontrib(contr, r, PRIMARY); // compute coefficient |
| 161 |
< |
if (contrib) |
| 161 |
> |
if (rcp->HasFlag(RCcontrib)) |
| 162 |
|
smultscolor(contr, r->rcol); // -> value contribution |
| 163 |
|
for (int i = 0; i < NCSAMP; i++) |
| 164 |
|
*dvp++ += contr[i]; // accumulate color/spectrum |
| 188 |
|
RcontribSimulManager::AddModifier(const char *modn, const char *outspec, |
| 189 |
|
const char *prms, const char *binval, int bincnt) |
| 190 |
|
{ |
| 191 |
< |
if (!modn | !outspec | (bincnt <= 0) || !*modn | !*outspec) { |
| 191 |
> |
if (!modn | !outspec || !*modn | !*outspec) { |
| 192 |
|
error(WARNING, "ignoring bad call to AddModifier()"); |
| 193 |
|
return false; |
| 194 |
|
} |
| 195 |
|
if (!nChan) { // initial call? |
| 196 |
+ |
if ((xres < 0) | (yres <= 0)) { |
| 197 |
+ |
error(USER, "xres, yres must be set before first modifier"); |
| 198 |
+ |
return false; |
| 199 |
+ |
} |
| 200 |
|
if (!SetDataFormat(dtyp)) |
| 201 |
|
return false; |
| 202 |
|
nChan = NCSAMP; |
| 203 |
|
} else if (nChan != NCSAMP) { |
| 204 |
< |
error(INTERNAL, "number of spectral channels must be fixed"); |
| 204 |
> |
error(USER, "number of spectral channels must be fixed"); |
| 205 |
|
return false; |
| 206 |
|
} |
| 207 |
|
if (Ready()) { |
| 224 |
|
const int binndx = hasFormat(outspec, "diouxX"); |
| 225 |
|
int bin0 = 0; |
| 226 |
|
char fnbuf[512]; |
| 227 |
< |
if (!modndx | (modndx > binndx)) |
| 227 |
> |
if (!modndx || (binndx > 0) & (modndx > binndx)) |
| 228 |
|
sprintf(fnbuf, outspec, bin0, modn); |
| 229 |
|
else |
| 230 |
|
sprintf(fnbuf, outspec, modn, bin0); |
| 253 |
|
mp->opl = op; // first (maybe only) output channel |
| 254 |
|
if (modndx) // remember modifier if part of name |
| 255 |
|
op->omod = lp->key; |
| 256 |
< |
if (binndx > 0) { // append output image/bin list |
| 256 |
> |
if (binndx) { // append output image/bin list |
| 257 |
|
op->rowBytes += dsiz; |
| 258 |
|
op->obin = bin0; |
| 259 |
|
for (bincnt = 1; bincnt < mp->nbins; bincnt++) { |
| 260 |
< |
if (!modndx | (modndx > binndx)) |
| 260 |
> |
if (!modndx || (binndx > 0) & (modndx > binndx)) |
| 261 |
|
sprintf(fnbuf, outspec, bin0+bincnt, modn); |
| 262 |
|
else |
| 263 |
|
sprintf(fnbuf, outspec, modn, bin0+bincnt); |
| 276 |
|
op->rowBytes += dsiz; |
| 277 |
|
} |
| 278 |
|
} else // else send all results to this channel |
| 279 |
< |
op->rowBytes += bincnt*dsiz; |
| 279 |
> |
op->rowBytes += mp->nbins*dsiz; |
| 280 |
|
return true; |
| 281 |
|
} |
| 282 |
|
|
| 323 |
|
error(INTERNAL, "PrepOutput() called before octree & modifiers assigned"); |
| 324 |
|
return -1; |
| 325 |
|
} |
| 326 |
+ |
if (!cdsF) { |
| 327 |
+ |
error(INTERNAL, "missing RdataShare constructor call (*cdsF)"); |
| 328 |
+ |
return -1; |
| 329 |
+ |
} |
| 330 |
|
if (lu_doall(&modLUT, checkModExists, NULL) < 0) |
| 331 |
|
return -1; |
| 332 |
|
|
| 391 |
|
strcpy(hdr+begData, ROWZEROSTR); |
| 392 |
|
rowCountPos = begData+LNROWSTR; |
| 393 |
|
begData += sizeof(ROWZEROSTR)-1; |
| 394 |
< |
if (!xres | (rowBytes > esiz)) { |
| 394 |
> |
if (!rcp->xres | (rowBytes > esiz)) { |
| 395 |
|
sprintf(hdr+begData, "NCOLS=%d\n", int(rowBytes/esiz)); |
| 396 |
|
begData += strlen(hdr+begData); |
| 397 |
|
} |
| 429 |
|
hdr[begData++] = ' '; |
| 430 |
|
hdr[begData++] = '\n'; // EOL for data format |
| 431 |
|
hdr[begData++] = '\n'; // end of nominal header |
| 432 |
< |
if ((xres > 0) & (rowBytes == esiz)) { // tack on resolution string? |
| 433 |
< |
sprintf(hdr+begData, PIXSTDFMT, yres, xres); |
| 432 |
> |
if ((rcp->xres > 0) & (rowBytes == esiz)) { // tack on resolution string? |
| 433 |
> |
sprintf(hdr+begData, PIXSTDFMT, rcp->yres, rcp->xres); |
| 434 |
|
begData += strlen(hdr+begData); |
| 435 |
|
} |
| 436 |
|
return rData->ReleaseMemory(hdr, RDSwrite); |
| 484 |
|
} |
| 485 |
|
// check #columns |
| 486 |
|
if (((cp = findArgs(hdr, "NCOLS=", begData)) && atoi(cp)*esiz != rowBytes) || |
| 487 |
< |
!xres | (rowBytes > esiz)) { |
| 487 |
> |
!rcp->xres | (rowBytes > esiz)) { |
| 488 |
|
sprintf(errmsg, "expected NCOLS=%d in '%s'", |
| 489 |
|
int(rowBytes/esiz), GetName()); |
| 490 |
|
error(USER, errmsg); |
| 499 |
|
rowCountPos = cp - hdr; |
| 500 |
|
int rlast = atoi(cp); |
| 501 |
|
begData++; // advance past closing EOL |
| 502 |
< |
if ((xres > 0) & (rowBytes == esiz)) { // check/skip resolution string? |
| 502 |
> |
if ((rcp->xres > 0) & (rowBytes == esiz)) { // check/skip resolution string? |
| 503 |
|
char rbuf[64]; |
| 504 |
< |
sprintf(rbuf, PIXSTDFMT, yres, xres); |
| 504 |
> |
sprintf(rbuf, PIXSTDFMT, rcp->yres, rcp->xres); |
| 505 |
|
int rlen = strlen(rbuf); |
| 506 |
|
if (strncmp(rbuf, hdr+begData, rlen)) { |
| 507 |
|
sprintf(errmsg, "bad resolution string in '%s'", GetName()); |
| 799 |
|
return 0; |
| 800 |
|
} |
| 801 |
|
if (nt < 0) |
| 802 |
< |
return nkids; |
| 802 |
> |
return NThreads(); |
| 803 |
|
if (!nt) nt = GetNCores(); |
| 804 |
|
int status = 0; |
| 805 |
|
if (nt == 1) |
| 812 |
|
sprintf(errmsg, "non-zero (%d) status from child", status); |
| 813 |
|
error(WARNING, errmsg); |
| 814 |
|
} |
| 815 |
< |
return nkids; |
| 815 |
> |
return NThreads(); |
| 816 |
|
} |