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.12 by greg, Wed Mar 4 17:42:54 2015 UTC vs.
Revision 2.19 by greg, Wed Feb 3 00:22:55 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 445 | Line 450 | writeBSDFblock(const char *caller, struct s_dfile *df)
450                  break;
451          case DSxbar31:
452                  puts("\t\t<Wavelength unit=\"Integral\">CIE-X</Wavelength>");
453 <                puts("\t\tSourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
453 >                puts("\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
454                  puts("\t\t<DetectorSpectrum>ASTM E308 1931 X.dsp</DetectorSpectrum>");
455                  break;
456          case DSzbar31:
457                  puts("\t\t<Wavelength unit=\"Integral\">CIE-Z</Wavelength>");
458 <                puts("\t\tSourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
458 >                puts("\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
459                  puts("\t\t<DetectorSpectrum>ASTM E308 1931 Z.dsp</DetectorSpectrum>");
460                  break;
461          case DSuprime:
462 <                puts("\t\t<Wavelength unit=\"Integral\">CIE-Z</Wavelength>");
463 <                puts("\t\tSourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
459 <                puts("\t\t<DetectorSpectrum>ASTM E308 1931 u.dsp</DetectorSpectrum>");
462 >                puts("\t\t<Wavelength unit=\"Integral\">CIE-u</Wavelength>");
463 >                puts("\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
464                  break;
465          case DSvprime:
466 <                puts("\t\t<Wavelength unit=\"Integral\">CIE-Z</Wavelength>");
467 <                puts("\t\tSourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
464 <                puts("\t\t<DetectorSpectrum>ASTM E308 1931 v.dsp</DetectorSpectrum>");
466 >                puts("\t\t<Wavelength unit=\"Integral\">CIE-v</Wavelength>");
467 >                puts("\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
468                  break;
469          case DSsolar:
470                  puts("\t\t<Wavelength unit=\"Integral\">Solar</Wavelength>");
471 <                puts("\t\tSourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
471 >                puts("\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
472                  puts("\t\t<DetectorSpectrum>None</DetectorSpectrum>");
473                  break;
474          case DSnir:
475                  puts("\t\t<Wavelength unit=\"Integral\">NIR</Wavelength>");
476 <                puts("\t\tSourceSpectrum>PLACE_HOLDER</SourceSpectrum>");
476 >                puts("\t\t<SourceSpectrum>PLACE_HOLDER</SourceSpectrum>");
477                  puts("\t\t<DetectorSpectrum>PLACE_HOLDER</DetectorSpectrum>");
478                  break;
479          default:
# Line 481 | Line 484 | writeBSDFblock(const char *caller, struct s_dfile *df)
484                                  spectr_file[df->spectrum]);
485                  if (cp != NULL)
486                          *cp = '.';
487 <                puts("\t\tSourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
487 >                puts("\t\t<SourceSpectrum>CIE Illuminant D65 1nm.ssp</SourceSpectrum>");
488                  printf("\t\t<DetectorSpectrum>%s</DetectorSpectrum>\n",
489                                  spectr_file[df->spectrum]);
490                  break;
# Line 587 | Line 590 | writeBSDF(const char *caller, ezxml_t fl)
590                  free(xml);
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 600 | 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 >        if (unlink_datafiles > 1 && mgf_geometry != NULL &&
617 >                        mgf_geometry != stdin_name &&
618 >                        mgf_geometry[0] != '!')
619 >                unlink(mgf_geometry);
620 >        return 1;
621   }
622  
623   /* Insert BSDF data into XML wrapper */
# Line 719 | Line 736 | UsageExit(const char *pname)
736          fputs("Usage: ", stderr);
737          fputs(pname, stderr);
738          fputs(" [-W][-c][-a {kf|kh|kq|t3|t4}][-u unit][-g geom][-f 'x=string;y=string']", stderr);
739 <        fputs(" [-s spectr][-tb inp][-tf inp][-rb inp][-rf inp]", stderr);
739 >        fputs(" [-s spectr][-tb inp][-tf inp][-rb inp][-rf inp][-C comm]", stderr);
740          fputs(" [input.xml]\n", stderr);
741          exit(1);
742   }
# Line 764 | Line 781 | main(int argc, char *argv[])
781                          }
782                          attr_unit = argv[i];
783                          continue;
784 +                case 'U':               /* unlink data files when done */
785 +                        unlink_datafiles = 1 + (argv[i][2] == 'U');
786 +                        continue;
787                  case 'a':               /* angle basis */
788                          if (++i >= argc)
789                                  UsageExit(argv[0]);
# Line 787 | Line 807 | main(int argc, char *argv[])
807                          continue;
808                  case 'c':               /* correct solid angle */
809                          correct_solid_angle = 1;
810 +                        continue;
811 +                case 'C':               /* comment */
812 +                        if (ncomm >= MAXCOMM) {
813 +                                fprintf(stderr, "%s: too many comments\n",
814 +                                                argv[0]);
815 +                                return 1;
816 +                        }
817 +                        if (strchr(argv[++i], '>') != NULL) {
818 +                                fprintf(stderr, "%s: illegal character in comment\n",
819 +                                                argv[0]);
820 +                                return 1;
821 +                        }
822 +                        commlist[ncomm++] = argv[i];
823                          continue;
824                  case 't':               /* transmission */
825                          if (i >= argc-1)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines