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.15 by greg, Sat Feb 22 02:07:28 2003 UTC vs.
Revision 2.27 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
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 < */
8 > #include "copyright.h"
9  
10 < #include  "standard.h"
10 > #include  <time.h>
11  
12 + #include  "platform.h"
13 + #include  "standard.h"
14   #include  "color.h"
68
15   #include  "resolu.h"
16 <
16 > #include  "view.h"
17   #include  "data.h"
18  
19                                  /* picture memory usage before warning */
20   #ifndef PSIZWARN
21 < #ifdef BIGMEM
76 < #define PSIZWARN        5000000
77 < #else
21 > #ifdef SMLMEM
22   #define PSIZWARN        1500000
23 + #else
24 + #define PSIZWARN        5000000
25   #endif
26   #endif
27  
# Line 88 | Line 34 | static const char      RCSid[] = "$Id$";
34  
35   static DATARRAY  *dtab[TABSIZ];         /* data array list */
36  
37 + static gethfunc headaspect;
38  
39 < DATARRAY *
40 < getdata(dname)                          /* get data array dname */
41 < char  *dname;
39 >
40 > extern DATARRAY *
41 > getdata(                                /* get data array dname */
42 >        char  *dname
43 > )
44   {
45          char  *dfname;
46          FILE  *fp;
# Line 122 | Line 71 | char  *dname;
71           *              0 0 ni p0i p1i .. pni
72           */
73  
74 <        if ((dfname = getpath(dname, getlibpath(), R_OK)) == NULL) {
74 >        if ((dfname = getpath(dname, getrlibpath(), R_OK)) == NULL) {
75                  sprintf(errmsg, "cannot find data file \"%s\"", dname);
76                  error(USER, errmsg);
77          }
# Line 133 | Line 82 | char  *dname;
82                                                          /* get dimensions */
83          if (fgetval(fp, 'i', (char *)&asize) <= 0)
84                  goto scanerr;
85 <        if (asize <= 0 | asize > MAXDDIM) {
85 >        if ((asize <= 0) | (asize > MAXDDIM)) {
86                  sprintf(errmsg, "bad number of dimensions for \"%s\"", dname);
87                  error(USER, errmsg);
88          }
# Line 189 | Line 138 | scanerr:
138          sprintf(errmsg, "%s in data file \"%s\"",
139                          feof(fp) ? "unexpected EOF" : "bad format", dfname);
140          error(USER, errmsg);
141 +        return NULL; /* pro forma return */
142   }
143  
144  
145   static int
146 < headaspect(s, iap)                      /* check string for aspect ratio */
147 < char  *s;
148 < double  *iap;
146 > headaspect(                     /* check string for aspect ratio */
147 >        char  *s,
148 >        void  *iap
149 > )
150   {
151          char    fmt[32];
152  
153          if (isaspect(s))
154 <                *iap *= aspectval(s);
154 >                *(double*)iap *= aspectval(s);
155          else if (formatval(fmt, s) && !globmatch(PICFMT, fmt))
156 <                *iap = 0.0;
156 >                *(double*)iap = 0.0;
157          return(0);
158   }
159  
160  
161 < DATARRAY *
162 < getpict(pname)                          /* get picture pname */
163 < char  *pname;
161 > extern DATARRAY *
162 > getpict(                                /* get picture pname */
163 >        char  *pname
164 > )
165   {
166          double  inpaspect;
167          char  *pfname;
# Line 217 | Line 169 | char  *pname;
169          COLR  *scanin;
170          int  sl, ns;
171          RESOLU  inpres;
172 <        FLOAT  loc[2];
172 >        RREAL  loc[2];
173          int  y;
174          register int  x, i;
175          register DATARRAY  *pp;
# Line 226 | Line 178 | char  *pname;
178                  if (!strcmp(pname, pp->name))
179                          return(pp);             /* found! */
180  
181 <        if ((pfname = getpath(pname, getlibpath(), R_OK)) == NULL) {
181 >        if ((pfname = getpath(pname, getrlibpath(), R_OK)) == NULL) {
182                  sprintf(errmsg, "cannot find picture file \"%s\"", pname);
183                  error(USER, errmsg);
184          }
# Line 239 | Line 191 | char  *pname;
191                  sprintf(errmsg, "cannot open picture file \"%s\"", pfname);
192                  error(SYSTEM, errmsg);
193          }
194 < #ifdef MSDOS
243 <        setmode(fileno(fp), O_BINARY);
244 < #endif
194 >        SET_FILE_BINARY(fp);
195                                                  /* get dimensions */
196          inpaspect = 1.0;
197 <        getheader(fp, headaspect, (char *)&inpaspect);
197 >        getheader(fp, headaspect, &inpaspect);
198          if (inpaspect <= FTINY || !fgetsresolu(&inpres, fp))
199                  goto readerr;
200          pp[0].nd = 2;
# Line 291 | Line 241 | char  *pname;
241          fclose(fp);
242          i = hash(pname);
243          pp[0].next = dtab[i];           /* link into picture list */
244 <        copystruct(&pp[1], &pp[0]);
245 <        copystruct(&pp[2], &pp[0]);
244 >        pp[1] = pp[0];
245 >        pp[2] = pp[0];
246          pp[0].type = RED;               /* differentiate RGB records */
247          pp[1].type = GRN;
248          pp[2].type = BLU;
# Line 303 | Line 253 | memerr:
253   readerr:
254          sprintf(errmsg, "bad picture file \"%s\"", pfname);
255          error(USER, errmsg);
256 +        return NULL; /* pro forma return */
257   }
258  
259  
260 < void
261 < freedata(dta)                   /* release data array reference */
262 < DATARRAY  *dta;
260 > extern void
261 > freedata(                       /* release data array reference */
262 >        DATARRAY  *dta
263 > )
264   {
265          DATARRAY  head;
266          int  hval, nents;
# Line 324 | Line 276 | DATARRAY  *dta;
276                  head.next = dtab[hval];
277                  dpl = &head;
278                  while ((dp = dpl->next) != NULL)
279 <                        if ((dta == NULL | dta == dp)) {
279 >                        if ((dta == NULL) | (dta == dp)) {
280                                  dpl->next = dp->next;
281                                  if (dp->type == DATATY)
282                                          free((void *)dp->arr.d);
# Line 342 | Line 294 | DATARRAY  *dta;
294   }
295  
296  
297 < double
298 < datavalue(dp, pt)               /* interpolate data value at a point */
299 < register DATARRAY  *dp;
300 < double  *pt;
297 > extern double
298 > datavalue(              /* interpolate data value at a point */
299 >        register DATARRAY  *dp,
300 >        double  *pt
301 > )
302   {
303          DATARRAY  sd;
304          int  asize;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines