cuikplotrrt.c
Go to the documentation of this file.
1 
2 #include "world.h"
3 #include "parameters.h"
4 
5 #include "defines.h"
6 #include "error.h"
7 #include "filename.h"
8 #include "rrt.h"
9 
10 #include <stdlib.h>
11 
66 int main(int argc, char **arg)
67 {
68  TAtlasBase world; /* The set of mechanism and obstacles. */
69  Tparameters parameters; /* Parameters used in the Cuik process. */
70  Trrt rrt; /* The rrt to plot. */
71 
72  unsigned int nx,ny,nz;
73  unsigned int xID,yID,zID;
74  unsigned int i,s,nv,nvs;
75  boolean *systemVars;
76 
77  Tfilename fparam;
78  Tfilename fplot;
79  Tfilename frrt;
80 
81  if (argc==5)
82  {
83  /*Init parameters*/
84  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
85  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
86  fprintf(stderr,"Reading parameters from : %s\n",GetFileFullName(&fparam));
87 
88  /*Read the world from file*/
89  CS_WD_INIT(&parameters,arg[1],&world);
90  nv=CS_WD_GET_SYSTEM_VARS(&systemVars,&world);
91 
92  CreateFileName(NULL,arg[1],NULL,RRT_EXT,&frrt);
93  fprintf(stderr,"Reading rrt from : %s\n",GetFileFullName(&frrt));
94  LoadRRT(&parameters,&frrt,&world,&rrt);
95 
96  nx=atoi(arg[2]);
97  ny=atoi(arg[3]);
98  nz=atoi(arg[4]);
99  nvs=0;
100  s=0;
101  for(i=0;i<nv;i++)
102  {
103  if (systemVars[i])
104  {
105  /* Transform index from system variables only to
106  all variables (in the original system in both cases!!) */
107  if (nx==nvs) {xID=i; s++;}
108  if (ny==nvs) {yID=i; s++;}
109  if (nz==nvs) {zID=i; s++;}
110  nvs++;
111  }
112  }
113 
114  if (s!=3)
115  Error("Projection dimensions are beyond the ambient space dimensionality");
116 
117  CreateFileName(NULL,arg[1],"_rrt",PLOT3D_EXT,&fplot);
118  fprintf(stderr,"Generating rrt plot to : %s\n",GetFileFullName(&fplot));
119 
120  PlotRRT(GetFileFullName(&fplot),argc,arg,&parameters,xID,yID,zID,&rrt);
121 
122  DeleteParameters(&parameters);
123 
124  free(systemVars);
125 
126  CS_WD_DELETE(&world);
127 
128  DeleteRRT(&rrt);
129 
130  DeleteFileName(&fplot);
131  DeleteFileName(&frrt);
132  DeleteFileName(&fparam);
133  }
134  else
135  {
136  fprintf(stderr," Wrong number of parameters.\n");
137  fprintf(stderr," Use:\n");
138  fprintf(stderr," cuikplotrrt <problem filename> <xID> <yID> <zID>\n");
139  fprintf(stderr," where <problem filename> is the rrt to plot\n");
140  fprintf(stderr," <xID> <yID> <zID> are the 3 projection dimensions\n");
141 
142  }
143  return(EXIT_SUCCESS);
144 }
145 
void DeleteRRT(Trrt *rrt)
Destructor.
Definition: rrt.c:4196
Data structure to hold the information about the name of a file.
Definition: filename.h:248
#define RRT_EXT
File extension for files storing rrt's.
Definition: filename.h:205
void PlotRRT(char *fname, int argc, char **arg, Tparameters *pr, unsigned int xID, unsigned int yID, unsigned int zID, Trrt *rrt)
Pots a projection of a RRT.
Definition: rrt.c:3729
Definition of the Tfilename type and the associated functions.
void Error(const char *s)
General error function.
Definition: error.c:80
#define PARAM_EXT
File extension for parameter files.
Definition: filename.h:131
A RRT on a manifold.
Definition: rrt.h:329
#define CS_WD_DELETE(wcs)
Destructor of the equation structure.
Definition: wcs.h:500
Definition of the Tworld type and the associated functions.
void LoadRRT(Tparameters *pr, Tfilename *fname, TAtlasBase *w, Trrt *rrt)
Defines a RRT from the information on a file.
Definition: rrt.c:4036
Definition of a rrt on a manifold.
Error and warning functions.
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
Definitions of constants and macros used in several parts of the cuik library.
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
Type defining the equations on which the atlas is defined.
Definition: wcs.h:30
#define CS_WD_GET_SYSTEM_VARS(sv, wcs)
Gets the system variables.
Definition: wcs.h:238
char * GetFileFullName(Tfilename *fn)
Gets the file full name (paht+name+extension).
Definition: filename.c:151
void DeleteParameters(Tparameters *p)
Destructor.
Definition: parameters.c:295
#define CS_WD_INIT(pr, name, wcs)
Initializes the equations from a file.
Definition: wcs.h:89
#define PLOT3D_EXT
File extension for 3D plot files.
Definition: filename.h:167
int main(int argc, char **arg)
Main body of the cuikplotrrt application.
Definition: cuikplotrrt.c:66
Definition of the Tparameters type and the associated functions.