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

Comparing ray/src/gen/mkillum3.c (file contents):
Revision 2.6 by greg, Wed Aug 12 14:24:08 1992 UTC vs.
Revision 2.13 by greg, Mon Aug 15 19:48:06 2011 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 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   * Routines to print mkillum objects
6   */
7  
8   #include  "mkillum.h"
9 + #include  "paths.h"
10  
11   #define  brt(col)       (.263*(col)[0]+.655*(col)[1]+.082*(col)[2])
12  
# Line 17 | Line 15 | char   DATSUF[] = ".dat";              /* data file suffix */
15   char    DSTSUF[] = ".dist";             /* distribution suffix */
16   char    FNCFNM[] = "illum.cal";         /* function file name */
17  
18 + void compinv(COLORV *rinv, COLORV *rp, int m);
19 + void colorout(int p, COLORV *da, int n, int m, double mult, FILE *fp);
20 + void fputnum(double d, FILE *fp);
21 + void brightout(COLORV *da, int n, int m, double mult, FILE *fp);
22 + void fputeol(FILE *fp);
23 + void compavg(COLOR col, COLORV *da, int n);
24 + char * dfname(struct illum_args *il, int c);
25 + FILE * dfopen(struct illum_args *il, int c);
26  
27 < printobj(mod, obj)              /* print out an object */
28 < char  *mod;
29 < register OBJREC  *obj;
27 >
28 > void
29 > printobj(               /* print out an object */
30 >        char  *mod,
31 >        register OBJREC  *obj
32 > )
33   {
34          register int  i;
35  
# Line 48 | Line 57 | register OBJREC  *obj;
57  
58  
59   char *
60 < dfname(il, c)                   /* return data file name */
61 < struct illum_args  *il;
62 < int  c;
60 > dfname(                 /* return data file name */
61 >        struct illum_args  *il,
62 >        int  c
63 > )
64   {
55        extern char  *getpath(), *strcpy();
65          char  fname[MAXSTR];
66          register char  *s;
67  
# Line 69 | Line 78 | int  c;
78  
79  
80   FILE *
81 < dfopen(il, c)                   /* open data file */
82 < register struct illum_args  *il;
83 < int  c;
81 > dfopen(                 /* open data file */
82 >        register struct illum_args  *il,
83 >        int  c
84 > )
85   {
86          char  *fn;
87          FILE  *fp;
# Line 89 | Line 99 | int  c;
99   }
100  
101  
102 < flatout(il, da, n, m, u, v, w)          /* write hemispherical distribution */
103 < struct illum_args  *il;
104 < float  *da;
105 < int  n, m;
106 < FVECT  u, v, w;
102 > extern void
103 > flatout(                /* write hemispherical distribution */
104 >        struct illum_args  *il,
105 >        COLORV  *da,
106 >        int  n,
107 >        int  m,
108 >        FVECT  u,
109 >        FVECT  v,
110 >        FVECT  w
111 > )
112   {
113 <        float  *Ninv;
113 >        COLORV  *Ninv;
114          FILE  *dfp;
115          int  i;
116  
117 <        if ((Ninv = (float *)malloc(3*m*sizeof(float))) == NULL)
117 >        if ((Ninv = (COLORV *)malloc(3*m*sizeof(COLORV))) == NULL)
118                  error(SYSTEM, "out of memory in flatout");
119          compinv(Ninv, da, m);
120          if (il->flags & IL_COLDST) {
# Line 137 | Line 152 | FVECT  u, v, w;
152          printf("\t%f\t%f\t%f\n", v[0], v[1], v[2]);
153          printf("\t%f\t%f\t%f\n", w[0], w[1], w[2]);
154          il->dfnum++;
155 <        free((char *)Ninv);
155 >        free(Ninv);
156   }
157  
158  
159 < roundout(il, da, n, m)                  /* write spherical distribution */
160 < struct illum_args  *il;
161 < float  *da;
162 < int  n, m;
159 > extern void
160 > roundout(                       /* write spherical distribution */
161 >        struct illum_args  *il,
162 >        COLORV  *da,
163 >        int  n,
164 >        int  m
165 > )
166   {
167 <        float  *Ninv, *Sinv;
167 >        COLORV  *Ninv, *Sinv;
168          FILE  *dfp;
169          int  i;
170  
171 <        if ((Ninv = (float *)malloc(3*m*sizeof(float))) == NULL ||
172 <                        (Sinv = (float *)malloc(3*m*sizeof(float))) == NULL)
171 >        if ((Ninv = (COLORV *)malloc(3*m*sizeof(COLORV))) == NULL ||
172 >                        (Sinv = (COLORV *)malloc(3*m*sizeof(COLORV))) == NULL)
173                  error(SYSTEM, "out of memory in roundout");
174          compinv(Ninv, da, m);
175          compinv(Sinv, da+3*m*(n-1), m);
# Line 189 | Line 207 | int  n, m;
207          printf("\n\t%s il_alt il_azi", FNCFNM);
208          printf("\n0\n0\n");
209          il->dfnum++;
210 <        free((char *)Ninv);
211 <        free((char *)Sinv);
210 >        free(Ninv);
211 >        free(Sinv);
212   }
213  
214  
215 < illumout(il, ob)                /* print illum object */
216 < register struct illum_args  *il;
217 < OBJREC  *ob;
215 > extern void
216 > illumout(               /* print illum object */
217 >        register struct illum_args  *il,
218 >        OBJREC  *ob
219 > )
220   {
221          double  cout[3];
222  
# Line 223 | Line 243 | OBJREC  *ob;
243   }
244  
245  
246 < compavg(col, da, n)             /* compute average for set of data values */
247 < float  col[3];
248 < register float  *da;
249 < int  n;
246 > void
247 > compavg(                /* compute average for set of data values */
248 >        COLOR  col,
249 >        register COLORV  *da,
250 >        int  n
251 > )
252   {
253          register int  i;
254  
255 <        col[0] = col[1] = col[2] = 0.;
255 >        setcolor(col, 0.0, 0.0, 0.0);
256          i = n;
257          while (i-- > 0) {
258 <                col[0] += *da++;
259 <                col[1] += *da++;
238 <                col[2] += *da++;
258 >                addcolor(col, da);
259 >                da += 3;
260          }
261 <        for (i = 0; i < 3; i++)
241 <                col[i] /= (double)n;
261 >        scalecolor(col, 1./(double)n);
262   }
263  
264  
265 < compinv(rinv, rp, m)            /* compute other side of row average */
266 < register float  *rinv, *rp;
267 < int  m;
265 > void
266 > compinv(                /* compute other side of row average */
267 >        register COLORV  *rinv,
268 >        register COLORV  *rp,
269 >        int  m
270 > )
271   {
272 <        float  avg[3];
272 >        COLOR  avg;
273  
274          compavg(avg, rp, m);            /* row average */
275          while (m-- > 0) {
# Line 257 | Line 280 | int  m;
280   }
281  
282  
283 < average(il, da, n)              /* evaluate average value for distribution */
284 < register struct illum_args  *il;
285 < float  *da;
286 < int  n;
283 > extern int
284 > average(                /* evaluate average value for distribution */
285 >        register struct illum_args  *il,
286 >        COLORV  *da,
287 >        int  n
288 > )
289   {
290          compavg(il->col, da, n);        /* average */
291          if (il->nsamps > 1) {
# Line 275 | Line 300 | int  n;
300  
301   static int      colmcnt = 0;    /* count of columns written */
302  
303 < fputnum(d, fp)                  /* put out a number to fp */
304 < double  d;
305 < FILE  *fp;
303 > void
304 > fputnum(                        /* put out a number to fp */
305 >        double  d,
306 >        FILE  *fp
307 > )
308   {
309          if (colmcnt++ % 5 == 0)
310                  putc('\n', fp);
# Line 285 | Line 312 | FILE  *fp;
312   }
313  
314  
315 < fputeol(fp)                     /* write end of line to fp */
316 < register FILE  *fp;
315 > void
316 > fputeol(                        /* write end of line to fp */
317 >        register FILE  *fp
318 > )
319   {
320          putc('\n', fp);
321          colmcnt = 0;
322   }
323  
324  
325 < colorout(p, da, n, m, mult, fp) /* put out color distribution data */
326 < int  p;
327 < register float  *da;
328 < int  n, m;
329 < double  mult;
330 < FILE  *fp;
325 > void
326 > colorout(       /* put out color distribution data */
327 >        int  p,
328 >        register COLORV  *da,
329 >        int  n,
330 >        int  m,
331 >        double  mult,
332 >        FILE  *fp
333 > )
334   {
335          register int  i, j;
336  
# Line 312 | Line 344 | FILE  *fp;
344   }
345  
346  
347 < brightout(da, n, m, mult, fp)   /* put out brightness distribution data */
348 < register float  *da;
349 < int  n, m;
350 < double  mult;
351 < FILE  *fp;
347 > void
348 > brightout(      /* put out brightness distribution data */
349 >        register COLORV  *da,
350 >        int  n,
351 >        int  m,
352 >        double  mult,
353 >        FILE  *fp
354 > )
355   {
356          register int  i, j;
357  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines