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  Tfilename fworld;
75  Tlist sol_box_list;
76  double axesLength;
77  double frameDelay;
78 
79  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
80  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
81 
82  CreateFileName(NULL,arg[1],NULL,WORLD_EXT,&fworld);
83  InitWorldFromFile(&parameters,&fworld,&world);
84 
85  CreateFileName(NULL,arg[2],NULL,SOL_EXT,&fsols);
86  if (!ReadListOfBoxes(GetFileFullName(&fsols),&sol_box_list))
87  Error("Solution file can not be opened");
88 
89  if (ListSize(&sol_box_list)==0)
90  Error("Empty list of solutions");
91 
92  axesLength=atof(arg[3]);
93 
94  frameDelay=atof(arg[4]);
95 
96  CreateFileName(NULL,arg[5],NULL,PLOT3D_EXT,&fcgl);
97 
98  AnimateWorld(&parameters,GetFileFullName(&fcgl),axesLength,
99  frameDelay,&sol_box_list,&world);
100 
101  DeleteListOfBoxes(&sol_box_list);
102 
103  DeleteWorld(&world);
104  DeleteParameters(&parameters);
105 
106  DeleteFileName(&fsols);
107  DeleteFileName(&fcgl);
108  DeleteFileName(&fworld);
109  DeleteFileName(&fparam);
110  }
111  else
112  {
113 
114  fprintf(stdout," Wrong number of parameters.\n");
115  fprintf(stdout," Use:\n");
116  fprintf(stdout," cuikanimate <world>.world <solutions>.sol <axes> <delay> <animation>.cgl\n");
117  fprintf(stdout," Where:\n");
118  fprintf(stdout," <world>: File describing the problem\n");
119  fprintf(stdout," <solutions>: Is the path of solutions to be animated\n");
120  fprintf(stdout," <axes>: Length for the axes for each link. 0 not to display them.\n");
121  fprintf(stdout," <delay>: Delay (in seconds) between frames.\n");
122  fprintf(stdout," To be added to the default delay (0.1 seconds).\n");
123  fprintf(stdout," <animation>: Is the output file (can be seen with 'geomview')\n");
124  fprintf(stdout," File extensions are not required\n");
125  }
126 
127  return(EXIT_SUCCESS);
128 }
Data structure to hold the information about the name of a file.
Definition: filename.h:248
void InitWorldFromFile(Tparameters *p, Tfilename *f, Tworld *w)
Constructor.
void Error(const char *s)
General error function.
Definition: error.c:80
#define PARAM_EXT
File extension for parameter files.
Definition: filename.h:131
All the necessary information to generate equations for mechanisms.
Definition: world.h:124
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:2792
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:2677
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:137
#define WORLD_EXT
File extension for problem files.
Definition: filename.h:161
void DeleteParameters(Tparameters *p)
Destructor.
Definition: parameters.c:295
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:167
unsigned int ListSize(Tlist *list)
Gets the number of elements in the list.
Definition: list.c:180