cuikplotatlas.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 "atlas.h"
9 #include "samples.h"
10 
11 #include <stdlib.h>
12 
71 int main(int argc, char **arg)
72 {
73  TAtlasBase world; /* The set of mechanism and obstacles. */
74  Tparameters parameters; /* Parameters used in the Cuik process. */
75  Tatlas atlas; /* The atlas to plot. */
76 
77  unsigned int nx,ny,nz;
78  unsigned int xID,yID,zID;
79  FILE *fc;
80  unsigned int i,s,nv,nvs;
81  boolean *systemVars;
82 
83  Tfilename fparam;
84  Tfilename fplot;
85  Tfilename fatlas;
86  Tfilename fcost;
87 
88 
89  if ((argc==5)||(argc==6))
90  {
91  /*Init parameters*/
92  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
93  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
94  fprintf(stderr,"Reading parameters from : %s\n",GetFileFullName(&fparam));
95 
96  /*Read the world from file*/
97  CS_WD_INIT(&parameters,arg[1],&world);
98  nv=CS_WD_GET_SYSTEM_VARS(&systemVars,&world);
99 
100  CreateFileName(NULL,arg[1],NULL,ATLAS_EXT,&fatlas);
101  fprintf(stderr,"Reading atlas from : %s\n",GetFileFullName(&fatlas));
102  LoadAtlas(&parameters,&fatlas,&world,&atlas);
103 
104  if (argc>5)
105  {
106  CreateFileName(NULL,arg[2],NULL,COST_EXT,&fcost);
107  fprintf(stderr,"Reading cost from : %s\n",GetFileFullName(&fcost));
108  fc=fopen(GetFileFullName(&fcost),"r");
109  if (!fc)
110  Error("Can not open the cost file");
111 
112  nx=atoi(arg[3]);
113  ny=atoi(arg[4]);
114  nz=atoi(arg[5]);
115  }
116  else
117  {
118  fc=NULL;
119  nx=atoi(arg[2]);
120  ny=atoi(arg[3]);
121  nz=atoi(arg[4]);
122  }
123  nvs=0;
124  s=0;
125  for(i=0;i<nv;i++)
126  {
127  if (systemVars[i])
128  {
129  /* Transform index from system variables only to
130  all variables (in the original system in both cases!!) */
131  if (nx==nvs) {xID=i; s++;}
132  if (ny==nvs) {yID=i; s++;}
133  if (nz==nvs) {zID=i; s++;}
134  nvs++;
135  }
136  }
137 
138  if (s!=3)
139  Error("Projection dimensions are beyond the ambient space dimensionality");
140 
141  CreateFileName(NULL,arg[1],"_atlas",PLOT3D_EXT,&fplot);
142  fprintf(stderr,"Generating atlas plot to : %s\n",GetFileFullName(&fplot));
143 
144  PlotAtlas(GetFileFullName(&fplot),argc,arg,&parameters,fc,xID,yID,zID,&atlas);
145 
146  if (fc!=NULL)
147  fclose(fc);
148 
149  DeleteParameters(&parameters);
150 
151  free(systemVars);
152 
153  CS_WD_DELETE(&world);
154 
155  DeleteAtlas(&atlas);
156 
157  DeleteFileName(&fplot);
158  DeleteFileName(&fatlas);
159  DeleteFileName(&fparam);
160  }
161  else
162  {
163  fprintf(stderr," Wrong number of parameters.\n");
164  fprintf(stderr," Use:\n");
165  fprintf(stderr," cuikplotatlas <problem filename> <cost file> <xID> <yID> <zID>\n");
166  fprintf(stderr," where <problem filename> is the atlas to plot.\n");
167  fprintf(stderr," <cost file> [optional] file with associated costs for each chart.\n");
168  fprintf(stderr," <xID> <yID> <zID> are the 3 projection dimensions.\n");
169  fprintf(stderr," (indices of system variables as those in the _path.sol file from 0)\n");
170 
171  }
172  return(EXIT_SUCCESS);
173 }
174 
void LoadAtlas(Tparameters *pr, Tfilename *fname, TAtlasBase *w, Tatlas *a)
Defines an atlas from the information on a file.
Definition: atlas.c:3869
Data structure to hold the information about the name of a file.
Definition: filename.h:248
Definition of the Tfilename type and the associated functions.
#define COST_EXT
File extension for arrays of costs.
Definition: filename.h:155
void DeleteAtlas(Tatlas *a)
Destructor.
Definition: atlas.c:4561
void Error(const char *s)
General error function.
Definition: error.c:80
#define PARAM_EXT
File extension for parameter files.
Definition: filename.h:131
#define CS_WD_DELETE(wcs)
Destructor of the equation structure.
Definition: wcs.h:500
Definition of the Tworld type and the associated functions.
Error and warning functions.
void DeleteFileName(Tfilename *fn)
Destructor.
Definition: filename.c:205
#define ATLAS_EXT
File extension for files storing atlas.
Definition: filename.h:199
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
Definition of an atlas on a manifold.
#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
A atlas on a manifold.
Definition: atlas.h:289
void DeleteParameters(Tparameters *p)
Destructor.
Definition: parameters.c:295
int main(int argc, char **arg)
Main body of the cuikplotatlas application.
Definition: cuikplotatlas.c:71
#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
Auxiliary functions to deal with sets of samples.
Definition of the Tparameters type and the associated functions.
void PlotAtlas(char *fname, int argc, char **arg, Tparameters *pr, FILE *fcost, unsigned int xID, unsigned int yID, unsigned int zID, Tatlas *a)
Pots a projection of an atlas.
Definition: atlas.c:4151