--- ray/src/util/findglare.c 1992/05/12 09:36:14 2.2 +++ ray/src/util/findglare.c 2003/02/22 02:07:30 2.9 @@ -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: findglare.c,v 2.9 2003/02/22 02:07:30 greg Exp $"; #endif - /* * Find glare sources in a scene or image. * @@ -16,8 +13,8 @@ static char SCCSid[] = "$SunId$ LBL"; #define VEQ(v1,v2) (FEQ((v1)[0],(v2)[0])&&FEQ((v1)[1],(v2)[1]) \ &&FEQ((v1)[2],(v2)[2])) -char *rtargv[32] = {"rtrace", "-h-", "-ov", "-fff"}; -int rtargc = 4; +char *rtargv[64] = {"rtrace", "-h-", "-ov", "-fff", "-ld-", "-i-", "-I-"}; +int rtargc = 7; VIEW ourview = STDVIEW; /* our view */ VIEW pictview = STDVIEW; /* picture view */ @@ -55,6 +52,14 @@ char *argv[]; progname = argv[0]; /* process options */ for (i = 1; i < argc && argv[i][0] == '-'; i++) { + /* expand arguments */ + while ((rval = expandarg(&argc, &argv, i)) > 0) + ; + if (rval < 0) { + fprintf(stderr, "%s: cannot expand '%s'", + argv[0], argv[i]); + exit(1); + } rval = getviewopt(&ourview, argc-i, argv+i); if (rval >= 0) { i += rval; @@ -75,7 +80,7 @@ char *argv[]; } if (argv[i][2] != 'f') goto userr; - rval = viewfile(argv[++i], &ourview, 0, 0); + rval = viewfile(argv[++i], &ourview, NULL); if (rval < 0) { fprintf(stderr, "%s: cannot open view file \"%s\"\n", @@ -105,11 +110,22 @@ char *argv[]; combine = !combine; break; case 'd': + rtargv[rtargc++] = argv[i]; + if (argv[i][2] != 'v') + rtargv[rtargc++] = argv[++i]; + break; case 'l': + if (argv[i][2] == 'd') + break; + /* FALL THROUGH */ case 's': + case 'P': rtargv[rtargc++] = argv[i]; rtargv[rtargc++] = argv[++i]; break; + case 'w': + rtargv[rtargc++] = argv[i]; + break; case 'a': rtargv[rtargc++] = argv[i]; if (argv[i][2] == 'v') { @@ -131,7 +147,7 @@ char *argv[]; } /* get view */ if (picture != NULL) { - rval = viewfile(picture, &pictview, 0, 0); + rval = viewfile(picture, &pictview, NULL); if (rval < 0) { fprintf(stderr, "%s: cannot open picture file \"%s\"\n", progname, picture); @@ -187,6 +203,7 @@ char *argv[]; absorb_specks(); /* eliminate tiny sources */ cleanup(); /* tidy up */ /* print header */ + newheader("RADIANCE", stdout); printargs(argc, argv, stdout); fputs(VIEWSTR, stdout); fprintview(&ourview, stdout); @@ -306,8 +323,8 @@ cleanup() /* close files, wait for children */ if (octree != NULL) done_rtrace(); if (npixinvw < 100*npixmiss) - fprintf(stderr, "%s: warning -- missing %ld%% of samples\n", - progname, 100L*npixmiss/npixinvw); + fprintf(stderr, "%s: warning -- missing %d%% of samples\n", + progname, (int)(100L*npixmiss/npixinvw)); } @@ -355,8 +372,8 @@ int x, y; xo = x-hl; else xo = 0; - disc = 1. - (double)(xo*xo + y*y)/(sampdens*sampdens); - if (disc <= FTINY) + disc = 1. - (double)((long)xo*xo + (long)y*y)/((long)sampdens*sampdens); + if (disc <= FTINY*FTINY) return(0.); return(1./(sampdens*sampdens*sqrt(disc))); }