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.10 by greg, Tue Sep 28 17:54:18 2004 UTC vs.
Revision 2.14 by greg, Thu Sep 15 22:34:41 2016 UTC

# Line 6 | Line 6 | static const char RCSid[] = "$Id$";
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 14 | 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(float *rinv, float *rp, int m);
19 < void colorout(int p, float *da, int n, int m, double mult, FILE *fp);
20 < void fputnum(double d, FILE *fp);
21 < void brightout(float *da, int n, int m, double mult, FILE *fp);
22 < void fputeol(FILE *fp);
23 < void compavg(float col[3], float *da, int n);
24 < char * dfname(struct illum_args *il, int c);
25 < FILE * dfopen(struct illum_args *il, int c);
18 > static void compinv(COLORV *rinv, COLORV *rp, int m);
19 > static void colorout(int p, COLORV *da, int n, int m, double mult, FILE *fp);
20 > static void fputnum(double d, FILE *fp);
21 > static void brightout(COLORV *da, int n, int m, double mult, FILE *fp);
22 > static void fputeol(FILE *fp);
23 > static void compavg(COLOR col, COLORV *da, int n);
24 > static char * dfname(struct illum_args *il, int c);
25 > static FILE * dfopen(struct illum_args *il, int c);
26  
27  
28   void
29   printobj(               /* print out an object */
30          char  *mod,
31 <        register OBJREC  *obj
31 >        OBJREC  *obj
32   )
33   {
34 <        register int  i;
34 >        int  i;
35  
36          if (issurface(obj->otype) && !strcmp(mod, VOIDID))
37                  return;         /* don't print void surfaces */
# Line 62 | Line 63 | dfname(                        /* return data file name */
63   )
64   {
65          char  fname[MAXSTR];
66 <        register char  *s;
66 >        char  *s;
67  
68          s = strcpy(fname, il->datafile);
69          s += strlen(s);
# Line 76 | Line 77 | dfname(                        /* return data file name */
77   }
78  
79  
80 < FILE *
80 > static FILE *
81   dfopen(                 /* open data file */
82 <        register struct illum_args  *il,
82 >        struct illum_args  *il,
83          int  c
84   )
85   {
# Line 98 | Line 99 | dfopen(                        /* open data file */
99   }
100  
101  
102 < extern void
102 > void
103   flatout(                /* write hemispherical distribution */
104          struct illum_args  *il,
105 <        float  *da,
105 >        COLORV  *da,
106          int  n,
107          int  m,
108          FVECT  u,
# Line 109 | Line 110 | flatout(               /* write hemispherical distribution */
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 151 | Line 152 | flatout(               /* write hemispherical distribution */
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((void *)Ninv);
155 >        free(Ninv);
156   }
157  
158  
159 < extern void
159 > void
160   roundout(                       /* write spherical distribution */
161          struct illum_args  *il,
162 <        float  *da,
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 206 | Line 207 | roundout(                      /* write spherical distribution */
207          printf("\n\t%s il_alt il_azi", FNCFNM);
208          printf("\n0\n0\n");
209          il->dfnum++;
210 <        free((void *)Ninv);
211 <        free((void *)Sinv);
210 >        free(Ninv);
211 >        free(Sinv);
212   }
213  
214  
215 < extern void
215 > void
216   illumout(               /* print illum object */
217 <        register struct illum_args  *il,
217 >        struct illum_args  *il,
218          OBJREC  *ob
219   )
220   {
# Line 242 | Line 243 | illumout(              /* print illum object */
243   }
244  
245  
246 < void
246 > static void
247   compavg(                /* compute average for set of data values */
248 <        float  col[3],
249 <        register float  *da,
248 >        COLOR  col,
249 >        COLORV  *da,
250          int  n
251   )
252   {
253 <        register int  i;
253 >        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++;
259 <                col[2] += *da++;
258 >                addcolor(col, da);
259 >                da += 3;
260          }
261 <        for (i = 0; i < 3; i++)
262 <                col[i] /= (double)n;
261 >        scalecolor(col, 1./(double)n);
262   }
263  
264  
265 < void
265 > static void
266   compinv(                /* compute other side of row average */
267 <        register float  *rinv,
268 <        register float  *rp,
267 >        COLORV  *rinv,
268 >        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 281 | Line 280 | compinv(               /* compute other side of row average */
280   }
281  
282  
283 < extern int
283 > int
284   average(                /* evaluate average value for distribution */
285 <        register struct illum_args  *il,
286 <        float  *da,
285 >        struct illum_args  *il,
286 >        COLORV  *da,
287          int  n
288   )
289   {
# Line 301 | Line 300 | average(               /* evaluate average value for distribution *
300  
301   static int      colmcnt = 0;    /* count of columns written */
302  
303 < void
303 > static void
304   fputnum(                        /* put out a number to fp */
305          double  d,
306          FILE  *fp
# Line 313 | Line 312 | fputnum(                       /* put out a number to fp */
312   }
313  
314  
315 < void
315 > static void
316   fputeol(                        /* write end of line to fp */
317 <        register FILE  *fp
317 >        FILE  *fp
318   )
319   {
320          putc('\n', fp);
# Line 323 | Line 322 | fputeol(                       /* write end of line to fp */
322   }
323  
324  
325 < void
325 > static void
326   colorout(       /* put out color distribution data */
327          int  p,
328 <        register float  *da,
328 >        COLORV  *da,
329          int  n,
330          int  m,
331          double  mult,
332          FILE  *fp
333   )
334   {
335 <        register int  i, j;
335 >        int  i, j;
336  
337          for (i = 0; i < n; i++) {
338                  for (j = 0; j < m; j++) {
# Line 345 | Line 344 | colorout(      /* put out color distribution data */
344   }
345  
346  
347 < void
347 > static void
348   brightout(      /* put out brightness distribution data */
349 <        register float  *da,
349 >        COLORV  *da,
350          int  n,
351          int  m,
352          double  mult,
353          FILE  *fp
354   )
355   {
356 <        register int  i, j;
356 >        int  i, j;
357  
358          for (i = 0; i < n; i++) {
359                  for (j = 0; j < m; j++) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines