1 |
< |
/* Copyright (c) 1994 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1997 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
105 |
|
c_ccname = NULL; |
106 |
|
return(MG_OK); |
107 |
|
} |
108 |
+ |
if (!isname(av[1])) |
109 |
+ |
return(MG_EILL); |
110 |
|
lp = lu_find(&clr_tab, av[1]); /* lookup context */ |
111 |
|
if (lp == NULL) |
112 |
|
return(MG_EMEM); |
177 |
|
if (!isflt(av[1])) |
178 |
|
return(MG_ETYPE); |
179 |
|
wsum = atof(av[1]); |
178 |
– |
if (wsum < 0.) |
179 |
– |
return(MG_EILL); |
180 |
|
if ((lp = lu_find(&clr_tab, av[2])) == NULL) |
181 |
|
return(MG_EMEM); |
182 |
|
if (lp->data == NULL) |
186 |
|
if (!isflt(av[i])) |
187 |
|
return(MG_ETYPE); |
188 |
|
w = atof(av[i]); |
189 |
– |
if (w < 0.) |
190 |
– |
return(MG_EILL); |
189 |
|
if ((lp = lu_find(&clr_tab, av[i+1])) == NULL) |
190 |
|
return(MG_EMEM); |
191 |
|
if (lp->data == NULL) |
194 |
|
w, (C_COLOR *)lp->data); |
195 |
|
wsum += w; |
196 |
|
} |
197 |
+ |
if (wsum <= 0.) |
198 |
+ |
return(MG_EILL); |
199 |
|
c_ccolor->clock++; |
200 |
|
return(MG_OK); |
201 |
|
} |
221 |
|
c_cmname = NULL; |
222 |
|
return(MG_OK); |
223 |
|
} |
224 |
+ |
if (!isname(av[1])) |
225 |
+ |
return(MG_EILL); |
226 |
|
lp = lu_find(&mat_tab, av[1]); /* lookup context */ |
227 |
|
if (lp == NULL) |
228 |
|
return(MG_EMEM); |
261 |
|
*c_cmaterial = *(C_MATERIAL *)lp->data; |
262 |
|
c_cmaterial->clock = i + 1; |
263 |
|
return(MG_OK); |
264 |
+ |
case MG_E_IR: /* set index of refraction */ |
265 |
+ |
if (ac != 3) |
266 |
+ |
return(MG_EARGC); |
267 |
+ |
if (!isflt(av[1]) | !isflt(av[2])) |
268 |
+ |
return(MG_ETYPE); |
269 |
+ |
c_cmaterial->nr = atof(av[1]); |
270 |
+ |
c_cmaterial->ni = atof(av[2]); |
271 |
+ |
if (c_cmaterial->nr <= FTINY) |
272 |
+ |
return(MG_EILL); |
273 |
+ |
c_cmaterial->clock++; |
274 |
+ |
return(MG_OK); |
275 |
|
case MG_E_RD: /* set diffuse reflectance */ |
276 |
|
if (ac != 2) |
277 |
|
return(MG_EARGC); |
368 |
|
c_cvname = NULL; |
369 |
|
return(MG_OK); |
370 |
|
} |
371 |
+ |
if (!isname(av[1])) |
372 |
+ |
return(MG_EILL); |
373 |
|
lp = lu_find(&vtx_tab, av[1]); /* lookup context */ |
374 |
|
if (lp == NULL) |
375 |
|
return(MG_EMEM); |
604 |
|
} |
605 |
|
if (n > 1) |
606 |
|
va[i] /= (double)n; |
592 |
– |
if (va[i] < 0.) |
593 |
– |
return(MG_EILL); |
607 |
|
if (va[i] > scale) |
608 |
|
scale = va[i]; |
609 |
+ |
else if (va[i] < -scale) |
610 |
+ |
scale = -va[i]; |
611 |
|
} |
612 |
|
if (scale <= FTINY) |
613 |
|
return(MG_EILL); |
665 |
|
} else { /* CIE xy mixing */ |
666 |
|
c_ccvt(c1, C_CSXY); |
667 |
|
c_ccvt(c2, C_CSXY); |
668 |
< |
scale = 1. / (w1/c1->cy + w2/c2->cy); |
668 |
> |
scale = w1/c1->cy + w2/c2->cy; |
669 |
> |
if (scale == 0.) |
670 |
> |
return; |
671 |
> |
scale = 1. / scale; |
672 |
|
cres->cx = (c1->cx*w1/c1->cy + c2->cx*w2/c2->cy) * scale; |
673 |
|
cres->cy = (w1 + w2) * scale; |
674 |
|
cres->flags = C_CDXY|C_CSXY; |