ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/mx_data.c
(Generate patch)

Comparing ray/src/rt/mx_data.c (file contents):
Revision 2.4 by gwlarson, Mon Aug 10 18:35:14 1998 UTC vs.
Revision 2.9 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  mx_data.c - routine for stored mixtures.
9 *
10 *     11/2/88
6   */
7  
8 < #include  "ray.h"
8 > #include "copyright.h"
9  
10 + #include  "ray.h"
11   #include  "data.h"
16
12   #include  "func.h"
13 + #include  "rtotypes.h"
14  
15   /*
16 < *      A stored mixture is specified:
16 > *  A stored mixture is specified:
17   *
18   *      modifier mixdata name
19   *      6+ foremod backmod func dfname vfname v0 v1 .. xf
20   *      0
21   *      n A1 A2 ..
22   *
23 + *  A picture mixture is specified as:
24 + *
25 + *      modifier mixpict name
26 + *      7+ foremod backmod func pfname vfname vx vy xf
27 + *      0
28 + *      n A1 A2 ..
29 + *
30 + *
31   *  Vfname is the name of the file where the variable definitions
32   *  can be found.  The list of real arguments can be accessed by
33   *  definitions in the file.  Dfname is the data file.
34 + *  (Pfname is a picture file.)
35   *  The dimensions of the data files and the number
36   *  of variables must match.  The func is a single argument
37 < *  function which returns the corrected data value given the
37 > *  function in the case of mixdata (three argument in the case
38 > *  of mixpict), which returns the corrected data value given the
39   *  interpolated value from the file.  The xf is a transformation
40   *  to get from the original coordinates to the current coordinates.
41   */
42  
43  
44 < mx_data(m, r)                   /* interpolate mixture data */
45 < register OBJREC  *m;
46 < RAY  *r;
44 > extern int
45 > mx_data(                        /* interpolate mixture data */
46 >        register OBJREC  *m,
47 >        RAY  *r
48 > )
49   {
50          OBJECT  obj;
51          double  coef;
# Line 65 | Line 73 | RAY  *r;
73          errno = 0;
74          for (i = 0; i < dp->nd; i++) {
75                  pt[i] = evalue(mf->ep[i]);
76 <                if (errno)
76 >                if (errno == EDOM || errno == ERANGE)
77                          goto computerr;
78          }
79          coef = datavalue(dp, pt);
80          errno = 0;
81          coef = funvalue(m->oargs.sarg[2], 1, &coef);
82 <        if (errno)
82 >        if (errno == EDOM || errno == ERANGE)
83 >                goto computerr;
84 >        if (raymixture(r, mod[0], mod[1], coef)) {
85 >                if (m->omod != OVOID)
86 >                        objerror(m, USER, "inappropriate modifier");
87 >                return(1);
88 >        }
89 >        return(0);
90 > computerr:
91 >        objerror(m, WARNING, "compute error");
92 >        return(0);
93 > }
94 >
95 >
96 > extern int
97 > mx_pdata(                       /* interpolate mixture picture */
98 >        register OBJREC  *m,
99 >        RAY  *r
100 > )
101 > {
102 >        OBJECT  obj;
103 >        double  col[3], coef;
104 >        double  pt[MAXDIM];
105 >        DATARRAY  *dp;
106 >        OBJECT  mod[2];
107 >        register MFUNC  *mf;
108 >        register int  i;
109 >
110 >        if (m->oargs.nsargs < 7)
111 >                objerror(m, USER, "bad # arguments");
112 >        obj = objndx(m);
113 >        for (i = 0; i < 2; i++)
114 >                if (!strcmp(m->oargs.sarg[i], VOIDID))
115 >                        mod[i] = OVOID;
116 >                else if ((mod[i] = lastmod(obj, m->oargs.sarg[i])) == OVOID) {
117 >                        sprintf(errmsg, "undefined modifier \"%s\"",
118 >                                        m->oargs.sarg[i]);
119 >                        objerror(m, USER, errmsg);
120 >                }
121 >        dp = getpict(m->oargs.sarg[3]);
122 >        mf = getfunc(m, 4, 0x3<<5, 0);
123 >        setfunc(m, r);
124 >        errno = 0;
125 >        pt[1] = evalue(mf->ep[0]);      /* y major ordering */
126 >        pt[0] = evalue(mf->ep[1]);
127 >        if (errno == EDOM || errno == ERANGE)
128 >                goto computerr;
129 >        for (i = 0; i < 3; i++)         /* get pixel from picture */
130 >                col[i] = datavalue(dp+i, pt);
131 >        errno = 0;                      /* evaluate function on pixel */
132 >        coef = funvalue(m->oargs.sarg[2], 3, col);
133 >        if (errno == EDOM || errno == ERANGE)
134                  goto computerr;
135          if (raymixture(r, mod[0], mod[1], coef)) {
136                  if (m->omod != OVOID)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines