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

Comparing ray/src/util/rmtxop.c (file contents):
Revision 2.35 by greg, Fri Nov 8 17:52:26 2024 UTC vs.
Revision 2.42 by greg, Sat Apr 19 03:58:00 2025 UTC

# Line 10 | Line 10 | static const char RCSid[] = "$Id$";
10   #include "rmatrix.h"
11   #include "platform.h"
12  
13 < #define MAXCOMP         MAXCSAMP        /* #components we support */
13 > /* Preferred BSDF component:
14 >        none, transmission, reflection front (normal side), reflection back */
15 > typedef enum {RMPnone=-1, RMPtrans=0, RMPreflF, RMPreflB} RMPref;
16  
17   /* Unary matrix operation(s) */
18   typedef struct {
# Line 37 | Line 39 | int    verbose = 0;                    /* verbose reporting? */
39   int
40   loadmatrix(ROPMAT *rop)
41   {
42 <        if (rop->mtx != NULL)           /* already loaded? */
42 >        if (rop->mtx)                   /* already loaded? */
43                  return(0);
44 +                                        /* check for BSDF input */
45 +        if ((rop->inspec[0] != '!') & (rop->rmp != RMPnone)) {
46 +                const char      *sp = strrchr(rop->inspec, '.');
47 +                if (sp > rop->inspec && !strcasecmp(sp+1, "XML")) {
48 +                        CMATRIX *cm = rop->rmp==RMPtrans ? cm_loadBTDF(rop->inspec) :
49 +                                        cm_loadBRDF(rop->inspec, rop->rmp==RMPreflB) ;
50 +                        if (!cm)
51 +                                return(-1);
52 +                        rop->mtx = rmx_from_cmatrix(cm);
53 +                        cm_free(cm);
54 +                        if (!rop->mtx)
55 +                                return(-1);
56 +                        rop->mtx->dtype = DTascii;
57 +                        return(1);      /* loaded BSDF XML file */
58 +                }
59 +        }                               /* else load regular matrix */
60 +        rop->mtx = rmx_load(rop->inspec);
61  
62 <        rop->mtx = rmx_load(rop->inspec, rop->rmp);
44 <
45 <        return(!rop->mtx ? -1 : 1);
62 >        return(rop->mtx ? 1 : -1);
63   }
64  
65   extern int      checksymbolic(ROPMAT *rop);
# Line 343 | Line 360 | loadop(ROPMAT *rop)
360                  }
361          }
362          if (rop->preop.transpose) {             /* transpose matrix? */
363 <                mres = rmx_transpose(rop->mtx);
347 <                if (mres == NULL) {
363 >                if (!rmx_transpose(rop->mtx)) {
364                          fputs(rop->inspec, stderr);
365                          fputs(": transpose failed\n", stderr);
366                          goto failure;
# Line 353 | Line 369 | loadop(ROPMAT *rop)
369                          fputs(rop->inspec, stderr);
370                          fputs(": transposed rows and columns\n", stderr);
371                  }
356                rmx_free(rop->mtx);
357                rop->mtx = mres;
372          }
373          mres = rop->mtx;
374          rop->mtx = NULL;
# Line 681 | Line 695 | main(int argc, char *argv[])
695          mres = loadop(mop+nmats);
696          if (mres == NULL)
697                  return(1);
698 <        if (outfmt == DTfromHeader)     /* check data type */
698 >        if ((outfmt == DTfromHeader) & (mres->dtype < DTspec))
699                  outfmt = mres->dtype;
700 <        if (outfmt == DTrgbe) {
700 >        if (outfmt == DTrgbe) {         /* check data type */
701                  if (mres->ncomp > 3)
702                          outfmt = DTspec;
703                  else if (mres->dtype == DTxyze)
704                          outfmt = DTxyze;
705          }
706 + #if DTrmx_native==DTfloat
707 +        if (outfmt == DTdouble)
708 +                fprintf(stderr,
709 +                        "%s: warning - writing float result as double\n",
710 +                                argv[0]);
711 + #endif
712          newheader("RADIANCE", stdout);  /* write result to stdout */
713          printargs(argc, argv, stdout);
714          return(rmx_write(mres, outfmt, stdout) ? 0 : 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines