12 |
|
|
13 |
|
#include <stdio.h> |
14 |
|
#include <ctype.h> |
15 |
+ |
#include "color.h" |
16 |
|
|
17 |
|
#define PI 3.14159265358979323846 |
18 |
|
/* floating comparisons */ |
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 */ |
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) */ |
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]); |
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) |
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; |
551 |
|
perror(buf); |
552 |
|
return(-1); |
553 |
|
} |
554 |
< |
if (cvdata(in, datout, 2, nangles, 1./683., bounds) != 0) { |
554 |
> |
if (cvdata(in, datout, 2, nangles, 1./WHTEFFICACY, bounds) != 0) { |
555 |
|
fprintf(stderr, "dosource: bad distribution data\n"); |
556 |
|
fclose(datout); |
557 |
|
unlink(fullname(buf,name,T_DST)); |
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); |