--- ray/src/rt/data.c 2003/06/08 12:03:10 2.20 +++ ray/src/rt/data.c 2013/08/07 05:10:09 2.30 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: data.c,v 2.20 2003/06/08 12:03:10 schorsch Exp $"; +static const char RCSid[] = "$Id: data.c,v 2.30 2013/08/07 05:10:09 greg Exp $"; #endif /* * data.c - routines dealing with interpolated data. @@ -7,18 +7,22 @@ static const char RCSid[] = "$Id: data.c,v 2.20 2003/0 #include "copyright.h" -#include "standard.h" +#include + #include "platform.h" +#include "paths.h" +#include "standard.h" #include "color.h" #include "resolu.h" +#include "view.h" #include "data.h" /* picture memory usage before warning */ #ifndef PSIZWARN #ifdef SMLMEM -#define PSIZWARN 1500000 +#define PSIZWARN 3000000 #else -#define PSIZWARN 5000000 +#define PSIZWARN 10000000 #endif #endif @@ -31,14 +35,17 @@ static const char RCSid[] = "$Id: data.c,v 2.20 2003/0 static DATARRAY *dtab[TABSIZ]; /* data array list */ +static gethfunc headaspect; -DATARRAY * -getdata(dname) /* get data array dname */ -char *dname; + +extern DATARRAY * +getdata( /* get data array dname */ + char *dname +) { char *dfname; FILE *fp; - int asize; + int asize=0; register int i, j; register DATARRAY *dp; /* look for array in list */ @@ -76,7 +83,7 @@ char *dname; /* get dimensions */ if (fgetval(fp, 'i', (char *)&asize) <= 0) goto scanerr; - if (asize <= 0 | asize > MAXDDIM) { + if ((asize <= 0) | (asize > MAXDDIM)) { sprintf(errmsg, "bad number of dimensions for \"%s\"", dname); error(USER, errmsg); } @@ -132,27 +139,30 @@ scanerr: sprintf(errmsg, "%s in data file \"%s\"", feof(fp) ? "unexpected EOF" : "bad format", dfname); error(USER, errmsg); + return NULL; /* pro forma return */ } static int -headaspect(s, iap) /* check string for aspect ratio */ -char *s; -double *iap; +headaspect( /* check string for aspect ratio */ + char *s, + void *iap +) { char fmt[32]; if (isaspect(s)) - *iap *= aspectval(s); + *(double*)iap *= aspectval(s); else if (formatval(fmt, s) && !globmatch(PICFMT, fmt)) - *iap = 0.0; + *(double*)iap = 0.0; return(0); } -DATARRAY * -getpict(pname) /* get picture pname */ -char *pname; +extern DATARRAY * +getpict( /* get picture pname */ + char *pname +) { double inpaspect; char *pfname; @@ -160,7 +170,7 @@ char *pname; COLR *scanin; int sl, ns; RESOLU inpres; - FLOAT loc[2]; + RREAL loc[2]; int y; register int x, i; register DATARRAY *pp; @@ -185,7 +195,7 @@ char *pname; SET_FILE_BINARY(fp); /* get dimensions */ inpaspect = 1.0; - getheader(fp, headaspect, (char *)&inpaspect); + getheader(fp, headaspect, &inpaspect); if (inpaspect <= FTINY || !fgetsresolu(&inpres, fp)) goto readerr; pp[0].nd = 2; @@ -208,8 +218,8 @@ char *pname; i = ns*sl*sizeof(COLR); #if PSIZWARN if (i > PSIZWARN) { /* memory warning */ - sprintf(errmsg, "picture file \"%s\" using %d bytes of memory", - pname, i); + sprintf(errmsg, "picture file \"%s\" using %.1f MB of memory", + pname, i*(1.0/(1024*1024))); error(WARNING, errmsg); } #endif @@ -232,8 +242,8 @@ char *pname; fclose(fp); i = hash(pname); pp[0].next = dtab[i]; /* link into picture list */ - copystruct(&pp[1], &pp[0]); - copystruct(&pp[2], &pp[0]); + pp[1] = pp[0]; + pp[2] = pp[0]; pp[0].type = RED; /* differentiate RGB records */ pp[1].type = GRN; pp[2].type = BLU; @@ -244,12 +254,14 @@ memerr: readerr: sprintf(errmsg, "bad picture file \"%s\"", pfname); error(USER, errmsg); + return NULL; /* pro forma return */ } -void -freedata(dta) /* release data array reference */ -DATARRAY *dta; +extern void +freedata( /* release data array reference */ + DATARRAY *dta +) { DATARRAY head; int hval, nents; @@ -265,7 +277,7 @@ DATARRAY *dta; head.next = dtab[hval]; dpl = &head; while ((dp = dpl->next) != NULL) - if ((dta == NULL | dta == dp)) { + if ((dta == NULL) | (dta == dp)) { dpl->next = dp->next; if (dp->type == DATATY) free((void *)dp->arr.d); @@ -283,10 +295,11 @@ DATARRAY *dta; } -double -datavalue(dp, pt) /* interpolate data value at a point */ -register DATARRAY *dp; -double *pt; +extern double +datavalue( /* interpolate data value at a point */ + register DATARRAY *dp, + double *pt +) { DATARRAY sd; int asize;