--- ray/src/util/makedist.c 1991/12/19 14:56:34 2.2 +++ ray/src/util/makedist.c 2004/03/26 21:36:19 2.5 @@ -1,9 +1,6 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: makedist.c,v 2.5 2004/03/26 21:36:19 schorsch Exp $"; #endif - /* * makedist.c - program to make a source distribution. * @@ -18,20 +15,21 @@ static char SCCSid[] = "$SunId$ LBL"; * Default axes are (x1,x2,x3) = (x,y,z). */ -#include +#include +#include +#include +#include +#include +#include +#include "rtmath.h" #include "random.h" - #include "setscan.h" #ifndef BSD #define vfork fork #endif -#define FTINY 1e-7 - -#define PI 3.14159265358979324 - #define atorad(a) ((PI/180.0) * (a)) char *rtargv[128] = {"rtrace", "-h"}; @@ -39,7 +37,6 @@ int rtargc = 2; #define passarg(s) (rtargv[rtargc++] = s) - /* default angles */ ANGLE alpha[181] = {10, 25, 40, 55, 70, 85, AEND}; ANGLE beta[361] = {0,30,60,90,120,150,180,210,240,270,300,330,AEND}; @@ -58,10 +55,21 @@ int header = 1; /* print header? */ char *progname; /* program name */ +static void printargs(int ac, char **av, FILE *fp); +static void fixaxes(void); +static int doscan(void); +static FILE * scanstart(void); +static int scanend(FILE *fp); +static void sendsamples(FILE *fp); +static void writesample(FILE *fp, ANGLE a, ANGLE b); +static double readsample(FILE *fp); -main(argc, argv) -int argc; -char *argv[]; + +int +main( + int argc, + char *argv[] +) { int i; @@ -210,13 +218,14 @@ badopt: fixaxes(); - if (header) - if (userformat > 0) + if (header) { + if (userformat > 0) { printf("Alpha\tBeta\tRadiance\n"); - else { + } else { printargs(argc, argv, stdout); putchar('\n'); } + } if (doscan() == -1) exit(1); @@ -225,10 +234,12 @@ badopt: } -printargs(ac, av, fp) /* print arguments to a file */ -int ac; -char **av; -FILE *fp; +static void +printargs( /* print arguments to a file */ + int ac, + char **av, + FILE *fp +) { while (ac-- > 0) { fputs(*av++, fp); @@ -238,9 +249,9 @@ FILE *fp; } -fixaxes() /* make sure axes are OK */ +static void +fixaxes(void) /* make sure axes are OK */ { - extern double normalize(), fdot(); double d; register int i; @@ -260,7 +271,8 @@ axerr: } -doscan() /* do scan for target */ +static int +doscan(void) /* do scan for target */ { FILE *fopen(), *scanstart(); double readsample(); @@ -278,8 +290,8 @@ doscan() /* do scan for target */ } -FILE * -scanstart() /* open scanner pipeline */ +static FILE * +scanstart(void) /* open scanner pipeline */ { int status; char *fgets(); @@ -334,8 +346,10 @@ err: } -scanend(fp) /* done with scanner input */ -FILE *fp; +static int +scanend( /* done with scanner input */ + FILE *fp +) { int status; @@ -348,8 +362,10 @@ FILE *fp; } -sendsamples(fp) /* send our samples to fp */ -FILE *fp; +static void +sendsamples( /* send our samples to fp */ + FILE *fp +) { ANGLE *a, *b; @@ -359,9 +375,12 @@ FILE *fp; } -writesample(fp, a, b) /* write out sample ray grid */ -FILE *fp; -ANGLE a, b; +static void +writesample( /* write out sample ray grid */ + FILE *fp, + ANGLE a, + ANGLE b +) { double sin(), cos(); float sp[6]; @@ -397,9 +416,10 @@ ANGLE a, b; } -double -readsample(fp) /* read in sample ray grid */ -FILE *fp; +static double +readsample( /* read in sample ray grid */ + FILE *fp +) { float col[3]; double sum;