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.88 by greg, Fri May 9 23:28:57 2014 UTC vs.
Revision 2.94 by greg, Mon Jul 20 15:52:30 2020 UTC

# Line 34 | Line 34 | static const char RCSid[] = "$Id$";
34   #include  "random.h"
35   #include  "paths.h"
36   #include  "hilbert.h"
37 + #include  "pmapbias.h"
38 + #include  "pmapdiag.h"
39  
38
40   #define  RFTEMPLATE     "rfXXXXXX"
41  
42   #ifndef SIGCONT
# Line 133 | Line 134 | static int pixnumber(int  x, int  y, int  xres, int  y
134  
135  
136  
136 #ifdef RHAS_STAT
137 #include  <sys/types.h>
138 #include  <sys/stat.h>
139 int
140 file_exists(fname)                              /* ordinary file exists? */
141 char  *fname;
142 {
143        struct stat  sbuf;
144        if (stat(fname, &sbuf) < 0) return(0);
145        return((sbuf.st_mode & S_IFREG) != 0);
146 }
147 #else
148 #define  file_exists(f) (access(f,F_OK)==0)
149 #endif
150
151
137   void
138 < quit(code)                      /* quit program */
154 < int  code;
138 > quit(int code)                  /* quit program */
139   {
140          if (code)                       /* report status */
141                  report(0);
# Line 167 | Line 151 | int  code;
151   static void
152   report(int dummy)               /* report progress */
153   {
154 +        char                    bcStat [128];
155          double          u, s;
156   #ifdef BSD
157          struct rusage   rubuf;
# Line 192 | Line 177 | report(int dummy)              /* report progress */
177          s = ( tbuf.tms_stime + tbuf.tms_cstime ) * period;
178   #endif
179  
180 +        /* PMAP: Get photon map bias compensation statistics */
181 +        pmapBiasCompReport(bcStat);
182 +        
183          sprintf(errmsg,
184 <            "%lu rays, %4.2f%% after %.3fu %.3fs %.3fr hours on %s (PID %d)\n",
185 <                        nrays, pctdone, u*(1./3600.), s*(1./3600.),
184 >                        "%lu rays, %s%4.2f%% after %.3fu %.3fs %.3fr hours on %s (PID %d)\n",
185 >                        nrays, bcStat, pctdone, u*(1./3600.), s*(1./3600.),
186                          (tlastrept-tstart)*(1./3600.), myhostname(), getpid());
187          eputs(errmsg);
188   #ifdef SIGCONT
# Line 205 | Line 193 | report(int dummy)              /* report progress */
193   static void
194   report(int dummy)               /* report progress */
195   {
196 +        char    bcStat [128];
197 +        
198          tlastrept = time((time_t *)NULL);
199 <        sprintf(errmsg, "%lu rays, %4.2f%% after %5.4f hours\n",
200 <                        nrays, pctdone, (tlastrept-tstart)/3600.0);
199 >
200 >        /* PMAP: Get photon map bias compensation statistics */
201 >        pmapBiasCompReport(bcStat);
202 >        
203 >        sprintf(errmsg, "%lu rays, %s%4.2f%% after %5.4f hours\n",
204 >                        nrays, bcStat, pctdone, (tlastrept-tstart)/3600.0);
205          eputs(errmsg);
206   }
207   #endif
# Line 293 | Line 287 | rpict(                 /* generate image(s) */
287                          break;
288                  pctdone = 0.0;
289                  if (pout != NULL) {
290 +                        int     myfd;
291 +                        close(1);                       /* reassign stdout */
292                          sprintf(fbuf, pout, seq);
293 <                        if (file_exists(fbuf)) {
294 <                                if (prvr != NULL || !strcmp(fbuf, pout)) {
293 >                tryagain:
294 >                        errno = 0;                      /* exclusive open */
295 >                        if ((myfd = open(fbuf, O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0) {
296 >                                if ((errno != EEXIST) | (prvr != NULL) ||
297 >                                                !strcmp(fbuf, pout)) {
298                                          sprintf(errmsg,
299 <                                                "output file \"%s\" exists",
299 >                                                "cannot open output file \"%s\"",
300                                                  fbuf);
301 <                                        error(USER, errmsg);
301 >                                        error(SYSTEM, errmsg);
302                                  }
303                                  setview(&ourview);
304                                  continue;               /* don't clobber */
305                          }
306 <                        if (freopen(fbuf, "w", stdout) == NULL) {
307 <                                sprintf(errmsg,
308 <                                        "cannot open output file \"%s\"", fbuf);
310 <                                error(SYSTEM, errmsg);
306 >                        if (myfd != 1) {
307 >                                unlink(fbuf);
308 >                                goto tryagain;          /* leave it open */
309                          }
310 <                        SET_FILE_BINARY(stdout);
310 >                        SET_FD_BINARY(1);
311                          dupheader();
312                  }
313                  hres = hresolu; vres = vresolu; pa = pixaspect;
# Line 735 | Line 733 | pixvalue(              /* compute pixel value */
733  
734          copycolor(col, thisray.rcol);           /* return color */
735  
736 <        return(thisray.rt);                     /* return distance */
736 >        return(raydistance(&thisray));          /* return distance */
737   }
738  
739  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines