ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/mx_data.c
Revision: 2.3
Committed: Wed Jan 12 16:46:42 1994 UTC (30 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.2: +7 -2 lines
Log Message:
made mixtures work with materials

File Contents

# User Rev Content
1 greg 2.2 /* Copyright (c) 1991 Regents of the University of California */
2 greg 1.1
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 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     double coef;
43     double pt[MAXDIM];
44     DATARRAY *dp;
45     OBJECT mod[2];
46 greg 2.2 register MFUNC *mf;
47     register int i;
48 greg 1.1
49     if (m->oargs.nsargs < 6)
50     objerror(m, USER, "bad # arguments");
51     for (i = 0; i < 2; i++)
52 greg 2.2 if (!strcmp(m->oargs.sarg[i], VOIDID))
53 greg 1.1 mod[i] = OVOID;
54 greg 2.2 else if ((mod[i] = modifier(m->oargs.sarg[i])) == OVOID) {
55     sprintf(errmsg, "undefined modifier \"%s\"",
56     m->oargs.sarg[i]);
57 greg 1.1 objerror(m, USER, errmsg);
58     }
59 greg 2.2 dp = getdata(m->oargs.sarg[3]);
60     i = (1 << dp->nd) - 1;
61     mf = getfunc(m, 4, i<<5, 0);
62     setfunc(m, r);
63     errno = 0;
64     for (i = 0; i < dp->nd; i++) {
65     pt[i] = evalue(mf->ep[i]);
66 greg 1.1 if (errno)
67     goto computerr;
68     }
69     coef = datavalue(dp, pt);
70     errno = 0;
71 greg 2.2 coef = funvalue(m->oargs.sarg[2], 1, &coef);
72 greg 1.1 if (errno)
73     goto computerr;
74 greg 2.3 if (raymixture(r, mod[0], mod[1], coef)) {
75     if (m->omod != OVOID)
76     objerror(m, USER, "inappropriate modifier");
77     return(1);
78     }
79     return(0);
80 greg 1.1 computerr:
81     objerror(m, WARNING, "compute error");
82 greg 2.3 return(0);
83 greg 1.1 }