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.22 by greg, Thu Mar 20 14:53:17 1997 UTC vs.
Revision 2.41 by schorsch, Sun Jul 27 22:12:03 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1996 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   * Radiance animation control program
6 + *
7 + * The main difference between this program and ranimove is that
8 + * we have many optimizations here for camera motion in static
9 + * environments, calling rpict and pinterp on multiple processors,
10 + * where ranimove puts its emphasis on object motion, and does
11 + * not use any external programs for image generation.
12 + *
13 + * See the ranimate(1) man page for further details.
14   */
15  
16 < #include "standard.h"
16 > #include "copyright.h"
17 >
18   #include <ctype.h>
13 #include <sys/types.h>
19   #include <sys/stat.h>
20 +
21 + #include "standard.h"
22 + #include "paths.h"
23   #include "view.h"
24   #include "vars.h"
25   #include "netproc.h"
26 +                                /* default blur samples */
27 + #ifndef DEF_NBLUR
28 + #define DEF_NBLUR       5
29 + #endif
30                                  /* default remote shell */
31   #ifdef _AUX_SOURCE
32   #define REMSH           "remsh"
33   #else
34   #define REMSH           "rsh"
35   #endif
36 <                                /* input variables */
37 < #define HOST            0               /* rendering host machine */
38 < #define RENDER          1               /* rendering options */
39 < #define PFILT           2               /* pfilt options */
40 < #define PINTERP         3               /* pinterp options */
41 < #define OCTREE          4               /* octree file name */
42 < #define DIRECTORY       5               /* working (sub)directory */
43 < #define BASENAME        6               /* output image base name */
44 < #define VIEWFILE        7               /* animation frame views */
45 < #define START           8               /* starting frame number */
46 < #define END             9               /* ending frame number */
47 < #define RIF             10              /* rad input file */
48 < #define NEXTANIM        11              /* next animation file */
49 < #define ANIMATE         12              /* animation command */
50 < #define TRANSFER        13              /* frame transfer command */
51 < #define ARCHIVE         14              /* archiving command */
52 < #define INTERP          15              /* # frames to interpolate */
53 < #define OVERSAMP        16              /* # times to oversample image */
54 < #define MBLUR           17              /* samples for motion blur */
55 < #define RTRACE          18              /* use rtrace with pinterp? */
56 < #define DISKSPACE       19              /* how much disk space to use */
57 < #define RESOLUTION      20              /* desired final resolution */
58 < #define EXPOSURE        21              /* how to compute exposure */
59 < #define RSH             22              /* remote shell script or program */
36 >                                /* input variables (alphabetical by name) */
37 > #define ANIMATE         0               /* animation command */
38 > #define ARCHIVE         1               /* archiving command */
39 > #define BASENAME        2               /* output image base name */
40 > #define DIRECTORY       3               /* working (sub)directory */
41 > #define DISKSPACE       4               /* how much disk space to use */
42 > #define END             5               /* ending frame number */
43 > #define EXPOSURE        6               /* how to compute exposure */
44 > #define HOST            7               /* rendering host machine */
45 > #define INTERP          8               /* # frames to interpolate */
46 > #define MBLUR           9               /* motion blur parameters */
47 > #define NEXTANIM        10              /* next animation file */
48 > #define OCTREE          11              /* octree file name */
49 > #define OVERSAMP        12              /* # times to oversample image */
50 > #define PFILT           13              /* pfilt options */
51 > #define PINTERP         14              /* pinterp options */
52 > #define RENDER          15              /* rendering options */
53 > #define RESOLUTION      16              /* desired final resolution */
54 > #define RIF             17              /* rad input file */
55 > #define RSH             18              /* remote shell script or program */
56 > #define RTRACE          19              /* use rtrace with pinterp? */
57 > #define START           20              /* starting frame number */
58 > #define TRANSFER        21              /* frame transfer command */
59 > #define VIEWFILE        22              /* animation frame views */
60  
61   int     NVARS = 23;             /* total number of variables */
62  
63   VARIABLE        vv[] = {                /* variable-value pairs */
52        {"host",        4,      0,      NULL,   NULL},
53        {"render",      3,      0,      NULL,   catvalues},
54        {"pfilt",       2,      0,      NULL,   catvalues},
55        {"pinterp",     2,      0,      NULL,   catvalues},
56        {"OCTREE",      3,      0,      NULL,   onevalue},
57        {"DIRECTORY",   3,      0,      NULL,   onevalue},
58        {"BASENAME",    3,      0,      NULL,   onevalue},
59        {"VIEWFILE",    2,      0,      NULL,   onevalue},
60        {"START",       2,      0,      NULL,   intvalue},
61        {"END",         2,      0,      NULL,   intvalue},
62        {"RIF",         3,      0,      NULL,   onevalue},
63        {"NEXTANIM",    3,      0,      NULL,   onevalue},
64          {"ANIMATE",     2,      0,      NULL,   onevalue},
65        {"TRANSFER",    2,      0,      NULL,   onevalue},
65          {"ARCHIVE",     2,      0,      NULL,   onevalue},
66 +        {"BASENAME",    3,      0,      NULL,   onevalue},
67 +        {"DIRECTORY",   3,      0,      NULL,   onevalue},
68 +        {"DISKSPACE",   3,      0,      NULL,   fltvalue},
69 +        {"END",         2,      0,      NULL,   intvalue},
70 +        {"EXPOSURE",    3,      0,      NULL,   onevalue},
71 +        {"host",        4,      0,      NULL,   NULL},
72          {"INTERPOLATE", 3,      0,      NULL,   intvalue},
68        {"OVERSAMPLE",  2,      0,      NULL,   fltvalue},
73          {"MBLUR",       2,      0,      NULL,   onevalue},
74 <        {"RTRACE",      2,      0,      NULL,   boolvalue},
75 <        {"DISKSPACE",   3,      0,      NULL,   fltvalue},
74 >        {"NEXTANIM",    3,      0,      NULL,   onevalue},
75 >        {"OCTREE",      3,      0,      NULL,   onevalue},
76 >        {"OVERSAMPLE",  2,      0,      NULL,   fltvalue},
77 >        {"pfilt",       2,      0,      NULL,   catvalues},
78 >        {"pinterp",     2,      0,      NULL,   catvalues},
79 >        {"render",      3,      0,      NULL,   catvalues},
80          {"RESOLUTION",  3,      0,      NULL,   onevalue},
81 <        {"EXPOSURE",    3,      0,      NULL,   onevalue},
81 >        {"RIF",         3,      0,      NULL,   onevalue},
82          {"RSH",         3,      0,      NULL,   onevalue},
83 +        {"RTRACE",      2,      0,      NULL,   boolvalue},
84 +        {"START",       2,      0,      NULL,   intvalue},
85 +        {"TRANSFER",    2,      0,      NULL,   onevalue},
86 +        {"VIEWFILE",    2,      0,      NULL,   onevalue},
87   };
88  
89   #define SFNAME  "STATUS"                /* status file name */
# Line 115 | Line 127 | struct pslot   *findpslot();
127   PSERVER *lastpserver;           /* last process server with error */
128  
129   VIEW    *getview();
130 < char    *getexp();
130 > char    *getexp(), *dirfile();
131 > int     getblur();
132  
133 < extern time_t   fdate(), time();
133 > extern time_t   time();
134  
135  
136   main(argc, argv)
# Line 450 | Line 463 | char   *rfargs;
463          char    combuf[256];
464          register int    i;
465          register char   *cp;
466 +        char    *pippt;
467                                          /* create rad command */
468          sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
469          sprintf(combuf,
470          "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH",
471                          rfargs, rendopt+2);
472          cp = combuf;
473 <        while (*cp) cp++;               /* match unset variables */
473 >        while (*cp) {
474 >                if (*cp == '|') pippt = cp;
475 >                cp++;
476 >        }                               /* match unset variables */
477          for (i = 0; mvar[i] >= 0; i++)
478                  if (!vdef(mvar[i])) {
479                          *cp++ = '|';
480                          strcpy(cp, vnam(mvar[i]));
481                          while (*cp) cp++;
482 +                        pippt = NULL;
483                  }
484 <        sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
485 <        cp += 11;                       /* point to file name */
486 <        if (system(combuf)) {
487 <                fprintf(stderr, "%s: error executing rad command:\n\t%s\n",
488 <                                progname, combuf);
471 <                quit(1);
484 >        if (pippt != NULL)
485 >                strcpy(pippt, "> " NULL_DEVICE);        /* nothing to match */
486 >        else {
487 >                sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
488 >                cp += 11;               /* point to file name */
489          }
490 <        loadvars(cp);                   /* load variables and remove file */
491 <        unlink(cp);
490 >        system(combuf);                 /* ignore exit code */
491 >        if (pippt == NULL) {            /* load variables and remove file */
492 >                loadvars(cp);
493 >                unlink(cp);
494 >        }
495   }
496  
497  
# Line 505 | Line 525 | animate()                      /* run animation */
525                                                  progname, vnam(INTERP));
526                          vval(INTERP) = "0";
527                  }
528 <                if (atoi(vval(MBLUR))) {        /* can't handle this yet */
528 >                if (strcmp(vval(MBLUR),"0")) {  /* can't handle this */
529                          if (!nowarn)
530                                  fprintf(stderr,
531                                          "%s: resetting %s=0 for animation\n",
# Line 515 | Line 535 | animate()                      /* run animation */
535          }
536                                          /* figure # frames per batch */
537          d1 = mult*xres*mult*yres*4;             /* space for orig. picture */
538 <        if ((i=vint(INTERP)) || atoi(vval(MBLUR)))
538 >        if ((i=vint(INTERP)) || getblur(NULL) > 1)
539                  d1 += mult*xres*mult*yres*sizeof(float);        /* Z-buffer */
540          d2 = xres*yres*4;                       /* space for final picture */
541          frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2);
# Line 525 | Line 545 | animate()                      /* run animation */
545                  quit(1);
546          }
547                                          /* initialize archive argument list */
548 <        i = 16;
529 <        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i)
530 <                i = strlen(vval(ARCHIVE));
548 >        i = vdef(ARCHIVE) ? strlen(vval(ARCHIVE))+132 : 132;
549          arcnext = arcfirst = arcargs + i;
550                                          /* initialize status file */
551          if (astat.rnext == 0)
# Line 613 | Line 631 | filterframes()                         /* catch up with filtering */
631          if (astat.tnext < astat.fnext)  /* other work to do first */
632                  return;
633                                          /* filter each view */
634 <        for (i = astat.fnext; i < astat.rnext; i++) {
635 <                if ((vp = getview(i)) == NULL) {        /* get view i */
636 <                        fprintf(stderr,
619 <                        "%s: unexpected error reading view for frame %d\n",
620 <                                        progname, i);
621 <                        quit(1);
622 <                }
623 <                dofilt(i, vp, getexp(i), 0);            /* filter frame */
624 <        }
634 >        for (i = astat.fnext; i < astat.rnext; i++)
635 >                dofilt(i, 0);
636 >
637          bwait(0);                       /* wait for filter processes */
638          archive();                      /* archive originals */
639          astat.fnext = i;                /* update status */
# Line 631 | Line 643 | filterframes()                         /* catch up with filtering */
643  
644   transferframes()                        /* catch up with picture transfers */
645   {
646 <        char    combuf[10240];
646 >        char    combuf[10240], *fbase;
647          register char   *cp;
648          register int    i;
649  
# Line 642 | Line 654 | transferframes()                       /* catch up with picture transfers
654                  putastat();             /* update status */
655                  return;
656          }
657 <        strcpy(combuf, vval(TRANSFER)); /* start transfer command */
658 <        cp = combuf + strlen(combuf);
657 >        strcpy(combuf, "cd ");          /* start transfer command */
658 >        fbase = dirfile(cp = combuf+3, vval(BASENAME));
659 >        if (*cp) {
660 >                while (*++cp) ;
661 >                *cp++ = ';'; *cp++ = ' ';
662 >        } else
663 >                cp = combuf;
664 >        strcpy(cp, vval(TRANSFER));
665 >        while (*cp) cp++;
666                                          /* make argument list */
667          for (i = astat.tnext; i < astat.fnext; i++) {
668                  *cp++ = ' ';
669 <                sprintf(cp, vval(BASENAME), i);
669 >                sprintf(cp, fbase, i);
670                  while (*cp) cp++;
671                  strcpy(cp, ".pic");
672                  cp += 4;
# Line 684 | Line 703 | walkwait(first, last, vfn)             /* walk-through frames */
703   int     first, last;
704   char    *vfn;
705   {
706 +        double  blurf;
707 +        int     nblur = getblur(&blurf);
708          char    combuf[2048];
709 <        char    *inspoint;
709 >        register char   *inspoint;
710          register int    i;
711  
712          if (!noaction && vint(INTERP))          /* create dummy frames */
# Line 696 | Line 717 | char   *vfn;
717                                  close(open(combuf, O_RDONLY|O_CREAT, 0666));
718                          }
719                                          /* create command */
720 <        sprintf(combuf, "rpict%s -w0", rendopt);
721 <        if (vint(INTERP) || atoi(vval(MBLUR)))
722 <                sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME));
723 <        sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d",
720 >        sprintf(combuf, "rpict%s%s -w0", rendopt,
721 >                        viewopt(getview(first>1 ? first-1 : 1)));
722 >        inspoint = combuf;
723 >        while (*inspoint) inspoint++;
724 >        if (nblur) {
725 >                sprintf(inspoint, " -pm %.3f", blurf/nblur);
726 >                while (*inspoint) inspoint++;
727 >        }
728 >        if (nblur > 1 || vint(INTERP)) {
729 >                sprintf(inspoint, " -z %s.zbf", vval(BASENAME));
730 >                while (*inspoint) inspoint++;
731 >        }
732 >        sprintf(inspoint, " -o %s.unf %s -S %d",
733                          vval(BASENAME), rresopt, first);
734 <        inspoint = combuf + strlen(combuf);
734 >        while (*inspoint) inspoint++;
735          sprintf(inspoint, " %s < %s", vval(OCTREE), vfn);
736                                          /* run in parallel */
737          i = (last-first+1)/(vint(INTERP)+1);
# Line 727 | Line 757 | int    frame;
757   {
758          static int      *rfrm;          /* list of recovered frames */
759          static int      nrfrms = 0;
760 +        double  blurf;
761 +        int     nblur = getblur(&blurf);
762          char    combuf[2048];
763          char    fname[128];
764          register char   *cp;
# Line 742 | Line 774 | int    frame;
774                                  vval(ANIMATE), frame, rendopt);
775          else
776                  sprintf(combuf, "rpict%s -w0", rendopt);
777 <        cp = combuf + strlen(combuf);
778 <        if (vint(INTERP) || atoi(vval(MBLUR))) {
777 >        cp = combuf;
778 >        while (*cp) cp++;
779 >        if (nblur) {
780 >                sprintf(cp, " -pm %.3f", blurf/nblur);
781 >                while (*cp) cp++;
782 >        }
783 >        if (nblur > 1 || vint(INTERP)) {
784                  sprintf(cp, " -z %s.zbf", fname);
785                  while (*cp) cp++;
786          }
# Line 757 | Line 794 | int    frame;
794                  return(1);
795                                          /* add frame to recovered list */
796          if (nrfrms)
797 <                rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int));
797 >                rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int));
798          else
799                  rfrm = (int *)malloc(sizeof(int));
800          if (rfrm == NULL) {
# Line 773 | Line 810 | int
810   frecover(frame)                         /* recover filtered frame */
811   int     frame;
812   {
813 <        VIEW    *vp;
777 <        char    *ex;
778 <
779 <        vp = getview(frame);
780 <        ex = getexp(frame);
781 <        if (dofilt(frame, vp, ex, 2) && dofilt(frame, vp, ex, 1))
813 >        if (dofilt(frame, 2) && dofilt(frame, 1))
814                  return(1);
815          return(0);
816   }
# Line 788 | Line 820 | archive()                      /* archive and remove renderings */
820   {
821   #define RMCOML  (sizeof(rmcom)-1)
822          static char     rmcom[] = "rm -f";
823 <        register int    i;
823 >        char    basedir[128];
824 >        int     dlen, alen;
825 >        register int    j;
826  
827          if (arcnext == arcfirst)
828                  return;                         /* nothing to do */
829 +        dirfile(basedir, vval(BASENAME));
830 +        dlen = strlen(basedir);
831          if (vdef(ARCHIVE)) {                    /* run archive command */
832 <                i = strlen(vval(ARCHIVE));
833 <                strncpy(arcfirst-i, vval(ARCHIVE), i);
834 <                if (runcom(arcfirst-i)) {
832 >                alen = strlen(vval(ARCHIVE));
833 >                if (dlen) {
834 >                        j = alen + dlen + 5;
835 >                        strncpy(arcfirst-j, "cd ", 3);
836 >                        strncpy(arcfirst-j+3, basedir, dlen);
837 >                        (arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' ';
838 >                } else
839 >                        j = alen;
840 >                strncpy(arcfirst-alen, vval(ARCHIVE), alen);
841 >                if (runcom(arcfirst-j)) {
842                          fprintf(stderr, "%s: error running archive command\n",
843                                          progname);
844                          quit(1);
845                  }
846          }
847 +        if (dlen) {
848 +                j = RMCOML + dlen + 5;
849 +                strncpy(arcfirst-j, "cd ", 3);
850 +                strncpy(arcfirst-j+3, basedir, dlen);
851 +                (arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' ';
852 +        } else
853 +                j = RMCOML;
854                                                  /* run remove command */
855          strncpy(arcfirst-RMCOML, rmcom, RMCOML);
856 <        runcom(arcfirst-RMCOML);
856 >        runcom(arcfirst-j);
857          arcnext = arcfirst;                     /* reset argument list */
858   #undef RMCOML
859   }
860  
861  
862   int
863 < dofilt(frame, vp, ep, rvr)                      /* filter frame */
863 > dofilt(frame, rvr)                              /* filter frame */
864   int     frame;
815 VIEW    *vp;
816 char    *ep;
865   int     rvr;
866   {
867          extern int      frecover();
868          static int      iter = 0;
869 <        char    fnbefore[128], fnafter[128];
869 >        double  blurf;
870 >        int     nblur = getblur(&blurf);
871 >        VIEW    *vp = getview(frame);
872 >        char    *ep = getexp(frame);
873 >        char    fnbefore[128], fnafter[128], *fbase;
874          char    combuf[1024], fname0[128], fname1[128];
875          int     usepinterp, usepfilt, nora_rgbe;
876          int     frseq[2];
877                                                  /* check what is needed */
878 <        usepinterp = atoi(vval(MBLUR));
879 <        usepfilt = pfiltalways | ep==NULL;
878 >        if (vp == NULL) {
879 >                 fprintf(stderr,
880 >                        "%s: unexpected error reading view for frame %d\n",
881 >                                          progname, frame);
882 >                quit(1);
883 >        }
884 >        if (ep == NULL) {
885 >                 fprintf(stderr,
886 >                        "%s: unexpected error reading exposure for frame %d\n",
887 >                                          progname, frame);
888 >                quit(1);
889 >        }
890 >        usepinterp = (nblur > 1);
891 >        usepfilt = pfiltalways | (ep==NULL);
892          if (ep != NULL && !strcmp(ep, "1"))
893                  ep = "+0";
894          nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL ||
# Line 832 | Line 896 | int    rvr;
896                                                  /* compute rendered views */
897          frseq[0] = frame - ((frame-1) % (vint(INTERP)+1));
898          frseq[1] = frseq[0] + vint(INTERP) + 1;
899 +        fbase = dirfile(NULL, vval(BASENAME));
900          if (frseq[1] > vint(END))
901                  frseq[1] = vint(END);
902          if (frseq[1] == frame) {                        /* pfilt only */
# Line 841 | Line 906 | int    rvr;
906          } else if (frseq[0] == frame) {         /* no interpolation needed */
907                  if (!rvr && frame > 1+vint(INTERP)) {   /* archive previous */
908                          *arcnext++ = ' ';
909 <                        sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1);
909 >                        sprintf(arcnext, fbase, frame-vint(INTERP)-1);
910                          while (*arcnext) arcnext++;
911                          strcpy(arcnext, ".unf");
912                          arcnext += 4;
913                          if (usepinterp || vint(INTERP)) {       /* and Z-buf */
914                                  *arcnext++ = ' ';
915 <                                sprintf(arcnext, vval(BASENAME),
851 <                                                frame-vint(INTERP)-1);
915 >                                sprintf(arcnext, fbase, frame-vint(INTERP)-1);
916                                  while (*arcnext) arcnext++;
917                                  strcpy(arcnext, ".zbf");
918                                  arcnext += 4;
# Line 868 | Line 932 | int    rvr;
932          if (usepinterp) {                       /* using pinterp */
933                  if (rvr == 2 && recover(frseq[1]))      /* recover after? */
934                          return(1);
935 <                if (atoi(vval(MBLUR))) {
872 <                        FILE    *fp;            /* motion blurring */
935 >                if (nblur > 1) {                /* with pmblur */
936                          sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
937                                          'a'+(iter%26));
875                        if ((fp = fopen(fname0, "w")) == NULL) {
876                                perror(fname0); quit(1);
877                        }
878                        fputs(VIEWSTR, fp);
879                        fprintview(vp, fp);
880                        putc('\n', fp); fclose(fp);
881                        if ((vp = getview(frame+1)) == NULL) {
882                                fprintf(stderr,
883                        "%s: unexpected error reading view for frame %d\n",
884                                                progname, frame+1);
885                                quit(1);
886                        }
938                          sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
939                                          'a'+(iter%26));
940 <                        if ((fp = fopen(fname1, "w")) == NULL) {
941 <                                perror(fname1); quit(1);
940 >                        if (!noaction) {
941 >                                FILE    *fp;            /* motion blurring */
942 >                                if ((fp = fopen(fname0, "w")) == NULL) {
943 >                                        perror(fname0); quit(1);
944 >                                }
945 >                                fputs(VIEWSTR, fp);
946 >                                fprintview(vp, fp);
947 >                                putc('\n', fp); fclose(fp);
948 >                                if ((vp = getview(frame+1)) == NULL) {
949 >                                        fprintf(stderr,
950 >                        "%s: unexpected error reading view for frame %d\n",
951 >                                                        progname, frame+1);
952 >                                        quit(1);
953 >                                }
954 >                                if ((fp = fopen(fname1, "w")) == NULL) {
955 >                                        perror(fname1); quit(1);
956 >                                }
957 >                                fputs(VIEWSTR, fp);
958 >                                fprintview(vp, fp);
959 >                                putc('\n', fp); fclose(fp);
960                          }
892                        fputs(VIEWSTR, fp);
893                        fprintview(vp, fp);
894                        putc('\n', fp); fclose(fp);
961                          sprintf(combuf,
962 <                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
963 <                        *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
898 <                                        atoi(vval(MBLUR)),
962 >                        "(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
963 >                                        blurf, nblur,
964                                          fname0, fname1, fname0, fname1);
965                          iter++;
966                  } else                          /* no blurring */
# Line 909 | Line 974 | int    rvr;
974                  if (usepfilt)
975                          sprintf(combuf+strlen(combuf), " %s", rresopt);
976                  else
977 <                        sprintf(combuf+strlen(combuf), " %s -e %s",
977 >                        sprintf(combuf+strlen(combuf), " -a %s -e %s",
978                                          fresopt, ep);
979                  sprintf(combuf+strlen(combuf), " %s.unf %s.zbf",
980                                  fnbefore, fnbefore);
# Line 970 | Line 1035 | int    n;
1035                          fclose(viewfp);
1036                          viewfp = NULL;
1037                          viewnum = 0;
1038 <                        copystruct(&curview, &stdview);
1038 >                        curview = stdview;
1039                  }
1040                  return(NULL);
1041          }
1042 <        if (viewfp == NULL) {           /* open file */
1042 >        if (viewfp == NULL) {                   /* open file */
1043                  if ((viewfp = fopen(vval(VIEWFILE), "r")) == NULL) {
1044                          perror(vval(VIEWFILE));
1045                          quit(1);
1046                  }
1047 <        } else if (n < viewnum) {       /* rewind file */
1047 >        } else if (n > 0 && n < viewnum) {      /* rewind file */
1048                  if (viewnum == 1 && feof(viewfp))
1049                          return(&curview);               /* just one view */
1050                  if (fseek(viewfp, 0L, 0) == EOF) {
1051                          perror(vval(VIEWFILE));
1052                          quit(1);
1053                  }
1054 <                copystruct(&curview, &stdview);
1054 >                curview = stdview;
1055                  viewnum = 0;
1056          }
1057 +        if (n < 0) {                            /* get next view */
1058 +                register int    c = getc(viewfp);
1059 +                if (c == EOF)
1060 +                        return((VIEW *)NULL);           /* that's it */
1061 +                ungetc(c, viewfp);
1062 +                n = viewnum + 1;
1063 +        }
1064          while (n > viewnum) {           /* scan to desired view */
1065                  if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL)
1066                          return(viewnum==1 ? &curview : (VIEW *)NULL);
# Line 1002 | Line 1074 | int    n;
1074   int
1075   countviews()                    /* count views in view file */
1076   {
1077 <        register int    n = 0;
1077 >        int     n;
1078  
1079 <        while (getview(n+1) != NULL)
1079 >        if (getview(n=1) == NULL)
1080 >                return(0);
1081 >        while (getview(-1) != NULL)
1082                  n++;
1083          return(n);
1084   }
# Line 1024 | Line 1098 | int    n;
1098          if (n == 0) {                           /* signal to close file */
1099                  if (expfp != NULL) {
1100                          fclose(expfp);
1101 <                        free((char *)exppos);
1101 >                        free((void *)exppos);
1102                          expfp = NULL;
1103                  }
1104                  return(NULL);
# Line 1229 | Line 1303 | int    maxcopies;
1303                          strcpy(com1=buf, com);  /* build -PP command */
1304                          sprintf(com1+(ppins-com), " -PP %s/%s.persist",
1305                                          vval(DIRECTORY), phostname(ps));
1306 +                        unlink(com1+(ppins-com)+5);
1307                          strcat(com1, ppins);
1308                  } else
1309                          com1 = com;
# Line 1289 | Line 1364 | rmfile(fn)                     /* remove a file */
1364   char    *fn;
1365   {
1366          if (!silent)
1367 < #ifdef MSDOS
1367 > #ifdef _WIN32
1368                  printf("\tdel %s\n", fn);
1369   #else
1370                  printf("\trm -f %s\n", fn);
# Line 1306 | Line 1381 | int    vc;
1381          fprintf(stderr, "%s: bad value for variable '%s'\n",
1382                          progname, vnam(vc));
1383          quit(1);
1384 + }
1385 +
1386 +
1387 + char *
1388 + dirfile(df, path)               /* separate path into directory and file */
1389 + char    *df;
1390 + register char   *path;
1391 + {
1392 +        register int    i;
1393 +        int     psep;
1394 +
1395 +        for (i = 0, psep = -1; path[i]; i++)
1396 +                if (path[i] == '/')
1397 +                        psep = i;
1398 +        if (df != NULL) {
1399 +                if (psep == 0) {
1400 +                        df[0] = '/';
1401 +                        df[1] = '\0';
1402 +                } else if (psep > 0) {
1403 +                        strncpy(df, path, psep);
1404 +                        df[psep] = '\0';
1405 +                } else
1406 +                        df[0] = '\0';
1407 +        }
1408 +        return(path+psep+1);
1409 + }
1410 +
1411 +
1412 + int
1413 + getblur(double *bf)             /* get # blur samples (and fraction) */
1414 + {
1415 +        double  blurf;
1416 +        int     nblur;
1417 +        char    *s;
1418 +
1419 +        if (!vdef(MBLUR)) {
1420 +                if (bf != NULL)
1421 +                        *bf = 0.0;
1422 +                return(0);
1423 +        }
1424 +        blurf = atof(vval(MBLUR));
1425 +        if (blurf < 0.0)
1426 +                blurf = 0.0;
1427 +        if (bf != NULL)
1428 +                *bf = blurf;
1429 +        if (blurf <= FTINY)
1430 +                return(0);
1431 +        s = sskip(vval(MBLUR));
1432 +        if (!*s)
1433 +                return(DEF_NBLUR);
1434 +        nblur = atoi(s);
1435 +        if (nblur <= 0)
1436 +                return(1);
1437 +        return(nblur);
1438   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines