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

Comparing ray/src/rt/rpict.c (file contents):
Revision 2.8 by greg, Fri Jul 10 14:58:19 1992 UTC vs.
Revision 2.16 by greg, Tue Oct 6 12:30:07 1992 UTC

# Line 18 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18   #endif
19  
20   #include  <signal.h>
21 #include  <fcntl.h>
21  
22   #include  "view.h"
23  
# Line 26 | Line 25 | static char SCCSid[] = "$SunId$ LBL";
25  
26   #include  "random.h"
27  
28 + #include  "paths.h"
29 +
30   int  dimlist[MAXDIM];                   /* sampling dimensions */
31   int  ndims = 0;                         /* number of sampling dimensions */
32   int  samplendx;                         /* sample index number */
# Line 33 | Line 34 | int  samplendx;                                /* sample index number */
34   VIEW  ourview = STDVIEW;                /* view parameters */
35   int  hresolu = 512;                     /* horizontal resolution */
36   int  vresolu = 512;                     /* vertical resolution */
37 < double  pixaspect = 1.0;                /* pixel aspect ratio */
37 > double  pixaspect = 1.0;                /* pixel aspect ratio */
38  
39   int  psample = 4;                       /* pixel sample size */
40 < double  maxdiff = .05;                  /* max. difference for interpolation */
41 < double  dstrpix = 0.67;                 /* square pixel distribution */
40 > double  maxdiff = .05;                  /* max. difference for interpolation */
41 > double  dstrpix = 0.67;                 /* square pixel distribution */
42  
43 < double  dstrsrc = 0.0;                  /* square source distribution */
44 < double  shadthresh = .05;               /* shadow threshold */
45 < double  shadcert = .5;                  /* shadow certainty */
43 > double  dstrsrc = 0.0;                  /* square source distribution */
44 > double  shadthresh = .05;               /* shadow threshold */
45 > double  shadcert = .5;                  /* shadow certainty */
46   int  directrelay = 1;                   /* number of source relays */
47   int  vspretest = 512;                   /* virtual source pretest density */
48   int  directinvis = 0;                   /* sources invisible? */
49 < double  srcsizerat = .25;               /* maximum ratio source size/dist. */
49 > double  srcsizerat = .25;               /* maximum ratio source size/dist. */
50  
51 < double  specthresh = .15;               /* specular sampling threshold */
52 < double  specjitter = 1.;                /* specular sampling jitter */
51 > double  specthresh = .15;               /* specular sampling threshold */
52 > double  specjitter = 1.;                /* specular sampling jitter */
53  
54   int  maxdepth = 6;                      /* maximum recursion depth */
55 < double  minweight = 5e-3;               /* minimum ray weight */
55 > double  minweight = 5e-3;               /* minimum ray weight */
56  
57   COLOR  ambval = BLKCOLOR;               /* ambient value */
58 < double  ambacc = 0.2;                   /* ambient accuracy */
58 > double  ambacc = 0.2;                   /* ambient accuracy */
59   int  ambres = 32;                       /* ambient resolution */
60   int  ambdiv = 128;                      /* ambient divisions */
61   int  ambssamp = 0;                      /* ambient super-samples */
# Line 62 | Line 63 | int  ambounce = 0;                     /* ambient bounces */
63   char  *amblist[128];                    /* ambient include/exclude list */
64   int  ambincl = -1;                      /* include == 1, exclude == 0 */
65  
66 + #ifdef MSDOS
67 + int  ralrm = 60;                        /* seconds between reports */
68 + #else
69   int  ralrm = 0;                         /* seconds between reports */
70 + #endif
71  
72 < double  pctdone = 0.0;                  /* percentage done */
72 > double  pctdone = 0.0;                  /* percentage done */
73  
74   long  tlastrept = 0L;                   /* time at last report */
75  
# Line 73 | Line 78 | extern long  tstart;                   /* starting time */
78  
79   extern long  nrays;                     /* number of rays traced */
80  
81 < #define  MAXDIV         16              /* maximum sample size */
81 > #define  MAXDIV         16              /* maximum sample size */
82  
83 < #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
83 > #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
84  
85 < #define  HFTEMPLATE     "/tmp/hfXXXXXX"
85 > #define  RFTEMPLATE     "rfXXXXXX"
86 > #define  HFTEMPLATE     TEMPLATE
87  
88   static char  *hfname = NULL;            /* header file name */
89   static FILE  *hfp = NULL;               /* header file pointer */
# Line 86 | Line 92 | static int  hres, vres;                        /* resolution for this frame
92  
93   extern char  *mktemp();
94  
95 < double  pixvalue();
95 > double  pixvalue();
96  
97  
98   quit(code)                      /* quit program */
# Line 107 | Line 113 | int  code;
113   report()                /* report progress */
114   {
115          struct rusage  rubuf;
116 <        double  t;
116 >        double  t;
117  
118          getrusage(RUSAGE_SELF, &rubuf);
119          t = (rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec) / 1e6;
# Line 179 | Line 185 | char  *pout, *zout, *prvr;
185   */
186   {
187          extern char  *rindex(), *strncpy(), *strcat();
188 <        char  fbuf[128], fbuf2[128], *zf;
189 <        RESOLU  rs;
190 <        double  pa;
188 >        char  fbuf[128], fbuf2[128];
189 >        register char  *cp;
190 >        RESOLU  rs;
191 >        double  pa;
192                                          /* finished writing header */
193          closeheader();
194                                          /* check sampling */
# Line 197 | Line 204 | char  *pout, *zout, *prvr;
204          if (seq <= 0)
205                  seq = 0;
206          else if (prvr != NULL && isint(prvr)) {
207 <                int  rn;                        /* skip to specified view */
207 >                register int  rn;               /* skip to specified view */
208                  if ((rn = atoi(prvr)) < seq)
209                          error(USER, "recover frame less than start frame");
210                  if (pout == NULL)
# Line 209 | Line 216 | char  *pout, *zout, *prvr;
216          }
217          if (pout != NULL) {
218                  sprintf(fbuf, pout, seq);
219 <                if (!strcmp(prvr, fbuf)) {      /* rename recover file */
219 >                if (prvr != NULL && !strcmp(prvr, fbuf)) {      /* rename */
220                          fbuf2[0] = '\0';
221 <                        if ((prvr = rindex(fbuf, '/')) != NULL)
222 <                                strncpy(fbuf2, fbuf, prvr-fbuf+1);
223 <                        strcat(fbuf2, "rfXXXXXX");
221 >                        if ((cp = rindex(fbuf, '/')) != NULL)
222 >                                strncpy(fbuf2, fbuf, cp-fbuf+1);
223 >                        strcat(fbuf2, RFTEMPLATE);
224                          prvr = mktemp(fbuf2);
225                          if (rename(fbuf, prvr) < 0 && errno != ENOENT) {
226                                  sprintf(errmsg,
# Line 244 | Line 251 | char  *pout, *zout, *prvr;
251                          "cannot recover view parameters from \"%s\"", prvr);
252                                  error(WARNING, errmsg);
253                          } else {
247                                char  *err;
248                                if ((err = setview(&ourview)) != NULL)
249                                        error(USER, err);
254                                  pa = 0.0;
255                                  hres = scanlen(&rs);
256                                  vres = numscans(&rs);
257                          }
258 +                if ((cp = setview(&ourview)) != NULL)
259 +                        error(USER, cp);
260                  normaspect(viewaspect(&ourview), &pa, &hres, &vres);
261                  if (seq) {
262                          if (ralrm > 0) {
263 <                                sprintf(errmsg, "starting frame %d\n", seq);
264 <                                eputs(errmsg);
263 >                                fprintf(stderr, "FRAME %d:", seq);
264 >                                fprintview(&ourview, stderr);
265 >                                putc('\n', stderr);
266 >                                fflush(stderr);
267                          }
268                          printf("FRAME=%d\n", seq);
269                  }
# Line 267 | Line 275 | char  *pout, *zout, *prvr;
275                  fputformat(COLRFMT, stdout);
276                  putchar('\n');
277                  if (zout != NULL)
278 <                        sprintf(zf=fbuf, zout, seq);
278 >                        sprintf(cp=fbuf, zout, seq);
279                  else
280 <                        zf = NULL;
281 <                render(zf, prvr);
280 >                        cp = NULL;
281 >                render(cp, prvr);
282                  prvr = NULL;
283          } while (seq++);
284   }
# Line 279 | Line 287 | char  *pout, *zout, *prvr;
287   nextview(fp)                            /* get next view from fp */
288   FILE  *fp;
289   {
290 <        char  linebuf[256], *err;
290 >        char  linebuf[256];
291  
292          while (fgets(linebuf, sizeof(linebuf), fp) != NULL)
293 <                if (isview(linebuf) && sscanview(&ourview, linebuf) > 0) {
286 <                        if ((err = setview(&ourview)) != NULL)
287 <                                error(USER, err);
293 >                if (isview(linebuf) && sscanview(&ourview, linebuf) > 0)
294                          return(0);
289                }
295          return(EOF);
296   }      
297  
# Line 347 | Line 352 | char  *zfile, *oldfile;
352          pctdone = 100.0*i/vres;
353          if (ralrm > 0)                  /* report init stats */
354                  report();
355 < #ifndef  BSD
355 > #ifndef  BSD
356          else
357   #endif
358          signal(SIGALRM, report);
# Line 372 | Line 377 | char  *zfile, *oldfile;
377                                                          /* fill bar */
378                  fillscanbar(scanbar, zbar, hres, ypos, ystep);
379                                                          /* write it out */
380 < #ifndef  BSD
380 > #ifndef  BSD
381                  signal(SIGALRM, SIG_IGN);       /* don't interrupt writes */
382   #endif
383                  for (i = ystep; i > 0; i--) {
# Line 389 | Line 394 | char  *zfile, *oldfile;
394                  pctdone = 100.0*(vres-1-ypos)/vres;
395                  if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
396                          report();
397 < #ifndef  BSD
397 > #ifndef  BSD
398                  else
399                          signal(SIGALRM, report);
400   #endif
# Line 413 | Line 418 | char  *zfile, *oldfile;
418          if (sampdens != NULL)
419                  free(sampdens);
420          pctdone = 100.0;
421 +        if (ralrm > 0)
422 +                report();
423          return;
424   writerr:
425          error(SYSTEM, "write error in render");
# Line 422 | Line 429 | memerr:
429  
430  
431   fillscanline(scanline, zline, sd, xres, y, xstep)       /* fill scan at y */
432 < register COLOR  *scanline;
433 < register float  *zline;
432 > register COLOR  *scanline;
433 > register float  *zline;
434   register char  *sd;
435   int  xres, y, xstep;
436   {
437          static int  nc = 0;             /* number of calls */
438          int  bl = xstep, b = xstep;
439 <        double  z;
439 >        double  z;
440          register int  i;
441          
442          z = pixvalue(scanline[0], 0, y);
# Line 457 | Line 464 | int  xres, y, xstep;
464  
465  
466   fillscanbar(scanbar, zbar, xres, y, ysize)      /* fill interior */
467 < register COLOR  *scanbar[];
468 < register float  *zbar[];
467 > register COLOR  *scanbar[];
468 > register float  *zbar[];
469   int  xres, y, ysize;
470   {
471          COLOR  vline[MAXDIV+1];
# Line 488 | Line 495 | int  xres, y, ysize;
495  
496  
497   int
498 < fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */
499 < register COLOR  *colline;
500 < register float  *zline;
498 > fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */
499 > register COLOR  *colline;
500 > register float  *zline;
501   int  x, y;
502   int  xlen, ylen;
503   int  b;
504   {
505 <        extern double  fabs();
506 <        double  ratio;
500 <        double  z;
505 >        double  ratio;
506 >        double  z;
507          COLOR  ctmp;
508          int  ncut;
509          register int  len;
# Line 615 | Line 621 | char  *oldfile;
621          unlink(oldfile);
622          return(y);
623   writerr:
624 <        error(SYSTEM, "write error in salvage");
624 >        sprintf(errmsg, "write error during recovery of \"%s\"", oldfile);
625 >        error(SYSTEM, errmsg);
626   }
627  
628  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines