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

Comparing ray/src/util/ranimate.c (file contents):
Revision 2.5 by greg, Tue Jan 23 16:14:28 1996 UTC vs.
Revision 2.11 by greg, Tue Apr 16 10:38:19 1996 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1995 Regents of the University of California */
1 > /* Copyright (c) 1996 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #include "view.h"
16   #include "vars.h"
17   #include "netproc.h"
18 +                                /* default remote shell */
19 + #ifdef _AUX_SOURCE
20 + #define REMSH           "remsh"
21 + #else
22 + #define REMSH           "rsh"
23 + #endif
24                                  /* input variables */
25   #define HOST            0               /* rendering host machine */
26   #define RENDER          1               /* rendering options */
# Line 38 | Line 44 | static char SCCSid[] = "$SunId$ LBL";
44   #define DISKSPACE       19              /* how much disk space to use */
45   #define RESOLUTION      20              /* desired final resolution */
46   #define EXPOSURE        21              /* how to compute exposure */
47 + #define RSH             22              /* remote shell script or program */
48  
49 < int     NVARS = 22;             /* total number of variables */
49 > int     NVARS = 23;             /* total number of variables */
50  
51   VARIABLE        vv[] = {                /* variable-value pairs */
52          {"host",        4,      0,      NULL,   NULL},
# Line 64 | Line 71 | VARIABLE       vv[] = {                /* variable-value pairs */
71          {"DISKSPACE",   3,      0,      NULL,   fltvalue},
72          {"RESOLUTION",  3,      0,      NULL,   onevalue},
73          {"EXPOSURE",    3,      0,      NULL,   onevalue},
74 +        {"RSH",         3,      0,      NULL,   onevalue},
75   };
76  
77   #define SFNAME  "STATUS"                /* status file name */
# Line 84 | Line 92 | int    nowarn = 0;             /* turn warnings off? */
92   int     silent = 0;             /* silent mode? */
93   int     noaction = 0;           /* take no action? */
94  
95 + char    *remsh;                 /* remote shell program/script */
96   char    rendopt[2048] = "";     /* rendering options */
97   char    rresopt[32];            /* rendering resolution options */
98   char    fresopt[32];            /* filter resolution options */
99   int     pfiltalways;            /* always use pfilt? */
100  
101 + char    arcargs[10240];         /* files to archive */
102 + char    *arcfirst, *arcnext;    /* pointers to first and next argument */
103 +
104   struct pslot {
105          int     pid;                    /* process ID (0 if empty) */
106          int     fout;                   /* output frame number */
# Line 163 | Line 175 | char   *argv[];
175                  argv[i] = vval(NEXTANIM);       /* just change input file */
176                  if (!silent)
177                          printargs(argc, argv, stdout);
178 <                execvp(progname, argv);         /* pass to next */
179 <                quit(1);                        /* shouldn't return */
178 >                if ((argv[0] = getpath(progname,getenv("PATH"),X_OK)) == NULL)
179 >                        fprintf(stderr, "%s: command not found\n", progname);
180 >                else
181 >                        execv(progname, argv);
182 >                quit(1);
183          }
184          quit(0);
185   userr:
# Line 201 | Line 216 | getastat()                     /* check/set animation status */
216                  goto fmterr;
217          fclose(fp);
218          if (astat.pid != 0) {                   /* thinks it's still running */
219 <                gethostname(buf, sizeof(buf));
205 <                if (strcmp(buf, astat.host)) {
219 >                if (strcmp(myhostname(), astat.host)) {
220                          fprintf(stderr,
221                          "%s: process %d may still be running on host %s\n",
222                                          progname, astat.pid, astat.host);
# Line 221 | Line 235 | getastat()                     /* check/set animation status */
235                  return(-1);
236          }
237   setours:                                        /* set our values */
238 <        gethostname(astat.host, sizeof(astat.host));
238 >        strcpy(astat.host, myhostname());
239          astat.pid = getpid();
240          strcpy(astat.cfname, cfname);
241          return(0);
# Line 279 | Line 293 | checkdir()                     /* make sure we have our directory */
293  
294   setdefaults()                   /* set default values */
295   {
296 +        extern char     *atos();
297          char    buf[256];
298  
299          if (vdef(ANIMATE)) {
# Line 344 | Line 359 | setdefaults()                  /* set default values */
359                  vval(DISKSPACE) = "100";
360                  vdef(DISKSPACE)++;
361          }
362 +        if (!vdef(RSH)) {
363 +                vval(RSH) = REMSH;
364 +                vdef(RSH)++;
365 +        }
366 +                                /* locate remote shell program */
367 +        atos(buf, sizeof(buf), vval(RSH));
368 +        if ((remsh = getpath(buf, getenv("PATH"), X_OK)) != NULL)
369 +                remsh = savqstr(remsh);
370 +        else
371 +                remsh = vval(RSH);      /* will generate error if used */
372 +
373                                  /* append rendering options */
374          if (vdef(RENDER))
375                  sprintf(rendopt+strlen(rendopt), " %s", vval(RENDER));
# Line 406 | Line 432 | sethosts()                     /* set up process servers */
432   }
433  
434  
435 < getradfile(rfname)              /* run rad and get needed variables */
436 < char    *rfname;
435 > getradfile(rfargs)              /* run rad and get needed variables */
436 > char    *rfargs;
437   {
438          static short    mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1};
439          char    combuf[256];
# Line 417 | Line 443 | char   *rfname;
443          sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
444          sprintf(combuf,
445          "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH",
446 <                        rfname, rendopt+2);
446 >                        rfargs, rendopt+2);
447          cp = combuf;
448          while (*cp) cp++;               /* match unset variables */
449          for (i = 0; mvar[i] >= 0; i++)
# Line 429 | Line 455 | char   *rfname;
455          sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
456          cp += 11;                       /* point to file name */
457          if (system(combuf)) {
458 <                fprintf(stderr, "%s: bad rad input file \"%s\"\n",
459 <                                progname, rfname);
458 >                fprintf(stderr, "%s: error executing rad command:\n\t%s\n",
459 >                                progname, combuf);
460                  quit(1);
461          }
462          loadvars(cp);                   /* load variables and remove file */
# Line 487 | Line 513 | animate()                      /* run animation */
513                                  progname);
514                  quit(1);
515          }
516 +                                        /* initialize archive argument list */
517 +        i = 16;
518 +        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i)
519 +                i = strlen(vval(ARCHIVE));
520 +        arcnext = arcfirst = arcargs + i;
521                                          /* initialize status file */
522          if (astat.rnext == 0)
523                  astat.rnext = astat.fnext = astat.tnext = vint(START);
# Line 581 | Line 612 | filterframes()                         /* catch up with filtering */
612                  dofilt(i, vp, getexp(i), 0);            /* filter frame */
613          }
614          bwait(0);                       /* wait for filter processes */
615 <        archive(astat.fnext, i-1);      /* archive originals */
615 >        archive();                      /* archive originals */
616          astat.fnext = i;                /* update status */
617          putastat();
618   }
# Line 662 | Line 693 | char   *vfn;
693          inspoint = combuf + strlen(combuf);
694          sprintf(inspoint, " %s < %s", vval(OCTREE), vfn);
695                                          /* run in parallel */
696 <        if (pruncom(combuf, inspoint, (last-first+1)/(vint(INTERP)+1))) {
696 >        i = (last-first+1)/(vint(INTERP)+1);
697 >        if (i < 1) i = 1;
698 >        if (pruncom(combuf, inspoint, i)) {
699                  fprintf(stderr, "%s: error rendering frames %d through %d\n",
700                                  progname, first, last);
701                  quit(1);
# Line 740 | Line 773 | int    frame;
773   }
774  
775  
776 < archive(first, last)                    /* archive and remove renderings */
744 < int     first, last;
776 > archive()                       /* archive and remove renderings */
777   {
778   #define RMCOML  (sizeof(rmcom)-1)
779          static char     rmcom[] = "rm -f";
748        int     offset = RMCOML;
749        char    combuf[10240];
750        struct stat     stb;
751        register char   *cp;
780          register int    i;
781  
782 <        if (noaction)
783 <                return;
756 <        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > offset)
757 <                offset = strlen(vval(ARCHIVE));
758 <        cp = combuf + offset;
759 <        *cp++ = ' ';                            /* make argument list */
760 <        for (i = first; i <= last; i++) {
761 <                sprintf(cp, vval(BASENAME), i);
762 <                strcat(cp, ".unf");
763 <                if (stat(cp, &stb) == 0 && stb.st_size > 0) {   /* non-zero? */
764 <                        while (*cp) cp++;
765 <                        *cp++ = ' ';
766 <                        sprintf(cp, vval(BASENAME), i);
767 <                        strcat(cp, ".zbf");
768 <                        if (access(cp, F_OK) == 0) {            /* exists? */
769 <                                while (*cp) cp++;
770 <                                *cp++ = ' ';
771 <                        }
772 <                }
773 <        }
774 <        *--cp = '\0';
775 <        if (cp <= combuf + offset)              /* no files? */
776 <                return;
782 >        if (arcnext == arcfirst)
783 >                return;                         /* nothing to do */
784          if (vdef(ARCHIVE)) {                    /* run archive command */
785                  i = strlen(vval(ARCHIVE));
786 <                strncpy(combuf+offset-i, vval(ARCHIVE), i);
787 <                if (runcom(combuf+offset-i)) {
788 <                        fprintf(stderr,
789 <                "%s: error running archive command on frames %d through %d\n",
783 <                                        progname, first, last);
786 >                strncpy(arcfirst-i, vval(ARCHIVE), i);
787 >                if (runcom(arcfirst-i)) {
788 >                        fprintf(stderr, "%s: error running archive command\n",
789 >                                        progname);
790                          quit(1);
791                  }
792          }
793                                                  /* run remove command */
794 <        strncpy(combuf+offset-RMCOML, rmcom, RMCOML);
795 <        runcom(combuf+offset-RMCOML);
794 >        strncpy(arcfirst-RMCOML, rmcom, RMCOML);
795 >        runcom(arcfirst-RMCOML);
796 >        arcnext = arcfirst;                     /* reset argument list */
797   #undef RMCOML
798   }
799  
# Line 799 | Line 806 | char   *ep;
806   int     rvr;
807   {
808          extern int      frecover();
809 +        static int      iter = 0;
810          char    fnbefore[128], fnafter[128];
811 <        char    combuf[1024], fname[128];
812 <        int     usepinterp, usepfilt;
811 >        char    combuf[1024], fname0[128], fname1[128];
812 >        int     usepinterp, usepfilt, nora_rgbe;
813          int     frseq[2];
814                                                  /* check what is needed */
815          usepinterp = atoi(vval(MBLUR));
816          usepfilt = pfiltalways | ep==NULL;
817 +        if (ep != NULL && !strcmp(ep, "1"))
818 +                ep = "+0";
819 +        nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL ||
820 +                        *ep != '+' || *ep != '-' || !isint(ep);
821                                                  /* compute rendered views */
822          frseq[0] = frame - ((frame-1) % (vint(INTERP)+1));
823          frseq[1] = frseq[0] + vint(INTERP) + 1;
# Line 814 | Line 826 | int    rvr;
826          if (frseq[1] == frame) {                        /* pfilt only */
827                  frseq[0] = frseq[1];
828                  usepinterp = 0;                 /* update what's needed */
829 <                usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1");
830 <        } else if (frseq[0] == frame) {         /* no interpolation */
831 <                                                /* update what's needed */
832 <                if (!usepinterp)
833 <                        usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1");
829 >                usepfilt |= nora_rgbe;
830 >        } else if (frseq[0] == frame) {         /* no interpolation needed */
831 >                if (!rvr && frame > 1+vint(INTERP)) {   /* archive previous */
832 >                        *arcnext++ = ' ';
833 >                        sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1);
834 >                        while (*arcnext) arcnext++;
835 >                        strcpy(arcnext, ".unf");
836 >                        arcnext += 4;
837 >                        if (usepinterp || vint(INTERP)) {       /* and z-buf */
838 >                                *arcnext++ = ' ';
839 >                                sprintf(arcnext, vval(BASENAME),
840 >                                                frame-vint(INTERP)-1);
841 >                                while (*arcnext) arcnext++;
842 >                                strcpy(arcnext, ".zbf");
843 >                                arcnext += 4;
844 >                        }
845 >                }
846 >                if (!usepinterp)                /* update what's needed */
847 >                        usepfilt |= nora_rgbe;
848          } else                                  /* interpolation needed */
849                  usepinterp++;
850          if (frseq[1] >= astat.rnext)            /* next batch unavailable */
# Line 833 | Line 859 | int    rvr;
859                          return(1);
860                  if (atoi(vval(MBLUR))) {
861                          FILE    *fp;            /* motion blurring */
862 <                        sprintf(fname, "%s/vw0", vval(DIRECTORY));
863 <                        if (access(fname, F_OK) == 0)
864 <                                sleep(10);
865 <                        if ((fp = fopen(fname, "w")) == NULL) {
840 <                                perror(fname); quit(1);
862 >                        sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
863 >                                        'a'+(iter%26));
864 >                        if ((fp = fopen(fname0, "w")) == NULL) {
865 >                                perror(fname0); quit(1);
866                          }
867                          fputs(VIEWSTR, fp);
868                          fprintview(vp, fp);
# Line 848 | Line 873 | int    rvr;
873                                                  progname, frame+1);
874                                  quit(1);
875                          }
876 <                        sprintf(fname, "%s/vw1", vval(DIRECTORY));
877 <                        if ((fp = fopen(fname, "w")) == NULL) {
878 <                                perror(fname); quit(1);
876 >                        sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
877 >                                        'a'+(iter%26));
878 >                        if ((fp = fopen(fname1, "w")) == NULL) {
879 >                                perror(fname1); quit(1);
880                          }
881                          fputs(VIEWSTR, fp);
882                          fprintview(vp, fp);
883                          putc('\n', fp); fclose(fp);
884                          sprintf(combuf,
885 <        "(pmblur %s %d %s/vw0 %s/vw1; rm -f %s/vw0 %s/vw1) | pinterp -B",
885 >                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
886                          *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
887 <                                        atoi(vval(MBLUR)), vval(DIRECTORY),
888 <                                        vval(DIRECTORY), vval(DIRECTORY),
889 <                                        vval(DIRECTORY), vval(DIRECTORY));
887 >                                        atoi(vval(MBLUR)),
888 >                                        fname0, fname1, fname0, fname1);
889 >                        iter++;
890                  } else                          /* no blurring */
891                          strcpy(combuf, "pinterp");
892                  strcat(combuf, viewopt(vp));
# Line 907 | Line 933 | int    rvr;
933          } else {                                /* else just check it */
934                  if (rvr == 2)
935                          return(1);
936 <                sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore);
936 >                sprintf(combuf, "ra_rgbe -e %s -r %s.unf", ep, fnbefore);
937          }
938                                                  /* output file name */
939 <        sprintf(fname, vval(BASENAME), frame);
940 <        sprintf(combuf+strlen(combuf), " > %s.pic", fname);
939 >        sprintf(fname0, vval(BASENAME), frame);
940 >        sprintf(combuf+strlen(combuf), " > %s.pic", fname0);
941          if (rvr)                                /* in recovery */
942                  return(runcom(combuf));
943          bruncom(combuf, frame, frecover);       /* else run in background */
# Line 943 | Line 969 | int    n;
969                          quit(1);
970                  }
971          } else if (n < viewnum) {       /* rewind file */
972 +                if (viewnum == 1 && feof(viewfp))
973 +                        return(&curview);               /* just one view */
974                  if (fseek(viewfp, 0L, 0) == EOF) {
975                          perror(vval(VIEWFILE));
976                          quit(1);
# Line 952 | Line 980 | int    n;
980          }
981          while (n > viewnum) {           /* scan to desired view */
982                  if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL)
983 <                        return(NULL);
983 >                        return(viewnum==1 ? &curview : NULL);
984                  if (isview(linebuf) && sscanview(&curview, linebuf) > 0)
985                          viewnum++;
986          }
# Line 1166 | Line 1194 | int    maxcopies;
1194          register PSERVER        *ps;
1195  
1196          if (!silent)
1197 <                printf("\t%s &\n", com);        /* echo command */
1197 >                printf("\t%s\n", com);  /* echo command */
1198          if (noaction)
1199                  return(0);
1200          fflush(stdout);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines