--- ray/src/util/findglare.c 2003/02/22 02:07:30 2.9 +++ ray/src/util/findglare.c 2014/07/29 21:36:08 2.14 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: findglare.c,v 2.9 2003/02/22 02:07:30 greg Exp $"; +static const char RCSid[] = "$Id: findglare.c,v 2.14 2014/07/29 21:36:08 greg Exp $"; #endif /* * Find glare sources in a scene or image. @@ -39,10 +39,19 @@ struct illum *indirect; /* array of indirect illumina long npixinvw; /* number of pixels in view */ long npixmiss; /* number of pixels missed */ +static int angcmp(const void *ap1, const void *ap2); +static void init(void); +static void cleanup(void); +static void printsources(void); +static void printillum(void); -main(argc, argv) -int argc; -char *argv[]; + + +int +main( + int argc, + char *argv[] +) { int combine = 1; int gotview = 0; @@ -56,7 +65,7 @@ char *argv[]; while ((rval = expandarg(&argc, &argv, i)) > 0) ; if (rval < 0) { - fprintf(stderr, "%s: cannot expand '%s'", + fprintf(stderr, "%s: cannot expand '%s'\n", argv[0], argv[i]); exit(1); } @@ -120,10 +129,13 @@ char *argv[]; /* FALL THROUGH */ case 's': case 'P': + case 'n': rtargv[rtargc++] = argv[i]; rtargv[rtargc++] = argv[++i]; break; case 'w': + case 'u': + case 'b': rtargv[rtargc++] = argv[i]; break; case 'a': @@ -134,6 +146,14 @@ char *argv[]; } rtargv[rtargc++] = argv[++i]; break; + case 'm': + rtargv[rtargc++] = argv[i]; + if ((argv[i][2] == 'e') | (argv[i][2] == 'a')) { + rtargv[rtargc++] = argv[++i]; + rtargv[rtargc++] = argv[++i]; + } + rtargv[rtargc++] = argv[++i]; + break; default: goto userr; } @@ -174,7 +194,7 @@ char *argv[]; progname); exit(1); } - copystruct(&ourview, &pictview); + ourview = pictview; } else if (picture != NULL && !VEQ(ourview.vp, pictview.vp)) { fprintf(stderr, "%s: picture must have same viewpoint\n", progname); @@ -221,14 +241,16 @@ userr: } -int -angcmp(ap1, ap2) /* compare two angles */ -ANGLE *ap1, *ap2; +static int +angcmp( /* compare two angles */ + const void *ap1, + const void *ap2 +) { register int a1, a2; - a1 = *ap1; - a2 = *ap2; + a1 = *(ANGLE *)ap1; + a2 = *(ANGLE *)ap2; if (a1 == a2) { fprintf(stderr, "%s: duplicate glare angle (%d)\n", progname, a1); @@ -238,7 +260,8 @@ ANGLE *ap1, *ap2; } -init() /* initialize global variables */ +static void +init(void) /* initialize global variables */ { double d; register int i; @@ -269,8 +292,8 @@ init() /* initialize global variables */ if (indirect == NULL) memerr("indirect illuminances"); npixinvw = npixmiss = 0L; - copystruct(&leftview, &ourview); - copystruct(&rightview, &ourview); + leftview = ourview; + rightview = ourview; spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta); spinvector(rightview.vdir, ourview.vdir, ourview.vup, -maxtheta); setview(&leftview); @@ -314,7 +337,8 @@ init() /* initialize global variables */ } -cleanup() /* close files, wait for children */ +static void +cleanup(void) /* close files, wait for children */ { if (verbose) fprintf(stderr, "%s: cleaning up... \n", progname); @@ -328,9 +352,12 @@ cleanup() /* close files, wait for children */ } -compdir(vd, x, y) /* compute direction for x,y */ -FVECT vd; -int x, y; +extern int +compdir( /* compute direction for x,y */ + FVECT vd, + int x, + int y +) { int hl; FVECT org; /* dummy variable */ @@ -358,9 +385,11 @@ int x, y; } -double -pixsize(x, y) /* return the solid angle of pixel at (x,y) */ -int x, y; +extern double +pixsize( /* return the solid angle of pixel at (x,y) */ + int x, + int y +) { register int hl, xo; double disc; @@ -379,15 +408,18 @@ int x, y; } -memerr(s) /* malloc failure */ -char *s; +extern void +memerr( /* malloc failure */ + char *s +) { fprintf(stderr, "%s: out of memory for %s\n", progname, s); exit(1); } -printsources() /* print out glare sources */ +static void +printsources(void) /* print out glare sources */ { register struct source *sp; @@ -400,7 +432,8 @@ printsources() /* print out glare sources */ } -printillum() /* print out indirect illuminances */ +static void +printillum(void) /* print out indirect illuminances */ { register int i;