--- ray/src/gen/mkillum3.c 2003/11/16 10:29:38 2.9 +++ ray/src/gen/mkillum3.c 2016/09/15 22:34:41 2.14 @@ -1,11 +1,12 @@ #ifndef lint -static const char RCSid[] = "$Id"; +static const char RCSid[] = "$Id: mkillum3.c,v 2.14 2016/09/15 22:34:41 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]) @@ -14,23 +15,23 @@ char DATSUF[] = ".dat"; /* data file suffix */ char DSTSUF[] = ".dist"; /* distribution suffix */ char FNCFNM[] = "illum.cal"; /* function file name */ -void compinv(float *rinv, float *rp, int m); -void colorout(int p, float *da, int n, int m, double mult, FILE *fp); -void fputnum(double d, FILE *fp); -void brightout(float *da, int n, int m, double mult, FILE *fp); -void fputeol(FILE *fp); -void compavg(float col[3], float *da, int n); -char * dfname(struct illum_args *il, int c); -FILE * dfopen(struct illum_args *il, int c); +static void compinv(COLORV *rinv, COLORV *rp, int m); +static void colorout(int p, COLORV *da, int n, int m, double mult, FILE *fp); +static void fputnum(double d, FILE *fp); +static void brightout(COLORV *da, int n, int m, double mult, FILE *fp); +static void fputeol(FILE *fp); +static void compavg(COLOR col, COLORV *da, int n); +static char * dfname(struct illum_args *il, int c); +static FILE * dfopen(struct illum_args *il, int c); void printobj( /* print out an object */ char *mod, - register OBJREC *obj + OBJREC *obj ) { - register int i; + int i; if (issurface(obj->otype) && !strcmp(mod, VOIDID)) return; /* don't print void surfaces */ @@ -62,7 +63,7 @@ dfname( /* return data file name */ ) { char fname[MAXSTR]; - register char *s; + char *s; s = strcpy(fname, il->datafile); s += strlen(s); @@ -76,9 +77,9 @@ dfname( /* return data file name */ } -FILE * +static FILE * dfopen( /* open data file */ - register struct illum_args *il, + struct illum_args *il, int c ) { @@ -98,10 +99,10 @@ dfopen( /* open data file */ } -extern void +void flatout( /* write hemispherical distribution */ struct illum_args *il, - float *da, + COLORV *da, int n, int m, FVECT u, @@ -109,11 +110,11 @@ flatout( /* write hemispherical distribution */ 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) { @@ -151,24 +152,24 @@ flatout( /* write hemispherical distribution */ 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((void *)Ninv); + free(Ninv); } -extern void +void roundout( /* write spherical distribution */ struct illum_args *il, - float *da, + 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) + 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); @@ -206,14 +207,14 @@ roundout( /* write spherical distribution */ printf("\n\t%s il_alt il_azi", FNCFNM); printf("\n0\n0\n"); il->dfnum++; - free((void *)Ninv); - free((void *)Sinv); + free(Ninv); + free(Sinv); } -extern void +void illumout( /* print illum object */ - register struct illum_args *il, + struct illum_args *il, OBJREC *ob ) { @@ -242,35 +243,33 @@ illumout( /* print illum object */ } -void +static void compavg( /* compute average for set of data values */ - float col[3], - register float *da, + COLOR col, + COLORV *da, int n ) { - register int i; + 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); } -void +static void compinv( /* compute other side of row average */ - register float *rinv, - register float *rp, + COLORV *rinv, + COLORV *rp, int m ) { - float avg[3]; + COLOR avg; compavg(avg, rp, m); /* row average */ while (m-- > 0) { @@ -281,10 +280,10 @@ compinv( /* compute other side of row average */ } -extern int +int average( /* evaluate average value for distribution */ - register struct illum_args *il, - float *da, + struct illum_args *il, + COLORV *da, int n ) { @@ -301,7 +300,7 @@ average( /* evaluate average value for distribution * static int colmcnt = 0; /* count of columns written */ -void +static void fputnum( /* put out a number to fp */ double d, FILE *fp @@ -313,9 +312,9 @@ fputnum( /* put out a number to fp */ } -void +static void fputeol( /* write end of line to fp */ - register FILE *fp + FILE *fp ) { putc('\n', fp); @@ -323,17 +322,17 @@ fputeol( /* write end of line to fp */ } -void +static void colorout( /* put out color distribution data */ int p, - register float *da, + COLORV *da, int n, int m, double mult, FILE *fp ) { - register int i, j; + int i, j; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) { @@ -345,16 +344,16 @@ colorout( /* put out color distribution data */ } -void +static void brightout( /* put out brightness distribution data */ - register float *da, + COLORV *da, int n, int m, double mult, FILE *fp ) { - register int i, j; + int i, j; for (i = 0; i < n; i++) { for (j = 0; j < m; j++) {