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

Comparing ray/src/util/wrapBSDF.c (file contents):
Revision 2.15 by greg, Fri May 29 07:16:49 2015 UTC vs.
Revision 2.18 by greg, Tue Feb 2 22:34:00 2016 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9  
10   #include <ctype.h>
11   #include "rtio.h"
12 < #include "rtprocess.h"
12 > #include "paths.h"
13   #include "ezxml.h"
14   #include "bsdf.h"
15   #include "bsdf_m.h"
# Line 25 | Line 25 | const char     *attr_unit = "meter";
25   const char      legal_units[] = "meter|foot|inch|centimeter|millimeter";
26                                          /* system materials & geometry */
27   const char      *mgf_geometry = NULL;
28 <
28 >                                        /* comment list */
29 > #define MAXCOMM         30
30 > const char      *commlist[MAXCOMM];
31 > int             ncomm = 0;
32                                          /* angle bases */
33   enum { ABdefault=-1, ABklemsFull=0, ABklemsHalf, ABklemsQuarter,
34                  ABtensorTree3, ABtensorTree4, ABend };
# Line 79 | Line 82 | struct s_dfile {
82  
83   int             ndataf = 0;             /* number of data files */
84  
85 + int             unlink_datafiles = 0;   /* unlink data files when done */
86 +
87   const char      *spectr_file[MAXFILES]; /* custom spectral curve input */
88  
89   const char      top_level_name[] = "WindowElement";
# Line 586 | Line 591 | writeBSDF(const char *caller, ezxml_t fl)
591                  return 0;
592          }
593          puts("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
594 +        for (i = 0; i < ncomm; i++)
595 +                printf("<!-- %s -->\n", commlist[i]);
596          fflush(stdout);                         /* write previous XML info. */
597          if (write(fileno(stdout), xml, ei) != ei) {
598                  free(xml);
# Line 599 | Line 606 | writeBSDF(const char *caller, ezxml_t fl)
606          fputs(xml+ei, stdout);                  /* write trailer */
607          free(xml);                              /* free string */
608          fputc('\n', stdout);
609 <        return (fflush(stdout) == 0);
609 >        if (fflush(stdout) != 0)
610 >                return 0;
611 >                                                /* unlink data files if req. */
612 >        for (i = ndataf*(unlink_datafiles != 0); i--; )
613 >                if (data_file[i].fname != stdin_name &&
614 >                                data_file[i].fname[0] != '!')
615 >                        unlink(data_file[i].fname);
616 >        return 1;
617   }
618  
619   /* Insert BSDF data into XML wrapper */
# Line 718 | Line 732 | UsageExit(const char *pname)
732          fputs("Usage: ", stderr);
733          fputs(pname, stderr);
734          fputs(" [-W][-c][-a {kf|kh|kq|t3|t4}][-u unit][-g geom][-f 'x=string;y=string']", stderr);
735 <        fputs(" [-s spectr][-tb inp][-tf inp][-rb inp][-rf inp]", stderr);
735 >        fputs(" [-s spectr][-tb inp][-tf inp][-rb inp][-rf inp][-C comm]", stderr);
736          fputs(" [input.xml]\n", stderr);
737          exit(1);
738   }
# Line 763 | Line 777 | main(int argc, char *argv[])
777                          }
778                          attr_unit = argv[i];
779                          continue;
780 +                case 'U':               /* unlink data files when done */
781 +                        unlink_datafiles = 1;
782 +                        continue;
783                  case 'a':               /* angle basis */
784                          if (++i >= argc)
785                                  UsageExit(argv[0]);
# Line 786 | Line 803 | main(int argc, char *argv[])
803                          continue;
804                  case 'c':               /* correct solid angle */
805                          correct_solid_angle = 1;
806 +                        continue;
807 +                case 'C':               /* comment */
808 +                        if (ncomm >= MAXCOMM) {
809 +                                fprintf(stderr, "%s: too many comments\n",
810 +                                                argv[0]);
811 +                                return 1;
812 +                        }
813 +                        if (strchr(argv[++i], '>') != NULL) {
814 +                                fprintf(stderr, "%s: illegal character in comment\n",
815 +                                                argv[0]);
816 +                                return 1;
817 +                        }
818 +                        commlist[ncomm++] = argv[i];
819                          continue;
820                  case 't':               /* transmission */
821                          if (i >= argc-1)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines