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.18 by greg, Mon Apr 18 22:39:13 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 >        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(int ec)                    /* make sure exit is called */
194   {
195 +        if (ray_pnprocs > 0)    /* close children if any */
196 +                ray_pclose(0);          
197 +        exit(ec);
198 + }
199 +
200 +
201 + static void
202 + setdefaults(void)                       /* set default values */
203 + {
204          int     nviews;
205          int     decades;
206          char    buf[256];
# Line 253 | Line 275 | setdefaults()                  /* set default values */
275   }
276  
277  
278 < void
279 < setmove(om, ms)                 /* assign a move object from spec. */
280 < struct ObjMove  *om;
281 < char    *ms;
278 > static void
279 > setmove(                        /* assign a move object from spec. */
280 >        struct ObjMove  *om,
281 >        char    *ms
282 > )
283   {
284          char    parname[128];
285          char    *cp;
# Line 313 | Line 336 | badspec:
336   }
337  
338  
339 < void
340 < setrendparams(optf, qval)       /* set global rendering parameters */
341 < char            *optf;
342 < char            *qval;
339 > static void
340 > setrendparams(  /* set global rendering parameters */
341 >        char            *optf,
342 >        char            *qval
343 > )
344   {
345          char    *argv[1024];
346          char    **av = argv;
# Line 325 | Line 349 | char           *qval;
349          av[ac=0] = NULL;
350                                  /* load options from file, first */
351          if (optf != NULL && *optf) {
352 <                ac = wordfile(av, optf);
352 >                ac = wordfile(av, 1024, optf);
353                  if (ac < 0) {
354                          sprintf(errmsg, "cannot load options file \"%s\"",
355                                          optf);
# Line 334 | Line 358 | char           *qval;
358          }
359                                  /* then from options string */
360          if (qval != NULL && qval[0] == '-')
361 <                ac += wordstring(av+ac, qval);
361 >                ac += wordstring(av+ac, 1024-ac, qval);
362  
363                                  /* restore default parameters */
364          ray_restore(NULL);
# Line 360 | Line 384 | char           *qval;
384   }
385  
386  
387 < void
388 < getradfile(rfargs)              /* run rad and get needed variables */
389 < char    *rfargs;
387 > static void
388 > getradfile(             /* run rad and get needed variables */
389 >        char    *rfargs
390 > )
391   {
392          static short    mvar[] = {OCONV,OCTREEF,RESOLUTION,EXPOSURE,-1};
393          char    combuf[256];
394 <        register int    i;
395 <        register char   *cp;
396 <        char    *pippt;
394 >        int     i;
395 >        char    *cp;
396 >        char    *pippt = NULL;
397                                          /* create rad command */
398          strcpy(lorendoptf, "ranim0.opt");
399          sprintf(combuf,
# Line 411 | Line 436 | char   *rfargs;
436   }
437  
438  
439 < void
440 < animate()                       /* run through animation */
439 > static void
440 > animate(void)                   /* run through animation */
441   {
442          int     rpass;
443  
# Line 444 | Line 469 | animate()                      /* run through animation */
469  
470  
471   VIEW *
472 < getview(n)                      /* get view number n */
473 < int     n;
472 > getview(                        /* get view number n */
473 >        int     n
474 > )
475   {
476          static FILE     *viewfp = NULL;         /* view file pointer */
477          static int      viewnum = 0;            /* current view number */
# Line 477 | Line 503 | int    n;
503                  viewnum = 0;
504          }
505          if (n < 0) {                            /* get next view */
506 <                register int    c = getc(viewfp);
506 >                int     c = getc(viewfp);
507                  if (c == EOF)
508                          return(NULL);                   /* that's it */
509                  ungetc(c, viewfp);
# Line 493 | Line 519 | int    n;
519   }
520  
521  
522 < int
523 < countviews()                    /* count views in view file */
522 > static int
523 > countviews(void)                        /* count views in view file */
524   {
525          int     n;
526  
# Line 507 | Line 533 | countviews()                   /* count views in view file */
533  
534  
535   char *
536 < getexp(n)                       /* get exposure for nth frame */
537 < int     n;
536 > getexp(                 /* get exposure for nth frame */
537 >        int     n
538 > )
539   {
540          extern char     *fskip();
541          static char     expval[32];
542          static FILE     *expfp = NULL;
543          static int      curfrm = 0;
544 <        register char   *cp;
544 >        char    *cp;
545  
546          if (n == 0) {                           /* signal to close file */
547                  if (expfp != NULL) {
# Line 560 | Line 587 | formerr:
587          sprintf(errmsg, "%s: exposure format error on line %d",
588                          vval(EXPOSURE), curfrm);
589          error(USER, errmsg);
590 +        return NULL; /* pro forma return */
591   }
592  
593  
594   double
595 < expspec_val(s)                  /* get exposure value from spec. */
596 < char    *s;
595 > expspec_val(                    /* get exposure value from spec. */
596 >        char    *s
597 > )
598   {
599          double  expval;
600  
# Line 580 | Line 609 | char   *s;
609  
610  
611   char *
612 < getoctspec(n)                   /* get octree for the given frame */
613 < int     n;
612 > getoctspec(                     /* get octree for the given frame */
613 >        int     n
614 > )
615   {
616          static char     combuf[1024];
617 <        int             cfm = 0;
617 >        static int      cfm = 0;
618          int     uses_inline;
619          FILE    *fp;
620          int     i;
621                                          /* is octree static? */
622          if (!vdef(MOVE))
623                  return(vval(OCTREEF));
624 <                                        /* done already */
624 >                                        /* done already? */
625          if (n == cfm)
626                  return(combuf);
627                                          /* else create object file */
628 <        strcpy(objtmpf, "movinobj.rad");
599 <        fp = fopen(objtmpf, "w");
628 >        fp = fopen(mktemp(strcpy(objtmpf, TEMPLATE)), "w");
629          if (fp == NULL) {
630                  sprintf(errmsg, "cannot write to moving objects file '%s'",
631                                  objtmpf);
# Line 627 | Line 656 | int    n;
656                                  vdef(OCONV) ? vval(OCONV) : "",
657                                  vval(OCTREEF), objtmpf);
658          else
659 <                sprintf(combuf, "!xform -f %s | oconv -f -i '%s' -",
660 <                                objtmpf, vval(OCTREEF));
659 >                sprintf(combuf, "!xform -f %s | oconv %s -f -i '%s' -",
660 >                                objtmpf, vdef(OCONV) ? vval(OCONV) : "",
661 >                                vval(OCTREEF));
662          return(combuf);
663   }
664  
665  
666 < char *
667 < getobjname(om)                  /* get fully qualified object name */
668 < register struct ObjMove *om;
666 > static char *
667 > getobjname(                     /* get fully qualified object name */
668 >        struct ObjMove  *om
669 > )
670   {
671          static char     objName[512];
672 <        register char   *cp = objName;
672 >        char    *cp = objName;
673          
674          strcpy(cp, om->name);
675          while (om->parent >= 0) {
# Line 651 | Line 682 | register struct ObjMove        *om;
682   }
683  
684  
685 < char *
686 < getxf(om, n)                    /* get total transform for object */
687 < register struct ObjMove *om;
688 < int     n;
685 > static char *
686 > getxf(                  /* get total transform for object */
687 >        struct ObjMove  *om,
688 >        int     n
689 > )
690   {
691          static char     xfsbuf[4096];
692          char            *xfp;
# Line 665 | Line 697 | int    n;
697          char            *av[64];
698          int             ac;
699          int             i;
700 <        register char   *cp;
700 >        char    *cp;
701                                          /* get parent transform, first */
702          if (om->parent >= 0)
703                  xfp = getxf(&obj_move[om->parent], n);
# Line 774 | Line 806 | int    n;
806  
807  
808   int
809 < getmove(obj)                            /* find matching move object */
810 < OBJECT  obj;
809 > getmove(                                /* find matching move object */
810 >        OBJECT  obj
811 > )
812   {
813          static int      lasti;
814          static OBJECT   lasto = OVOID;
815          char    *onm, *objnm;
816          int     len, len2;
817 <        register int    i;
817 >        int     i;
818  
819          if (obj == OVOID)
820                  return(-1);
# Line 807 | Line 840 | OBJECT obj;
840  
841  
842   double
843 < obj_prio(obj)                   /* return priority for object */
844 < OBJECT  obj;
843 > obj_prio(                       /* return priority for object */
844 >        OBJECT  obj
845 > )
846   {
847          int     moi;
848          
# Line 818 | Line 852 | OBJECT obj;
852   }
853  
854  
855 + #if defined(_WIN32) || defined(_WIN64)
856 +                                /* replacement function for Windoze */
857 + static int
858 + gettimeofday(struct timeval *tp, void *dummy)
859 + {
860 +    FILETIME        ft;
861 +    LARGE_INTEGER   li;
862 +    __int64         t;
863 +
864 +        SYSTEMTIME              st;
865 +        FILETIME                ft2;
866 +        LARGE_INTEGER   li2;
867 +        __int64                 t2;
868 +
869 +        st.wYear = 1970;
870 +        st.wHour = 0;
871 +        st.wMinute = 0;
872 +        st.wSecond = 0;
873 +        st.wMilliseconds = 1;
874 +
875 +        SystemTimeToFileTime(&st, &ft2);
876 +        li2.LowPart = ft2.dwLowDateTime;
877 +        li2.HighPart = ft2.dwHighDateTime;
878 +        t2 = li2.QuadPart;
879 +
880 +    GetSystemTimeAsFileTime(&ft);
881 +    li.LowPart  = ft.dwLowDateTime;
882 +    li.HighPart = ft.dwHighDateTime;
883 +    t  = li.QuadPart;      
884 +    t -= t2; // From 1970
885 +    t /= 10; // In microseconds
886 +    tp->tv_sec  = (long)(t / 1000000);
887 +    tp->tv_usec = (long)(t % 1000000);
888 +    return 0;
889 + }
890 +
891 + #endif
892 +
893   double
894 < getTime()                       /* get current time (CPU or real) */
894 > getTime(void)                   /* get current time (CPU or real) */
895   {
896          struct timeval  time_now;
897                                          /* return CPU time if one process */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines