ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/mx_data.c
Revision: 2.4
Committed: Mon Aug 10 18:35:14 1998 UTC (25 years, 8 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 2.3: +5 -3 lines
Log Message:
changed modifier checking to take most recent definition

File Contents

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