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.32 by greg, Sat Dec 28 18:05:14 2019 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 70 | Line 69 | static const char      RCSid[] = "$Id$";
69   *  Extensive comments added by Randolph Fritz May2018
70   */
71  
73 #include <stdio.h>
74 #include <string.h>
72   #include <math.h>
76 #include <sys/types.h>
73   #include <ctype.h>
74  
75   #include "rtio.h"
# Line 92 | Line 88 | static const char      RCSid[] = "$Id$";
88   /* Since 1991, LM-63 files have begun with the magic keyword IESNA */
89   #define MAGICID         "IESNA"
90   #define LMAGICID        5
91 + /* But newer files start with IESNA:LM-63- */
92 + #define MAGICID2        "IESNA:LM-63-"
93 + #define LMAGICID2       12
94   /* ies2rad supports the 1986, 1991, and 1995 versions of
95   * LM-63. FIRSTREV describes the first version; LASTREV describes the
96   * 1995 version. */
# Line 204 | Line 203 | int    filerev = FIRSTREV;
203   #define U_METERS        2
204  
205   /* string lengths */
206 < /* Maximum input line is 132 characters including CR LF at end. */
207 < #define MAXLINE         133
206 > /* Maximum input line is 256 characters including CR LF at end. */
207 > #define MAXLINE         257
208   #define RMAXWORD        76
209  
210   /* End of LM-63-related #defines */
# Line 725 | Line 724 | k_match(
724          char    *hdl            /* header line */
725   )
726   {
727 +        /* Skip leading spaces */
728 +        while (isspace(*hdl))
729 +                hdl++;
730          /* The line has to begin with '[' */
731          if (*hdl++ != '[')
732                  return(0);
# Line 840 | Line 842 | ies2rad(               /* convert IES file */
842                          continue;
843                  /* increment the header line count, and check for the
844                   * "TILT=" line that terminates the header */
845 <                if (!lineno++ && strncmp(buf, MAGICID, LMAGICID) == 0) {
846 <                        /* This code doesn't work for LM-63-95 and
847 <                         * LM-63-02 files and will instead default to
848 <                         * LM-63-86. */
849 <                        filerev = atoi(buf+LMAGICID);
845 >                if (!lineno++) {        /* first line may be magic */
846 >                        if (!strncmp(buf, MAGICID2, LMAGICID2))
847 >                                filerev = atoi(buf+LMAGICID2) - 1900;
848 >                        else if (!strncmp(buf, MAGICID, LMAGICID))
849 >                                filerev = atoi(buf+LMAGICID);
850                          if (filerev < FIRSTREV)
851                                  filerev = FIRSTREV;
852                          else if (filerev > LASTREV)
# Line 860 | Line 862 | ies2rad(               /* convert IES file */
862                   * in the "[LAMP]" and "[LAMPCAT]" keyword lines;
863                   * otherwise check all lines.  */
864                  if (lampcolor == NULL && checklamp(buf))
865 <                        lampcolor = matchlamp( buf[0] == '[' ?
865 >                        lampcolor = matchlamp(*sskip2(buf,0) == '[' ?
866                                                  keyargs(buf) : buf );
867                  /* Look for a materials and geometry file in the keywords. */
868                  if (keymatch(K_LMG, buf)) {
# Line 881 | Line 883 | ies2rad(               /* convert IES file */
883          } else if (lamptype == NULL)
884                  fprintf(outfp,"# CIE(x,y) = (%f,%f)\n# Depreciation = %.1f%%\n",
885                                  lampcolor[3], lampcolor[4], 100.*lampcolor[5]);
886 +
887          /* If the file ended before a "TILT=" line, that's an error. */
888          if (feof(inpfp)) {
889                  fprintf(stderr, "%s: not in IES format\n", inpname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines