63 |
|
RcontribMod * |
64 |
|
NewRcMod(const char *prms, const char *binexpr, int ncbins) |
65 |
|
{ |
66 |
– |
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) + |
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(INTERNAL, "xres, yres must be set before first modifier"); |
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 |
|
|