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.16 by greg, Tue Oct 6 12:30:07 1992 UTC vs.
Revision 2.24 by greg, Tue May 25 10:30:08 1993 UTC

# Line 27 | Line 27 | static char SCCSid[] = "$SunId$ LBL";
27  
28   #include  "paths.h"
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 45 | Line 51 | double shadthresh = .05;               /* shadow threshold */
51   double  shadcert = .5;                  /* shadow certainty */
52   int  directrelay = 1;                   /* number of source relays */
53   int  vspretest = 512;                   /* virtual source pretest density */
54 < int  directinvis = 0;                   /* sources invisible? */
54 > int  directvis = 1;                     /* sources visible? */
55   double  srcsizerat = .25;               /* maximum ratio source size/dist. */
56  
57   double  specthresh = .15;               /* specular sampling threshold */
# Line 76 | 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  
89   #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
90  
85 #define  RFTEMPLATE     "rfXXXXXX"
86 #define  HFTEMPLATE     TEMPLATE
87
88 static char  *hfname = NULL;            /* header file name */
89 static FILE  *hfp = NULL;               /* header file pointer */
90
91   static int  hres, vres;                 /* resolution for this frame */
92  
93   extern char  *mktemp();
# Line 100 | Line 100 | int  code;
100   {
101          if (code)                       /* report status */
102                  report();
103 <        if (hfname != NULL) {           /* delete header file */
104 <                if (hfp != NULL)
105 <                        fclose(hfp);
106 <                unlink(hfname);
107 <        }
103 >        headclean();                    /* delete header file */
104 >        pfclean();                      /* clean up persist files */
105          exit(code);
106   }
107  
# Line 122 | 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 131 | 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  
138  
142 openheader()                    /* save standard output to header file */
143 {
144        hfname = mktemp(HFTEMPLATE);
145        if (freopen(hfname, "w", stdout) == NULL) {
146                sprintf(errmsg, "cannot open header file \"%s\"", hfname);
147                error(SYSTEM, errmsg);
148        }
149 }
150
151
152 closeheader()                   /* done with header output */
153 {
154        if (hfname == NULL)
155                return;
156        if (fflush(stdout) == EOF || (hfp = fopen(hfname, "r")) == NULL)
157                error(SYSTEM, "error reopening header file");
158 }
159
160
161 dupheader()                     /* repeat header on standard output */
162 {
163        register int  c;
164
165        if (fseek(hfp, 0L, 0) < 0)
166                error(SYSTEM, "seek error on header file");
167        while ((c = getc(hfp)) != EOF)
168                putchar(c);
169 }
170
171
139   rpict(seq, pout, zout, prvr)                    /* generate image(s) */
140   int  seq;
141   char  *pout, *zout, *prvr;
# Line 184 | Line 151 | char  *pout, *zout, *prvr;
151   * sequenced file naming.
152   */
153   {
154 <        extern char  *rindex(), *strncpy(), *strcat();
154 >        extern char  *rindex(), *strncpy(), *strcat(), *strcpy();
155          char  fbuf[128], fbuf2[128];
156          register char  *cp;
157          RESOLU  rs;
158          double  pa;
192                                        /* finished writing header */
193        closeheader();
159                                          /* check sampling */
160          if (psample < 1)
161                  psample = 1;
# Line 214 | Line 179 | char  *pout, *zout, *prvr;
179                                  error(USER, "unexpected EOF on view input");
180                  prvr = fbuf;                    /* mark for renaming */
181          }
182 <        if (pout != NULL) {
182 >        if (pout != NULL & prvr != NULL) {
183                  sprintf(fbuf, pout, seq);
184 <                if (prvr != NULL && !strcmp(prvr, fbuf)) {      /* rename */
185 <                        fbuf2[0] = '\0';
186 <                        if ((cp = rindex(fbuf, '/')) != NULL)
187 <                                strncpy(fbuf2, fbuf, cp-fbuf+1);
188 <                        strcat(fbuf2, RFTEMPLATE);
184 >                if (!strcmp(prvr, fbuf)) {      /* rename */
185 >                        strcpy(fbuf2, fbuf);
186 >                        for (cp = fbuf2; *cp; cp++)
187 >                                ;
188 >                        while (cp > fbuf2 && !ISDIRSEP(cp[-1]))
189 >                                cp--;
190 >                        strcpy(cp, RFTEMPLATE);
191                          prvr = mktemp(fbuf2);
192                          if (rename(fbuf, prvr) < 0 && errno != ENOENT) {
193                                  sprintf(errmsg,
# Line 241 | Line 208 | char  *pout, *zout, *prvr;
208                                          "cannot open output file \"%s\"", fbuf);
209                                  error(SYSTEM, errmsg);
210                          }
211 + #ifdef MSDOS
212 +                        setmode(fileno(stdout), O_BINARY);
213 + #endif
214                          dupheader();
215                  }
216                  hres = hresolu; vres = vresolu; pa = pixaspect;
# Line 332 | Line 302 | char  *zfile, *oldfile;
302                          sprintf(errmsg, "cannot open z file \"%s\"", zfile);
303                          error(SYSTEM, errmsg);
304                  }
305 + #ifdef MSDOS
306 +                setmode(zfd, O_BINARY);
307 + #endif
308                  for (i = 0; i <= psample; i++) {
309                          zbar[i] = (float *)malloc(hres*sizeof(float));
310                          if (zbar[i] == NULL)
# Line 355 | Line 328 | char  *zfile, *oldfile;
328   #ifndef  BSD
329          else
330   #endif
331 <        signal(SIGALRM, report);
331 >        signal(SIGCONT, report);
332          ypos = vres-1 - i;
333          fillscanline(scanbar[0], zbar[0], sampdens, hres, ypos, hstep);
334                                                  /* compute scanlines */
# Line 378 | Line 351 | char  *zfile, *oldfile;
351                  fillscanbar(scanbar, zbar, hres, ypos, ystep);
352                                                          /* write it out */
353   #ifndef  BSD
354 <                signal(SIGALRM, SIG_IGN);       /* don't interrupt writes */
354 >                signal(SIGCONT, SIG_IGN);       /* don't interrupt writes */
355   #endif
356                  for (i = ystep; i > 0; i--) {
357                          if (zfd != -1 && write(zfd, (char *)zbar[i],
# Line 396 | Line 369 | char  *zfile, *oldfile;
369                          report();
370   #ifndef  BSD
371                  else
372 <                        signal(SIGALRM, report);
372 >                        signal(SIGCONT, report);
373   #endif
374          }
375                                                  /* clean up */
376 <        signal(SIGALRM, SIG_IGN);
376 >        signal(SIGCONT, SIG_IGN);
377          if (zfd != -1) {
378                  if (write(zfd, (char *)zbar[0], hres*sizeof(float))
379                                  < hres*sizeof(float))
# Line 420 | Line 393 | char  *zfile, *oldfile;
393          pctdone = 100.0;
394          if (ralrm > 0)
395                  report();
396 +        signal(SIGCONT, SIG_DFL);
397          return;
398   writerr:
399          error(SYSTEM, "write error in render");
# Line 589 | Line 563 | char  *oldfile;
563                  error(WARNING, errmsg);
564                  return(0);
565          }
566 + #ifdef MSDOS
567 +        setmode(fileno(fp), O_BINARY);
568 + #endif
569                                  /* discard header */
570 <        getheader(fp, NULL);
570 >        getheader(fp, NULL, NULL);
571                                  /* get picture size */
572          if (!fscnresolu(&x, &y, fp)) {
573                  sprintf(errmsg, "bad recover file \"%s\"", oldfile);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines