cuikplotpath.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 
76  unsigned int nx,ny,nz;
77  unsigned int i,nv,nvs;
78  boolean *systemVars;
79 
80  unsigned int ns;
81  double **path;
82 
83  Tfilename fparam;
84  Tfilename fpath;
85 
86  //boolean smooth;
87 
88  if (argc>=5)
89  {
90  /*Init parameters*/
91  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
92  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
93  fprintf(stderr,"Reading parameters from : %s\n",GetFileFullName(&fparam));
94 
95  /*Read the world from file*/
96  CS_WD_INIT(&parameters,arg[1],&world);
97  nv=CS_WD_GET_SYSTEM_VARS(&systemVars,&world);
98 
99  if (argc>5)
100  {
101  CreateFileName(NULL,arg[2],NULL,SOL_EXT,&fpath);
102 
103  nx=atoi(arg[3]);
104  ny=atoi(arg[4]);
105  nz=atoi(arg[5]);
106  }
107  else
108  {
109  CreateFileName(NULL,arg[1],"_path",SOL_EXT,&fpath);
110 
111  nx=atoi(arg[2]);
112  ny=atoi(arg[3]);
113  nz=atoi(arg[4]);
114  }
115 
116  nvs=0;
117  for(i=0;i<nv;i++)
118  {
119  if (systemVars[i])
120  nvs++;
121  }
122  if ((nx>=nvs)||(ny>=nvs)||(nz>=nvs))
123  Error("Projection dimensions are beyond the ambient space dimensionality");
124 
125  free(systemVars);
126 
127 
128  if (LoadSamples(fpath,&nvs,&ns,&path))
129  {
130  /*If the path was actually saved*/
131  Tfilename fpathplot;
132  Tplot3d p3d;
133 
134  if (argc>5)
135  CreateFileName(NULL,arg[2],NULL,PLOT3D_EXT,&fpathplot);
136  else
137  CreateFileName(NULL,arg[1],"_path",PLOT3D_EXT,&fpathplot);
138 
139  fprintf(stderr,"Generating path plot to : %s\n",GetFileFullName(&fpathplot));
140 
141  InitPlot3d(GetFileFullName(&fpathplot),FALSE,argc,arg,&p3d);
142 
143  PlotSamples(&parameters,&p3d,nx,ny,nz,ns,path);
144 
145  ClosePlot3d(FALSE,0,0,0,&p3d);
146 
147  DeleteFileName(&fpathplot);
148  DeleteSamples(ns,path);
149  }
150 
151  DeleteParameters(&parameters);
152  CS_WD_DELETE(&world);
153 
154  DeleteFileName(&fpath);
155  DeleteFileName(&fparam);
156  }
157  else
158  {
159  fprintf(stderr," Wrong number of parameters.\n");
160  fprintf(stderr," Use:\n");
161  fprintf(stderr," cuikplotpath <problem filename> [<path filename>] <xID> <yID> <zID>\n");
162  fprintf(stderr," where <problem filename> is the description of the problem.\n");
163  fprintf(stderr," <path filename> is the path to plot. If not given we use <problem filename>_path.sol\n");
164  fprintf(stderr," <xID> <yID> <zID> are the 3 projection dimensions.\n");
165  fprintf(stderr," (indices of system variables as those in the _path.sol file from 0)\n");
166  }
167  return(EXIT_SUCCESS);
168 }
169 
#define FALSE
FALSE.
Definition: boolean.h:30
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.
void InitPlot3d(char *name, boolean axes, int argc, char **arg, Tplot3d *p)
Constructor.
Definition: plot3d.c:41
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
A 3D plot.
Definition: plot3d.h:54
Definitions of constants and macros used in several parts of the cuik library.
void PlotSamples(Tparameters *p, Tplot3d *p3d, unsigned int xID, unsigned int yID, unsigned int zID, unsigned int ns, double **path)
Plots a 3D projection of a path.
Definition: samples.c:1399
int main(int argc, char **arg)
Main body of the cuikplotpath application.
Definition: cuikplotpath.c:71
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
#define SOL_EXT
File extension for solution files.
Definition: filename.h:137
boolean LoadSamples(Tfilename fname, unsigned int *nvs, unsigned int *ns, double ***path)
Reads a set of samples from file.
Definition: samples.c:1352
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
Auxiliary functions to deal with sets of samples.
void DeleteSamples(unsigned int ns, double **path)
Deletes the space used by a set of samples.
Definition: samples.c:1495
Definition of the Tparameters type and the associated functions.
void ClosePlot3d(boolean quit, double average_x, double average_y, double average_z, Tplot3d *p)
Destructor.
Definition: plot3d.c:473