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 
100  fprintf(stderr,"Projecting on variables : ");
101  PRINT_VARIABLE_NAME(stderr,CS_WD_GET_SYSTEM_VAR_NAME(nx,&world));fprintf(stderr,",");
102  PRINT_VARIABLE_NAME(stderr,CS_WD_GET_SYSTEM_VAR_NAME(ny,&world));fprintf(stderr,",");
103  PRINT_VARIABLE_NAME(stderr,CS_WD_GET_SYSTEM_VAR_NAME(nz,&world));fprintf(stderr,"\n");
104 
105  nvs=0;
106  s=0;
107  for(i=0;i<nv;i++)
108  {
109  if (systemVars[i])
110  {
111  /* Transform index from system variables only to
112  all variables (in the original system in both cases!!) */
113  if (nx==nvs) {xID=i; s++;}
114  if (ny==nvs) {yID=i; s++;}
115  if (nz==nvs) {zID=i; s++;}
116  nvs++;
117  }
118  }
119 
120  if (s!=3)
121  Error("Projection dimensions are beyond the ambient space dimensionality");
122 
123  CreateFileName(NULL,arg[1],"_rrt",PLOT3D_EXT,&fplot);
124  fprintf(stderr,"Generating rrt plot to : %s\n",GetFileFullName(&fplot));
125 
126  PlotRRT(GetFileFullName(&fplot),argc,arg,&parameters,xID,yID,zID,&rrt);
127 
128  DeleteParameters(&parameters);
129 
130  free(systemVars);
131 
132  CS_WD_DELETE(&world);
133 
134  DeleteRRT(&rrt);
135 
136  DeleteFileName(&fplot);
137  DeleteFileName(&frrt);
138  DeleteFileName(&fparam);
139  }
140  else
141  {
142  fprintf(stderr," Wrong number of parameters.\n");
143  fprintf(stderr," Use:\n");
144  fprintf(stderr," cuikplotrrt <problem filename> <xID> <yID> <zID>\n");
145  fprintf(stderr," where <problem filename> is the rrt to plot\n");
146  fprintf(stderr," <xID> <yID> <zID> are the 3 projection dimensions\n");
147 
148  }
149  return(EXIT_SUCCESS);
150 }
151 
void DeleteRRT(Trrt *rrt)
Destructor.
Definition: rrt.c:4201
Data structure to hold the information about the name of a file.
Definition: filename.h:271
#define RRT_EXT
File extension for files storing rrt's.
Definition: filename.h:213
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:3734
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:132
A RRT on a manifold.
Definition: rrt.h:322
#define CS_WD_DELETE(wcs)
Destructor of the equation structure.
Definition: wcs.h:592
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:4041
Definition of a rrt on a manifold.
Error and warning functions.
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
#define PRINT_VARIABLE_NAME(f, name)
Prints a variable name into a file.
Definition: defines.h:427
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:294
#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:168
int main(int argc, char **arg)
Main body of the cuikplotrrt application.
Definition: cuikplotrrt.c:66
#define CS_WD_GET_SYSTEM_VAR_NAME(id, wcs)
Name of a particular system variables.
Definition: wcs.h:252
Definition of the Tparameters type and the associated functions.