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.23 by greg, Fri Jan 29 12:15:40 1993 UTC vs.
Revision 2.27 by greg, Mon Aug 2 21:48:37 1993 UTC

# Line 82 | 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 94 | Line 94 | extern char  *mktemp();
94  
95   double  pixvalue();
96  
97 + #ifdef NIX
98 + #define  file_exists(f) (access(f,F_OK)==0)
99 + #else
100 + #include  <sys/types.h>
101 + #include  <sys/stat.h>
102 + int
103 + file_exists(fname)                              /* ordinary file exists? */
104 + char  *fname;
105 + {
106 +        struct stat  sbuf;
107 +        if (stat(fname, &sbuf) < 0) return(0);
108 +        return((sbuf.st_mode & S_IFREG) != 0);
109 + }
110 + #endif
111  
112 +
113   quit(code)                      /* quit program */
114   int  code;
115   {
# Line 119 | Line 134 | report()               /* report progress */
134          t += (rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec) / 1e6;
135          t += rubuf.ru_utime.tv_sec + rubuf.ru_stime.tv_sec;
136  
137 <        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n",
137 >        sprintf(errmsg, "%lu rays, %4.2f%% done after %5.4f CPU hours\n",
138                          nrays, pctdone, t/3600.0);
139          eputs(errmsg);
140          tlastrept = time((long *)0);
# Line 128 | Line 143 | report()               /* report progress */
143   report()                /* report progress */
144   {
145          tlastrept = time((long *)0);
146 <        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n",
146 >        sprintf(errmsg, "%lu rays, %4.2f%% done after %5.4f hours\n",
147                          nrays, pctdone, (tlastrept-tstart)/3600.0);
148          eputs(errmsg);
149          signal(SIGCONT, report);
# Line 153 | Line 168 | char  *pout, *zout, *prvr;
168   {
169          extern char  *rindex(), *strncpy(), *strcat(), *strcpy();
170          char  fbuf[128], fbuf2[128];
171 +        int  npicts;
172          register char  *cp;
173          RESOLU  rs;
174          double  pa;
# Line 197 | Line 213 | char  *pout, *zout, *prvr;
213                          }
214                  }
215          }
216 <                                        /* render sequence */
216 >        npicts = 0;                     /* render sequence */
217          do {
218                  if (seq && nextview(stdin) == EOF)
219                          break;
220 +                pctdone = 0.0;
221                  if (pout != NULL) {
222                          sprintf(fbuf, pout, seq);
223 +                        if (file_exists(fbuf)) {
224 +                                if (prvr != NULL || !strcmp(fbuf, pout)) {
225 +                                        sprintf(errmsg,
226 +                                                "output file \"%s\" exists",
227 +                                                fbuf);
228 +                                        error(USER, errmsg);
229 +                                }
230 +                                continue;               /* don't clobber */
231 +                        }
232                          if (freopen(fbuf, "w", stdout) == NULL) {
233                                  sprintf(errmsg,
234                                          "cannot open output file \"%s\"", fbuf);
# Line 250 | Line 276 | char  *pout, *zout, *prvr;
276                          cp = NULL;
277                  render(cp, prvr);
278                  prvr = NULL;
279 +                npicts++;
280          } while (seq++);
281 +                                        /* check that we did something */
282 +        if (npicts == 0)
283 +                error(WARNING, "no output produced");
284   }
285  
286  
# Line 296 | Line 326 | char  *zfile, *oldfile;
326                          sampdens[i] = hstep;
327          } else
328                  sampdens = NULL;
329 <                                        /* open z file */
329 >                                        /* open z-file */
330          if (zfile != NULL) {
331                  if ((zfd = open(zfile, O_WRONLY|O_CREAT, 0666)) == -1) {
332 <                        sprintf(errmsg, "cannot open z file \"%s\"", zfile);
332 >                        sprintf(errmsg, "cannot open z-file \"%s\"", zfile);
333                          error(SYSTEM, errmsg);
334                  }
335   #ifdef MSDOS
# Line 321 | Line 351 | char  *zfile, *oldfile;
351          i = salvage(oldfile);
352          if (zfd != -1 && i > 0 &&
353                          lseek(zfd, (long)i*hres*sizeof(float), 0) == -1)
354 <                error(SYSTEM, "z file seek error in render");
354 >                error(SYSTEM, "z-file seek error in render");
355          pctdone = 100.0*i/vres;
356          if (ralrm > 0)                  /* report init stats */
357                  report();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines