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

Comparing ray/src/rt/data.c (file contents):
Revision 1.11 by greg, Mon Nov 11 14:02:43 1991 UTC vs.
Revision 2.5 by greg, Sun Nov 22 10:02:57 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20  
21  
22   extern char  *fgetword();
23 extern double  atof();
23  
24   extern char  *libpath;                  /* library search path */
25  
26 < static DATARRAY  *dlist = NULL;         /* data array list */
26 > static DATARRAY  *dlist = NULL;         /* data array list */
27  
28 < static DATARRAY  *plist = NULL;         /* picture list */
28 > static DATARRAY  *plist = NULL;         /* picture list */
29  
30  
31   DATARRAY *
# Line 46 | Line 45 | char  *dname;
45  
46          /*
47           *      If we haven't loaded the data already, we will look
48 <         *  for it in the directorys specified by the library path.
48 >         *  for it in the directories specified by the library path.
49           *
50           *      The file has the following format:
51           *
# Line 140 | Line 139 | scanerr:
139   }
140  
141  
143 static double  inpaspect;               /* aspect ratio of input picture */
144
142   static
143 < headaspect(s)                           /* check string for aspect ratio */
143 > headaspect(s, iap)                      /* check string for aspect ratio */
144   char  *s;
145 + double  *iap;
146   {
147          if (isaspect(s))
148 <                inpaspect *= aspectval(s);
148 >                *iap *= aspectval(s);
149   }
150  
151  
# Line 156 | Line 154 | getpict(pname)                         /* get picture pname */
154   char  *pname;
155   {
156          extern char  *libpath;
157 +        double  inpaspect;
158          char  *pfname;
159          FILE  *fp;
160          COLOR  *scanin;
161          int  sl, ns;
162 <        RESOLU  inpres;
162 >        RESOLU  inpres;
163          FLOAT  loc[2];
164          int  y;
165          register int  x, i;
# Line 185 | Line 184 | char  *pname;
184                  sprintf(errmsg, "cannot open picture file \"%s\"", pfname);
185                  error(SYSTEM, errmsg);
186          }
187 + #ifdef MSDOS
188 +        setmode(fileno(fp), O_BINARY);
189 + #endif
190                                                  /* get dimensions */
191          inpaspect = 1.0;
192 <        getheader(fp, headaspect);
192 >        getheader(fp, headaspect, &inpaspect);
193          if (!fgetsresolu(&inpres, fp))
194                  goto readerr;
195          for (i = 0; i < 3; i++) {
# Line 246 | Line 248 | readerr:
248   freedata(dname)                 /* free memory associated with dname */
249   char  *dname;
250   {
251 +        DATARRAY  head;
252          register DATARRAY  *dp, *dpl;
253          register int  i;
254  
255 <        for (dpl = NULL, dp = dlist; dp != NULL; dpl = dp, dp = dp->next)
256 <                if (!strcmp(dname, dp->name)) {
257 <                        if (dpl == NULL)
258 <                                dlist = dp->next;
259 <                        else
257 <                                dpl->next = dp->next;
255 >        head.next = dlist;
256 >        dpl = &head;
257 >        while ((dp = dpl->next) != NULL)
258 >                if (dname == NULL || !strcmp(dname, dp->name)) {
259 >                        dpl->next = dp->next;
260                          free((char *)dp->arr);
261                          for (i = 0; i < dp->nd; i++)
262                                  if (dp->dim[i].p != NULL)
263                                          free((char *)dp->dim[i].p);
264                          freestr(dp->name);
265                          free((char *)dp);
266 <                        return;
267 <                }
266 >                } else
267 >                        dpl = dp;
268 >        dlist = head.next;
269   }
270  
271  
272   freepict(pname)                 /* free memory associated with pname */
273   char  *pname;
274   {
275 +        DATARRAY  head;
276          register DATARRAY  *pp, *ppl;
277  
278 <        for (ppl = NULL, pp = plist; pp != NULL; ppl = pp, pp = pp->next)
279 <                if (!strcmp(pname, pp->name)) {
280 <                        if (ppl == NULL)
281 <                                plist = pp->next;
282 <                        else
279 <                                ppl->next = pp->next;
278 >        head.next = plist;
279 >        ppl = &head;
280 >        while ((pp = ppl->next) != NULL)
281 >                if (pname == NULL || !strcmp(pname, pp->name)) {
282 >                        ppl->next = pp->next;
283                          free((char *)pp[0].arr);
284                          free((char *)pp[1].arr);
285                          free((char *)pp[2].arr);
286                          freestr(pp[0].name);
287                          free((char *)pp);
288 <                        return;
289 <                }
288 >                } else
289 >                        ppl = pp;
290 >        plist = head.next;
291   }
292  
293  
294   double
295   datavalue(dp, pt)               /* interpolate data value at a point */
296   register DATARRAY  *dp;
297 < double  *pt;
297 > double  *pt;
298   {
299          DATARRAY  sd;
300          int  asize;
301          int  lower, upper;
302          register int  i;
303 <        double  x, y, y0, y1;
303 >        double  x, y, y0, y1;
304                                          /* set up dimensions for recursion */
305          sd.nd = dp->nd - 1;
306          asize = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines