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) |
76 |
|
RcontribMod * |
77 |
|
NewRcMod(const char *prms, const char *binexpr, int ncbins) |
78 |
|
{ |
66 |
– |
if (ncbins <= 0) return NULL; |
79 |
|
if (!prms) prms = ""; |
80 |
|
if (!binexpr & (ncbins > 1)) { |
81 |
< |
error(INTERNAL, "missing bin expression"); |
81 |
> |
error(USER, "missing bin expression"); |
82 |
|
return NULL; |
83 |
|
} |
84 |
< |
if (ncbins == 1) { // shouldn't have bin expression? |
84 |
> |
if (ncbins <= 1) { // shouldn't have bin expression? |
85 |
|
if (binexpr && strcmp(binexpr, "0")) |
86 |
|
error(WARNING, "ignoring non-zero expression for single bin"); |
87 |
|
prms = ""; |
88 |
|
binexpr = NULL; |
89 |
+ |
ncbins = 1; |
90 |
|
} |
91 |
|
RcontribMod * mp = (RcontribMod *)ecalloc(1, sizeof(RcontribMod) + |
92 |
|
sizeof(DCOLORV)*(NCSAMP*ncbins-1) + |
201 |
|
RcontribSimulManager::AddModifier(const char *modn, const char *outspec, |
202 |
|
const char *prms, const char *binval, int bincnt) |
203 |
|
{ |
204 |
< |
if (!modn | !outspec | (bincnt <= 0) || !*modn | !*outspec) { |
204 |
> |
if (!modn | !outspec || !*modn | !*outspec) { |
205 |
|
error(WARNING, "ignoring bad call to AddModifier()"); |
206 |
|
return false; |
207 |
|
} |
208 |
|
if (!nChan) { // initial call? |
209 |
|
if ((xres < 0) | (yres <= 0)) { |
210 |
< |
error(INTERNAL, "xres, yres must be set before first modifier"); |
210 |
> |
error(USER, "xres, yres must be set before first modifier"); |
211 |
|
return false; |
212 |
|
} |
213 |
|
if (!SetDataFormat(dtyp)) |
214 |
|
return false; |
215 |
|
nChan = NCSAMP; |
216 |
|
} else if (nChan != NCSAMP) { |
217 |
< |
error(INTERNAL, "number of spectral channels must be fixed"); |
217 |
> |
error(USER, "number of spectral channels must be fixed"); |
218 |
|
return false; |
219 |
|
} |
220 |
|
if (Ready()) { |
237 |
|
const int binndx = hasFormat(outspec, "diouxX"); |
238 |
|
int bin0 = 0; |
239 |
|
char fnbuf[512]; |
240 |
< |
if (!modndx | (modndx > binndx)) |
240 |
> |
if (!modndx || (binndx > 0) & (modndx > binndx)) |
241 |
|
sprintf(fnbuf, outspec, bin0, modn); |
242 |
|
else |
243 |
|
sprintf(fnbuf, outspec, modn, bin0); |
266 |
|
mp->opl = op; // first (maybe only) output channel |
267 |
|
if (modndx) // remember modifier if part of name |
268 |
|
op->omod = lp->key; |
269 |
< |
if (binndx > 0) { // append output image/bin list |
269 |
> |
if (binndx) { // append output image/bin list |
270 |
|
op->rowBytes += dsiz; |
271 |
|
op->obin = bin0; |
272 |
|
for (bincnt = 1; bincnt < mp->nbins; bincnt++) { |
273 |
< |
if (!modndx | (modndx > binndx)) |
273 |
> |
if (!modndx || (binndx > 0) & (modndx > binndx)) |
274 |
|
sprintf(fnbuf, outspec, bin0+bincnt, modn); |
275 |
|
else |
276 |
|
sprintf(fnbuf, outspec, modn, bin0+bincnt); |
289 |
|
op->rowBytes += dsiz; |
290 |
|
} |
291 |
|
} else // else send all results to this channel |
292 |
< |
op->rowBytes += bincnt*dsiz; |
292 |
> |
op->rowBytes += mp->nbins*dsiz; |
293 |
|
return true; |
294 |
|
} |
295 |
|
|