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

Comparing ray/src/util/rmatrix.c (file contents):
Revision 2.67 by greg, Fri Dec 1 02:05:00 2023 UTC vs.
Revision 2.68 by greg, Sat Dec 2 16:28:35 2023 UTC

# Line 292 | Line 292 | rmx_load_header(RMATRIX *rm, FILE *fp)
292                  fputs("Unrecognized matrix format\n", stderr);
293                  return(0);
294          }
295 <                                                /* resolution string? */
296 <        if ((rm->nrows <= 0) | (rm->ncols <= 0)) {
297 <                if (!fscnresolu(&rm->ncols, &rm->nrows, fp))
298 <                        return(0);
299 <                if ((rm->dtype == DTrgbe) | (rm->dtype == DTxyze) &&
300 <                                rm->ncomp != 3)
301 <                        return(0);
302 <        }
303 <        if (rm->dtype == DTascii)               /* set input type (WINDOWS) */
295 >        if ((rm->dtype == DTrgbe) | (rm->dtype == DTxyze) &&
296 >                        rm->ncomp != 3)
297 >                return(0);
298 >        if (rm->ncols <= 0 &&                   /* resolution string? */
299 >                        !fscnresolu(&rm->ncols, &rm->nrows, fp))
300 >                return(0);
301 >        if (rm->dtype == DTascii)               /* set file type (WINDOWS) */
302                  SET_FILE_TEXT(fp);
303          else
304                  SET_FILE_BINARY(fp);
# Line 527 | Line 525 | findCIEprims(const char *info)
525   int
526   rmx_write_header(const RMATRIX *rm, int dtype, FILE *fp)
527   {
528 <        if (!rm | !fp || !rm->mtx)
528 >        if (!rm | !fp || !rm->mtx | (rm->ncols <= 0))
529                  return(0);
530          if (rm->info)
531                  fputs(rm->info, fp);
# Line 538 | Line 536 | rmx_write_header(const RMATRIX *rm, int dtype, FILE *f
536                  dtype = DTxyze;
537          else if ((dtype == DTxyze) & (rm->dtype == DTrgbe))
538                  dtype = DTrgbe;
539 +        if ((dtype == DTspec) & (rm->ncomp < 3))
540 +                return(0);
541  
542 <        if (dtype == DTascii)                   /* set output type (WINDOWS) */
542 >        if (dtype == DTascii)                   /* set file type (WINDOWS) */
543                  SET_FILE_TEXT(fp);
544          else
545                  SET_FILE_BINARY(fp);
# Line 549 | Line 549 | rmx_write_header(const RMATRIX *rm, int dtype, FILE *f
549                  fputcolcor(rm->cexp, fp);
550          else if (rm->cexp[GRN] != 1.f)
551                  fputexpos(rm->cexp[GRN], fp);
552 <        if ((dtype != DTrgbe) & (dtype != DTxyze)) {
553 <                if (dtype != DTspec) {
552 >                                                /* matrix size? */
553 >        if ((dtype > DTspec) | (rm->nrows <= 0)) {
554 >                if (rm->nrows > 0)
555                          fprintf(fp, "NROWS=%d\n", rm->nrows);
556 <                        fprintf(fp, "NCOLS=%d\n", rm->ncols);
557 <                } else if (rm->ncomp < 3)
558 <                        return(0);              /* bad # components */
556 >                fprintf(fp, "NCOLS=%d\n", rm->ncols);
557 >        }
558 >        if (dtype >= DTspec) {                  /* # components & split? */
559                  fputncomp(rm->ncomp, fp);
560                  if (dtype == DTspec || (rm->ncomp > 3 &&
561                                  memcmp(rm->wlpart, WLPART, sizeof(WLPART))))
# Line 565 | Line 566 | rmx_write_header(const RMATRIX *rm, int dtype, FILE *f
566                  fputendian(fp);                 /* important to record */
567          fputformat(cm_fmt_id[dtype], fp);
568          fputc('\n', fp);                        /* end of header */
569 <        if (dtype <= DTspec)
569 >        if ((dtype <= DTspec) & (rm->nrows > 0))
570                  fprtresolu(rm->ncols, rm->nrows, fp);
571          return(dtype);
572   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines