cuikanimate.c
Go to the documentation of this file.
1 #include "world.h"
2 #include "box_list.h"
3 #include "error.h"
4 
65 int main(int argc, char **arg)
66 {
67  if (argc>5)
68  {
69  Tworld world;
70  Tparameters parameters;
71  Tfilename fsols;
72  Tfilename fparam;
73  Tfilename fcgl;
74  Tlist sol_box_list;
75  double axesLength;
76  double frameDelay;
77 
78  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
79  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
80 
81  InitWorldFromFile(&parameters,TRUE,arg[1],&world);
82 
83  CreateFileName(NULL,arg[2],NULL,SOL_EXT,&fsols);
84  if (!ReadListOfBoxes(GetFileFullName(&fsols),&sol_box_list))
85  Error("Solution file can not be opened");
86 
87  if (ListSize(&sol_box_list)==0)
88  Error("Empty list of solutions");
89 
90  axesLength=atof(arg[3]);
91 
92  frameDelay=atof(arg[4]);
93 
94  CreateFileName(NULL,arg[5],NULL,PLOT3D_EXT,&fcgl);
95 
96  AnimateWorld(&parameters,GetFileFullName(&fcgl),axesLength,
97  frameDelay,&sol_box_list,&world);
98 
99  DeleteListOfBoxes(&sol_box_list);
100 
101  DeleteWorld(&world);
102  DeleteParameters(&parameters);
103 
104  DeleteFileName(&fsols);
105  DeleteFileName(&fcgl);
106  DeleteFileName(&fparam);
107  }
108  else
109  {
110 
111  fprintf(stdout," Wrong number of parameters.\n");
112  fprintf(stdout," Use:\n");
113  fprintf(stdout," cuikanimate <world>.world <solutions>.sol <axes> <delay> <animation>.cgl\n");
114  fprintf(stdout," Where:\n");
115  fprintf(stdout," <world>: File describing the problem\n");
116  fprintf(stdout," <solutions>: Is the path of solutions to be animated\n");
117  fprintf(stdout," <axes>: Length for the axes for each link. 0 not to display them.\n");
118  fprintf(stdout," <delay>: Delay (in seconds) between frames.\n");
119  fprintf(stdout," To be added to the default delay (0.1 seconds).\n");
120  fprintf(stdout," <animation>: Is the output file (can be seen with 'geomview')\n");
121  fprintf(stdout," File extensions are not required\n");
122  }
123 
124  return(EXIT_SUCCESS);
125 }
Data structure to hold the information about the name of a file.
Definition: filename.h:271
#define TRUE
TRUE.
Definition: boolean.h:21
void Error(const char *s)
General error function.
Definition: error.c:80
#define PARAM_EXT
File extension for parameter files.
Definition: filename.h:132
All the necessary information to generate equations for mechanisms.
Definition: world.h:229
boolean ReadListOfBoxes(char *filename, Tlist *l)
Reads a list of boxes from a file.
Definition: box_list.c:286
Collection of methods to work on Tlist of boxes.
Definition of the Tworld type and the associated functions.
void DeleteWorld(Tworld *w)
Destructor.
Definition: world.c:3952
Error and warning functions.
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
void DeleteListOfBoxes(Tlist *l)
Destructor.
Definition: box_list.c:353
void AnimateWorld(Tparameters *pr, char *pname, double axesLength, double frameDelay, Tlist *p, Tworld *w)
Produces an animation along a path.
Definition: world.c:3837
A generic list.
Definition: list.h:46
A table of parameters.
void CreateFileName(char *path, char *name, char *suffix, char *ext, Tfilename *fn)
Constructor.
Definition: filename.c:22
void InitParametersFromFile(char *file, Tparameters *p)
Constructor from a file.
Definition: parameters.c:51
char * GetFileFullName(Tfilename *fn)
Gets the file full name (paht+name+extension).
Definition: filename.c:151
#define SOL_EXT
File extension for solution files.
Definition: filename.h:138
boolean InitWorldFromFile(Tparameters *p, boolean error, char *fn, Tworld *w)
Constructor.
void DeleteParameters(Tparameters *p)
Destructor.
Definition: parameters.c:294
int main(int argc, char **arg)
Main body of the cuikanimate application.
Definition: cuikanimate.c:65
#define PLOT3D_EXT
File extension for 3D plot files.
Definition: filename.h:168
unsigned int ListSize(Tlist *list)
Gets the number of elements in the list.
Definition: list.c:180