ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/t_data.c
Revision: 2.7
Committed: Wed Mar 5 16:16:53 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.6: +2 -2 lines
Log Message:
Made errno checking explicit after math calls to avoid spurious warnings

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id$";
3 #endif
4 /*
5 * t_data.c - routine for stored textures
6 */
7
8 #include "copyright.h"
9
10 #include "ray.h"
11
12 #include "data.h"
13
14 #include "func.h"
15
16 /*
17 * A stored texture is specified as follows:
18 *
19 * modifier texdata name
20 * 8+ xfunc yfunc zfunc xdfname ydfname zdfname vfname v0 v1 .. xf
21 * 0
22 * n A1 A2 .. An
23 *
24 * Vfname is the name of the file where the variable definitions
25 * can be found. The list of real arguments can be accessed by
26 * definitions in the file. The dfnames are the data file
27 * names. The dimensions of the data files and the number
28 * of variables must match. The funcs take three arguments to produce
29 * interpolated values from the file. The xf is a transformation
30 * to get from the original coordinates to the current coordinates.
31 */
32
33
34 t_data(m, r) /* interpolate texture data */
35 register OBJREC *m;
36 RAY *r;
37 {
38 int nv;
39 FVECT disp;
40 double dval[3], pt[MAXDIM];
41 double d;
42 DATARRAY *dp;
43 register MFUNC *mf;
44 register int i;
45
46 if (m->oargs.nsargs < 8)
47 objerror(m, USER, "bad # arguments");
48 dp = getdata(m->oargs.sarg[3]);
49 i = (1 << (nv = dp->nd)) - 1;
50 mf = getfunc(m, 6, i<<7, 1);
51 setfunc(m, r);
52 errno = 0;
53 for (i = 0; i < nv; i++)
54 pt[i] = evalue(mf->ep[i]);
55 if (errno == EDOM || errno == ERANGE)
56 goto computerr;
57 dval[0] = datavalue(dp, pt);
58 for (i = 1; i < 3; i++) {
59 dp = getdata(m->oargs.sarg[i+3]);
60 if (dp->nd != nv)
61 objerror(m, USER, "dimension error");
62 dval[i] = datavalue(dp, pt);
63 }
64 errno = 0;
65 for (i = 0; i < 3; i++)
66 disp[i] = funvalue(m->oargs.sarg[i], 3, dval);
67 if (errno == EDOM || errno == ERANGE)
68 goto computerr;
69 if (mf->f != &unitxf)
70 multv3(disp, disp, mf->f->xfm);
71 if (r->rox != NULL) {
72 multv3(disp, disp, r->rox->f.xfm);
73 d = 1.0 / (mf->f->sca * r->rox->f.sca);
74 } else
75 d = 1.0 / mf->f->sca;
76 for (i = 0; i < 3; i++)
77 r->pert[i] += disp[i] * d;
78 return(0);
79 computerr:
80 objerror(m, WARNING, "compute error");
81 return(0);
82 }