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