1 |
< |
/* Copyright (c) 1994 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
27 |
|
|
28 |
|
int (*mg_ehand[MG_NENTITIES])(); |
29 |
|
|
30 |
+ |
/* Handler routine for unknown entities */ |
31 |
+ |
|
32 |
+ |
int (*mg_uhand)() = mg_defuhand; |
33 |
+ |
|
34 |
+ |
unsigned mg_nunknown; /* count of unknown entities */ |
35 |
+ |
|
36 |
|
/* error messages */ |
37 |
|
|
38 |
|
char *mg_err[MG_NERRS] = MG_ERRLIST; |
65 |
|
e_ies(), /* IES luminaire file */ |
66 |
|
e_include(), /* include file */ |
67 |
|
e_sph(), /* sphere */ |
68 |
+ |
e_cct(), /* color temperature */ |
69 |
|
e_cmix(), /* color mixtures */ |
70 |
|
e_cspec(), /* color spectra */ |
71 |
|
e_cyl(), /* cylinder */ |
95 |
|
mg_ehand[MG_E_INCLUDE] = e_include; |
96 |
|
if (mg_ehand[MG_E_SPH] == NULL) { |
97 |
|
mg_ehand[MG_E_SPH] = e_sph; |
98 |
< |
ineed |= 1<<MG_E_POINT|1<<MG_E_VERTEX; |
98 |
> |
ineed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX; |
99 |
|
} else |
100 |
< |
uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF; |
100 |
> |
uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF; |
101 |
|
if (mg_ehand[MG_E_CYL] == NULL) { |
102 |
|
mg_ehand[MG_E_CYL] = e_cyl; |
103 |
< |
ineed |= 1<<MG_E_POINT|1<<MG_E_VERTEX; |
103 |
> |
ineed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX; |
104 |
|
} else |
105 |
< |
uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF; |
105 |
> |
uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF; |
106 |
|
if (mg_ehand[MG_E_CONE] == NULL) { |
107 |
|
mg_ehand[MG_E_CONE] = e_cone; |
108 |
< |
ineed |= 1<<MG_E_POINT|1<<MG_E_VERTEX; |
108 |
> |
ineed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX; |
109 |
|
} else |
110 |
< |
uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF; |
110 |
> |
uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF; |
111 |
|
if (mg_ehand[MG_E_RING] == NULL) { |
112 |
|
mg_ehand[MG_E_RING] = e_ring; |
113 |
< |
ineed |= 1<<MG_E_POINT|1<<MG_E_NORMAL|1<<MG_E_VERTEX; |
113 |
> |
ineed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX; |
114 |
|
} else |
115 |
< |
uneed |= 1<<MG_E_POINT|1<<MG_E_NORMAL|1<<MG_E_VERTEX|1<<MG_E_XF; |
115 |
> |
uneed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX|1L<<MG_E_XF; |
116 |
|
if (mg_ehand[MG_E_PRISM] == NULL) { |
117 |
|
mg_ehand[MG_E_PRISM] = e_prism; |
118 |
< |
ineed |= 1<<MG_E_POINT|1<<MG_E_VERTEX; |
118 |
> |
ineed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX; |
119 |
|
} else |
120 |
< |
uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF; |
120 |
> |
uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF; |
121 |
|
if (mg_ehand[MG_E_TORUS] == NULL) { |
122 |
|
mg_ehand[MG_E_TORUS] = e_torus; |
123 |
< |
ineed |= 1<<MG_E_POINT|1<<MG_E_NORMAL|1<<MG_E_VERTEX; |
123 |
> |
ineed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX; |
124 |
|
} else |
125 |
< |
uneed |= 1<<MG_E_POINT|1<<MG_E_NORMAL|1<<MG_E_VERTEX|1<<MG_E_XF; |
125 |
> |
uneed |= 1L<<MG_E_POINT|1L<<MG_E_NORMAL|1L<<MG_E_VERTEX|1L<<MG_E_XF; |
126 |
|
if (mg_ehand[MG_E_COLOR] != NULL) { |
127 |
|
if (mg_ehand[MG_E_CMIX] == NULL) { |
128 |
|
mg_ehand[MG_E_CMIX] = e_cmix; |
129 |
< |
ineed |= 1<<MG_E_COLOR|1<<MG_E_CXY|1<<MG_E_CSPEC|1<<MG_E_CMIX; |
129 |
> |
ineed |= 1L<<MG_E_COLOR|1L<<MG_E_CXY|1L<<MG_E_CSPEC|1L<<MG_E_CMIX|1L<<MG_E_CCT; |
130 |
|
} |
131 |
|
if (mg_ehand[MG_E_CSPEC] == NULL) { |
132 |
|
mg_ehand[MG_E_CSPEC] = e_cspec; |
133 |
< |
ineed |= 1<<MG_E_COLOR|1<<MG_E_CXY|1<<MG_E_CSPEC|1<<MG_E_CMIX; |
133 |
> |
ineed |= 1L<<MG_E_COLOR|1L<<MG_E_CXY|1L<<MG_E_CSPEC|1L<<MG_E_CMIX|1L<<MG_E_CCT; |
134 |
|
} |
135 |
+ |
if (mg_ehand[MG_E_CCT] == NULL) { |
136 |
+ |
mg_ehand[MG_E_CCT] = e_cct; |
137 |
+ |
ineed |= 1L<<MG_E_COLOR|1L<<MG_E_CXY|1L<<MG_E_CSPEC|1L<<MG_E_CMIX|1L<<MG_E_CCT; |
138 |
+ |
} |
139 |
|
} |
140 |
|
/* check for consistency */ |
141 |
|
if (mg_ehand[MG_E_FACE] != NULL) |
142 |
< |
uneed |= 1<<MG_E_POINT|1<<MG_E_VERTEX|1<<MG_E_XF; |
142 |
> |
uneed |= 1L<<MG_E_POINT|1L<<MG_E_VERTEX|1L<<MG_E_XF; |
143 |
|
if (mg_ehand[MG_E_CXY] != NULL || mg_ehand[MG_E_CSPEC] != NULL || |
144 |
|
mg_ehand[MG_E_CMIX] != NULL) |
145 |
< |
uneed |= 1<<MG_E_COLOR; |
145 |
> |
uneed |= 1L<<MG_E_COLOR; |
146 |
|
if (mg_ehand[MG_E_RD] != NULL || mg_ehand[MG_E_TD] != NULL || |
147 |
+ |
mg_ehand[MG_E_IR] != NULL || |
148 |
|
mg_ehand[MG_E_ED] != NULL || |
149 |
|
mg_ehand[MG_E_RS] != NULL || |
150 |
|
mg_ehand[MG_E_TS] != NULL || |
151 |
|
mg_ehand[MG_E_SIDES] != NULL) |
152 |
< |
uneed |= 1<<MG_E_MATERIAL; |
152 |
> |
uneed |= 1L<<MG_E_MATERIAL; |
153 |
|
for (i = 0; i < MG_NENTITIES; i++) |
154 |
< |
if (uneed & 1<<i && mg_ehand[i] == NULL) { |
154 |
> |
if (uneed & 1L<<i && mg_ehand[i] == NULL) { |
155 |
|
fprintf(stderr, "Missing support for \"%s\" entity\n", |
156 |
|
mg_ename[i]); |
157 |
|
exit(1); |
158 |
|
} |
159 |
|
/* add support as needed */ |
160 |
< |
if (ineed & 1<<MG_E_VERTEX && mg_ehand[MG_E_VERTEX] != c_hvertex) |
160 |
> |
if (ineed & 1L<<MG_E_VERTEX && mg_ehand[MG_E_VERTEX] != c_hvertex) |
161 |
|
e_supp[MG_E_VERTEX] = c_hvertex; |
162 |
< |
if (ineed & 1<<MG_E_POINT && mg_ehand[MG_E_POINT] != c_hvertex) |
162 |
> |
if (ineed & 1L<<MG_E_POINT && mg_ehand[MG_E_POINT] != c_hvertex) |
163 |
|
e_supp[MG_E_POINT] = c_hvertex; |
164 |
< |
if (ineed & 1<<MG_E_NORMAL && mg_ehand[MG_E_NORMAL] != c_hvertex) |
164 |
> |
if (ineed & 1L<<MG_E_NORMAL && mg_ehand[MG_E_NORMAL] != c_hvertex) |
165 |
|
e_supp[MG_E_NORMAL] = c_hvertex; |
166 |
< |
if (ineed & 1<<MG_E_COLOR && mg_ehand[MG_E_COLOR] != c_hcolor) |
166 |
> |
if (ineed & 1L<<MG_E_COLOR && mg_ehand[MG_E_COLOR] != c_hcolor) |
167 |
|
e_supp[MG_E_COLOR] = c_hcolor; |
168 |
< |
if (ineed & 1<<MG_E_CXY && mg_ehand[MG_E_CXY] != c_hcolor) |
168 |
> |
if (ineed & 1L<<MG_E_CXY && mg_ehand[MG_E_CXY] != c_hcolor) |
169 |
|
e_supp[MG_E_CXY] = c_hcolor; |
170 |
< |
if (ineed & 1<<MG_E_CSPEC && mg_ehand[MG_E_CSPEC] != c_hcolor) |
170 |
> |
if (ineed & 1L<<MG_E_CSPEC && mg_ehand[MG_E_CSPEC] != c_hcolor) |
171 |
|
e_supp[MG_E_CSPEC] = c_hcolor; |
172 |
< |
if (ineed & 1<<MG_E_CMIX && mg_ehand[MG_E_CMIX] != c_hcolor) |
172 |
> |
if (ineed & 1L<<MG_E_CMIX && mg_ehand[MG_E_CMIX] != c_hcolor) |
173 |
|
e_supp[MG_E_CMIX] = c_hcolor; |
174 |
+ |
if (ineed & 1L<<MG_E_CCT && mg_ehand[MG_E_CCT] != c_hcolor) |
175 |
+ |
e_supp[MG_E_CCT] = c_hcolor; |
176 |
|
/* discard remaining entities */ |
177 |
|
for (i = 0; i < MG_NENTITIES; i++) |
178 |
|
if (mg_ehand[i] == NULL) |
180 |
|
} |
181 |
|
|
182 |
|
|
169 |
– |
|
183 |
|
int |
184 |
|
mg_entity(name) /* get entity number from its name */ |
185 |
|
char *name; |
209 |
|
{ |
210 |
|
int rv; |
211 |
|
|
212 |
< |
if (en < 0 && (en = mg_entity(av[0])) < 0) |
212 |
> |
if (en < 0 && (en = mg_entity(av[0])) < 0) { /* unknown entity */ |
213 |
> |
if (mg_uhand != NULL) |
214 |
> |
return((*mg_uhand)(ac, av)); |
215 |
|
return(MG_EUNK); |
216 |
< |
if (e_supp[en] != NULL) { |
216 |
> |
} |
217 |
> |
if (e_supp[en] != NULL) { /* support handler */ |
218 |
|
if ((rv = (*e_supp[en])(ac, av)) != MG_OK) |
219 |
|
return(rv); |
220 |
|
} |
221 |
< |
return((*mg_ehand[en])(ac, av)); |
221 |
> |
return((*mg_ehand[en])(ac, av)); /* assigned handler */ |
222 |
|
} |
223 |
|
|
224 |
|
|
228 |
|
char *fn; |
229 |
|
{ |
230 |
|
static int nfids; |
215 |
– |
int olen; |
231 |
|
register char *cp; |
232 |
|
|
233 |
|
ctx->fid = ++nfids; |
240 |
|
return(MG_OK); |
241 |
|
} |
242 |
|
/* get name relative to this context */ |
243 |
< |
if (mg_file != NULL && |
229 |
< |
(cp = strrchr(mg_file->fname, '/')) != NULL) |
230 |
< |
olen = cp - mg_file->fname + 1; |
231 |
< |
else |
232 |
< |
olen = 0; |
233 |
< |
if (olen) |
243 |
> |
if (mg_file != NULL && (cp = strrchr(mg_file->fname, '/')) != NULL) { |
244 |
|
strcpy(ctx->fname, mg_file->fname); |
245 |
< |
strcpy(ctx->fname+olen, fn); |
245 |
> |
strcpy(ctx->fname+(cp-mg_file->fname+1), fn); |
246 |
> |
} else |
247 |
> |
strcpy(ctx->fname, fn); |
248 |
|
ctx->fp = fopen(ctx->fname, "r"); |
249 |
|
if (ctx->fp == NULL) |
250 |
|
return(MG_ENOFILE); |
349 |
|
{ |
350 |
|
MG_FCTXT cntxt; |
351 |
|
int rval; |
352 |
+ |
register int nbr; |
353 |
|
|
354 |
|
if ((rval = mg_open(&cntxt, fn)) != MG_OK) { |
355 |
|
fprintf(stderr, "%s: %s\n", fn, mg_err[rval]); |
356 |
|
return(rval); |
357 |
|
} |
358 |
< |
while (mg_read()) /* parse each line */ |
358 |
> |
while ((nbr = mg_read()) > 0) { /* parse each line */ |
359 |
> |
if (nbr >= MG_MAXLINE-1 && cntxt.inpline[nbr-1] != '\n') { |
360 |
> |
fprintf(stderr, "%s: %d: %s\n", cntxt.fname, |
361 |
> |
cntxt.lineno, mg_err[rval=MG_ELINE]); |
362 |
> |
break; |
363 |
> |
} |
364 |
|
if ((rval = mg_parse()) != MG_OK) { |
365 |
|
fprintf(stderr, "%s: %d: %s:\n%s", cntxt.fname, |
366 |
|
cntxt.lineno, mg_err[rval], |
367 |
|
cntxt.inpline); |
368 |
|
break; |
369 |
|
} |
370 |
+ |
} |
371 |
|
mg_close(); |
372 |
|
return(rval); |
373 |
|
} |
374 |
|
|
375 |
|
|
376 |
+ |
int |
377 |
+ |
mg_defuhand(ac, av) /* default handler for unknown entities */ |
378 |
+ |
int ac; |
379 |
+ |
char **av; |
380 |
+ |
{ |
381 |
+ |
if (mg_nunknown++ == 0) /* report first incident */ |
382 |
+ |
fprintf(stderr, "%s: %d: %s: %s\n", mg_file->fname, |
383 |
+ |
mg_file->lineno, mg_err[MG_EUNK], av[0]); |
384 |
+ |
return(MG_OK); |
385 |
+ |
} |
386 |
+ |
|
387 |
+ |
|
388 |
|
void |
389 |
|
mg_clear() /* clear parser history */ |
390 |
|
{ |
414 |
|
{ |
415 |
|
char *xfarg[MG_MAXARGC]; |
416 |
|
MG_FCTXT ictx; |
417 |
< |
int rv; |
417 |
> |
XF_SPEC *xf_orig = xf_context; |
418 |
> |
register int rv; |
419 |
|
|
420 |
|
if (ac < 2) |
421 |
|
return(MG_EARGC); |
428 |
|
for (i = 1; i < ac-1; i++) |
429 |
|
xfarg[i] = av[i+1]; |
430 |
|
xfarg[ac-1] = NULL; |
431 |
< |
if ((rv = mg_handle(MG_E_XF, ac-1, xfarg)) != MG_OK) |
431 |
> |
if ((rv = mg_handle(MG_E_XF, ac-1, xfarg)) != MG_OK) { |
432 |
> |
mg_close(); |
433 |
|
return(rv); |
434 |
+ |
} |
435 |
|
} |
436 |
< |
while (!feof(mg_file->fp)) { |
437 |
< |
while (mg_read()) |
436 |
> |
do { |
437 |
> |
while ((rv = mg_read()) > 0) { |
438 |
> |
if (rv >= MG_MAXLINE-1 && ictx.inpline[rv-1] != '\n') { |
439 |
> |
fprintf(stderr, "%s: %d: %s\n", ictx.fname, |
440 |
> |
ictx.lineno, mg_err[MG_ELINE]); |
441 |
> |
mg_close(); |
442 |
> |
return(MG_EINCL); |
443 |
> |
} |
444 |
|
if ((rv = mg_parse()) != MG_OK) { |
445 |
|
fprintf(stderr, "%s: %d: %s:\n%s", ictx.fname, |
446 |
|
ictx.lineno, mg_err[rv], |
448 |
|
mg_close(); |
449 |
|
return(MG_EINCL); |
450 |
|
} |
451 |
+ |
} |
452 |
|
if (ac > 2) |
453 |
< |
if ((rv = mg_handle(MG_E_XF, 1, xfarg)) != MG_OK) |
453 |
> |
if ((rv = mg_handle(MG_E_XF, 1, xfarg)) != MG_OK) { |
454 |
> |
mg_close(); |
455 |
|
return(rv); |
456 |
< |
} |
456 |
> |
} |
457 |
> |
} while (xf_context != xf_orig); |
458 |
|
mg_close(); |
459 |
|
return(MG_OK); |
460 |
|
} |
751 |
|
static char *p4ent[5] = {mg_ename[MG_E_POINT],p4[0],p4[1],p4[2]}; |
752 |
|
static char *n4ent[5] = {mg_ename[MG_E_NORMAL],n4[0],n4[1],n4[2]}; |
753 |
|
static char *fent[6] = {mg_ename[MG_E_FACE],"_cv1","_cv2","_cv3","_cv4"}; |
754 |
+ |
char *v1n; |
755 |
|
register C_VERTEX *cv1, *cv2; |
756 |
|
register int i, j; |
757 |
|
FVECT u, v, w; |
767 |
|
if ((cv1 = c_getvert(av[1])) == NULL || |
768 |
|
(cv2 = c_getvert(av[3])) == NULL) |
769 |
|
return(MG_EUNDEF); |
770 |
+ |
v1n = av[1]; |
771 |
|
if (!isflt(av[2]) || !isflt(av[4])) |
772 |
|
return(MG_ETYPE); |
773 |
|
rad1 = atof(av[2]); |
786 |
|
cv = cv1; |
787 |
|
cv1 = cv2; |
788 |
|
cv2 = cv; |
789 |
+ |
v1n = av[3]; |
790 |
|
d = rad1; |
791 |
|
rad1 = rad2; |
792 |
|
rad2 = d; |
820 |
|
if ((rv = mg_handle(MG_E_NORMAL, 4, n3ent)) != MG_OK) |
821 |
|
return(rv); |
822 |
|
if (rad1 == 0.) { /* triangles */ |
823 |
< |
v1ent[3] = av[1]; |
823 |
> |
v1ent[3] = v1n; |
824 |
|
if ((rv = mg_handle(MG_E_VERTEX, 4, v1ent)) != MG_OK) |
825 |
|
return(rv); |
826 |
|
for (j = 0; j < 3; j++) |
1014 |
|
|
1015 |
|
|
1016 |
|
static int |
1017 |
< |
e_cspec(ac, av) /* handle spectral color */ |
972 |
< |
int ac; |
973 |
< |
char **av; |
1017 |
> |
put_cxy() /* put out current xy chromaticities */ |
1018 |
|
{ |
1019 |
|
static char xbuf[24], ybuf[24]; |
1020 |
|
static char *ccom[4] = {mg_ename[MG_E_CXY], xbuf, ybuf}; |
1021 |
|
int rv; |
1022 |
|
|
1023 |
+ |
sprintf(xbuf, "%.4f", c_ccolor->cx); |
1024 |
+ |
sprintf(ybuf, "%.4f", c_ccolor->cy); |
1025 |
+ |
if ((rv = mg_handle(MG_E_CXY, 3, ccom)) != MG_OK) |
1026 |
+ |
return(rv); |
1027 |
+ |
return(MG_OK); |
1028 |
+ |
} |
1029 |
+ |
|
1030 |
+ |
|
1031 |
+ |
static int |
1032 |
+ |
put_cspec() /* put out current color spectrum */ |
1033 |
+ |
{ |
1034 |
+ |
char wl[2][6], vbuf[C_CNSS][24]; |
1035 |
+ |
char *newav[C_CNSS+4]; |
1036 |
+ |
double sf; |
1037 |
+ |
register int i; |
1038 |
+ |
|
1039 |
+ |
if (mg_ehand[MG_E_CSPEC] != c_hcolor) { |
1040 |
+ |
sprintf(wl[0], "%d", C_CMINWL); |
1041 |
+ |
sprintf(wl[1], "%d", C_CMAXWL); |
1042 |
+ |
newav[0] = mg_ename[MG_E_CSPEC]; |
1043 |
+ |
newav[1] = wl[0]; |
1044 |
+ |
newav[2] = wl[1]; |
1045 |
+ |
sf = (double)C_CNSS / c_ccolor->ssum; |
1046 |
+ |
for (i = 0; i < C_CNSS; i++) { |
1047 |
+ |
sprintf(vbuf[i], "%.4f", sf*c_ccolor->ssamp[i]); |
1048 |
+ |
newav[i+3] = vbuf[i]; |
1049 |
+ |
} |
1050 |
+ |
newav[C_CNSS+3] = NULL; |
1051 |
+ |
if ((i = mg_handle(MG_E_CSPEC, C_CNSS+3, newav)) != MG_OK) |
1052 |
+ |
return(i); |
1053 |
+ |
} |
1054 |
+ |
return(MG_OK); |
1055 |
+ |
} |
1056 |
+ |
|
1057 |
+ |
|
1058 |
+ |
static int |
1059 |
+ |
e_cspec(ac, av) /* handle spectral color */ |
1060 |
+ |
int ac; |
1061 |
+ |
char **av; |
1062 |
+ |
{ |
1063 |
+ |
/* convert to xy chromaticity */ |
1064 |
|
c_ccvt(c_ccolor, C_CSXY); |
1065 |
|
/* if it's really their handler, use it */ |
1066 |
< |
if (mg_ehand[MG_E_CXY] != c_hcolor) { |
1067 |
< |
sprintf(xbuf, "%.4f", c_ccolor->cx); |
983 |
< |
sprintf(ybuf, "%.4f", c_ccolor->cy); |
984 |
< |
if ((rv = mg_handle(MG_E_CXY, 3, ccom)) != MG_OK) |
985 |
< |
return(rv); |
986 |
< |
} |
1066 |
> |
if (mg_ehand[MG_E_CXY] != c_hcolor) |
1067 |
> |
return(put_cxy()); |
1068 |
|
return(MG_OK); |
1069 |
|
} |
1070 |
|
|
1074 |
|
int ac; |
1075 |
|
char **av; |
1076 |
|
{ |
996 |
– |
char wl[2][6], vbuf[C_CNSS][24]; |
997 |
– |
char *newav[C_CNSS+4]; |
998 |
– |
int rv; |
999 |
– |
register int i; |
1077 |
|
/* |
1078 |
|
* Contorted logic works as follows: |
1079 |
|
* 1. the colors are already mixed in c_hcolor() support function |
1084 |
|
*/ |
1085 |
|
if (mg_ehand[MG_E_CSPEC] == e_cspec) |
1086 |
|
c_ccvt(c_ccolor, C_CSXY); |
1087 |
< |
else if (c_ccolor->flags & C_CDSPEC) { |
1088 |
< |
if (mg_ehand[MG_E_CSPEC] != c_hcolor) { |
1089 |
< |
sprintf(wl[0], "%d", C_CMINWL); |
1090 |
< |
sprintf(wl[1], "%d", C_CMAXWL); |
1091 |
< |
newav[0] = mg_ename[MG_E_CSPEC]; |
1092 |
< |
newav[1] = wl[0]; |
1093 |
< |
newav[2] = wl[1]; |
1094 |
< |
for (i = 0; i < C_CNSS; i++) { |
1095 |
< |
sprintf(vbuf[i], "%.6f", |
1096 |
< |
(double)c_ccolor->ssamp[i] / |
1097 |
< |
c_ccolor->ssum); |
1098 |
< |
newav[i+3] = vbuf[i]; |
1099 |
< |
} |
1100 |
< |
newav[C_CNSS+3] = NULL; |
1101 |
< |
if ((rv = mg_handle(MG_E_CSPEC, C_CNSS+3, newav)) != MG_OK) |
1102 |
< |
return(rv); |
1103 |
< |
} |
1104 |
< |
return(MG_OK); |
1105 |
< |
} |
1106 |
< |
if (mg_ehand[MG_E_CXY] != c_hcolor) { |
1107 |
< |
sprintf(vbuf[0], "%.4f", c_ccolor->cx); |
1108 |
< |
sprintf(vbuf[1], "%.4f", c_ccolor->cy); |
1109 |
< |
newav[0] = mg_ename[MG_E_CXY]; |
1110 |
< |
newav[1] = vbuf[0]; |
1034 |
< |
newav[2] = vbuf[1]; |
1035 |
< |
newav[3] = NULL; |
1036 |
< |
if ((rv = mg_handle(MG_E_CXY, 3, newav)) != MG_OK) |
1037 |
< |
return(rv); |
1038 |
< |
} |
1087 |
> |
else if (c_ccolor->flags & C_CDSPEC) |
1088 |
> |
return(put_cspec()); |
1089 |
> |
if (mg_ehand[MG_E_CXY] != c_hcolor) |
1090 |
> |
return(put_cxy()); |
1091 |
> |
return(MG_OK); |
1092 |
> |
} |
1093 |
> |
|
1094 |
> |
|
1095 |
> |
static int |
1096 |
> |
e_cct(ac, av) /* handle color temperature */ |
1097 |
> |
int ac; |
1098 |
> |
char **av; |
1099 |
> |
{ |
1100 |
> |
/* |
1101 |
> |
* Logic is similar to e_cmix here. Support handler has already |
1102 |
> |
* converted temperature to spectral color. Put it out as such |
1103 |
> |
* if they support it, otherwise convert to xy chromaticity and |
1104 |
> |
* put it out if they handle it. |
1105 |
> |
*/ |
1106 |
> |
if (mg_ehand[MG_E_CSPEC] != e_cspec) |
1107 |
> |
return(put_cspec()); |
1108 |
> |
c_ccvt(c_ccolor, C_CSXY); |
1109 |
> |
if (mg_ehand[MG_E_CXY] != c_hcolor) |
1110 |
> |
return(put_cxy()); |
1111 |
|
return(MG_OK); |
1112 |
|
} |