--- ray/src/util/rpiece.c 1994/02/28 09:22:32 2.29 +++ ray/src/util/rpiece.c 1995/11/30 14:21:48 2.32 @@ -1,4 +1,4 @@ -/* Copyright (c) 1993 Regents of the University of California */ +/* Copyright (c) 1995 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -69,6 +69,7 @@ int nforked = 0; char *progname; int verbose = 0; +unsigned timelim = 0; int rvrlim = -1; extern long lseek(), ftell(); @@ -120,6 +121,11 @@ char *argv[]; break; pixaspect = atof(argv[i+1]); continue; + case 'T': /* time limit (hours) */ + if (argv[i][2]) + break; + timelim = atof(argv[++i])*3600. + .5; + break; case 'x': /* overall x resolution */ if (argv[i][2]) break; @@ -280,6 +286,8 @@ char **av; exit(1); } signal(SIGALRM, onalrm); + if (timelim) + alarm(timelim); return; filerr: fprintf(stderr, "%s: i/o error on file \"%s\"\n", progname, outfile); @@ -345,6 +353,10 @@ register int *xp, *yp; return(0); /* only check if asked */ if (pdone == NULL) /* first call */ pdone = calloc(hmult*vmult, sizeof(char)); + if (pdone == NULL) { + fprintf(stderr, "%s: out of memory\n", progname); + exit(1); + } if (readpos != -1) /* mark what's been done */ fseek(syncfp, readpos, 0); while (fscanf(syncfp, "%d %d", xp, yp) == 2) @@ -403,6 +415,11 @@ rpiece() /* render picture piece by piece */ pview.horiz = ourview.horiz / hmult; pview.vert = ourview.vert / vmult; break; + case VT_CYL: + pview.horiz = ourview.horiz / hmult; + pview.vert = 2.*180./PI*atan( + tan(PI/180./2.*ourview.vert)/vmult ); + break; case VT_HEM: pview.horiz = 2.*180./PI*asin( sin(PI/180./2.*ourview.horiz)/hmult ); @@ -510,6 +527,10 @@ int xpos, ypos; if (fcntl(outfd, F_SETLKW, &fls) < 0) filerr("lock"); #endif + if (verbose) { /* notify caller */ + printf("%d %d done\n", xpos, ypos); + fflush(stdout); + } if (syncfp != NULL) { /* record what's been done */ sflock(F_WRLCK); fseek(syncfp, 0L, 2); /* append index */ @@ -517,10 +538,6 @@ int xpos, ypos; fflush(syncfp); /*** Unlock not necessary, since sflock(F_UNLCK); _exit() or nextpiece() is next ***/ - } - if (verbose) { /* notify caller */ - printf("%d %d done\n", xpos, ypos); - fflush(stdout); } if (pid == -1) /* didn't fork or fork failed */ return(0);