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

Comparing ray/src/cv/pkgBSDF.c (file contents):
Revision 2.2 by greg, Thu Aug 25 04:32:29 2011 UTC vs.
Revision 2.9 by greg, Sun Dec 8 18:33:23 2024 UTC

# Line 12 | Line 12 | static const char RCSid[] = "$Id$";
12   int     do_stdout = 0;                  /* send Radiance object to stdout? */
13   int     do_instance = 0;                /* produce instance/octree pairs? */
14  
15 + char    *progname;                      /* global argv[0] */
16  
17   /* Return appropriate suffix for Z offset */
18   static const char *
# Line 53 | Line 54 | geomBSDF(const SDData *bsp)
54          char    command[SDnameLn+64];
55          int     fd;
56                                          /* write MGF to temp file */
57 <        fd = open(mktemp(strcpy(tmpfile,TEMPLATE)), O_WRONLY|O_CREAT|O_EXCL);
57 >        fd = open(mktemp(strcpy(tmpfile,TEMPLATE)), O_WRONLY|O_CREAT|O_EXCL, 0600);
58          if (fd < 0) {
59                  fprintf(stderr, "Cannot open temp file '%s'\n", tmpfile);
60                  return(0);
61          }
62 <        write(fd, bsp->mgf, strlen(bsp->mgf));
62 >        (void)write(fd, bsp->mgf, strlen(bsp->mgf));
63          close(fd);
64                                          /* set up command */
65          if (do_instance) {
66 <                sprintf(command, "mgf2rad %s | oconv -f - > %s.oct",
66 >                sprintf(command, "mgf2rad -s %s | oconv -f - > %s.oct",
67                                          tmpfile, bsp->name);
68          } else {
69                  fflush(stdout);
70 <                sprintf(command, "mgf2rad %s", tmpfile);
70 >                sprintf(command, "mgf2rad -s %s", tmpfile);
71          }
72          if (system(command)) {
73                  fprintf(stderr, "Error running: %s\n", command);
# Line 87 | Line 88 | cvtBSDF(char *fname)
88   {
89          int     retOK;
90          SDData  myBSDF;
91 <        char    *pname;
91 >        char    *pname, *fnbeg;
92                                          /* find and load the XML file */
93          retOK = strlen(fname);
94 <        if (retOK < 5 || strcmp(fname+retOK-4, ".xml")) {
94 >        if (retOK < 5 || strcasecmp(fname+retOK-4, ".xml")) {
95                  fprintf(stderr, "%s: input does not end in '.xml'\n", fname);
96                  return(0);
97          }
# Line 99 | Line 100 | cvtBSDF(char *fname)
100                  fprintf(stderr, "%s: cannot find BSDF file\n", fname);
101                  return(0);
102          }
103 +        fnbeg = strrchr(fname, DIRSEP);
104 +        if (fnbeg != NULL)              /* eliminate directory */
105 +                fname = fnbeg+1;
106          SDclearBSDF(&myBSDF, fname);
107 <        if (SDreportEnglish(SDloadFile(&myBSDF, pname), stderr))
107 >        if (SDreportError(SDloadFile(&myBSDF, pname), stderr))
108                  return(0);
109          retOK = (myBSDF.dim[0] > FTINY) & (myBSDF.dim[1] > FTINY);
110          if (!retOK) {
# Line 113 | Line 117 | cvtBSDF(char *fname)
117                          retOK = (freopen(rname, "w", stdout) != NULL);
118                  }
119                  if (retOK) {
120 +                        printf("# Produced by: %s %s\n", progname, fname);
121 +                        if (myBSDF.matn[0] && myBSDF.makr[0])
122 +                                printf("# Material '%s' by '%s'\n\n",
123 +                                                myBSDF.matn, myBSDF.makr);
124                          if (myBSDF.mgf == NULL) {
125                                  faceBSDF(&myBSDF, .0);
126                          } else {
# Line 134 | Line 142 | main(int argc, char *argv[])
142   {
143          int     status = 0;
144          int     i;
145 +
146 +        progname = argv[0];
147  
148          for (i = 1; i < argc && argv[i][0] == '-'; i++)
149                  switch (argv[i][1]) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines