1 |
greg |
1.1 |
/* Copyright (c) 1988 Regents of the University of California */ |
2 |
|
|
|
3 |
|
|
#ifndef lint |
4 |
|
|
static char SCCSid[] = "$SunId$ LBL"; |
5 |
|
|
#endif |
6 |
|
|
|
7 |
|
|
/* |
8 |
|
|
* mx_data.c - routine for stored mixtures. |
9 |
|
|
* |
10 |
|
|
* 11/2/88 |
11 |
|
|
*/ |
12 |
|
|
|
13 |
|
|
#include "ray.h" |
14 |
|
|
|
15 |
|
|
#include "data.h" |
16 |
|
|
|
17 |
|
|
/* |
18 |
|
|
* A stored mixture is specified: |
19 |
|
|
* |
20 |
|
|
* modifier mixdata name |
21 |
|
|
* 6+ foremod backmod func dfname vfname v0 v1 .. xf |
22 |
|
|
* 0 |
23 |
|
|
* n A1 A2 .. |
24 |
|
|
* |
25 |
|
|
* Vfname is the name of the file where the variable definitions |
26 |
|
|
* can be found. The list of real arguments can be accessed by |
27 |
|
|
* definitions in the file. Dfname is the data file. |
28 |
|
|
* The dimensions of the data files and the number |
29 |
|
|
* of variables must match. The func is a single argument |
30 |
|
|
* function which returns the corrected data value given the |
31 |
|
|
* interpolated value from the file. The xf is a transformation |
32 |
|
|
* to get from the original coordinates to the current coordinates. |
33 |
|
|
*/ |
34 |
|
|
|
35 |
|
|
|
36 |
|
|
mx_data(m, r) /* interpolate mixture data */ |
37 |
|
|
register OBJREC *m; |
38 |
|
|
RAY *r; |
39 |
|
|
{ |
40 |
|
|
extern double varvalue(), funvalue(), datavalue(); |
41 |
|
|
extern int errno; |
42 |
|
|
register int i; |
43 |
|
|
double coef; |
44 |
|
|
double pt[MAXDIM]; |
45 |
|
|
DATARRAY *dp; |
46 |
|
|
OBJECT mod[2]; |
47 |
|
|
register char **sa; |
48 |
|
|
|
49 |
|
|
setfunc(m, r); |
50 |
|
|
|
51 |
|
|
sa = m->oargs.sarg; |
52 |
|
|
|
53 |
|
|
if (m->oargs.nsargs < 6) |
54 |
|
|
objerror(m, USER, "bad # arguments"); |
55 |
|
|
for (i = 0; i < 2; i++) |
56 |
|
|
if (!strcmp(sa[i], VOIDID)) |
57 |
|
|
mod[i] = OVOID; |
58 |
|
|
else if ((mod[i] = modifier(sa[i])) == OVOID) { |
59 |
|
|
sprintf(errmsg, "undefined modifier \"%s\"", sa[i]); |
60 |
|
|
objerror(m, USER, errmsg); |
61 |
|
|
} |
62 |
|
|
if (!vardefined(sa[5])) |
63 |
|
|
loadfunc(sa[4]); |
64 |
|
|
for (i = 0; i+5 < m->oargs.nsargs && |
65 |
|
|
sa[i+5][0] != '-'; i++) { |
66 |
|
|
if (i >= MAXDIM) |
67 |
|
|
objerror(m, USER, "dimension error"); |
68 |
|
|
errno = 0; |
69 |
|
|
pt[i] = varvalue(sa[i+5]); |
70 |
|
|
if (errno) |
71 |
|
|
goto computerr; |
72 |
|
|
} |
73 |
|
|
dp = getdata(sa[3]); |
74 |
|
|
if (dp->nd != i) |
75 |
|
|
objerror(m, USER, "dimension error"); |
76 |
|
|
coef = datavalue(dp, pt); |
77 |
|
|
errno = 0; |
78 |
|
|
coef = funvalue(sa[2], 1, &coef); |
79 |
|
|
if (errno) |
80 |
|
|
goto computerr; |
81 |
|
|
raymixture(r, mod[0], mod[1], coef); |
82 |
|
|
return; |
83 |
|
|
|
84 |
|
|
computerr: |
85 |
|
|
objerror(m, WARNING, "compute error"); |
86 |
|
|
} |