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

Comparing ray/src/util/ranimove.c (file contents):
Revision 3.9 by schorsch, Tue Oct 21 19:19:29 2003 UTC vs.
Revision 3.17 by greg, Mon Mar 21 19:06:08 2016 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char RCSid[] = "$Id";
2 > static const char RCSid[] = "$Id$";
3   #endif
4   /*
5   *  Radiance object animation program
# Line 12 | Line 12 | static const char RCSid[] = "$Id";
12   #include "copyright.h"
13  
14   #include <time.h>
15 < #ifdef _WIN32
15 > #if defined(_WIN32) || defined(_WIN64)
16    #include <winsock.h> /* struct timeval. XXX find a replacement? */
17   #else
18    #include <sys/time.h>
# Line 20 | Line 20 | static const char RCSid[] = "$Id";
20   #include <ctype.h>
21   #include <string.h>
22  
23 + #include "platform.h"
24   #include "paths.h"
25   #include "ranimove.h"
26  
# Line 62 | Line 63 | int            haveprio = 0;   /* high-level saliency specified */
63   int             gargc;          /* global argc for printargs */
64   char            **gargv;        /* global argv for printargs */
65  
66 + static void setdefaults(void);
67 + static void setmove(struct ObjMove      *om, char       *ms);
68 + static void setrendparams(char          *optf, char             *qval);
69 + static void getradfile(char     *rfargs);
70 + static void animate(void);
71 + static int countviews(void); /* XXX duplicated function */
72 + static char * getobjname(struct ObjMove *om);
73 + static char * getxf(struct ObjMove      *om, int        n);
74  
75 +
76   int
77 < main(argc, argv)
78 < int     argc;
79 < char    *argv[];
77 > main(
78 >        int     argc,
79 >        char    *argv[]
80 > )
81   {
82          int     explicate = 0;
83          char    *cfname;
# Line 153 | Line 164 | userr:
164   "Usage: %s [-n nprocs][-f beg,end][-t sec][-d jnd][-s][-w][-e] anim_file\n",
165                          progname);
166          quit(1);
167 +        return 1; /* pro forma return */
168   }
169  
170  
171   void
172 < eputs(s)                                /* put string to stderr */
173 < register char  *s;
172 > eputs(                          /* put string to stderr */
173 >        register char  *s
174 > )
175   {
176          static int  midline = 0;
177  
# Line 177 | Line 190 | register char  *s;
190  
191  
192   void
193 < setdefaults()                   /* set default values */
193 > quit(ec)                        /* make sure exit is called */
194 > int     ec;
195   {
196 +        if (ray_pnprocs > 0)    /* close children if any */
197 +                ray_pclose(0);          
198 +        exit(ec);
199 + }
200 +
201 +
202 + static void
203 + setdefaults(void)                       /* set default values */
204 + {
205          int     nviews;
206          int     decades;
207          char    buf[256];
# Line 253 | Line 276 | setdefaults()                  /* set default values */
276   }
277  
278  
279 < void
280 < setmove(om, ms)                 /* assign a move object from spec. */
281 < struct ObjMove  *om;
282 < char    *ms;
279 > static void
280 > setmove(                        /* assign a move object from spec. */
281 >        struct ObjMove  *om,
282 >        char    *ms
283 > )
284   {
285          char    parname[128];
286          char    *cp;
# Line 313 | Line 337 | badspec:
337   }
338  
339  
340 < void
341 < setrendparams(optf, qval)       /* set global rendering parameters */
342 < char            *optf;
343 < char            *qval;
340 > static void
341 > setrendparams(  /* set global rendering parameters */
342 >        char            *optf,
343 >        char            *qval
344 > )
345   {
346          char    *argv[1024];
347          char    **av = argv;
# Line 325 | Line 350 | char           *qval;
350          av[ac=0] = NULL;
351                                  /* load options from file, first */
352          if (optf != NULL && *optf) {
353 <                ac = wordfile(av, optf);
353 >                ac = wordfile(av, 1024, optf);
354                  if (ac < 0) {
355                          sprintf(errmsg, "cannot load options file \"%s\"",
356                                          optf);
# Line 334 | Line 359 | char           *qval;
359          }
360                                  /* then from options string */
361          if (qval != NULL && qval[0] == '-')
362 <                ac += wordstring(av+ac, qval);
362 >                ac += wordstring(av+ac, 1024-ac, qval);
363  
364                                  /* restore default parameters */
365          ray_restore(NULL);
# Line 360 | Line 385 | char           *qval;
385   }
386  
387  
388 < void
389 < getradfile(rfargs)              /* run rad and get needed variables */
390 < char    *rfargs;
388 > static void
389 > getradfile(             /* run rad and get needed variables */
390 >        char    *rfargs
391 > )
392   {
393          static short    mvar[] = {OCONV,OCTREEF,RESOLUTION,EXPOSURE,-1};
394          char    combuf[256];
395          register int    i;
396          register char   *cp;
397 <        char    *pippt;
397 >        char    *pippt = NULL;
398                                          /* create rad command */
399          strcpy(lorendoptf, "ranim0.opt");
400          sprintf(combuf,
# Line 411 | Line 437 | char   *rfargs;
437   }
438  
439  
440 < void
441 < animate()                       /* run through animation */
440 > static void
441 > animate(void)                   /* run through animation */
442   {
443          int     rpass;
444  
# Line 443 | Line 469 | animate()                      /* run through animation */
469   }
470  
471  
472 < VIEW *
473 < getview(n)                      /* get view number n */
474 < int     n;
472 > extern VIEW *
473 > getview(                        /* get view number n */
474 >        int     n
475 > )
476   {
477          static FILE     *viewfp = NULL;         /* view file pointer */
478          static int      viewnum = 0;            /* current view number */
# Line 493 | Line 520 | int    n;
520   }
521  
522  
523 < int
524 < countviews()                    /* count views in view file */
523 > static int
524 > countviews(void)                        /* count views in view file */
525   {
526          int     n;
527  
# Line 506 | Line 533 | countviews()                   /* count views in view file */
533   }
534  
535  
536 < char *
537 < getexp(n)                       /* get exposure for nth frame */
538 < int     n;
536 > extern char *
537 > getexp(                 /* get exposure for nth frame */
538 >        int     n
539 > )
540   {
541          extern char     *fskip();
542          static char     expval[32];
# Line 560 | Line 588 | formerr:
588          sprintf(errmsg, "%s: exposure format error on line %d",
589                          vval(EXPOSURE), curfrm);
590          error(USER, errmsg);
591 +        return NULL; /* pro forma return */
592   }
593  
594  
595 < double
596 < expspec_val(s)                  /* get exposure value from spec. */
597 < char    *s;
595 > extern double
596 > expspec_val(                    /* get exposure value from spec. */
597 >        char    *s
598 > )
599   {
600          double  expval;
601  
# Line 579 | Line 609 | char   *s;
609   }
610  
611  
612 < char *
613 < getoctspec(n)                   /* get octree for the given frame */
614 < int     n;
612 > extern char *
613 > getoctspec(                     /* get octree for the given frame */
614 >        int     n
615 > )
616   {
617          static char     combuf[1024];
618 <        int             cfm = 0;
618 >        static int      cfm = 0;
619          int     uses_inline;
620          FILE    *fp;
621          int     i;
622                                          /* is octree static? */
623          if (!vdef(MOVE))
624                  return(vval(OCTREEF));
625 <                                        /* done already */
625 >                                        /* done already? */
626          if (n == cfm)
627                  return(combuf);
628                                          /* else create object file */
629 <        strcpy(objtmpf, "movinobj.rad");
599 <        fp = fopen(objtmpf, "w");
629 >        fp = fopen(mktemp(strcpy(objtmpf, TEMPLATE)), "w");
630          if (fp == NULL) {
631                  sprintf(errmsg, "cannot write to moving objects file '%s'",
632                                  objtmpf);
# Line 627 | Line 657 | int    n;
657                                  vdef(OCONV) ? vval(OCONV) : "",
658                                  vval(OCTREEF), objtmpf);
659          else
660 <                sprintf(combuf, "!xform -f %s | oconv -f -i '%s' -",
661 <                                objtmpf, vval(OCTREEF));
660 >                sprintf(combuf, "!xform -f %s | oconv %s -f -i '%s' -",
661 >                                objtmpf, vdef(OCONV) ? vval(OCONV) : "",
662 >                                vval(OCTREEF));
663          return(combuf);
664   }
665  
666  
667 < char *
668 < getobjname(om)                  /* get fully qualified object name */
669 < register struct ObjMove *om;
667 > static char *
668 > getobjname(                     /* get fully qualified object name */
669 >        register struct ObjMove *om
670 > )
671   {
672          static char     objName[512];
673          register char   *cp = objName;
# Line 651 | Line 683 | register struct ObjMove        *om;
683   }
684  
685  
686 < char *
687 < getxf(om, n)                    /* get total transform for object */
688 < register struct ObjMove *om;
689 < int     n;
686 > static char *
687 > getxf(                  /* get total transform for object */
688 >        register struct ObjMove *om,
689 >        int     n
690 > )
691   {
692          static char     xfsbuf[4096];
693          char            *xfp;
# Line 773 | Line 806 | int    n;
806   }
807  
808  
809 < int
810 < getmove(obj)                            /* find matching move object */
811 < OBJECT  obj;
809 > extern int
810 > getmove(                                /* find matching move object */
811 >        OBJECT  obj
812 > )
813   {
814          static int      lasti;
815          static OBJECT   lasto = OVOID;
# Line 806 | Line 840 | OBJECT obj;
840   }
841  
842  
843 < double
844 < obj_prio(obj)                   /* return priority for object */
845 < OBJECT  obj;
843 > extern double
844 > obj_prio(                       /* return priority for object */
845 >        OBJECT  obj
846 > )
847   {
848          int     moi;
849          
# Line 818 | Line 853 | OBJECT obj;
853   }
854  
855  
856 < double
857 < getTime()                       /* get current time (CPU or real) */
856 > #if defined(_WIN32) || defined(_WIN64)
857 >                                /* replacement function for Windoze */
858 > static int
859 > gettimeofday(struct timeval *tp, void *dummy)
860 > {
861 >    FILETIME        ft;
862 >    LARGE_INTEGER   li;
863 >    __int64         t;
864 >
865 >        SYSTEMTIME              st;
866 >        FILETIME                ft2;
867 >        LARGE_INTEGER   li2;
868 >        __int64                 t2;
869 >
870 >        st.wYear = 1970;
871 >        st.wHour = 0;
872 >        st.wMinute = 0;
873 >        st.wSecond = 0;
874 >        st.wMilliseconds = 1;
875 >
876 >        SystemTimeToFileTime(&st, &ft2);
877 >        li2.LowPart = ft2.dwLowDateTime;
878 >        li2.HighPart = ft2.dwHighDateTime;
879 >        t2 = li2.QuadPart;
880 >
881 >    GetSystemTimeAsFileTime(&ft);
882 >    li.LowPart  = ft.dwLowDateTime;
883 >    li.HighPart = ft.dwHighDateTime;
884 >    t  = li.QuadPart;      
885 >    t -= t2; // From 1970
886 >    t /= 10; // In microseconds
887 >    tp->tv_sec  = (long)(t / 1000000);
888 >    tp->tv_usec = (long)(t % 1000000);
889 >    return 0;
890 > }
891 >
892 > #endif
893 >
894 > extern double
895 > getTime(void)                   /* get current time (CPU or real) */
896   {
897          struct timeval  time_now;
898                                          /* return CPU time if one process */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines