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.12 by greg, Thu Sep 13 17:52:35 2007 UTC vs.
Revision 2.15 by greg, Sat Dec 16 18:35:27 2023 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   #include  "mkillum.h"
9   #include  "paths.h"
10  
11 #define  brt(col)       (.263*(col)[0]+.655*(col)[1]+.082*(col)[2])
12
11   char    DATORD[] = "RGB";               /* data ordering */
12   char    DATSUF[] = ".dat";              /* data file suffix */
13   char    DSTSUF[] = ".dist";             /* distribution suffix */
14   char    FNCFNM[] = "illum.cal";         /* function file name */
15  
16 < void compinv(COLORV *rinv, COLORV *rp, int m);
17 < void colorout(int p, COLORV *da, int n, int m, double mult, FILE *fp);
18 < void fputnum(double d, FILE *fp);
19 < void brightout(COLORV *da, int n, int m, double mult, FILE *fp);
20 < void fputeol(FILE *fp);
21 < void compavg(COLOR col, COLORV *da, int n);
22 < char * dfname(struct illum_args *il, int c);
23 < FILE * dfopen(struct illum_args *il, int c);
16 > static void compinv(COLORV *rinv, COLORV *rp, int m);
17 > static void colorout(int p, COLORV *da, int n, int m, double mult, FILE *fp);
18 > static void fputnum(double d, FILE *fp);
19 > static void brightout(COLORV *da, int n, int m, double mult, FILE *fp);
20 > static void fputeol(FILE *fp);
21 > static void compavg(COLOR col, COLORV *da, int n);
22 > static char * dfname(struct illum_args *il, int c);
23 > static FILE * dfopen(struct illum_args *il, int c);
24  
25  
26   void
27   printobj(               /* print out an object */
28          char  *mod,
29 <        register OBJREC  *obj
29 >        OBJREC  *obj
30   )
31   {
32 <        register int  i;
32 >        int  i;
33  
34          if (issurface(obj->otype) && !strcmp(mod, VOIDID))
35                  return;         /* don't print void surfaces */
# Line 63 | Line 61 | dfname(                        /* return data file name */
61   )
62   {
63          char  fname[MAXSTR];
64 <        register char  *s;
64 >        char  *s;
65  
66          s = strcpy(fname, il->datafile);
67          s += strlen(s);
# Line 77 | Line 75 | dfname(                        /* return data file name */
75   }
76  
77  
78 < FILE *
78 > static FILE *
79   dfopen(                 /* open data file */
80 <        register struct illum_args  *il,
80 >        struct illum_args  *il,
81          int  c
82   )
83   {
# Line 99 | Line 97 | dfopen(                        /* open data file */
97   }
98  
99  
100 < extern void
100 > void
101   flatout(                /* write hemispherical distribution */
102          struct illum_args  *il,
103          COLORV  *da,
# Line 140 | Line 138 | flatout(               /* write hemispherical distribution */
138                  fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
139                                  1.+.5/n, .5/n, n+1,
140                                  0., 2.*PI, m+1);
141 <                brightout(Ninv, 1, m, 1./il->nsamps/brt(il->col), dfp);
142 <                brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp);
141 >                brightout(Ninv, 1, m, 1./il->nsamps/bright(il->col), dfp);
142 >                brightout(da, n, m, 1./il->nsamps/bright(il->col), dfp);
143                  fputeol(dfp);
144                  fclose(dfp);
145                  printf(" %s", dfname(il, 0));
# Line 152 | Line 150 | flatout(               /* write hemispherical distribution */
150          printf("\t%f\t%f\t%f\n", v[0], v[1], v[2]);
151          printf("\t%f\t%f\t%f\n", w[0], w[1], w[2]);
152          il->dfnum++;
153 <        free((void *)Ninv);
153 >        free(Ninv);
154   }
155  
156  
157 < extern void
157 > void
158   roundout(                       /* write spherical distribution */
159          struct illum_args  *il,
160          COLORV  *da,
# Line 197 | Line 195 | roundout(                      /* write spherical distribution */
195                  fprintf(dfp, "2\n%f %f %d\n%f %f %d\n",
196                                  1.+1./n, -1.-1./n, n+2,
197                                  0., 2.*PI, m+1);
198 <                brightout(Ninv, 1, m, 1./il->nsamps/brt(il->col), dfp);
199 <                brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp);
200 <                brightout(Sinv, 1, m, 1./il->nsamps/brt(il->col), dfp);
198 >                brightout(Ninv, 1, m, 1./il->nsamps/bright(il->col), dfp);
199 >                brightout(da, n, m, 1./il->nsamps/bright(il->col), dfp);
200 >                brightout(Sinv, 1, m, 1./il->nsamps/bright(il->col), dfp);
201                  fputeol(dfp);
202                  fclose(dfp);
203                  printf(" %s", dfname(il, 0));
# Line 207 | Line 205 | roundout(                      /* write spherical distribution */
205          printf("\n\t%s il_alt il_azi", FNCFNM);
206          printf("\n0\n0\n");
207          il->dfnum++;
208 <        free((void *)Ninv);
209 <        free((void *)Sinv);
208 >        free(Ninv);
209 >        free(Sinv);
210   }
211  
212  
213 < extern void
213 > void
214   illumout(               /* print illum object */
215 <        register struct illum_args  *il,
215 >        struct illum_args  *il,
216          OBJREC  *ob
217   )
218   {
# Line 235 | Line 233 | illumout(              /* print illum object */
233                  cout[1] = il->col[1];
234                  cout[2] = il->col[2];
235          } else {
236 <                cout[0] = cout[1] = cout[2] = brt(il->col);
236 >                cout[0] = cout[1] = cout[2] = bright(il->col);
237          }
238          printf("\n0\n3 %f %f %f\n", cout[0], cout[1], cout[2]);
239  
# Line 243 | Line 241 | illumout(              /* print illum object */
241   }
242  
243  
244 < void
244 > static void
245   compavg(                /* compute average for set of data values */
246          COLOR  col,
247 <        register COLORV  *da,
247 >        COLORV  *da,
248          int  n
249   )
250   {
251 <        register int  i;
251 >        int  i;
252  
253          setcolor(col, 0.0, 0.0, 0.0);
254          i = n;
# Line 262 | Line 260 | compavg(               /* compute average for set of data values */
260   }
261  
262  
263 < void
263 > static void
264   compinv(                /* compute other side of row average */
265 <        register COLORV  *rinv,
266 <        register COLORV  *rp,
265 >        COLORV  *rinv,
266 >        COLORV  *rp,
267          int  m
268   )
269   {
# Line 280 | Line 278 | compinv(               /* compute other side of row average */
278   }
279  
280  
281 < extern int
281 > int
282   average(                /* evaluate average value for distribution */
283 <        register struct illum_args  *il,
283 >        struct illum_args  *il,
284          COLORV  *da,
285          int  n
286   )
# Line 294 | Line 292 | average(               /* evaluate average value for distribution *
292                  il->col[2] /= (double)il->nsamps;
293          }
294                                          /* brighter than minimum? */
295 <        return(brt(il->col) > il->minbrt+FTINY);
295 >        return(bright(il->col) > il->minbrt+FTINY);
296   }
297  
298  
299   static int      colmcnt = 0;    /* count of columns written */
300  
301 < void
301 > static void
302   fputnum(                        /* put out a number to fp */
303          double  d,
304          FILE  *fp
# Line 312 | Line 310 | fputnum(                       /* put out a number to fp */
310   }
311  
312  
313 < void
313 > static void
314   fputeol(                        /* write end of line to fp */
315 <        register FILE  *fp
315 >        FILE  *fp
316   )
317   {
318          putc('\n', fp);
# Line 322 | Line 320 | fputeol(                       /* write end of line to fp */
320   }
321  
322  
323 < void
323 > static void
324   colorout(       /* put out color distribution data */
325          int  p,
326 <        register COLORV  *da,
326 >        COLORV  *da,
327          int  n,
328          int  m,
329          double  mult,
330          FILE  *fp
331   )
332   {
333 <        register int  i, j;
333 >        int  i, j;
334  
335          for (i = 0; i < n; i++) {
336                  for (j = 0; j < m; j++) {
# Line 344 | Line 342 | colorout(      /* put out color distribution data */
342   }
343  
344  
345 < void
345 > static void
346   brightout(      /* put out brightness distribution data */
347 <        register COLORV  *da,
347 >        COLORV  *da,
348          int  n,
349          int  m,
350          double  mult,
351          FILE  *fp
352   )
353   {
354 <        register int  i, j;
354 >        int  i, j;
355  
356          for (i = 0; i < n; i++) {
357                  for (j = 0; j < m; j++) {
358 <                        fputnum(mult*brt(da), fp);
358 >                        fputnum(mult*bright(da), fp);
359                          da += 3;
360                  }
361 <                fputnum(mult*brt(da-3*m), fp);  /* wrap phi */
361 >                fputnum(mult*bright(da-3*m), fp);       /* wrap phi */
362          }
363   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines