ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/RcontribSimulManager.cpp
(Generate patch)

Comparing ray/src/rt/RcontribSimulManager.cpp (file contents):
Revision 2.7 by greg, Wed Nov 6 19:45:59 2024 UTC vs.
Revision 2.9 by greg, Tue Dec 3 17:39:42 2024 UTC

# Line 52 | Line 52 | struct RowAssignment {
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)
# Line 63 | Line 76 | defDataShare(const char *name, RCOutputOp op, size_t s
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) +
# Line 188 | Line 201 | bool
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()) {
# Line 224 | Line 237 | RcontribSimulManager::AddModifier(const char *modn, co
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);
# Line 253 | Line 266 | RcontribSimulManager::AddModifier(const char *modn, co
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);
# Line 276 | Line 289 | RcontribSimulManager::AddModifier(const char *modn, co
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines