ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rpiece.c
(Generate patch)

Comparing ray/src/util/rpiece.c (file contents):
Revision 2.28 by greg, Tue Oct 19 16:02:39 1993 UTC vs.
Revision 2.36 by gwlarson, Thu Jun 18 09:23:49 1998 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1993 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 47 | Line 47 | char *argv[];
47   #define guard_io()      0
48   #define unguard()       0
49   #endif
50 +
51 + #ifndef linux
52 + extern char  *sys_errlist[];
53 + #endif
54 +
55                                  /* rpict command */
56   char  *rpargv[128] = {"rpict", "-S", "1"};
57   int  rpargc = 3;
# Line 69 | Line 74 | int  nforked = 0;
74  
75   char  *progname;
76   int  verbose = 0;
77 + unsigned  timelim = 0;
78   int  rvrlim = -1;
79  
74 extern long  lseek(), ftell();
75
80   int  gotalrm = 0;
81   int  onalrm() { gotalrm++; }
82  
# Line 118 | Line 122 | char  *argv[];
122                          case 'p':               /* pixel aspect ratio? */
123                                  if (argv[i][2] != 'a' || argv[i][3])
124                                          break;
125 <                                pixaspect = atof(argv[i+1]);
125 >                                pixaspect = atof(argv[++i]);
126                                  continue;
127 +                        case 'T':               /* time limit (hours) */
128 +                                if (argv[i][2])
129 +                                        break;
130 +                                timelim = atof(argv[++i])*3600. + .5;
131 +                                break;
132                          case 'x':               /* overall x resolution */
133                                  if (argv[i][2])
134                                          break;
# Line 187 | Line 196 | int  fd;
196   int  ltyp;
197   {
198          static struct flock  fls;       /* static so initialized to zeroes */
190        extern char  *sys_errlist[];
199  
200          fls.l_type = ltyp;
201          if (fcntl(fd, F_SETLKW, &fls) < 0) {
# Line 233 | Line 241 | char  **av;
241                  dolock(outfd, F_WRLCK);
242                  if ((fp = fdopen(dup(outfd), "w")) == NULL)
243                          goto filerr;
244 <                printargs(ac, av, fp);          /* write header */
244 >                newheader("RADIANCE", fp);      /* create header */
245 >                printargs(ac, av, fp);
246                  fprintf(fp, "SOFTWARE= %s\n", VersionID);
247                  fputs(VIEWSTR, fp);
248                  fprintview(&ourview, fp);
# Line 279 | Line 288 | char  **av;
288                  exit(1);
289          }
290          signal(SIGALRM, onalrm);
291 +        if (timelim)
292 +                alarm(timelim);
293          return;
294   filerr:
295          fprintf(stderr, "%s: i/o error on file \"%s\"\n", progname, outfile);
# Line 344 | Line 355 | register int  *xp, *yp;
355                  return(0);              /* only check if asked */
356          if (pdone == NULL)              /* first call */
357                  pdone = calloc(hmult*vmult, sizeof(char));
358 +        if (pdone == NULL) {
359 +                fprintf(stderr, "%s: out of memory\n", progname);
360 +                exit(1);
361 +        }
362          if (readpos != -1)              /* mark what's been done */
363                  fseek(syncfp, readpos, 0);
364          while (fscanf(syncfp, "%d %d", xp, yp) == 2)
# Line 402 | Line 417 | rpiece()                       /* render picture piece by piece */
417                  pview.horiz = ourview.horiz / hmult;
418                  pview.vert = ourview.vert / vmult;
419                  break;
420 +        case VT_CYL:
421 +                pview.horiz = ourview.horiz / hmult;
422 +                pview.vert = 2.*180./PI*atan(
423 +                                tan(PI/180./2.*ourview.vert)/vmult );
424 +                break;
425          case VT_HEM:
426                  pview.horiz = 2.*180./PI*asin(
427                                  sin(PI/180./2.*ourview.horiz)/hmult );
# Line 415 | Line 435 | rpiece()                       /* render picture piece by piece */
435          }
436                                          /* render each piece */
437          while (nextpiece(&xorg, &yorg)) {
438 <                pview.hoff = ourview.hoff + xorg - 0.5*(hmult-1);
439 <                pview.voff = ourview.voff + yorg - 0.5*(vmult-1);
438 >                pview.hoff = ourview.hoff*hmult + xorg - 0.5*(hmult-1);
439 >                pview.voff = ourview.voff*vmult + yorg - 0.5*(vmult-1);
440                  fputs(VIEWSTR, torp);
441                  fprintview(&pview, torp);
442                  putc('\n', torp);
# Line 488 | Line 508 | int  xpos, ypos;
508                  filerr("lock");
509   #endif
510                                  /* write new piece to file */
511 <        if (lseek(outfd, fls.l_start, 0) == -1)
511 >        if (lseek(outfd, fls.l_start, 0) < 0)
512                  filerr("seek");
513          if (hmult == 1) {
514                  if (writebuf(outfd, (char *)pbuf,
# Line 501 | Line 521 | int  xpos, ypos;
521                                  filerr("write");
522                          if (y < vr-1 && lseek(outfd,
523                                          (long)(hmult-1)*hr*sizeof(COLR),
524 <                                        1) == -1)
524 >                                        1) < 0)
525                                  filerr("seek");
526                  }
527   #if NFS
# Line 509 | Line 529 | int  xpos, ypos;
529          if (fcntl(outfd, F_SETLKW, &fls) < 0)
530                  filerr("lock");
531   #endif
532 +        if (verbose) {                          /* notify caller */
533 +                printf("%d %d done\n", xpos, ypos);
534 +                fflush(stdout);
535 +        }
536          if (syncfp != NULL) {                   /* record what's been done */
537                  sflock(F_WRLCK);
538                  fseek(syncfp, 0L, 2);           /* append index */
# Line 517 | Line 541 | int  xpos, ypos;
541                                  /*** Unlock not necessary, since
542                  sflock(F_UNLCK);        _exit() or nextpiece() is next ***/
543          }
520        if (verbose) {                          /* notify caller */
521                printf("%d %d done\n", xpos, ypos);
522                fflush(stdout);
523        }
544          if (pid == -1)          /* didn't fork or fork failed */
545                  return(0);
546          _exit(0);               /* else exit child process (releasing locks) */
# Line 530 | Line 550 | int  xpos, ypos;
550   filerr(t)                       /* report file error and exit */
551   char  *t;
552   {
533        extern char  *sys_errlist[];
534
553          fprintf(stderr, "%s: %s error on file \"%s\": %s\n",
554                          progname, t, outfile, sys_errlist[errno]);
555          _exit(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines