--- ray/src/gen/mkillum.c 2003/03/11 19:29:05 2.12 +++ ray/src/gen/mkillum.c 2003/11/16 10:29:38 2.19 @@ -1,16 +1,17 @@ #ifndef lint -static const char RCSid[] = "$Id: mkillum.c,v 2.12 2003/03/11 19:29:05 greg Exp $"; +static const char RCSid[] = "$Id: mkillum.c,v 2.19 2003/11/16 10:29:38 schorsch Exp $"; #endif /* * Make illum sources for optimizing rendering process */ -#include "mkillum.h" - #include - #include +#include "platform.h" +#include "mkillum.h" +#include "random.h" + /* default parameters */ #define SAMPDENS 48 /* points per projected steradian */ #define NSAMPS 32 /* samples per point */ @@ -24,7 +25,7 @@ static const char RCSid[] = "$Id: mkillum.c,v 2.12 200 /* rtrace command and defaults */ char *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-dv-", - "-ab", "2", "-ad", "256", "-as", "128", "-aa", ".15", }; + "-ab", "2", "-ad", "1024", "-as", "512", "-aa", ".1", }; int rtargc = 14; /* overriding rtrace options */ char *myrtopts[] = { "-I-", "-i-", "-ld-", "-ov", "-h-", @@ -57,10 +58,19 @@ int doneheader = 0; /* printed header yet? */ int warnings = 1; /* print warnings? */ +void init(void); +void filter(register FILE *infp, char *name); +void xoptions(char *s, char *nm); +void printopts(void); +void printhead(register int ac, register char **av); +void xobject(FILE *fp, char *nm); -main(argc, argv) /* compute illum distributions using rtrace */ -int argc; -char *argv[]; + +int +main( /* compute illum distributions using rtrace */ + int argc, + char *argv[] +) { char *rtpath; FILE *fp; @@ -126,7 +136,7 @@ char *argv[]; } else filter(stdin, "standard input"); - quit(0); + return 0; } @@ -136,18 +146,19 @@ int status; { int rtstat; - rtstat = close_process(rt.pd); - if (status == 0) + rtstat = close_process(&(rt.pd)); + if (status == 0) { if (rtstat < 0) error(WARNING, "unknown return status from rtrace process"); else status = rtstat; + } exit(status); } - -init() /* start rtrace and set up buffers */ +void +init(void) /* start rtrace and set up buffers */ { extern int o_face(), o_sphere(), o_ring(); int maxbytes; @@ -156,10 +167,12 @@ init() /* start rtrace and set up buffers */ ofun[OBJ_SPHERE].funp = o_sphere; ofun[OBJ_RING].funp = o_ring; /* set up signal handling */ +#ifdef SIGPIPE /* not present on Windows */ signal(SIGPIPE, quit); +#endif /* start rtrace process */ errno = 0; - maxbytes = open_process(rt.pd, rtargv); + maxbytes = open_process(&(rt.pd), rtargv); if (maxbytes == 0) { eputs(rtargv[0]); eputs(": command not found\n"); @@ -179,8 +192,9 @@ init() /* start rtrace and set up buffers */ void -eputs(s) /* put string to stderr */ -register char *s; +eputs( /* put string to stderr */ + register char *s +) { static int midline = 0; @@ -203,9 +217,11 @@ char *s; } -filter(infp, name) /* process stream */ -register FILE *infp; -char *name; +void +filter( /* process stream */ + register FILE *infp, + char *name +) { char buf[512]; FILE *pfp; @@ -235,9 +251,11 @@ char *name; } -xoptions(s, nm) /* process options in string s */ -char *s; -char *nm; +void +xoptions( /* process options in string s */ + char *s, + char *nm +) { extern FILE *freopen(); char buf[64]; @@ -396,8 +414,8 @@ char *nm; printf("# %s", s+2); } - -printopts() /* print out option default values */ +void +printopts(void) /* print out option default values */ { printf("m=%-15s\t\t# material name\n", thisillum.matname); printf("f=%-15s\t\t# data file name\n", thisillum.datafile); @@ -418,9 +436,11 @@ printopts() /* print out option default values */ } -printhead(ac, av) /* print out header */ -register int ac; -register char **av; +void +printhead( /* print out header */ + register int ac, + register char **av +) { putchar('#'); while (ac-- > 0) { @@ -431,9 +451,11 @@ register char **av; } -xobject(fp, nm) /* translate an object from fp */ -FILE *fp; -char *nm; +void +xobject( /* translate an object from fp */ + FILE *fp, + char *nm +) { OBJREC thisobj; char str[MAXSTR];