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 1.1 by greg, Tue Dec 11 08:45:48 1990 UTC vs.
Revision 1.3 by greg, Tue Jan 29 12:19:10 1991 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include <stdio.h>
14   #include <ctype.h>
15 + #include "color.h"
16  
17   #define PI              3.14159265358979323846
18                                          /* floating comparisons */
# Line 50 | Line 51 | static char SCCSid[] = "$SunId$ LBL";
51  
52   #define abspath(p)      ((p)[0] == '/' || (p)[0] == '.')
53  
54 + static char     default_name[] = "default";
55 +
56   char    *libdir = NULL;                 /* library directory location */
57   char    *prefdir = NULL;                /* subdirectory */
58   char    *lampdat = "lamp.tab";          /* lamp data file */
59  
60   double  meters2out = 1.0;               /* conversion from meters to output */
61   char    *lamptype = NULL;               /* selected lamp type */
62 < float   *lampcolor = NULL;              /* pointer to lamp color */
62 > char    *deflamp = NULL;                /* default lamp type */
63   float   defcolor[3] = {1.,1.,1.};       /* default lamp color */
64 + float   *lampcolor = defcolor;          /* pointer to current lamp color */
65   double  multiplier = 1.0;               /* multiplier for all light sources */
66   char    units[64] = "meters";           /* output units */
67   double  minaspect = 0.0;                /* minimum allowed aspect ratio */
# Line 67 | Line 71 | double illumrad = 0.0;                 /* radius for illum sphere */
71   typedef struct {
72          int     type;                           /* RECT, DISK, SPHERE */
73          double  w, l, h;                        /* width, length, height */
74 <        double  area;                           /* effective radiating area */
74 >        double  area;                           /* max. projected area */
75   } SHAPE;                                /* a source shape */
76  
77   int     gargc;                          /* global argc (minus filenames) */
# Line 166 | Line 170 | char   *argv[];
170                          if (illumrad < MINDIM)
171                                  illumrad = MINDIM;
172                          break;
173 <                case 't':               /* select lamp type */
173 >                case 't':               /* override lamp type */
174                          lamptype = argv[++i];
175                          break;
176 +                case 'u':               /* default lamp type */
177 +                        deflamp = argv[++i];
178 +                        break;
179                  case 'c':               /* default lamp color */
180                          defcolor[0] = atof(argv[++i]);
181                          defcolor[1] = atof(argv[++i]);
# Line 185 | Line 192 | char   *argv[];
192                  }
193          gargc = i;
194          gargv = argv;
195 <                                        /* get lamp data */
189 <        if ((status = loadlamps(lampdat)) < 0)
190 <                exit(1);
191 <        if (status == 0 || (lamptype != NULL &&
192 <                        (lampcolor = matchlamp(lamptype)) == NULL)) {
193 <                lampcolor = defcolor;
194 <                fprintf(stderr, "%s: warning - no lamp data\n", argv[0]);
195 <        }
195 >        initlamps();                    /* get lamp data (if needed) */
196                                          /* convert ies file(s) */
197          if (outfile != NULL) {
198                  if (i == argc)
# Line 219 | Line 219 | char   *argv[];
219   }
220  
221  
222 + initlamps()                             /* set up lamps */
223 + {
224 +        float   *lcol;
225 +        int     status;
226 +
227 +        if (lamptype != NULL && !strcmp(lamptype, default_name) &&
228 +                        deflamp == NULL)
229 +                return;                         /* no need for data */
230 +                                                /* else load file */
231 +        if ((status = loadlamps(lampdat)) < 0)
232 +                exit(1);
233 +        if (status == 0) {
234 +                fprintf(stderr, "%s: warning - no lamp data\n", lampdat);
235 +                lamptype = default_name;
236 +                return;
237 +        }
238 +        if (deflamp != NULL) {                  /* match default type */
239 +                if ((lcol = matchlamp(deflamp)) == NULL)
240 +                        fprintf(stderr,
241 +                                "%s: warning - unknown default lamp type\n",
242 +                                        deflamp);
243 +                else
244 +                        copycolor(defcolor, lcol);
245 +        }
246 +        if (lamptype != NULL) {                 /* match selected type */
247 +                if (strcmp(lamptype, default_name)) {
248 +                        if ((lcol = matchlamp(lamptype)) == NULL) {
249 +                                fprintf(stderr,
250 +                                        "%s: warning - unknown lamp type\n",
251 +                                                lamptype);
252 +                                lamptype = default_name;
253 +                        } else
254 +                                copycolor(defcolor, lcol);
255 +                }
256 +                freelamps();                    /* all done with data */
257 +        }
258 +                                                /* else keep lamp data */
259 + }
260 +
261 +
262   char *
263   stradd(dst, src, sep)                   /* add a string at dst */
264   register char   *dst, *src;
# Line 656 | Line 696 | double width, length, height;
696                  shp->area = shp->w * shp->l;
697                  break;
698          case DISK:
659                shp->area = PI/4. * shp->w * shp->w;
660                break;
699          case SPHERE:
700 <                shp->area = PI * shp->w * shp->w;
700 >                shp->area = PI/4. * shp->w * shp->w;
701                  break;
702          }
703          return(0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines