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 2.14 by gwlarson, Thu Nov 5 17:11:56 1998 UTC vs.
Revision 2.15 by greg, Sat Feb 22 02:07:28 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1996 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  data.c - routines dealing with interpolated data.
6   */
7  
8 + /* ====================================================================
9 + * The Radiance Software License, Version 1.0
10 + *
11 + * Copyright (c) 1990 - 2002 The Regents of the University of California,
12 + * through Lawrence Berkeley National Laboratory.   All rights reserved.
13 + *
14 + * Redistribution and use in source and binary forms, with or without
15 + * modification, are permitted provided that the following conditions
16 + * are met:
17 + *
18 + * 1. Redistributions of source code must retain the above copyright
19 + *         notice, this list of conditions and the following disclaimer.
20 + *
21 + * 2. Redistributions in binary form must reproduce the above copyright
22 + *       notice, this list of conditions and the following disclaimer in
23 + *       the documentation and/or other materials provided with the
24 + *       distribution.
25 + *
26 + * 3. The end-user documentation included with the redistribution,
27 + *           if any, must include the following acknowledgment:
28 + *             "This product includes Radiance software
29 + *                 (http://radsite.lbl.gov/)
30 + *                 developed by the Lawrence Berkeley National Laboratory
31 + *               (http://www.lbl.gov/)."
32 + *       Alternately, this acknowledgment may appear in the software itself,
33 + *       if and wherever such third-party acknowledgments normally appear.
34 + *
35 + * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
36 + *       and "The Regents of the University of California" must
37 + *       not be used to endorse or promote products derived from this
38 + *       software without prior written permission. For written
39 + *       permission, please contact [email protected].
40 + *
41 + * 5. Products derived from this software may not be called "Radiance",
42 + *       nor may "Radiance" appear in their name, without prior written
43 + *       permission of Lawrence Berkeley National Laboratory.
44 + *
45 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
46 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 + * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
49 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
52 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
55 + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 + * SUCH DAMAGE.
57 + * ====================================================================
58 + *
59 + * This software consists of voluntary contributions made by many
60 + * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
61 + * information on Lawrence Berkeley National Laboratory, please see
62 + * <http://www.lbl.gov/>.
63 + */
64 +
65   #include  "standard.h"
66  
67   #include  "color.h"
# Line 32 | Line 86 | static char SCCSid[] = "$SunId$ LBL";
86   #define hash(s)         (shash(s)%TABSIZ)
87  
88  
35 extern char  *getlibpath();             /* library search path */
36
89   static DATARRAY  *dtab[TABSIZ];         /* data array list */
90  
91  
# Line 50 | Line 102 | char  *dname;
102          for (dp = dtab[hash(dname)]; dp != NULL; dp = dp->next)
103                  if (!strcmp(dname, dp->name))
104                          return(dp);             /* found! */
53
105          /*
106           *      If we haven't loaded the data already, we will look
107           *  for it in the directories specified by the library path.
# Line 80 | Line 131 | char  *dname;
131                  error(SYSTEM, errmsg);
132          }
133                                                          /* get dimensions */
134 <        if (fgetval(fp, 'i', &asize) <= 0)
134 >        if (fgetval(fp, 'i', (char *)&asize) <= 0)
135                  goto scanerr;
136          if (asize <= 0 | asize > MAXDDIM) {
137                  sprintf(errmsg, "bad number of dimensions for \"%s\"", dname);
# Line 93 | Line 144 | char  *dname;
144          dp->nd = asize;
145          asize = 1;
146          for (i = 0; i < dp->nd; i++) {
147 <                if (fgetval(fp, DATATY, &dp->dim[i].org) <= 0)
147 >                if (fgetval(fp, DATATY, (char *)&dp->dim[i].org) <= 0)
148                          goto scanerr;
149 <                if (fgetval(fp, DATATY, &dp->dim[i].siz) <= 0)
149 >                if (fgetval(fp, DATATY, (char *)&dp->dim[i].siz) <= 0)
150                          goto scanerr;
151 <                if (fgetval(fp, 'i', &dp->dim[i].ne) <= 0)
151 >                if (fgetval(fp, 'i', (char *)&dp->dim[i].ne) <= 0)
152                          goto scanerr;
153                  if (dp->dim[i].ne < 2)
154                          goto scanerr;
# Line 108 | Line 159 | char  *dname;
159                          if (dp->dim[i].p == NULL)
160                                  goto memerr;
161                          for (j = 0; j < dp->dim[i].ne; j++)
162 <                                if (fgetval(fp, DATATY, &dp->dim[i].p[j]) <= 0)
162 >                                if (fgetval(fp, DATATY,
163 >                                                (char *)&dp->dim[i].p[j]) <= 0)
164                                          goto scanerr;
165                          for (j = 1; j < dp->dim[i].ne-1; j++)
166                                  if ((dp->dim[i].p[j-1] < dp->dim[i].p[j]) !=
# Line 124 | Line 176 | char  *dname;
176                  goto memerr;
177          
178          for (i = 0; i < asize; i++)
179 <                if (fgetval(fp, DATATY, &dp->arr.d[i]) <= 0)
179 >                if (fgetval(fp, DATATY, (char *)&dp->arr.d[i]) <= 0)
180                          goto scanerr;
181          fclose(fp);
182          i = hash(dname);
# Line 140 | Line 192 | scanerr:
192   }
193  
194  
195 < static
195 > static int
196   headaspect(s, iap)                      /* check string for aspect ratio */
197   char  *s;
198   double  *iap;
# Line 149 | Line 201 | double  *iap;
201  
202          if (isaspect(s))
203                  *iap *= aspectval(s);
204 <        else if (formatval(fmt, s) && strcmp(fmt, COLRFMT))
204 >        else if (formatval(fmt, s) && !globmatch(PICFMT, fmt))
205                  *iap = 0.0;
206          return(0);
207   }
# Line 192 | Line 244 | char  *pname;
244   #endif
245                                                  /* get dimensions */
246          inpaspect = 1.0;
247 <        getheader(fp, headaspect, &inpaspect);
247 >        getheader(fp, headaspect, (char *)&inpaspect);
248          if (inpaspect <= FTINY || !fgetsresolu(&inpres, fp))
249                  goto readerr;
250          pp[0].nd = 2;
# Line 235 | Line 287 | char  *pname;
287                          copycolr(pp[0].arr.c[i], scanin[x]);
288                  }
289          }
290 <        free((char *)scanin);
290 >        free((void *)scanin);
291          fclose(fp);
292          i = hash(pname);
293          pp[0].next = dtab[i];           /* link into picture list */
# Line 254 | Line 306 | readerr:
306   }
307  
308  
309 < freedata(dname)                 /* free memory associated with dname */
310 < char  *dname;
309 > void
310 > freedata(dta)                   /* release data array reference */
311 > DATARRAY  *dta;
312   {
313          DATARRAY  head;
314          int  hval, nents;
315 <        register DATARRAY  *dp, *dpl;
315 >        register DATARRAY  *dpl, *dp;
316          register int  i;
317  
318 <        if (dname == NULL) {                    /* free all if NULL */
318 >        if (dta == NULL) {                      /* free all if NULL */
319                  hval = 0; nents = TABSIZ;
320          } else {
321 <                hval = hash(dname); nents = 1;
321 >                hval = hash(dta->name); nents = 1;
322          }
323          while (nents--) {
324                  head.next = dtab[hval];
325                  dpl = &head;
326                  while ((dp = dpl->next) != NULL)
327 <                        if (dname == NULL || !strcmp(dname, dp->name)) {
327 >                        if ((dta == NULL | dta == dp)) {
328                                  dpl->next = dp->next;
329                                  if (dp->type == DATATY)
330 <                                        free((char *)dp->arr.d);
330 >                                        free((void *)dp->arr.d);
331                                  else
332 <                                        free((char *)dp->arr.c);
332 >                                        free((void *)dp->arr.c);
333                                  for (i = 0; i < dp->nd; i++)
334                                          if (dp->dim[i].p != NULL)
335 <                                                free((char *)dp->dim[i].p);
335 >                                                free((void *)dp->dim[i].p);
336                                  freestr(dp->name);
337 <                                free((char *)dp);
337 >                                free((void *)dp);
338                          } else
339                                  dpl = dp;
340                  dtab[hval++] = head.next;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines