ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/p_data.c
Revision: 1.5
Committed: Thu Aug 8 11:30:04 1991 UTC (32 years, 8 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.4: +3 -6 lines
Log Message:
added contexts to function files

File Contents

# Content
1 /* Copyright (c) 1991 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * p_data.c - routine for stored patterns.
9 *
10 * 6/4/86
11 */
12
13 #include "ray.h"
14
15 #include "data.h"
16
17 /*
18 * A stored pattern can either be brightness or
19 * color data. Brightness data is specified as:
20 *
21 * modifier brightdata name
22 * 4+ func dfname vfname v0 v1 .. xf
23 * 0
24 * n A1 A2 ..
25 *
26 * Color data is specified as:
27 *
28 * modifier colordata name
29 * 8+ rfunc gfunc bfunc rdfname gdfname bdfname vfname v0 v1 .. xf
30 * 0
31 * n A1 A2 ..
32 *
33 * Color picture data is specified as:
34 *
35 * modifier colorpict name
36 * 7+ rfunc gfunc bfunc pfname vfname vx vy xf
37 * 0
38 * n A1 A2 ..
39 *
40 * Vfname is the name of the file where the variable definitions
41 * can be found. The list of real arguments can be accessed by
42 * definitions in the file. The dfnames are the data file
43 * names. The dimensions of the data files and the number
44 * of variables must match. The funcs take a single argument
45 * for brightdata, and three for colordata and colorpict to produce
46 * interpolated values from the file. The xf is a transformation
47 * to get from the original coordinates to the current coordinates.
48 */
49
50
51 p_bdata(m, r) /* interpolate brightness data */
52 register OBJREC *m;
53 RAY *r;
54 {
55 extern double varvalue(), funvalue(), datavalue();
56 extern int errno;
57 int nv;
58 double bval;
59 double pt[MAXDIM];
60 DATARRAY *dp;
61 register char **sa;
62
63 setfunc(m, r);
64
65 sa = m->oargs.sarg;
66
67 if (m->oargs.nsargs < 4)
68 objerror(m, USER, "bad # arguments");
69 funcfile(sa[2]);
70 errno = 0;
71 for (nv = 0; nv+3 < m->oargs.nsargs &&
72 sa[nv+3][0] != '-'; nv++) {
73 if (nv >= MAXDIM)
74 goto dimerr;
75 pt[nv] = varvalue(sa[nv+3]);
76 }
77 if (errno)
78 goto computerr;
79 dp = getdata(sa[1]);
80 if (dp->nd != nv)
81 goto dimerr;
82 bval = datavalue(dp, pt);
83 errno = 0;
84 bval = funvalue(sa[0], 1, &bval);
85 if (errno)
86 goto computerr;
87 scalecolor(r->pcol, bval);
88 return;
89
90 dimerr:
91 objerror(m, USER, "dimension error");
92
93 computerr:
94 objerror(m, WARNING, "compute error");
95 return;
96 }
97
98
99 p_cdata(m, r) /* interpolate color data */
100 register OBJREC *m;
101 RAY *r;
102 {
103 extern double varvalue(), funvalue(), datavalue();
104 extern int errno;
105 int i, nv;
106 double col[3];
107 COLOR cval;
108 double pt[MAXDIM];
109 DATARRAY *dp;
110 register char **sa;
111
112 setfunc(m, r);
113
114 sa = m->oargs.sarg;
115
116 if (m->oargs.nsargs < 8)
117 objerror(m, USER, "bad # arguments");
118 funcfile(sa[6]);
119 for (nv = 0; nv+7 < m->oargs.nsargs &&
120 sa[nv+7][0] != '-'; nv++) {
121 if (nv >= MAXDIM)
122 goto dimerr;
123 errno = 0;
124 pt[nv] = varvalue(sa[nv+7]);
125 if (errno)
126 goto computerr;
127 }
128 for (i = 0; i < 3; i++) {
129 dp = getdata(sa[i+3]);
130 if (dp->nd != nv)
131 goto dimerr;
132 col[i] = datavalue(dp, pt);
133 }
134 errno = 0;
135 setcolor(cval, funvalue(sa[0], 3, col),
136 funvalue(sa[1], 3, col),
137 funvalue(sa[2], 3, col));
138 if (errno)
139 goto computerr;
140 multcolor(r->pcol, cval);
141 return;
142
143 dimerr:
144 objerror(m, USER, "dimension error");
145
146 computerr:
147 objerror(m, WARNING, "compute error");
148 return;
149 }
150
151
152 p_pdata(m, r) /* interpolate picture data */
153 register OBJREC *m;
154 RAY *r;
155 {
156 extern double varvalue(), funvalue(), datavalue();
157 extern int errno;
158 int i;
159 double col[3];
160 COLOR cval;
161 double pt[2];
162 DATARRAY *dp;
163 register char **sa;
164
165 setfunc(m, r);
166
167 sa = m->oargs.sarg;
168
169 if (m->oargs.nsargs < 7)
170 objerror(m, USER, "bad # arguments");
171 funcfile(sa[4]);
172 errno = 0;
173 pt[1] = varvalue(sa[5]); /* y major ordering */
174 pt[0] = varvalue(sa[6]);
175 if (errno)
176 goto computerr;
177 dp = getpict(sa[3]);
178 for (i = 0; i < 3; i++)
179 col[i] = datavalue(dp+i, pt);
180 errno = 0;
181 setcolor(cval, funvalue(sa[0], 3, col),
182 funvalue(sa[1], 3, col),
183 funvalue(sa[2], 3, col));
184 if (errno)
185 goto computerr;
186 multcolor(r->pcol, cval);
187 return;
188
189 computerr:
190 objerror(m, WARNING, "compute error");
191 return;
192 }