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.36 by greg, Sun Dec 12 13:56:08 1993 UTC vs.
Revision 2.43 by greg, Wed Feb 7 16:35:18 1996 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1993 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20   #include  <sys/resource.h>
21   #else
22   #include  <sys/times.h>
23 #include  <sys/utsname.h>
23   #include  <unistd.h>
24   #endif
25   #endif
# Line 64 | Line 63 | int  vspretest = 512;                  /* virtual source pretest dens
63   int  directvis = 1;                     /* sources visible? */
64   double  srcsizerat = .25;               /* maximum ratio source size/dist. */
65  
66 + COLOR  cextinction = BLKCOLOR;          /* global extinction coefficient */
67 + double  salbedo = 0.;                   /* global scattering albedo */
68 + double  seccg = 0.;                     /* global scattering eccentricity */
69 + double  ssampdist = 0.;                 /* scatter sampling distance */
70 +
71   double  specthresh = .15;               /* specular sampling threshold */
72   double  specjitter = 1.;                /* specular sampling jitter */
73  
74 + int  backvis = 1;                       /* back face visibility */
75 +
76   int  maxdepth = 6;                      /* maximum recursion depth */
77   double  minweight = 5e-3;               /* minimum ray weight */
78  
# Line 133 | Line 139 | int  code;
139   #ifndef NIX
140   report()                /* report progress */
141   {
142 +        extern char  *myhostname();
143          double  u, s;
144   #ifdef BSD
138        char  hostname[257];
145          struct rusage  rubuf;
146   #else
147          struct tms  tbuf;
142        struct utsname  nambuf;
148          double  period;
144 #define hostname  nambuf.nodename
149   #endif
150  
151          tlastrept = time((time_t *)NULL);
# Line 152 | Line 156 | report()               /* report progress */
156          getrusage(RUSAGE_CHILDREN, &rubuf);
157          u += rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6;
158          s += rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec/1e6;
155        gethostname(hostname, sizeof(hostname));
159   #else
160          times(&tbuf);
161   #ifdef _SC_CLK_TCK
# Line 162 | Line 165 | report()               /* report progress */
165   #endif
166          u = ( tbuf.tms_utime + tbuf.tms_cutime ) * period;
167          s = ( tbuf.tms_stime + tbuf.tms_cstime ) * period;
165        uname(&nambuf);
168   #endif
169  
170          sprintf(errmsg,
171                  "%lu rays, %4.2f%% after %.3fu %.3fs %.3fr hours on %s\n",
172                          nrays, pctdone, u/3600., s/3600.,
173 <                        (tlastrept-tstart)/3600., hostname);
173 >                        (tlastrept-tstart)/3600., myhostname());
174          eputs(errmsg);
175   #ifndef BSD
176          signal(SIGCONT, report);
175 #undef hostname
177   #endif
178   }
179   #else
# Line 391 | Line 392 | char  *zfile, *oldfile;
392          fprtresolu(hres, vres, stdout);
393                                          /* recover file and compute first */
394          i = salvage(oldfile);
395 +        if (i >= vres)
396 +                goto alldone;
397          if (zfd != -1 && i > 0 &&
398                          lseek(zfd, (long)i*hres*sizeof(float), 0) == -1)
399                  error(SYSTEM, "z-file seek error in render");
# Line 446 | Line 449 | char  *zfile, *oldfile;
449          }
450                                                  /* clean up */
451          signal(SIGCONT, SIG_IGN);
452 <        if (zfd != -1) {
450 <                if (write(zfd, (char *)zbar[0], hres*sizeof(float))
452 >        if (zfd != -1 && write(zfd, (char *)zbar[0], hres*sizeof(float))
453                                  < hres*sizeof(float))
454 <                        goto writerr;
454 >                goto writerr;
455 >        fwritescan(scanbar[0], hres, stdout);
456 >        if (fflush(stdout) == EOF)
457 >                goto writerr;
458 > alldone:
459 >        if (zfd != -1) {
460                  if (close(zfd) == -1)
461                          goto writerr;
462                  for (i = 0; i <= psample; i++)
463                          free((char *)zbar[i]);
464          }
458        fwritescan(scanbar[0], hres, stdout);
459        if (fflush(stdout) == EOF)
460                goto writerr;
465          for (i = 0; i <= psample; i++)
466                  free((char *)scanbar[i]);
467          if (sampdens != NULL)
# Line 500 | Line 504 | int  xres, y, xstep;
504                          b = fillsample(scanline, zline, 0, y, i, 0, b/2);
505                  else
506                          b = fillsample(scanline+i-xstep,
507 <                                        zline ? zline+i-xstep : NULL,
507 >                                        zline ? zline+i-xstep : (float *)NULL,
508                                          i-xstep, y, xstep, 0, b/2);
509                  if (sd) *sd++ = nc & 1 ? bl : b;
510                  bl = b;
# Line 528 | Line 532 | int  xres, y, ysize;
532                          zline[ysize] = zbar[ysize][i];
533                  }
534                  
535 <                b = fillsample(vline, zbar[0] ? zline : NULL,
535 >                b = fillsample(vline, zbar[0] ? zline : (float *)NULL,
536                                  i, y, 0, ysize, b/2);
537                  
538                  for (j = 1; j < ysize; j++)
# Line 586 | Line 590 | int  b;
590                                                          /* recurse */
591          ncut += fillsample(colline, zline, x, y, xlen>>1, ylen>>1, (b-1)/2);
592          
593 <        ncut += fillsample(colline+(len>>1), zline ? zline+(len>>1) : NULL,
593 >        ncut += fillsample(colline+(len>>1),
594 >                        zline ? zline+(len>>1) : (float *)NULL,
595                          x+(xlen>>1), y+(ylen>>1),
596                          xlen-(xlen>>1), ylen-(ylen>>1), b/2);
597  
# Line 601 | Line 606 | int  x, y;                     /* pixel position */
606   {
607          static RAY  thisray;
608  
609 <        if (viewray(thisray.rorg, thisray.rdir, &ourview,
610 <                        (x+pixjitter())/hres, (y+pixjitter())/vres) < 0) {
609 >        if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview,
610 >                        (x+pixjitter())/hres, (y+pixjitter())/vres)) < -FTINY) {
611                  setcolor(col, 0.0, 0.0, 0.0);
612                  return(0.0);
613          }
# Line 628 | Line 633 | char  *oldfile;
633          int  x, y;
634  
635          if (oldfile == NULL)
636 <                return(0);
637 <        
636 >                goto gotzip;
637 >
638          if ((fp = fopen(oldfile, "r")) == NULL) {
639                  sprintf(errmsg, "cannot open recover file \"%s\"", oldfile);
640                  error(WARNING, errmsg);
641 <                return(0);
641 >                goto gotzip;
642          }
643   #ifdef MSDOS
644          setmode(fileno(fp), O_BINARY);
# Line 646 | Line 651 | char  *oldfile;
651                                  oldfile);
652                  error(WARNING, errmsg);
653                  fclose(fp);
654 <                return(0);
654 >                goto gotzip;
655          }
656  
657          if (x != hres || y != vres) {
# Line 670 | Line 675 | char  *oldfile;
675          fclose(fp);
676          unlink(oldfile);
677          return(y);
678 + gotzip:
679 +        if (fflush(stdout) == EOF)
680 +                error(SYSTEM, "error writing picture header");
681 +        return(0);
682   writerr:
683          sprintf(errmsg, "write error during recovery of \"%s\"", oldfile);
684          error(SYSTEM, errmsg);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines