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

Comparing ray/src/cv/ies2rad.c (file contents):
Revision 2.29 by greg, Mon Jun 4 18:53:09 2018 UTC vs.
Revision 2.31 by greg, Tue Jun 5 16:04:00 2018 UTC

# Line 20 | Line 20 | static const char      RCSid[] = "$Id$";
20   * Radiance (θ,φ) luminaire coordinates and then apply photometric and
21   * tilt data to generate Radiance light. θ is altitude from the
22   * negative z-axis and φ is azimuth from the positive x-axis,
23 < * increasing towards the positive y-axis. [??? Greg, is there a
24 < * source for this convention?] This system matches none of the usual
25 < * goniophotometric conventions, but it is closest to IES type C; V in
26 < * type C photometry is θ in Radiance and L is -φ.
23 > * increasing towards the positive y-axis. This system matches none of
24 > * the usual goniophotometric conventions, but it is closest to IES
25 > * type C; V in type C photometry is θ in Radiance and L is -φ.
26   *
27   * The ies2rad scene description for a luminaire LUM, with tilt data,
28   * uses the following Radiance scene description primitives:
# Line 92 | Line 91 | static const char      RCSid[] = "$Id$";
91   /* Since 1991, LM-63 files have begun with the magic keyword IESNA */
92   #define MAGICID         "IESNA"
93   #define LMAGICID        5
94 + /* But newer files start with IESNA:LM-63- */
95 + #define MAGICID2        "IESNA:LM-63-"
96 + #define LMAGICID2       12
97   /* ies2rad supports the 1986, 1991, and 1995 versions of
98   * LM-63. FIRSTREV describes the first version; LASTREV describes the
99   * 1995 version. */
# Line 204 | Line 206 | int    filerev = FIRSTREV;
206   #define U_METERS        2
207  
208   /* string lengths */
209 < /* Maximum input line is 132 characters including CR LF at end. */
210 < #define MAXLINE         133
209 > /* Maximum input line is 256 characters including CR LF at end. */
210 > #define MAXLINE         257
211   #define RMAXWORD        76
212  
213   /* End of LM-63-related #defines */
# Line 725 | Line 727 | k_match(
727          char    *hdl            /* header line */
728   )
729   {
730 +        /* Skip leading spaces */
731 +        while (isspace(*hdl))
732 +                hdl++;
733          /* The line has to begin with '[' */
734          if (*hdl++ != '[')
735                  return(0);
# Line 840 | Line 845 | ies2rad(               /* convert IES file */
845                          continue;
846                  /* increment the header line count, and check for the
847                   * "TILT=" line that terminates the header */
848 <                if (!lineno++ && strncmp(buf, MAGICID, LMAGICID) == 0) {
849 <                        /* This code doesn't work for LM-63-95 and
850 <                         * LM-63-02 files and will instead default to
851 <                         * LM-63-86. */
852 <                        filerev = atoi(buf+LMAGICID);
848 >                if (!lineno++) {        /* first line may be magic */
849 >                        if (!strncmp(buf, MAGICID2, LMAGICID2))
850 >                                filerev = atoi(buf+LMAGICID2) - 1900;
851 >                        else if (!strncmp(buf, MAGICID, LMAGICID))
852 >                                filerev = atoi(buf+LMAGICID);
853                          if (filerev < FIRSTREV)
854                                  filerev = FIRSTREV;
855                          else if (filerev > LASTREV)
# Line 860 | Line 865 | ies2rad(               /* convert IES file */
865                   * in the "[LAMP]" and "[LAMPCAT]" keyword lines;
866                   * otherwise check all lines.  */
867                  if (lampcolor == NULL && checklamp(buf))
868 <                        lampcolor = matchlamp( buf[0] == '[' ?
868 >                        lampcolor = matchlamp(*sskip2(buf,0) == '[' ?
869                                                  keyargs(buf) : buf );
870                  /* Look for a materials and geometry file in the keywords. */
871                  if (keymatch(K_LMG, buf)) {
# Line 881 | Line 886 | ies2rad(               /* convert IES file */
886          } else if (lamptype == NULL)
887                  fprintf(outfp,"# CIE(x,y) = (%f,%f)\n# Depreciation = %.1f%%\n",
888                                  lampcolor[3], lampcolor[4], 100.*lampcolor[5]);
889 +
890          /* If the file ended before a "TILT=" line, that's an error. */
891          if (feof(inpfp)) {
892                  fprintf(stderr, "%s: not in IES format\n", inpname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines