ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhpict.c
(Generate patch)

Comparing ray/src/hd/rhpict.c (file contents):
Revision 3.2 by gwlarson, Fri Mar 5 17:02:41 1999 UTC vs.
Revision 3.10 by greg, Fri Jun 20 00:25:49 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1999 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Radiance holodeck picture generator
6   */
7  
8   #include "rholo.h"
9   #include "view.h"
13 #include "resolu.h"
10  
11   char    *progname;              /* our program name */
12   char    *hdkfile;               /* holodeck file name */
13 + char    gargc;                  /* global argc */
14 + char    **gargv;                /* global argv */
15  
16   VIEW    myview = STDVIEW;       /* current output view */
17   int     xres = 512, yres = 512; /* max. horizontal and vertical resolution */
18   char    *outspec = NULL;        /* output file specification */
19 + double  randfrac = -1.;         /* random resampling fraction */
20   double  pixaspect = 1.;         /* pixel aspect ratio */
21   int     seqstart = 0;           /* sequence start frame */
22   double  expval = 1.;            /* exposure value */
# Line 36 | Line 35 | char   *argv[];
35   {
36          int     i, rval;
37  
38 +        gargc = argc; gargv = argv;
39          progname = argv[0];                     /* get arguments */
40          for (i = 1; i < argc && argv[i][0] == '-'; i++) {
41                  rval = getviewopt(&myview, argc-i, argv+i);
# Line 50 | Line 50 | char   *argv[];
50                  case 'p':                       /* pixel aspect/exposure */
51                          if (badarg(argc-i-1,argv+i+1,"f"))
52                                  goto userr;
53 <                        if (argv[i][1] == 'a')
53 >                        if (argv[i][2] == 'a')
54                                  pixaspect = atof(argv[++i]);
55 <                        else if (argv[i][1] == 'e') {
55 >                        else if (argv[i][2] == 'e') {
56                                  expval = atof(argv[++i]);
57                                  if (argv[i][0] == '-' | argv[i][0] == '+')
58                                          expval = pow(2., expval);
# Line 74 | Line 74 | char   *argv[];
74                                  goto userr;
75                          outspec = argv[++i];
76                          break;
77 +                case 'r':                       /* random sampling */
78 +                        if (badarg(argc-i-1,argv+i+1,"f"))
79 +                                goto userr;
80 +                        randfrac = atof(argv[++i]);
81 +                        break;
82 +                case 's':                       /* smooth sampling */
83 +                        randfrac = -1.;
84 +                        break;
85                  case 'S':                       /* sequence start */
86                          if (badarg(argc-i-1,argv+i+1,"i"))
87                                  goto userr;
88                          seqstart = atoi(argv[++i]);
89                          break;
90                  case 'v':                       /* view file */
91 <                        if (argv[i][1]!='f' || badarg(argc-i-1,argv+i+1,"s"))
91 >                        if (argv[i][2]!='f' || badarg(argc-i-1,argv+i+1,"s"))
92                                  goto userr;
93                          rval = viewfile(argv[++i], &myview, NULL);
94                          if (rval < 0) {
# Line 98 | Line 106 | char   *argv[];
106                  }
107          }
108                                                  /* open holodeck file */
109 <        if (i >= argc)
109 >        if (i != argc-1)
110                  goto userr;
111 <        hdkfile = argv[i++];
111 >        hdkfile = argv[i];
112          initialize();
113                                                  /* render picture(s) */
114          if (seqstart <= 0)
# Line 111 | Line 119 | char   *argv[];
119          quit(0);                                /* all done! */
120   userr:
121          fprintf(stderr,
122 < "Usage: %s [-w][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n",
122 > "Usage: %s [-w][-r rf][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n",
123                          progname);
124          quit(1);
125   }
# Line 135 | Line 143 | int    fn;
143                                          /* render image */
144          if (blist.nb > 0) {
145                  render_frame(blist.bl, blist.nb);
146 <                free((char *)blist.bl);
146 >                free((void *)blist.bl);
147          } else {
148                  sprintf(errmsg, "no section visible in frame %d", fn);
149                  error(WARNING, errmsg);
# Line 145 | Line 153 | int    fn;
153                  sprintf(errmsg, "error writing frame %d", fn);
154                  error(SYSTEM, errmsg);
155          }
156 + #ifdef DEBUG
157          if (blist.nb > 0 & rval > 0) {
158 <                sprintf(errmsg, "%.1f%% unrendered pixels in frame %d",
159 <                                100.*rval/(hres*vres), fn);
158 >                sprintf(errmsg, "%d unrendered pixels in frame %d (%.1f%%)",
159 >                                rval, fn, 100.*rval/(hres*vres));
160                  error(WARNING, errmsg);
161          }
162 + #endif
163   }
164  
165  
# Line 169 | Line 179 | int    nb;
179                  bil[i].b = bl[i].bi;
180          }
181          hdloadbeams(bil, nb, pixBeam);
182 <        pixFlush();
183 <        free((char *)bil);
182 >        pixFinish(randfrac);
183 >        free((void *)bil);
184   }
185  
186  
# Line 194 | Line 204 | int    fn;
204                                  /* write header */
205          newheader("RADIANCE", stdout);
206          printf("SOFTWARE= %s\n", VersionID);
207 <        printf("%s %s\n", progname, hdkfile);
207 >        printargs(gargc, gargv, stdout);
208          if (fn)
209                  printf("FRAME=%d\n", fn);
210          fputs(VIEWSTR, stdout);
# Line 218 | Line 228 | int    fn;
228   int
229   endpicture()                    /* finish and write out pixels */
230   {
231 <        int     nunrend = 0;
232 <        int     v;
231 >        int     lastr = -1, nunrend = 0;
232 >        int32   lastp, lastrp;
233 >        register int32  p;
234          register double d;
224        register int    p;
235                                  /* compute final pixel values */
236          for (p = hres*vres; p--; ) {
237                  if (myweight[p] <= FTINY) {
238 +                        if (lastr >= 0)
239 +                                if (p/hres == lastp/hres)
240 +                                        copycolor(mypixel[p], mypixel[lastp]);
241 +                                else
242 +                                        copycolor(mypixel[p], mypixel[lastrp]);
243                          nunrend++;
244                          continue;
245                  }
246                  d = expval/myweight[p];
247                  scalecolor(mypixel[p], d);
248 +                if ((lastp=p)/hres != lastr)
249 +                        lastr = (lastrp=p)/hres;
250          }
251                                  /* write each scanline */
252 <        for (v = vres; v--; )
253 <                if (fwritescan(mypixel+v*hres, hres, stdout) < 0)
252 >        for (p = vres; p--; )
253 >                if (fwritescan(mypixel+p*hres, hres, stdout) < 0)
254                          return(-1);
255          if (fflush(stdout) == EOF)
256                  return(-1);
# Line 243 | Line 260 | endpicture()                   /* finish and write out pixels */
260  
261   initialize()                    /* initialize holodeck and buffers */
262   {
246        extern long     ftell();
263          int     fd;
264          FILE    *fp;
265          int     n;
266 <        int4    nextloc;
266 >        int32   nextloc;
267                                          /* open holodeck file */
268          if ((fp = fopen(hdkfile, "r")) == NULL) {
269                  sprintf(errmsg, "cannot open \"%s\" for reading", hdkfile);
# Line 265 | Line 281 | initialize()                   /* initialize holodeck and buffers */
281          fd = dup(fileno(fp));                   /* dup file descriptor */
282          fclose(fp);                             /* done with stdio */
283          for (n = 0; nextloc > 0L; n++) {        /* initialize each section */
284 <                lseek(fd, (long)nextloc, 0);
284 >                lseek(fd, (off_t)nextloc, 0);
285                  read(fd, (char *)&nextloc, sizeof(nextloc));
286                  hdinit(fd, NULL);
287          }
# Line 278 | Line 294 | initialize()                   /* initialize holodeck and buffers */
294   }
295  
296  
297 + void
298   eputs(s)                        /* put error message to stderr */
299   register char  *s;
300   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines