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.39 by schorsch, Thu Jun 26 00:58:11 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 23 | Line 20 | char *argv[];
20   #else
21  
22   #include <signal.h>
23 +
24   #include "color.h"
25   #include "view.h"
26 < #include "resolu.h"
26 > #include "rtprocess.h"
27  
28   #ifndef NFS
29   #define  NFS                    1
# Line 47 | Line 45 | char *argv[];
45   #define guard_io()      0
46   #define unguard()       0
47   #endif
48 +
49 + extern char  *strerror();
50 +
51                                  /* rpict command */
52   char  *rpargv[128] = {"rpict", "-S", "1"};
53   int  rpargc = 3;
53 int  rpd[3];
54   FILE  *torp, *fromrp;
55   COLR  *pbuf;
56                                  /* our view parameters */
# Line 69 | Line 69 | int  nforked = 0;
69  
70   char  *progname;
71   int  verbose = 0;
72 + unsigned  timelim = 0;
73   int  rvrlim = -1;
74  
74 extern long  lseek(), ftell();
75
75   int  gotalrm = 0;
76 < int  onalrm() { gotalrm++; }
76 > void  onalrm(int i) { gotalrm++; }
77  
78  
79   main(argc, argv)
# Line 86 | Line 85 | char  *argv[];
85          progname = argv[0];
86          for (i = 1; i < argc; i++) {
87                                                  /* expand arguments */
88 <                while (rval = expandarg(&argc, &argv, i))
89 <                        if (rval < 0) {
90 <                                fprintf(stderr, "%s: cannot expand '%s'",
91 <                                                argv[0], argv[i]);
92 <                                exit(1);
93 <                        }
88 >                while ((rval = expandarg(&argc, &argv, i)) > 0)
89 >                        ;
90 >                if (rval < 0) {
91 >                        fprintf(stderr, "%s: cannot expand '%s'",
92 >                                        argv[0], argv[i]);
93 >                        exit(1);
94 >                }
95                  if (argv[i][0] == '-')
96                          switch (argv[i][1]) {
97                          case 'v':
# Line 118 | Line 118 | char  *argv[];
118                          case 'p':               /* pixel aspect ratio? */
119                                  if (argv[i][2] != 'a' || argv[i][3])
120                                          break;
121 <                                pixaspect = atof(argv[i+1]);
121 >                                pixaspect = atof(argv[++i]);
122                                  continue;
123 +                        case 'T':               /* time limit (hours) */
124 +                                if (argv[i][2])
125 +                                        break;
126 +                                timelim = atof(argv[++i])*3600. + .5;
127 +                                break;
128                          case 'x':               /* overall x resolution */
129                                  if (argv[i][2])
130                                          break;
# Line 187 | Line 192 | int  fd;
192   int  ltyp;
193   {
194          static struct flock  fls;       /* static so initialized to zeroes */
190        extern char  *sys_errlist[];
195  
196          fls.l_type = ltyp;
197          if (fcntl(fd, F_SETLKW, &fls) < 0) {
198                  fprintf(stderr, "%s: cannot lock/unlock file: %s\n",
199 <                                progname, sys_errlist[errno]);
199 >                                progname, strerror(errno));
200                  exit(1);
201          }
202   }
# Line 207 | Line 211 | char  **av;
211          char  *err;
212          FILE  *fp;
213          int  hr, vr;
214 +        SUBPROC  rpd; /* since we don't close_process(), this can be local */
215                                          /* set up view */
216          if ((err = setview(&ourview)) != NULL) {
217                  fprintf(stderr, "%s: %s\n", progname, err);
# Line 265 | Line 270 | char  **av;
270                  goto filerr;
271          dolock(outfd, F_UNLCK);
272                                          /* start rpict process */
273 <        if (open_process(rpd, rpargv) <= 0) {
273 >        if (open_process(&rpd, rpargv) <= 0) {
274                  fprintf(stderr, "%s: cannot start %s\n", progname, rpargv[0]);
275                  exit(1);
276          }
277 <        if ((fromrp = fdopen(rpd[0], "r")) == NULL ||
278 <                        (torp = fdopen(rpd[1], "w")) == NULL) {
277 >        if ((fromrp = fdopen(rpd.r, "r")) == NULL ||
278 >                        (torp = fdopen(rpd.w, "w")) == NULL) {
279                  fprintf(stderr, "%s: cannot open stream to %s\n",
280                                  progname, rpargv[0]);
281                  exit(1);
# Line 280 | Line 285 | char  **av;
285                  exit(1);
286          }
287          signal(SIGALRM, onalrm);
288 +        if (timelim)
289 +                alarm(timelim);
290          return;
291   filerr:
292          fprintf(stderr, "%s: i/o error on file \"%s\"\n", progname, outfile);
# Line 345 | Line 352 | register int  *xp, *yp;
352                  return(0);              /* only check if asked */
353          if (pdone == NULL)              /* first call */
354                  pdone = calloc(hmult*vmult, sizeof(char));
355 +        if (pdone == NULL) {
356 +                fprintf(stderr, "%s: out of memory\n", progname);
357 +                exit(1);
358 +        }
359          if (readpos != -1)              /* mark what's been done */
360                  fseek(syncfp, readpos, 0);
361          while (fscanf(syncfp, "%d %d", xp, yp) == 2)
# Line 403 | Line 414 | rpiece()                       /* render picture piece by piece */
414                  pview.horiz = ourview.horiz / hmult;
415                  pview.vert = ourview.vert / vmult;
416                  break;
417 +        case VT_CYL:
418 +                pview.horiz = ourview.horiz / hmult;
419 +                pview.vert = 2.*180./PI*atan(
420 +                                tan(PI/180./2.*ourview.vert)/vmult );
421 +                break;
422          case VT_HEM:
423                  pview.horiz = 2.*180./PI*asin(
424                                  sin(PI/180./2.*ourview.horiz)/hmult );
# Line 416 | Line 432 | rpiece()                       /* render picture piece by piece */
432          }
433                                          /* render each piece */
434          while (nextpiece(&xorg, &yorg)) {
435 <                pview.hoff = ourview.hoff + xorg - 0.5*(hmult-1);
436 <                pview.voff = ourview.voff + yorg - 0.5*(vmult-1);
435 >                pview.hoff = ourview.hoff*hmult + xorg - 0.5*(hmult-1);
436 >                pview.voff = ourview.voff*vmult + yorg - 0.5*(vmult-1);
437                  fputs(VIEWSTR, torp);
438                  fprintview(&pview, torp);
439                  putc('\n', torp);
# Line 489 | Line 505 | int  xpos, ypos;
505                  filerr("lock");
506   #endif
507                                  /* write new piece to file */
508 <        if (lseek(outfd, fls.l_start, 0) == -1)
508 >        if (lseek(outfd, (off_t)fls.l_start, 0) < 0)
509                  filerr("seek");
510          if (hmult == 1) {
511                  if (writebuf(outfd, (char *)pbuf,
# Line 501 | Line 517 | int  xpos, ypos;
517                                          hr*sizeof(COLR)) != hr*sizeof(COLR))
518                                  filerr("write");
519                          if (y < vr-1 && lseek(outfd,
520 <                                        (long)(hmult-1)*hr*sizeof(COLR),
521 <                                        1) == -1)
520 >                                        (off_t)(hmult-1)*hr*sizeof(COLR),
521 >                                        1) < 0)
522                                  filerr("seek");
523                  }
524   #if NFS
# Line 510 | Line 526 | int  xpos, ypos;
526          if (fcntl(outfd, F_SETLKW, &fls) < 0)
527                  filerr("lock");
528   #endif
529 +        if (verbose) {                          /* notify caller */
530 +                printf("%d %d done\n", xpos, ypos);
531 +                fflush(stdout);
532 +        }
533          if (syncfp != NULL) {                   /* record what's been done */
534                  sflock(F_WRLCK);
535                  fseek(syncfp, 0L, 2);           /* append index */
# Line 518 | Line 538 | int  xpos, ypos;
538                                  /*** Unlock not necessary, since
539                  sflock(F_UNLCK);        _exit() or nextpiece() is next ***/
540          }
521        if (verbose) {                          /* notify caller */
522                printf("%d %d done\n", xpos, ypos);
523                fflush(stdout);
524        }
541          if (pid == -1)          /* didn't fork or fork failed */
542                  return(0);
543          _exit(0);               /* else exit child process (releasing locks) */
# Line 531 | Line 547 | int  xpos, ypos;
547   filerr(t)                       /* report file error and exit */
548   char  *t;
549   {
534        extern char  *sys_errlist[];
535
550          fprintf(stderr, "%s: %s error on file \"%s\": %s\n",
551 <                        progname, t, outfile, sys_errlist[errno]);
551 >                        progname, t, outfile, strerror(errno));
552          _exit(1);
553   }
554  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines