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.44 by greg, Thu May 7 18:45:16 2020 UTC vs.
Revision 2.47 by greg, Fri Jan 22 16:19:15 2021 UTC

# Line 24 | Line 24 | rmx_alloc(int nr, int nc, int n)
24          if ((nr <= 0) | (nc <= 0) | (n <= 0))
25                  return(NULL);
26          dnew = (RMATRIX *)malloc(sizeof(RMATRIX)-sizeof(dnew->mtx) +
27 <                                        sizeof(dnew->mtx[0])*(n*nr*nc));
27 >                                        sizeof(dnew->mtx[0])*n*nr*nc);
28          if (!dnew)
29                  return(NULL);
30          dnew->nrows = nr; dnew->ncols = nc; dnew->ncomp = n;
# Line 203 | Line 203 | rmx_load_rgbe(RMATRIX *rm, FILE *fp)
203  
204   /* Load matrix from supported file type */
205   RMATRIX *
206 < rmx_load(const char *inspec)
206 > rmx_load(const char *inspec, RMPref rmp)
207   {
208 <        FILE            *fp = stdin;
208 >        FILE            *fp;
209          RMATRIX         dinfo;
210          RMATRIX         *dnew;
211  
212 <        if (!inspec) {                          /* reading from stdin? */
213 <                inspec = "<stdin>";
214 <                SET_FILE_BINARY(stdin);
212 >        if (!inspec)
213 >                inspec = stdin_name;
214 >        else if (!*inspec)
215 >                return(NULL);
216 >        if (inspec == stdin_name) {             /* reading from stdin? */
217 >                fp = stdin;
218          } else if (inspec[0] == '!') {
219                  if (!(fp = popen(inspec+1, "r")))
220                          return(NULL);
218                SET_FILE_BINARY(fp);
221          } else {
222                  const char      *sp = inspec;   /* check suffix */
223                  while (*sp)
# Line 223 | Line 225 | rmx_load(const char *inspec)
225                  while (sp > inspec && sp[-1] != '.')
226                          --sp;
227                  if (!strcasecmp(sp, "XML")) {   /* assume it's a BSDF */
228 <                        CMATRIX *cm = cm_loadBTDF((char *)inspec);
228 >                        CMATRIX *cm = rmp==RMPtrans ? cm_loadBTDF(inspec) :
229 >                                        cm_loadBRDF(inspec, rmp==RMPreflB) ;
230                          if (!cm)
231                                  return(NULL);
232                          dnew = rmx_from_cmatrix(cm);
# Line 232 | Line 235 | rmx_load(const char *inspec)
235                          return(dnew);
236                  }
237                                                  /* else open it ourselves */
238 <                if (!(fp = fopen(inspec, "rb")))
238 >                if (!(fp = fopen(inspec, "r")))
239                          return(NULL);
240          }
241 +        SET_FILE_BINARY(fp);
242   #ifdef getc_unlocked
243          flockfile(fp);
244   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines