--- ray/src/gen/mkillum3.c 1992/08/12 14:18:04 2.5 +++ ray/src/gen/mkillum3.c 2007/09/13 17:52:35 2.12 @@ -1,14 +1,12 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: mkillum3.c,v 2.12 2007/09/13 17:52:35 greg Exp $"; #endif - /* * Routines to print mkillum objects */ #include "mkillum.h" +#include "paths.h" #define brt(col) (.263*(col)[0]+.655*(col)[1]+.082*(col)[2]) @@ -17,10 +15,21 @@ char DATSUF[] = ".dat"; /* data file suffix */ char DSTSUF[] = ".dist"; /* distribution suffix */ char FNCFNM[] = "illum.cal"; /* function file name */ +void compinv(COLORV *rinv, COLORV *rp, int m); +void colorout(int p, COLORV *da, int n, int m, double mult, FILE *fp); +void fputnum(double d, FILE *fp); +void brightout(COLORV *da, int n, int m, double mult, FILE *fp); +void fputeol(FILE *fp); +void compavg(COLOR col, COLORV *da, int n); +char * dfname(struct illum_args *il, int c); +FILE * dfopen(struct illum_args *il, int c); -printobj(mod, obj) /* print out an object */ -char *mod; -register OBJREC *obj; + +void +printobj( /* print out an object */ + char *mod, + register OBJREC *obj +) { register int i; @@ -48,11 +57,11 @@ register OBJREC *obj; char * -dfname(il, c) /* return data file name */ -struct illum_args *il; -int c; +dfname( /* return data file name */ + struct illum_args *il, + int c +) { - extern char *getpath(), *strcpy(); char fname[MAXSTR]; register char *s; @@ -69,9 +78,10 @@ int c; FILE * -dfopen(il, c) /* open data file */ -register struct illum_args *il; -int c; +dfopen( /* open data file */ + register struct illum_args *il, + int c +) { char *fn; FILE *fp; @@ -89,17 +99,22 @@ int c; } -flatout(il, da, n, m, u, v, w) /* write hemispherical distribution */ -struct illum_args *il; -float *da; -int n, m; -FVECT u, v, w; +extern void +flatout( /* write hemispherical distribution */ + struct illum_args *il, + COLORV *da, + int n, + int m, + FVECT u, + FVECT v, + FVECT w +) { - float *Ninv; + COLORV *Ninv; FILE *dfp; int i; - if ((Ninv = (float *)malloc(3*m*sizeof(float))) == NULL) + if ((Ninv = (COLORV *)malloc(3*m*sizeof(COLORV))) == NULL) error(SYSTEM, "out of memory in flatout"); compinv(Ninv, da, m); if (il->flags & IL_COLDST) { @@ -122,7 +137,8 @@ FVECT u, v, w; il->matname, DSTSUF); printf("\n5 noneg"); dfp = dfopen(il, 0); - fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.+.5/n, .5/n, n+1, + fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", + 1.+.5/n, .5/n, n+1, 0., 2.*PI, m+1); brightout(Ninv, 1, m, 1./il->nsamps/brt(il->col), dfp); brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp); @@ -136,22 +152,25 @@ FVECT u, v, w; printf("\t%f\t%f\t%f\n", v[0], v[1], v[2]); printf("\t%f\t%f\t%f\n", w[0], w[1], w[2]); il->dfnum++; - free((char *)Ninv); + free((void *)Ninv); } -roundout(il, da, n, m) /* write spherical distribution */ -struct illum_args *il; -float *da; -int n, m; +extern void +roundout( /* write spherical distribution */ + struct illum_args *il, + COLORV *da, + int n, + int m +) { - float *Ninv, *Sinv; + COLORV *Ninv, *Sinv; FILE *dfp; int i; - if ((Ninv = (float *)malloc(3*m*sizeof(float))) == NULL || - (Sinv = (float *)malloc(3*m*sizeof(float))) == NULL) - error(SYSTEM, "out of memory in flatout"); + if ((Ninv = (COLORV *)malloc(3*m*sizeof(COLORV))) == NULL || + (Sinv = (COLORV *)malloc(3*m*sizeof(COLORV))) == NULL) + error(SYSTEM, "out of memory in roundout"); compinv(Ninv, da, m); compinv(Sinv, da+3*m*(n-1), m); if (il->flags & IL_COLDST) { @@ -175,7 +194,8 @@ int n, m; il->matname, DSTSUF); printf("\n5 noneg"); dfp = dfopen(il, 0); - fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", 1.-1./n, -1.+1./n, n, + fprintf(dfp, "2\n%f %f %d\n%f %f %d\n", + 1.+1./n, -1.-1./n, n+2, 0., 2.*PI, m+1); brightout(Ninv, 1, m, 1./il->nsamps/brt(il->col), dfp); brightout(da, n, m, 1./il->nsamps/brt(il->col), dfp); @@ -187,14 +207,16 @@ int n, m; printf("\n\t%s il_alt il_azi", FNCFNM); printf("\n0\n0\n"); il->dfnum++; - free((char *)Ninv); - free((char *)Sinv); + free((void *)Ninv); + free((void *)Sinv); } -illumout(il, ob) /* print illum object */ -register struct illum_args *il; -OBJREC *ob; +extern void +illumout( /* print illum object */ + register struct illum_args *il, + OBJREC *ob +) { double cout[3]; @@ -221,30 +243,33 @@ OBJREC *ob; } -compavg(col, da, n) /* compute average for set of data values */ -float col[3]; -register float *da; -int n; +void +compavg( /* compute average for set of data values */ + COLOR col, + register COLORV *da, + int n +) { register int i; - col[0] = col[1] = col[2] = 0.; + setcolor(col, 0.0, 0.0, 0.0); i = n; while (i-- > 0) { - col[0] += *da++; - col[1] += *da++; - col[2] += *da++; + addcolor(col, da); + da += 3; } - for (i = 0; i < 3; i++) - col[i] /= (double)n; + scalecolor(col, 1./(double)n); } -compinv(rinv, rp, m) /* compute other side of row average */ -register float *rinv, *rp; -int m; +void +compinv( /* compute other side of row average */ + register COLORV *rinv, + register COLORV *rp, + int m +) { - float avg[3]; + COLOR avg; compavg(avg, rp, m); /* row average */ while (m-- > 0) { @@ -255,10 +280,12 @@ int m; } -average(il, da, n) /* evaluate average value for distribution */ -register struct illum_args *il; -float *da; -int n; +extern int +average( /* evaluate average value for distribution */ + register struct illum_args *il, + COLORV *da, + int n +) { compavg(il->col, da, n); /* average */ if (il->nsamps > 1) { @@ -273,9 +300,11 @@ int n; static int colmcnt = 0; /* count of columns written */ -fputnum(d, fp) /* put out a number to fp */ -double d; -FILE *fp; +void +fputnum( /* put out a number to fp */ + double d, + FILE *fp +) { if (colmcnt++ % 5 == 0) putc('\n', fp); @@ -283,20 +312,25 @@ FILE *fp; } -fputeol(fp) /* write end of line to fp */ -register FILE *fp; +void +fputeol( /* write end of line to fp */ + register FILE *fp +) { putc('\n', fp); colmcnt = 0; } -colorout(p, da, n, m, mult, fp) /* put out color distribution data */ -int p; -register float *da; -int n, m; -double mult; -FILE *fp; +void +colorout( /* put out color distribution data */ + int p, + register COLORV *da, + int n, + int m, + double mult, + FILE *fp +) { register int i, j; @@ -310,11 +344,14 @@ FILE *fp; } -brightout(da, n, m, mult, fp) /* put out brightness distribution data */ -register float *da; -int n, m; -double mult; -FILE *fp; +void +brightout( /* put out brightness distribution data */ + register COLORV *da, + int n, + int m, + double mult, + FILE *fp +) { register int i, j;