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.72 by greg, Tue Dec 5 21:45:39 2023 UTC vs.
Revision 2.74 by greg, Fri Dec 8 00:12:31 2023 UTC

# Line 539 | Line 539 | rmx_write_header(const RMATRIX *rm, int dtype, FILE *f
539                  dtype = DTxyze;
540          else if ((dtype == DTxyze) & (rm->dtype == DTrgbe))
541                  dtype = DTrgbe;
542 <        if ((dtype == DTspec) & (rm->ncomp < 3))
542 >        if ((dtype == DTspec) & (rm->ncomp <= 3))
543                  return(0);
544  
545          if (dtype == DTascii)                   /* set file type (WINDOWS) */
# Line 560 | Line 560 | rmx_write_header(const RMATRIX *rm, int dtype, FILE *f
560          }
561          if (dtype >= DTspec) {                  /* # components & split? */
562                  fputncomp(rm->ncomp, fp);
563 <                if (dtype == DTspec || (rm->ncomp > 3 &&
564 <                                memcmp(rm->wlpart, WLPART, sizeof(WLPART))))
563 >                if (rm->ncomp > 3 &&
564 >                                memcmp(rm->wlpart, WLPART, sizeof(WLPART)))
565                          fputwlsplit(rm->wlpart, fp);
566          } else if ((rm->ncomp != 3) & (rm->ncomp != 1))
567                  return(0);                      /* wrong # components */
# Line 666 | Line 666 | rmx_copy(const RMATRIX *rm)
666          copycolor(dnew->cexp, rm->cexp);
667          memcpy(dnew->wlpart, rm->wlpart, sizeof(dnew->wlpart));
668          return(dnew);
669 + }
670 +
671 + /* Replace data in first matrix with data from second */
672 + int
673 + rmx_transfer_data(RMATRIX *rdst, RMATRIX *rsrc, int dometa)
674 + {
675 +        if (!rdst | !rsrc || (rdst->nrows != rsrc->nrows) |
676 +                        (rdst->ncols != rsrc->ncols) |
677 +                        (rdst->ncomp != rsrc->ncomp))
678 +                return(0);
679 +
680 +        if (dometa) {           /* transfer everything? */
681 +                rmx_reset(rdst);
682 +                *rdst = *rsrc;
683 +                rsrc->info = NULL; rsrc->mapped = NULL; rsrc->mtx = NULL;
684 +                return(1);
685 +        }
686 +        if (rdst->mapped)
687 +                return(0);      /* XXX can't handle this case */
688 +                                /* just matrix data -- leave metadata */
689 +        if (rdst->mtx) free(rdst->mtx);
690 +        rdst->mtx = rsrc->mtx;
691 +        rsrc->mtx = NULL;
692 +        return(1);
693   }
694  
695   /* Allocate and assign transposed matrix */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines