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.21 by greg, Wed Jan 20 15:19:47 1993 UTC vs.
Revision 2.26 by greg, Fri Jul 30 10:31:09 1993 UTC

# Line 29 | Line 29 | static char SCCSid[] = "$SunId$ LBL";
29  
30   #define  RFTEMPLATE     "rfXXXXXX"
31  
32 + #ifndef SIGCONT
33 + #define SIGCONT         SIGIO
34 + #endif
35 +
36   int  dimlist[MAXDIM];                   /* sampling dimensions */
37   int  ndims = 0;                         /* number of sampling dimensions */
38   int  samplendx;                         /* sample index number */
# Line 78 | Line 82 | long  tlastrept = 0L;                  /* time at last report */
82   extern long  time();
83   extern long  tstart;                    /* starting time */
84  
85 < extern long  nrays;                     /* number of rays traced */
85 > extern unsigned long  nrays;            /* number of rays traced */
86  
87   #define  MAXDIV         16              /* maximum sample size */
88  
# Line 115 | Line 119 | report()               /* report progress */
119          t += (rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec) / 1e6;
120          t += rubuf.ru_utime.tv_sec + rubuf.ru_stime.tv_sec;
121  
122 <        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n",
122 >        sprintf(errmsg, "%lu rays, %4.2f%% done after %5.4f CPU hours\n",
123                          nrays, pctdone, t/3600.0);
124          eputs(errmsg);
125          tlastrept = time((long *)0);
# Line 124 | Line 128 | report()               /* report progress */
128   report()                /* report progress */
129   {
130          tlastrept = time((long *)0);
131 <        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n",
131 >        sprintf(errmsg, "%lu rays, %4.2f%% done after %5.4f hours\n",
132                          nrays, pctdone, (tlastrept-tstart)/3600.0);
133          eputs(errmsg);
134 <        signal(SIGALRM, report);
134 >        signal(SIGCONT, report);
135   }
136   #endif
137  
# Line 149 | Line 153 | char  *pout, *zout, *prvr;
153   {
154          extern char  *rindex(), *strncpy(), *strcat(), *strcpy();
155          char  fbuf[128], fbuf2[128];
156 +        int  npicts;
157          register char  *cp;
158          RESOLU  rs;
159          double  pa;
# Line 193 | Line 198 | char  *pout, *zout, *prvr;
198                          }
199                  }
200          }
201 <                                        /* render sequence */
201 >        npicts = 0;                     /* render sequence */
202          do {
203                  if (seq && nextview(stdin) == EOF)
204                          break;
205 +                pctdone = 0.0;
206                  if (pout != NULL) {
207                          sprintf(fbuf, pout, seq);
208 +                        if (prvr == NULL && access(fbuf, F_OK) == 0)
209 +                                continue;               /* don't clobber */
210                          if (freopen(fbuf, "w", stdout) == NULL) {
211                                  sprintf(errmsg,
212                                          "cannot open output file \"%s\"", fbuf);
# Line 246 | Line 254 | char  *pout, *zout, *prvr;
254                          cp = NULL;
255                  render(cp, prvr);
256                  prvr = NULL;
257 +                npicts++;
258          } while (seq++);
259 +                                        /* check that we did something */
260 +        if (npicts == 0)
261 +                error(WARNING, "no output produced");
262   }
263  
264  
# Line 292 | Line 304 | char  *zfile, *oldfile;
304                          sampdens[i] = hstep;
305          } else
306                  sampdens = NULL;
307 <                                        /* open z file */
307 >                                        /* open z-file */
308          if (zfile != NULL) {
309                  if ((zfd = open(zfile, O_WRONLY|O_CREAT, 0666)) == -1) {
310 <                        sprintf(errmsg, "cannot open z file \"%s\"", zfile);
310 >                        sprintf(errmsg, "cannot open z-file \"%s\"", zfile);
311                          error(SYSTEM, errmsg);
312                  }
313   #ifdef MSDOS
# Line 317 | Line 329 | char  *zfile, *oldfile;
329          i = salvage(oldfile);
330          if (zfd != -1 && i > 0 &&
331                          lseek(zfd, (long)i*hres*sizeof(float), 0) == -1)
332 <                error(SYSTEM, "z file seek error in render");
332 >                error(SYSTEM, "z-file seek error in render");
333          pctdone = 100.0*i/vres;
334          if (ralrm > 0)                  /* report init stats */
335                  report();
336   #ifndef  BSD
337          else
338   #endif
339 <        signal(SIGALRM, report);
339 >        signal(SIGCONT, report);
340          ypos = vres-1 - i;
341          fillscanline(scanbar[0], zbar[0], sampdens, hres, ypos, hstep);
342                                                  /* compute scanlines */
# Line 347 | Line 359 | char  *zfile, *oldfile;
359                  fillscanbar(scanbar, zbar, hres, ypos, ystep);
360                                                          /* write it out */
361   #ifndef  BSD
362 <                signal(SIGALRM, SIG_IGN);       /* don't interrupt writes */
362 >                signal(SIGCONT, SIG_IGN);       /* don't interrupt writes */
363   #endif
364                  for (i = ystep; i > 0; i--) {
365                          if (zfd != -1 && write(zfd, (char *)zbar[i],
# Line 365 | Line 377 | char  *zfile, *oldfile;
377                          report();
378   #ifndef  BSD
379                  else
380 <                        signal(SIGALRM, report);
380 >                        signal(SIGCONT, report);
381   #endif
382          }
383                                                  /* clean up */
384 <        signal(SIGALRM, SIG_IGN);
384 >        signal(SIGCONT, SIG_IGN);
385          if (zfd != -1) {
386                  if (write(zfd, (char *)zbar[0], hres*sizeof(float))
387                                  < hres*sizeof(float))
# Line 389 | Line 401 | char  *zfile, *oldfile;
401          pctdone = 100.0;
402          if (ralrm > 0)
403                  report();
404 +        signal(SIGCONT, SIG_DFL);
405          return;
406   writerr:
407          error(SYSTEM, "write error in render");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines