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.29 by greg, Mon Feb 28 09:22:32 1994 UTC vs.
Revision 2.37 by greg, Sat Feb 22 02:07:30 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1993 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Generate sections of a picture.
6   */
# Line 25 | Line 22 | char *argv[];
22   #include <signal.h>
23   #include "color.h"
24   #include "view.h"
28 #include "resolu.h"
25  
26   #ifndef NFS
27   #define  NFS                    1
# Line 47 | Line 43 | char *argv[];
43   #define guard_io()      0
44   #define unguard()       0
45   #endif
46 +
47 + extern char  *strerror();
48 +
49                                  /* rpict command */
50   char  *rpargv[128] = {"rpict", "-S", "1"};
51   int  rpargc = 3;
# Line 69 | Line 68 | int  nforked = 0;
68  
69   char  *progname;
70   int  verbose = 0;
71 + unsigned  timelim = 0;
72   int  rvrlim = -1;
73  
74 extern long  lseek(), ftell();
75
74   int  gotalrm = 0;
75   int  onalrm() { gotalrm++; }
76  
# Line 86 | Line 84 | char  *argv[];
84          progname = argv[0];
85          for (i = 1; i < argc; i++) {
86                                                  /* expand arguments */
87 <                while (rval = expandarg(&argc, &argv, i))
88 <                        if (rval < 0) {
89 <                                fprintf(stderr, "%s: cannot expand '%s'",
90 <                                                argv[0], argv[i]);
91 <                                exit(1);
92 <                        }
87 >                while ((rval = expandarg(&argc, &argv, i)) > 0)
88 >                        ;
89 >                if (rval < 0) {
90 >                        fprintf(stderr, "%s: cannot expand '%s'",
91 >                                        argv[0], argv[i]);
92 >                        exit(1);
93 >                }
94                  if (argv[i][0] == '-')
95                          switch (argv[i][1]) {
96                          case 'v':
# Line 118 | Line 117 | char  *argv[];
117                          case 'p':               /* pixel aspect ratio? */
118                                  if (argv[i][2] != 'a' || argv[i][3])
119                                          break;
120 <                                pixaspect = atof(argv[i+1]);
120 >                                pixaspect = atof(argv[++i]);
121                                  continue;
122 +                        case 'T':               /* time limit (hours) */
123 +                                if (argv[i][2])
124 +                                        break;
125 +                                timelim = atof(argv[++i])*3600. + .5;
126 +                                break;
127                          case 'x':               /* overall x resolution */
128                                  if (argv[i][2])
129                                          break;
# Line 187 | Line 191 | int  fd;
191   int  ltyp;
192   {
193          static struct flock  fls;       /* static so initialized to zeroes */
190        extern char  *sys_errlist[];
194  
195          fls.l_type = ltyp;
196          if (fcntl(fd, F_SETLKW, &fls) < 0) {
197                  fprintf(stderr, "%s: cannot lock/unlock file: %s\n",
198 <                                progname, sys_errlist[errno]);
198 >                                progname, strerror(errno));
199                  exit(1);
200          }
201   }
# Line 280 | Line 283 | char  **av;
283                  exit(1);
284          }
285          signal(SIGALRM, onalrm);
286 +        if (timelim)
287 +                alarm(timelim);
288          return;
289   filerr:
290          fprintf(stderr, "%s: i/o error on file \"%s\"\n", progname, outfile);
# Line 345 | Line 350 | register int  *xp, *yp;
350                  return(0);              /* only check if asked */
351          if (pdone == NULL)              /* first call */
352                  pdone = calloc(hmult*vmult, sizeof(char));
353 +        if (pdone == NULL) {
354 +                fprintf(stderr, "%s: out of memory\n", progname);
355 +                exit(1);
356 +        }
357          if (readpos != -1)              /* mark what's been done */
358                  fseek(syncfp, readpos, 0);
359          while (fscanf(syncfp, "%d %d", xp, yp) == 2)
# Line 403 | Line 412 | rpiece()                       /* render picture piece by piece */
412                  pview.horiz = ourview.horiz / hmult;
413                  pview.vert = ourview.vert / vmult;
414                  break;
415 +        case VT_CYL:
416 +                pview.horiz = ourview.horiz / hmult;
417 +                pview.vert = 2.*180./PI*atan(
418 +                                tan(PI/180./2.*ourview.vert)/vmult );
419 +                break;
420          case VT_HEM:
421                  pview.horiz = 2.*180./PI*asin(
422                                  sin(PI/180./2.*ourview.horiz)/hmult );
# Line 416 | Line 430 | rpiece()                       /* render picture piece by piece */
430          }
431                                          /* render each piece */
432          while (nextpiece(&xorg, &yorg)) {
433 <                pview.hoff = ourview.hoff + xorg - 0.5*(hmult-1);
434 <                pview.voff = ourview.voff + yorg - 0.5*(vmult-1);
433 >                pview.hoff = ourview.hoff*hmult + xorg - 0.5*(hmult-1);
434 >                pview.voff = ourview.voff*vmult + yorg - 0.5*(vmult-1);
435                  fputs(VIEWSTR, torp);
436                  fprintview(&pview, torp);
437                  putc('\n', torp);
# Line 489 | Line 503 | int  xpos, ypos;
503                  filerr("lock");
504   #endif
505                                  /* write new piece to file */
506 <        if (lseek(outfd, fls.l_start, 0) == -1)
506 >        if (lseek(outfd, (off_t)fls.l_start, 0) < 0)
507                  filerr("seek");
508          if (hmult == 1) {
509                  if (writebuf(outfd, (char *)pbuf,
# Line 501 | Line 515 | int  xpos, ypos;
515                                          hr*sizeof(COLR)) != hr*sizeof(COLR))
516                                  filerr("write");
517                          if (y < vr-1 && lseek(outfd,
518 <                                        (long)(hmult-1)*hr*sizeof(COLR),
519 <                                        1) == -1)
518 >                                        (off_t)(hmult-1)*hr*sizeof(COLR),
519 >                                        1) < 0)
520                                  filerr("seek");
521                  }
522   #if NFS
# Line 510 | Line 524 | int  xpos, ypos;
524          if (fcntl(outfd, F_SETLKW, &fls) < 0)
525                  filerr("lock");
526   #endif
527 +        if (verbose) {                          /* notify caller */
528 +                printf("%d %d done\n", xpos, ypos);
529 +                fflush(stdout);
530 +        }
531          if (syncfp != NULL) {                   /* record what's been done */
532                  sflock(F_WRLCK);
533                  fseek(syncfp, 0L, 2);           /* append index */
# Line 518 | Line 536 | int  xpos, ypos;
536                                  /*** Unlock not necessary, since
537                  sflock(F_UNLCK);        _exit() or nextpiece() is next ***/
538          }
521        if (verbose) {                          /* notify caller */
522                printf("%d %d done\n", xpos, ypos);
523                fflush(stdout);
524        }
539          if (pid == -1)          /* didn't fork or fork failed */
540                  return(0);
541          _exit(0);               /* else exit child process (releasing locks) */
# Line 531 | Line 545 | int  xpos, ypos;
545   filerr(t)                       /* report file error and exit */
546   char  *t;
547   {
534        extern char  *sys_errlist[];
535
548          fprintf(stderr, "%s: %s error on file \"%s\": %s\n",
549 <                        progname, t, outfile, sys_errlist[errno]);
549 >                        progname, t, outfile, strerror(errno));
550          _exit(1);
551   }
552  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines