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.30 by greg, Thu Oct 28 15:24:19 1993 UTC vs.
Revision 2.39 by greg, Tue Dec 20 20:18:30 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1992 Regents of the University of California */
1 > /* Copyright (c) 1994 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include  "ray.h"
14  
15 + #include  <sys/types.h>
16 +
17   #ifndef NIX
18   #ifdef BSD
19   #include  <sys/time.h>
20   #include  <sys/resource.h>
21   #else
20 #include  <sys/types.h>
22   #include  <sys/times.h>
23 < #include  <limits.h>
23 > #include  <sys/utsname.h>
24 > #include  <unistd.h>
25   #endif
26   #endif
27  
28 + extern time_t   time();
29 +
30   #include  <signal.h>
31  
32   #include  "view.h"
# Line 83 | Line 87 | int  ralrm = 0;                                /* seconds between reports */
87  
88   double  pctdone = 0.0;                  /* percentage done */
89  
90 < long  tlastrept = 0L;                   /* time at last report */
90 > time_t  tlastrept = 0L;                 /* time at last report */
91  
92 < extern long  time();
89 < extern long  tstart;                    /* starting time */
92 > extern time_t  tstart;                  /* starting time */
93  
94   extern unsigned long  nrays;            /* number of rays traced */
95  
# Line 130 | Line 133 | int  code;
133   #ifndef NIX
134   report()                /* report progress */
135   {
133        char  hostname[128];
136          double  u, s;
137   #ifdef BSD
138 +        char  hostname[257];
139          struct rusage  rubuf;
140   #else
141          struct tms  tbuf;
142 +        struct utsname  nambuf;
143 +        double  period;
144 + #define hostname  nambuf.nodename
145   #endif
146  
147 <        tlastrept = time((long *)0);
147 >        tlastrept = time((time_t *)NULL);
148   #ifdef BSD
149          getrusage(RUSAGE_SELF, &rubuf);
150          u = rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6;
# Line 146 | Line 152 | report()               /* report progress */
152          getrusage(RUSAGE_CHILDREN, &rubuf);
153          u += rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6;
154          s += rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec/1e6;
155 +        gethostname(hostname, sizeof(hostname));
156   #else
157          times(&tbuf);
158 <        u = ( tbuf.tms_utime + tbuf.tms_cutime ) / CLK_TCK;
159 <        s = ( tbuf.tms_stime + tbuf.tms_cstime ) / CLK_TCK;
158 > #ifdef _SC_CLK_TCK
159 >        period = 1.0 / sysconf(_SC_CLK_TCK);
160 > #else
161 >        period = 1.0 / 60.0;
162   #endif
163 <        gethostname(hostname, sizeof(hostname));
163 >        u = ( tbuf.tms_utime + tbuf.tms_cutime ) * period;
164 >        s = ( tbuf.tms_stime + tbuf.tms_cstime ) * period;
165 >        uname(&nambuf);
166 > #endif
167  
168          sprintf(errmsg,
169                  "%lu rays, %4.2f%% after %.3fu %.3fs %.3fr hours on %s\n",
170                          nrays, pctdone, u/3600., s/3600.,
171                          (tlastrept-tstart)/3600., hostname);
172          eputs(errmsg);
173 + #ifndef BSD
174 +        signal(SIGCONT, report);
175 + #undef hostname
176 + #endif
177   }
178   #else
179   report()                /* report progress */
180   {
181 <        tlastrept = time((long *)0);
181 >        tlastrept = time((time_t *)NULL);
182          sprintf(errmsg, "%lu rays, %4.2f%% after %5.4f hours\n",
183                          nrays, pctdone, (tlastrept-tstart)/3600.0);
184          eputs(errmsg);
169        signal(SIGCONT, report);
185   }
186   #endif
187  
# Line 422 | Line 437 | char  *zfile, *oldfile;
437                          goto writerr;
438                                                          /* record progress */
439                  pctdone = 100.0*(vres-1-ypos)/vres;
440 <                if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
440 >                if (ralrm > 0 && time((time_t *)NULL) >= tlastrept+ralrm)
441                          report();
442   #ifndef  BSD
443                  else
# Line 485 | Line 500 | int  xres, y, xstep;
500                          b = fillsample(scanline, zline, 0, y, i, 0, b/2);
501                  else
502                          b = fillsample(scanline+i-xstep,
503 <                                        zline ? zline+i-xstep : NULL,
503 >                                        zline ? zline+i-xstep : (float *)NULL,
504                                          i-xstep, y, xstep, 0, b/2);
505                  if (sd) *sd++ = nc & 1 ? bl : b;
506                  bl = b;
# Line 513 | Line 528 | int  xres, y, ysize;
528                          zline[ysize] = zbar[ysize][i];
529                  }
530                  
531 <                b = fillsample(vline, zbar[0] ? zline : NULL,
531 >                b = fillsample(vline, zbar[0] ? zline : (float *)NULL,
532                                  i, y, 0, ysize, b/2);
533                  
534                  for (j = 1; j < ysize; j++)
# Line 571 | Line 586 | int  b;
586                                                          /* recurse */
587          ncut += fillsample(colline, zline, x, y, xlen>>1, ylen>>1, (b-1)/2);
588          
589 <        ncut += fillsample(colline+(len>>1), zline ? zline+(len>>1) : NULL,
589 >        ncut += fillsample(colline+(len>>1),
590 >                        zline ? zline+(len>>1) : (float *)NULL,
591                          x+(xlen>>1), y+(ylen>>1),
592                          xlen-(xlen>>1), ylen-(ylen>>1), b/2);
593  
# Line 586 | Line 602 | int  x, y;                     /* pixel position */
602   {
603          static RAY  thisray;
604  
605 <        if (viewray(thisray.rorg, thisray.rdir, &ourview,
606 <                        (x+pixjitter())/hres, (y+pixjitter())/vres) < 0) {
605 >        if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview,
606 >                        (x+pixjitter())/hres, (y+pixjitter())/vres)) < -FTINY) {
607                  setcolor(col, 0.0, 0.0, 0.0);
608                  return(0.0);
609          }
# Line 613 | Line 629 | char  *oldfile;
629          int  x, y;
630  
631          if (oldfile == NULL)
632 <                return(0);
633 <        
632 >                goto gotzip;
633 >
634          if ((fp = fopen(oldfile, "r")) == NULL) {
635                  sprintf(errmsg, "cannot open recover file \"%s\"", oldfile);
636                  error(WARNING, errmsg);
637 <                return(0);
637 >                goto gotzip;
638          }
639   #ifdef MSDOS
640          setmode(fileno(fp), O_BINARY);
# Line 631 | Line 647 | char  *oldfile;
647                                  oldfile);
648                  error(WARNING, errmsg);
649                  fclose(fp);
650 <                return(0);
650 >                goto gotzip;
651          }
652  
653          if (x != hres || y != vres) {
# Line 655 | Line 671 | char  *oldfile;
671          fclose(fp);
672          unlink(oldfile);
673          return(y);
674 + gotzip:
675 +        if (fflush(stdout) == EOF)
676 +                error(SYSTEM, "error writing picture header");
677 +        return(0);
678   writerr:
679          sprintf(errmsg, "write error during recovery of \"%s\"", oldfile);
680          error(SYSTEM, errmsg);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines