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.53 by greg, Tue Feb 25 02:47:23 2003 UTC vs.
Revision 2.59 by greg, Thu Jul 3 18:03:58 2003 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char       RCSid[] = "$Id$";
2 > static const char RCSid[] = "$Id";
3   #endif
4   /*
5   *  rpict.c - routines and variables for picture generation.
# Line 11 | Line 11 | static const char      RCSid[] = "$Id$";
11  
12   #include  <sys/types.h>
13  
14 < #ifndef NIX
14 > #ifndef NON_POSIX
15   #ifdef BSD
16   #include  <sys/time.h>
17   #include  <sys/resource.h>
# Line 21 | Line 21 | static const char      RCSid[] = "$Id$";
21   #endif
22   #endif
23  
24 < extern time_t   time();
25 <
24 > #include  <time.h>
25   #include  <signal.h>
26  
27 + #include  "platform.h"
28   #include  "view.h"
29
29   #include  "random.h"
31
30   #include  "paths.h"
31  
32 +
33   #define  RFTEMPLATE     "rfXXXXXX"
34  
35   #ifndef SIGCONT
36 + #ifdef SIGIO     /* XXX can we live without this? */
37   #define SIGCONT         SIGIO
38   #endif
39 + #endif
40  
41   CUBE  thescene;                         /* our scene */
42   OBJECT  nsceneobjs;                     /* number of objects in our scene */
# Line 108 | Line 109 | int  hres, vres;                       /* resolution for this frame */
109  
110   static VIEW     lastview;               /* the previous view input */
111  
112 < extern char  *mktemp();
112 > extern char  *mktemp();  /* XXX should be in stdlib.h or unistd.h */
113  
114   void  report();
115  
116   double  pixvalue();
117  
118 < #ifdef NIX
118 < #define  file_exists(f) (access(f,F_OK)==0)
119 < #else
118 > #ifdef RHAS_STAT
119   #include  <sys/types.h>
120   #include  <sys/stat.h>
121   int
# Line 127 | Line 126 | char  *fname;
126          if (stat(fname, &sbuf) < 0) return(0);
127          return((sbuf.st_mode & S_IFREG) != 0);
128   }
129 + #else
130 + #define  file_exists(f) (access(f,F_OK)==0)
131   #endif
132  
133  
# Line 136 | Line 137 | int  code;
137   {
138          if (code)                       /* report status */
139                  report();
140 < #ifndef NIX
140 > #ifndef NON_POSIX
141          headclean();                    /* delete header file */
142          pfclean();                      /* clean up persist files */
143   #endif
# Line 144 | Line 145 | int  code;
145   }
146  
147  
148 < #ifndef NIX
148 > #ifndef NON_POSIX
149   void
150   report()                /* report progress */
151   {
# Line 181 | Line 182 | report()               /* report progress */
182                          nrays, pctdone, u/3600., s/3600.,
183                          (tlastrept-tstart)/3600., myhostname());
184          eputs(errmsg);
185 < #ifndef BSD
185 > #ifdef SIGCONT
186          signal(SIGCONT, report);
187   #endif
188   }
# Line 213 | Line 214 | char  *pout, *zout, *prvr;
214   * sequenced file naming.
215   */
216   {
216        extern char  *rindex(), *strncpy(), *strcat(), *strcpy();
217          char  fbuf[128], fbuf2[128];
218          int  npicts;
219          register char  *cp;
# Line 290 | Line 290 | char  *pout, *zout, *prvr;
290                                          "cannot open output file \"%s\"", fbuf);
291                                  error(SYSTEM, errmsg);
292                          }
293 < #ifdef MSDOS
294 <                        setmode(fileno(stdout), O_BINARY);
295 < #endif
293 >                        SET_FILE_BINARY(stdout);
294                          dupheader();
295                  }
296                  hres = hresolu; vres = vresolu; pa = pixaspect;
# Line 324 | Line 322 | char  *pout, *zout, *prvr;
322                  putchar('\n');
323                  if (pa < .99 || pa > 1.01)
324                          fputaspect(pa, stdout);
325 +                fputnow();
326                  fputformat(COLRFMT, stdout);
327                  putchar('\n');
328                  if (zout != NULL)
# Line 394 | Line 393 | char  *zfile, *oldfile;
393                          sprintf(errmsg, "cannot open z-file \"%s\"", zfile);
394                          error(SYSTEM, errmsg);
395                  }
396 < #ifdef MSDOS
398 <                setmode(zfd, O_BINARY);
399 < #endif
396 >                SET_FD_BINARY(zfd);
397                  for (i = 0; i <= psample; i++) {
398                          zbar[i] = (float *)malloc(hres*sizeof(float));
399                          if (zbar[i] == NULL)
# Line 419 | Line 416 | char  *zfile, *oldfile;
416          pctdone = 100.0*i/vres;
417          if (ralrm > 0)                  /* report init stats */
418                  report();
419 < #ifndef  BSD
419 > #ifdef SIGCONT
420          else
424 #endif
421          signal(SIGCONT, report);
422 + #endif
423          ypos = vres-1 - i;                      /* initialize sampling */
424          if (directvis)
425                  init_drawsources(psample);
# Line 448 | Line 445 | char  *zfile, *oldfile;
445                  if (directvis)                          /* add bitty sources */
446                          drawsources(scanbar, zbar, 0, hres, ypos, ystep);
447                                                          /* write it out */
448 < #ifndef  BSD
448 > #ifdef SIGCONT
449                  signal(SIGCONT, SIG_IGN);       /* don't interrupt writes */
450   #endif
451                  for (i = ystep; i > 0; i--) {
# Line 465 | Line 462 | char  *zfile, *oldfile;
462                  pctdone = 100.0*(vres-1-ypos)/vres;
463                  if (ralrm > 0 && time((time_t *)NULL) >= tlastrept+ralrm)
464                          report();
465 < #ifndef  BSD
465 > #ifdef SIGCONT
466                  else
467                          signal(SIGCONT, report);
468   #endif
469          }
470                                                  /* clean up */
471 + #ifdef SIGCONT
472          signal(SIGCONT, SIG_IGN);
473 + #endif
474          if (zfd != -1 && write(zfd, (char *)zbar[0], hres*sizeof(float))
475                                  < hres*sizeof(float))
476                  goto writerr;
# Line 492 | Line 491 | alldone:
491          pctdone = 100.0;
492          if (ralrm > 0)
493                  report();
494 + #ifdef SIGCONT
495          signal(SIGCONT, SIG_DFL);
496 + #endif
497          return;
498   writerr:
499          error(SYSTEM, "write error in render");
# Line 678 | Line 679 | char  *oldfile;
679                  error(WARNING, errmsg);
680                  goto gotzip;
681          }
682 < #ifdef MSDOS
682 <        setmode(fileno(fp), O_BINARY);
683 < #endif
682 >        SET_FILE_BINARY(fp);
683                                  /* discard header */
684          getheader(fp, NULL, NULL);
685                                  /* get picture size */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines