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 2.3 by greg, Thu May 21 09:56:36 1992 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 75 | Line 79 | char   **gargv;                        /* global argv */
79  
80   extern char     *strcpy(), *strcat(), *stradd(), *tailtrunc(), *filetrunc(),
81                  *filename(), *libname(), *fullname(), *malloc();
78 extern double   atof();
82   extern float    *matchlamp();
83  
84  
# Line 166 | Line 169 | char   *argv[];
169                          if (illumrad < MINDIM)
170                                  illumrad = MINDIM;
171                          break;
172 <                case 't':               /* select lamp type */
172 >                case 't':               /* override lamp type */
173                          lamptype = argv[++i];
174                          break;
175 +                case 'u':               /* default lamp type */
176 +                        deflamp = argv[++i];
177 +                        break;
178                  case 'c':               /* default lamp color */
179                          defcolor[0] = atof(argv[++i]);
180                          defcolor[1] = atof(argv[++i]);
# Line 185 | Line 191 | char   *argv[];
191                  }
192          gargc = i;
193          gargv = argv;
194 <                                        /* 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 <        }
194 >        initlamps();                    /* get lamp data (if needed) */
195                                          /* convert ies file(s) */
196          if (outfile != NULL) {
197                  if (i == argc)
# Line 219 | Line 218 | char   *argv[];
218   }
219  
220  
221 + initlamps()                             /* set up lamps */
222 + {
223 +        float   *lcol;
224 +        int     status;
225 +
226 +        if (lamptype != NULL && !strcmp(lamptype, default_name) &&
227 +                        deflamp == NULL)
228 +                return;                         /* no need for data */
229 +                                                /* else load file */
230 +        if ((status = loadlamps(lampdat)) < 0)
231 +                exit(1);
232 +        if (status == 0) {
233 +                fprintf(stderr, "%s: warning - no lamp data\n", lampdat);
234 +                lamptype = default_name;
235 +                return;
236 +        }
237 +        if (deflamp != NULL) {                  /* match default type */
238 +                if ((lcol = matchlamp(deflamp)) == NULL)
239 +                        fprintf(stderr,
240 +                                "%s: warning - unknown default lamp type\n",
241 +                                        deflamp);
242 +                else
243 +                        copycolor(defcolor, lcol);
244 +        }
245 +        if (lamptype != NULL) {                 /* match selected type */
246 +                if (strcmp(lamptype, default_name)) {
247 +                        if ((lcol = matchlamp(lamptype)) == NULL) {
248 +                                fprintf(stderr,
249 +                                        "%s: warning - unknown lamp type\n",
250 +                                                lamptype);
251 +                                lamptype = default_name;
252 +                        } else
253 +                                copycolor(defcolor, lcol);
254 +                }
255 +                freelamps();                    /* all done with data */
256 +        }
257 +                                                /* else keep lamp data */
258 + }
259 +
260 +
261   char *
262   stradd(dst, src, sep)                   /* add a string at dst */
263   register char   *dst, *src;
# Line 511 | Line 550 | char   *mod, *name;
550                  perror(buf);
551                  return(-1);
552          }
553 <        if (cvdata(in, datout, 2, nangles, 1./683., bounds) != 0) {
553 >        if (cvdata(in, datout, 2, nangles, 1./WHTEFFICACY, bounds) != 0) {
554                  fprintf(stderr, "dosource: bad distribution data\n");
555                  fclose(datout);
556                  unlink(fullname(buf,name,T_DST));
# Line 656 | Line 695 | double width, length, height;
695                  shp->area = shp->w * shp->l;
696                  break;
697          case DISK:
698 +        case SPHERE:
699                  shp->area = PI/4. * shp->w * shp->w;
700                  break;
661        case SPHERE:
662                shp->area = PI * shp->w * shp->w;
663                break;
701          }
702          return(0);
703   }
# Line 769 | Line 806 | FILE   *in, *out;
806   int     ndim, npts[];
807   double  mult, lim[][2];
808   {
809 <        register double *pt[4];
809 >        double  *pt[4];
810          register int    i, j;
811          double  val;
812          int     total;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines