1 |
– |
/* Copyright (c) 1986 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 |
|
* p_data.c - routine for stored patterns. |
9 |
– |
* |
10 |
– |
* 6/4/86 |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include "copyright.h" |
9 |
+ |
|
10 |
|
#include "ray.h" |
11 |
|
|
12 |
|
#include "data.h" |
13 |
|
|
14 |
+ |
#include "func.h" |
15 |
+ |
|
16 |
|
/* |
17 |
|
* A stored pattern can either be brightness or |
18 |
|
* color data. Brightness data is specified as: |
51 |
|
register OBJREC *m; |
52 |
|
RAY *r; |
53 |
|
{ |
55 |
– |
extern double varvalue(), funvalue(), datavalue(); |
56 |
– |
extern int errno; |
57 |
– |
int nv; |
54 |
|
double bval; |
55 |
|
double pt[MAXDIM]; |
56 |
|
DATARRAY *dp; |
57 |
< |
register char **sa; |
57 |
> |
register MFUNC *mf; |
58 |
> |
register int i; |
59 |
|
|
63 |
– |
setfunc(m, r); |
64 |
– |
|
65 |
– |
sa = m->oargs.sarg; |
66 |
– |
|
60 |
|
if (m->oargs.nsargs < 4) |
61 |
|
objerror(m, USER, "bad # arguments"); |
62 |
< |
if (!vardefined(sa[3])) |
63 |
< |
loadfunc(sa[2]); |
62 |
> |
dp = getdata(m->oargs.sarg[1]); |
63 |
> |
i = (1 << dp->nd) - 1; |
64 |
> |
mf = getfunc(m, 2, i<<3, 0); |
65 |
> |
setfunc(m, r); |
66 |
|
errno = 0; |
67 |
< |
for (nv = 0; nv+3 < m->oargs.nsargs && |
68 |
< |
sa[nv+3][0] != '-'; nv++) { |
69 |
< |
if (nv >= MAXDIM) |
70 |
< |
goto dimerr; |
76 |
< |
pt[nv] = varvalue(sa[nv+3]); |
67 |
> |
for (i = dp->nd; i-- > 0; ) { |
68 |
> |
pt[i] = evalue(mf->ep[i]); |
69 |
> |
if (errno == EDOM || errno == ERANGE) |
70 |
> |
goto computerr; |
71 |
|
} |
78 |
– |
if (errno) |
79 |
– |
goto computerr; |
80 |
– |
dp = getdata(sa[1]); |
81 |
– |
if (dp->nd != nv) |
82 |
– |
goto dimerr; |
72 |
|
bval = datavalue(dp, pt); |
73 |
|
errno = 0; |
74 |
< |
bval = funvalue(sa[0], 1, &bval); |
75 |
< |
if (errno) |
74 |
> |
bval = funvalue(m->oargs.sarg[0], 1, &bval); |
75 |
> |
if (errno == EDOM || errno == ERANGE) |
76 |
|
goto computerr; |
77 |
|
scalecolor(r->pcol, bval); |
78 |
< |
return; |
90 |
< |
|
91 |
< |
dimerr: |
92 |
< |
objerror(m, USER, "dimension error"); |
93 |
< |
|
78 |
> |
return(0); |
79 |
|
computerr: |
80 |
|
objerror(m, WARNING, "compute error"); |
81 |
< |
return; |
81 |
> |
return(0); |
82 |
|
} |
83 |
|
|
84 |
|
|
86 |
|
register OBJREC *m; |
87 |
|
RAY *r; |
88 |
|
{ |
104 |
– |
extern double varvalue(), funvalue(), datavalue(); |
105 |
– |
extern int errno; |
106 |
– |
int i, nv; |
89 |
|
double col[3]; |
90 |
|
COLOR cval; |
91 |
|
double pt[MAXDIM]; |
92 |
+ |
int nv; |
93 |
|
DATARRAY *dp; |
94 |
< |
register char **sa; |
94 |
> |
register MFUNC *mf; |
95 |
> |
register int i; |
96 |
|
|
113 |
– |
setfunc(m, r); |
114 |
– |
|
115 |
– |
sa = m->oargs.sarg; |
116 |
– |
|
97 |
|
if (m->oargs.nsargs < 8) |
98 |
|
objerror(m, USER, "bad # arguments"); |
99 |
< |
if (!vardefined(sa[7])) |
100 |
< |
loadfunc(sa[6]); |
101 |
< |
for (nv = 0; nv+7 < m->oargs.nsargs && |
102 |
< |
sa[nv+7][0] != '-'; nv++) { |
103 |
< |
if (nv >= MAXDIM) |
104 |
< |
goto dimerr; |
105 |
< |
errno = 0; |
106 |
< |
pt[nv] = varvalue(sa[nv+7]); |
127 |
< |
if (errno) |
99 |
> |
dp = getdata(m->oargs.sarg[3]); |
100 |
> |
i = (1 << (nv = dp->nd)) - 1; |
101 |
> |
mf = getfunc(m, 6, i<<7, 0); |
102 |
> |
setfunc(m, r); |
103 |
> |
errno = 0; |
104 |
> |
for (i = 0; i < nv; i++) { |
105 |
> |
pt[i] = evalue(mf->ep[i]); |
106 |
> |
if (errno == EDOM || errno == ERANGE) |
107 |
|
goto computerr; |
108 |
|
} |
109 |
< |
for (i = 0; i < 3; i++) { |
110 |
< |
dp = getdata(sa[i+3]); |
109 |
> |
col[0] = datavalue(dp, pt); |
110 |
> |
for (i = 1; i < 3; i++) { |
111 |
> |
dp = getdata(m->oargs.sarg[i+3]); |
112 |
|
if (dp->nd != nv) |
113 |
< |
goto dimerr; |
113 |
> |
objerror(m, USER, "dimension error"); |
114 |
|
col[i] = datavalue(dp, pt); |
115 |
|
} |
116 |
|
errno = 0; |
117 |
< |
setcolor(cval, funvalue(sa[0], 3, col), |
118 |
< |
funvalue(sa[1], 3, col), |
119 |
< |
funvalue(sa[2], 3, col)); |
120 |
< |
if (errno) |
117 |
> |
for (i = 0; i < 3; i++) |
118 |
> |
if (fundefined(m->oargs.sarg[i]) < 3) |
119 |
> |
colval(cval,i) = funvalue(m->oargs.sarg[i], 1, col+i); |
120 |
> |
else |
121 |
> |
colval(cval,i) = funvalue(m->oargs.sarg[i], 3, col); |
122 |
> |
if (errno == EDOM || errno == ERANGE) |
123 |
|
goto computerr; |
124 |
|
multcolor(r->pcol, cval); |
125 |
< |
return; |
144 |
< |
|
145 |
< |
dimerr: |
146 |
< |
objerror(m, USER, "dimension error"); |
147 |
< |
|
125 |
> |
return(0); |
126 |
|
computerr: |
127 |
|
objerror(m, WARNING, "compute error"); |
128 |
< |
return; |
128 |
> |
return(0); |
129 |
|
} |
130 |
|
|
131 |
|
|
133 |
|
register OBJREC *m; |
134 |
|
RAY *r; |
135 |
|
{ |
158 |
– |
extern double varvalue(), funvalue(), datavalue(); |
159 |
– |
extern int errno; |
160 |
– |
int i; |
136 |
|
double col[3]; |
137 |
|
COLOR cval; |
138 |
|
double pt[2]; |
139 |
|
DATARRAY *dp; |
140 |
< |
register char **sa; |
140 |
> |
register MFUNC *mf; |
141 |
> |
register int i; |
142 |
|
|
167 |
– |
setfunc(m, r); |
168 |
– |
|
169 |
– |
sa = m->oargs.sarg; |
170 |
– |
|
143 |
|
if (m->oargs.nsargs < 7) |
144 |
|
objerror(m, USER, "bad # arguments"); |
145 |
< |
if (!vardefined(sa[5])) |
146 |
< |
loadfunc(sa[4]); |
147 |
< |
for (i = 0; i < 2; i++) { |
148 |
< |
errno = 0; |
149 |
< |
pt[i] = varvalue(sa[i+5]); |
150 |
< |
if (errno) |
151 |
< |
goto computerr; |
152 |
< |
} |
181 |
< |
dp = getpict(sa[3]); |
145 |
> |
mf = getfunc(m, 4, 0x3<<5, 0); |
146 |
> |
setfunc(m, r); |
147 |
> |
errno = 0; |
148 |
> |
pt[1] = evalue(mf->ep[0]); /* y major ordering */ |
149 |
> |
pt[0] = evalue(mf->ep[1]); |
150 |
> |
if (errno == EDOM || errno == ERANGE) |
151 |
> |
goto computerr; |
152 |
> |
dp = getpict(m->oargs.sarg[3]); |
153 |
|
for (i = 0; i < 3; i++) |
154 |
|
col[i] = datavalue(dp+i, pt); |
155 |
|
errno = 0; |
156 |
< |
setcolor(cval, funvalue(sa[0], 3, col), |
157 |
< |
funvalue(sa[1], 3, col), |
158 |
< |
funvalue(sa[2], 3, col)); |
159 |
< |
if (errno) |
156 |
> |
for (i = 0; i < 3; i++) |
157 |
> |
if (fundefined(m->oargs.sarg[i]) < 3) |
158 |
> |
colval(cval,i) = funvalue(m->oargs.sarg[i], 1, col+i); |
159 |
> |
else |
160 |
> |
colval(cval,i) = funvalue(m->oargs.sarg[i], 3, col); |
161 |
> |
if (errno == EDOM || errno == ERANGE) |
162 |
|
goto computerr; |
163 |
|
multcolor(r->pcol, cval); |
164 |
< |
return; |
164 |
> |
return(0); |
165 |
|
|
166 |
|
computerr: |
167 |
|
objerror(m, WARNING, "compute error"); |
168 |
< |
return; |
168 |
> |
return(0); |
169 |
|
} |