--- ray/src/hd/rhpict.c 1999/03/09 10:55:24 3.4 +++ ray/src/hd/rhpict.c 2003/06/20 00:25:49 3.10 @@ -1,23 +1,22 @@ -/* Copyright (c) 1999 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: rhpict.c,v 3.10 2003/06/20 00:25:49 greg Exp $"; #endif - /* * Radiance holodeck picture generator */ #include "rholo.h" #include "view.h" -#include "resolu.h" char *progname; /* our program name */ char *hdkfile; /* holodeck file name */ +char gargc; /* global argc */ +char **gargv; /* global argv */ VIEW myview = STDVIEW; /* current output view */ int xres = 512, yres = 512; /* max. horizontal and vertical resolution */ char *outspec = NULL; /* output file specification */ +double randfrac = -1.; /* random resampling fraction */ double pixaspect = 1.; /* pixel aspect ratio */ int seqstart = 0; /* sequence start frame */ double expval = 1.; /* exposure value */ @@ -36,6 +35,7 @@ char *argv[]; { int i, rval; + gargc = argc; gargv = argv; progname = argv[0]; /* get arguments */ for (i = 1; i < argc && argv[i][0] == '-'; i++) { rval = getviewopt(&myview, argc-i, argv+i); @@ -74,6 +74,14 @@ char *argv[]; goto userr; outspec = argv[++i]; break; + case 'r': /* random sampling */ + if (badarg(argc-i-1,argv+i+1,"f")) + goto userr; + randfrac = atof(argv[++i]); + break; + case 's': /* smooth sampling */ + randfrac = -1.; + break; case 'S': /* sequence start */ if (badarg(argc-i-1,argv+i+1,"i")) goto userr; @@ -111,7 +119,7 @@ char *argv[]; quit(0); /* all done! */ userr: fprintf(stderr, -"Usage: %s [-w][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", +"Usage: %s [-w][-r rf][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", progname); quit(1); } @@ -135,7 +143,7 @@ int fn; /* render image */ if (blist.nb > 0) { render_frame(blist.bl, blist.nb); - free((char *)blist.bl); + free((void *)blist.bl); } else { sprintf(errmsg, "no section visible in frame %d", fn); error(WARNING, errmsg); @@ -171,8 +179,8 @@ int nb; bil[i].b = bl[i].bi; } hdloadbeams(bil, nb, pixBeam); - pixFlush(); - free((char *)bil); + pixFinish(randfrac); + free((void *)bil); } @@ -196,7 +204,7 @@ int fn; /* write header */ newheader("RADIANCE", stdout); printf("SOFTWARE= %s\n", VersionID); - printf("%s %s\n", progname, hdkfile); + printargs(gargc, gargv, stdout); if (fn) printf("FRAME=%d\n", fn); fputs(VIEWSTR, stdout); @@ -221,8 +229,8 @@ int endpicture() /* finish and write out pixels */ { int lastr = -1, nunrend = 0; - int4 lastp, lastrp; - register int4 p; + int32 lastp, lastrp; + register int32 p; register double d; /* compute final pixel values */ for (p = hres*vres; p--; ) { @@ -252,11 +260,10 @@ endpicture() /* finish and write out pixels */ initialize() /* initialize holodeck and buffers */ { - extern long ftell(); int fd; FILE *fp; int n; - int4 nextloc; + int32 nextloc; /* open holodeck file */ if ((fp = fopen(hdkfile, "r")) == NULL) { sprintf(errmsg, "cannot open \"%s\" for reading", hdkfile); @@ -274,7 +281,7 @@ initialize() /* initialize holodeck and buffers */ fd = dup(fileno(fp)); /* dup file descriptor */ fclose(fp); /* done with stdio */ for (n = 0; nextloc > 0L; n++) { /* initialize each section */ - lseek(fd, (long)nextloc, 0); + lseek(fd, (off_t)nextloc, 0); read(fd, (char *)&nextloc, sizeof(nextloc)); hdinit(fd, NULL); } @@ -287,6 +294,7 @@ initialize() /* initialize holodeck and buffers */ } +void eputs(s) /* put error message to stderr */ register char *s; {