--- ray/src/rt/data.c 1992/11/22 10:47:51 2.6 +++ ray/src/rt/data.c 1994/05/13 13:05:13 2.9 @@ -1,4 +1,4 @@ -/* Copyright (c) 1992 Regents of the University of California */ +/* Copyright (c) 1993 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -18,15 +18,25 @@ static char SCCSid[] = "$SunId$ LBL"; #include "data.h" + /* picture memory usage before warning */ +#ifndef PSIZWARN +#ifdef BIGMEM +#define PSIZWARN 3000000 +#else +#define PSIZWARN 1000000 +#endif +#endif +#ifndef TABSIZ #define TABSIZ 97 /* table size (prime) */ +#endif #define hash(s) (shash(s)%TABSIZ) extern char *fgetword(); -extern char *libpath; /* library search path */ +extern char *getlibpath(); /* library search path */ static DATARRAY *dtab[TABSIZ]; /* data array list */ @@ -68,7 +78,7 @@ char *dname; * 0 0 ni p0i p1i .. pni */ - if ((dfname = getpath(dname, libpath, R_OK)) == NULL) { + if ((dfname = getpath(dname, getlibpath(), R_OK)) == NULL) { sprintf(errmsg, "cannot find data file \"%s\"", dname); error(USER, errmsg); } @@ -159,7 +169,6 @@ DATARRAY * getpict(pname) /* get picture pname */ char *pname; { - extern char *libpath; double inpaspect; char *pfname; FILE *fp; @@ -175,7 +184,7 @@ char *pname; if (!strcmp(pname, pp->name)) return(pp); /* found! */ - if ((pfname = getpath(pname, libpath, R_OK)) == NULL) { + if ((pfname = getpath(pname, getlibpath(), R_OK)) == NULL) { sprintf(errmsg, "cannot find picture file \"%s\"", pname); error(USER, errmsg); } @@ -198,6 +207,15 @@ char *pname; getheader(fp, headaspect, &inpaspect); if (!fgetsresolu(&inpres, fp)) goto readerr; +#if PSIZWARN + /* check memory usage */ + i = 3*sizeof(DATATYPE)*inpres.xr*inpres.yr; + if (i > PSIZWARN) { + sprintf(errmsg, "picture file \"%s\" using %d bytes of memory", + pname, i); + error(WARNING, errmsg); + } +#endif for (i = 0; i < 3; i++) { pp[i].nd = 2; pp[i].dim[0].ne = inpres.yr; @@ -323,7 +341,7 @@ double *pt; int asize; int lower, upper; register int i; - double x, y, y0, y1; + double x, y0, y1; /* set up dimensions for recursion */ sd.nd = dp->nd - 1; asize = 1; @@ -336,7 +354,7 @@ double *pt; /* get independent variable */ if (dp->dim[0].p == NULL) { /* evenly spaced points */ x = (pt[0] - dp->dim[0].org)/dp->dim[0].siz; - x = x * (dp->dim[0].ne - 1); + x *= (double)(dp->dim[0].ne - 1); i = x; if (i < 0) i = 0; @@ -377,11 +395,10 @@ double *pt; * taper off harmonically to zero. */ if (x > i+2) - y = (2*y1-y0)/(x-i-1); - else if (x < i-1) - y = (2*y0-y1)/(i-x); - else - y = y0*((i+1)-x) + y1*(x-i); + return( (2*y1-y0)/(x-(i-1)) ); - return(y); + if (x < i-1) + return( (2*y0-y1)/(i-x) ); + + return( y0*((i+1)-x) + y1*(x-i) ); }