| 1 |
– |
/* Copyright (c) 1997 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* Context handlers |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
|
#include <stdio.h> |
| 9 |
|
#include <math.h> |
| 10 |
+ |
#include <stdlib.h> |
| 11 |
|
#include <string.h> |
| 12 |
|
#include "parser.h" |
| 13 |
|
#include "lookup.h" |
| 35 |
|
static LUTAB vtx_tab = LU_SINIT(free,free); /* vertex lookup table */ |
| 36 |
|
|
| 37 |
|
/* CIE 1931 Standard Observer curves */ |
| 38 |
< |
static C_COLOR cie_xf = { 1, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF, |
| 38 |
> |
static C_COLOR cie_xf = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF, |
| 39 |
|
{14,42,143,435,1344,2839,3483,3362,2908,1954,956, |
| 40 |
|
320,49,93,633,1655,2904,4334,5945,7621,9163,10263, |
| 41 |
|
10622,10026,8544,6424,4479,2835,1649,874,468,227, |
| 42 |
|
114,58,29,14,7,3,2,1,0}, 106836L, .467, .368, 362.230 |
| 43 |
|
}; |
| 44 |
< |
static C_COLOR cie_yf = { 1, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF, |
| 44 |
> |
static C_COLOR cie_yf = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF, |
| 45 |
|
{0,1,4,12,40,116,230,380,600,910,1390,2080,3230, |
| 46 |
|
5030,7100,8620,9540,9950,9950,9520,8700,7570,6310, |
| 47 |
|
5030,3810,2650,1750,1070,610,320,170,82,41,21,10, |
| 48 |
|
5,2,1,1,0,0}, 106856L, .398, .542, 493.525 |
| 49 |
|
}; |
| 50 |
< |
static C_COLOR cie_zf = { 1, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF, |
| 50 |
> |
static C_COLOR cie_zf = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY|C_CSEFF, |
| 51 |
|
{65,201,679,2074,6456,13856,17471,17721,16692, |
| 52 |
|
12876,8130,4652,2720,1582,782,422,203,87,39,21,17, |
| 53 |
|
11,8,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, |
| 54 |
|
106770L, .147, .077, 54.363 |
| 55 |
|
}; |
| 56 |
|
/* Derived CIE 1931 Primaries (imaginary) */ |
| 57 |
< |
static C_COLOR cie_xp = { 1, C_CDSPEC|C_CSSPEC|C_CSXY, |
| 57 |
> |
static C_COLOR cie_xp = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY, |
| 58 |
|
{-174,-198,-195,-197,-202,-213,-235,-272,-333, |
| 59 |
|
-444,-688,-1232,-2393,-4497,-6876,-6758,-5256, |
| 60 |
|
-3100,-815,1320,3200,4782,5998,6861,7408,7754, |
| 62 |
|
8336,8336,8336,8336,8336,8336}, |
| 63 |
|
127424L, 1., .0, |
| 64 |
|
}; |
| 65 |
< |
static C_COLOR cie_yp = { 1, C_CDSPEC|C_CSSPEC|C_CSXY, |
| 65 |
> |
static C_COLOR cie_yp = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY, |
| 66 |
|
{-451,-431,-431,-430,-427,-417,-399,-366,-312, |
| 67 |
|
-204,57,691,2142,4990,8810,9871,9122,7321,5145, |
| 68 |
|
3023,1123,-473,-1704,-2572,-3127,-3474,-3704, |
| 70 |
|
-4066,-4066,-4066,-4066,-4066,-4066}, |
| 71 |
|
-23035L, .0, 1., |
| 72 |
|
}; |
| 73 |
< |
static C_COLOR cie_zp = { 1, C_CDSPEC|C_CSSPEC|C_CSXY, |
| 73 |
> |
static C_COLOR cie_zp = { 1, NULL, C_CDSPEC|C_CSSPEC|C_CSXY, |
| 74 |
|
{4051,4054,4052,4053,4054,4056,4059,4064,4071, |
| 75 |
|
4074,4056,3967,3677,2933,1492,313,-440,-795, |
| 76 |
|
-904,-918,-898,-884,-869,-863,-855,-855,-851, |
| 128 |
|
c_ccname = lp->key; |
| 129 |
|
c_ccolor = (C_COLOR *)lp->data; |
| 130 |
|
c_ccolor->clock = 0; |
| 131 |
+ |
c_ccolor->client_data = NULL; |
| 132 |
|
} |
| 133 |
|
i = c_ccolor->clock; |
| 134 |
|
if (ac == 3) { /* use default template */ |
| 152 |
|
c_ccolor->cx = atof(av[1]); |
| 153 |
|
c_ccolor->cy = atof(av[2]); |
| 154 |
|
c_ccolor->flags = C_CDXY|C_CSXY; |
| 155 |
< |
if (c_ccolor->cx < 0. | c_ccolor->cy < 0. | |
| 156 |
< |
c_ccolor->cx + c_ccolor->cy > 1.) |
| 155 |
> |
if ((c_ccolor->cx < 0.) | (c_ccolor->cy < 0.) | |
| 156 |
> |
(c_ccolor->cx + c_ccolor->cy > 1.)) |
| 157 |
|
return(MG_EILL); |
| 158 |
|
c_ccolor->clock++; |
| 159 |
|
return(MG_OK); |
| 245 |
|
c_cmname = lp->key; |
| 246 |
|
c_cmaterial = (C_MATERIAL *)lp->data; |
| 247 |
|
c_cmaterial->clock = 0; |
| 248 |
+ |
c_cmaterial->client_data = NULL; |
| 249 |
|
} |
| 250 |
|
i = c_cmaterial->clock; |
| 251 |
|
if (ac == 3) { /* use default template */ |
| 278 |
|
if (!isflt(av[1])) |
| 279 |
|
return(MG_ETYPE); |
| 280 |
|
c_cmaterial->rd = atof(av[1]); |
| 281 |
< |
if (c_cmaterial->rd < 0. | c_cmaterial->rd > 1.) |
| 281 |
> |
if ((c_cmaterial->rd < 0.) | (c_cmaterial->rd > 1.)) |
| 282 |
|
return(MG_EILL); |
| 283 |
|
c_cmaterial->rd_c = *c_ccolor; |
| 284 |
|
c_cmaterial->clock++; |
| 300 |
|
if (!isflt(av[1])) |
| 301 |
|
return(MG_ETYPE); |
| 302 |
|
c_cmaterial->td = atof(av[1]); |
| 303 |
< |
if (c_cmaterial->td < 0. | c_cmaterial->td > 1.) |
| 303 |
> |
if ((c_cmaterial->td < 0.) | (c_cmaterial->td > 1.)) |
| 304 |
|
return(MG_EILL); |
| 305 |
|
c_cmaterial->td_c = *c_ccolor; |
| 306 |
|
c_cmaterial->clock++; |
| 312 |
|
return(MG_ETYPE); |
| 313 |
|
c_cmaterial->rs = atof(av[1]); |
| 314 |
|
c_cmaterial->rs_a = atof(av[2]); |
| 315 |
< |
if (c_cmaterial->rs < 0. | c_cmaterial->rs > 1. | |
| 316 |
< |
c_cmaterial->rs_a < 0.) |
| 315 |
> |
if ((c_cmaterial->rs < 0.) | (c_cmaterial->rs > 1.) | |
| 316 |
> |
(c_cmaterial->rs_a < 0.)) |
| 317 |
|
return(MG_EILL); |
| 318 |
|
c_cmaterial->rs_c = *c_ccolor; |
| 319 |
|
c_cmaterial->clock++; |
| 325 |
|
return(MG_ETYPE); |
| 326 |
|
c_cmaterial->ts = atof(av[1]); |
| 327 |
|
c_cmaterial->ts_a = atof(av[2]); |
| 328 |
< |
if (c_cmaterial->ts < 0. | c_cmaterial->ts > 1. | |
| 329 |
< |
c_cmaterial->ts_a < 0.) |
| 328 |
> |
if ((c_cmaterial->ts < 0.) | (c_cmaterial->ts > 1.) | |
| 329 |
> |
(c_cmaterial->ts_a < 0.)) |
| 330 |
|
return(MG_EILL); |
| 331 |
|
c_cmaterial->ts_c = *c_ccolor; |
| 332 |
|
c_cmaterial->clock++; |
| 392 |
|
return(MG_EMEM); |
| 393 |
|
c_cvname = lp->key; |
| 394 |
|
c_cvertex = (C_VERTEX *)lp->data; |
| 395 |
+ |
c_cvertex->clock = 0; |
| 396 |
+ |
c_cvertex->client_data = NULL; |
| 397 |
|
} |
| 398 |
|
i = c_cvertex->clock; |
| 399 |
|
if (ac == 3) { /* use default template */ |
| 573 |
|
double wl0, wlstep; |
| 574 |
|
double boxpos, boxstep; |
| 575 |
|
/* check bounds */ |
| 576 |
< |
if (wlmax <= C_CMINWL | wlmax <= wlmin | wlmin >= C_CMAXWL) |
| 576 |
> |
if ((wlmax <= C_CMINWL) | (wlmax <= wlmin) | (wlmin >= C_CMAXWL)) |
| 577 |
|
return(MG_EILL); |
| 578 |
|
wlstep = (wlmax - wlmin)/(ac-1); |
| 579 |
|
while (wlmin < C_CMINWL) { |
| 618 |
|
wl0 = wlmin; |
| 619 |
|
pos = 0; |
| 620 |
|
for (i = 0, wl = C_CMINWL; i < C_CNSS; i++, wl += C_CWLI) |
| 621 |
< |
if (wl < wlmin | wl > wlmax) |
| 621 |
> |
if ((wl < wlmin) | (wl > wlmax)) |
| 622 |
|
clr->ssamp[i] = 0; |
| 623 |
|
else { |
| 624 |
|
while (wl0 + wlstep < wl+FTINY) { |
| 625 |
|
wl0 += wlstep; |
| 626 |
|
pos++; |
| 627 |
|
} |
| 628 |
< |
if (wl+FTINY >= wl0 & wl-FTINY <= wl0) |
| 628 |
> |
if ((wl+FTINY >= wl0) & (wl-FTINY <= wl0)) |
| 629 |
|
clr->ssamp[i] = scale*va[pos] + .5; |
| 630 |
|
else /* interpolate if necessary */ |
| 631 |
|
clr->ssamp[i] = .5 + scale / wlstep * |