ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rcomb.c
(Generate patch)

Comparing ray/src/util/rcomb.c (file contents):
Revision 2.1 by greg, Tue Dec 12 16:31:45 2023 UTC vs.
Revision 2.2 by greg, Mon Dec 18 23:04:05 2023 UTC

# Line 45 | Line 45 | int            nmats = 0;                      /* number of actual inputs */
45   RMATRIX         *mcat = NULL;                   /* final concatenation */
46   int             mcat_last = 0;                  /* goes after trailing ops? */
47  
48 < int             in_nrows;                       /* input row count */
49 < #define in_ncols        (mop[0].rmp->ncols)     /* input column count */
48 > int             in_nrows;                       /* number of input rows (or 0) */
49 > #define in_ncols        (mop[0].rmp->ncols)     /* number of input columns */
50   #define in_ncomp        (mop[0].rmp->ncomp)     /* input #components */
51  
52   extern int      nowarn;                         /* turn off warnings? */
# Line 469 | Line 469 | initialize(RMATRIX *imp)
469                          fprintf(stderr, "%s: warning - data type mismatch\n",
470                                          mop[i].inspec);
471                  if (!i) {
472                        imp->nrows = in_nrows = mop[0].rmp->nrows;
472                          imp->ncols = mop[0].rmp->ncols;
473                          imp->ncomp = mop[0].rmp->ncomp;
474                          memcpy(imp->wlpart, mop[0].rmp->wlpart, sizeof(imp->wlpart));
475 <                } else if ((mop[i].rmp->nrows != imp->nrows) |
476 <                                (mop[i].rmp->ncols != imp->ncols) |
477 <                                (mop[i].rmp->ncomp != imp->ncomp)) {
475 >                } else if ((mop[i].rmp->ncols != imp->ncols) |
476 >                                (mop[i].rmp->ncomp != imp->ncomp) |
477 >                                ((in_nrows > 0) & (mop[i].rmp->nrows > 0) &
478 >                                        (mop[i].rmp->nrows != in_nrows))) {
479                          fprintf(stderr, "%s: mismatch in size or #components\n",
480                                          mop[i].inspec);
481                          return(0);
482                  }                       /* XXX should check wlpart? */
483 +                if (in_nrows <= 0)
484 +                        in_nrows = imp->nrows = mop[i].rmp->nrows;
485          }                               /* set up .cal environment */
486          esupport |= E_VARIABLE|E_FUNCTION|E_RCONST;
487          esupport &= ~(E_OUTCHAN|E_INCHAN);
# Line 569 | Line 571 | combine_input(ROPMAT *res, FILE *fout)
571          } else                          /* save a little time */
572                  set_r = set_c = 0;
573                                          /* read/process row-by-row */
574 <        for (cur_row = 0; cur_row < in_nrows; cur_row++) {
574 >        for (cur_row = 0; (in_nrows <= 0) | (cur_row < in_nrows); cur_row++) {
575              RMATRIX     *mres = NULL;
576              for (i = 0; i < nmats; i++) {
577                  if (!rmx_load_row(mop[i].imx.mtx, &mop[i].imx, mop[i].infp)) {
578 +                        if (in_nrows <= 0)      /* normal end? */
579 +                                goto loop_exit;
580                          fprintf(stderr, "%s: read error at row %d\n",
581                                          mop[i].inspec, cur_row);
582                          return(0);
# Line 620 | Line 624 | combine_input(ROPMAT *res, FILE *fout)
624                                  res->rmp->ncols, res->rmp->dtype, fout))
625                  return(0);
626          }
627 + loop_exit:
628   #if 0           /* we're about to exit, so who cares? */
629          rmx_free(tmp);                  /* clean up */
630          rmx_reset(res->rmp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines