cuikatlasvolume.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 
62 int main(int argc, char **arg)
63 {
64  TAtlasBase world; /* The set of mechanism and obstacles. */
65  Tparameters parameters; /* Parameters used in the Cuik process. */
66  Tatlas atlas; /* The atlas to plot. */
67 
68  boolean collisionFree;
69  double v;
70 
71  Tfilename fparam;
72  Tfilename fatlas;
73 
74 
75  if ((argc==2)||(argc==3))
76  {
77  /*Init parameters*/
78  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
79  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
80  fprintf(stderr,"Reading parameters from : %s\n",GetFileFullName(&fparam));
81 
82  /*Read the world from file*/
83  CS_WD_INIT(&parameters,arg[1],&world);
84 
85  CreateFileName(NULL,arg[1],NULL,ATLAS_EXT,&fatlas);
86  fprintf(stderr,"Reading atlas from : %s\n",GetFileFullName(&fatlas));
87  LoadAtlas(&parameters,&fatlas,&world,&atlas);
88 
89  if (argc==2)
90  collisionFree=FALSE;
91  else
92  collisionFree=atoi(arg[2]);
93 
94  v=AtlasVolume(&parameters,collisionFree,&atlas);
95 
96  if (collisionFree)
97  fprintf(stderr,"Volume of C-free : %g\n",v);
98  else
99  fprintf(stderr,"Volume of C : %g\n",v);
100 
101  DeleteParameters(&parameters);
102 
103  CS_WD_DELETE(&world);
104 
105  DeleteAtlas(&atlas);
106 
107  DeleteFileName(&fatlas);
108  DeleteFileName(&fparam);
109  }
110  else
111  {
112  fprintf(stderr," Wrong number of parameters.\n");
113  fprintf(stderr," Use:\n");
114  fprintf(stderr," cuikatlasvolume <problem filename> <collisionFree>\n");
115  fprintf(stderr," where <problem filename> is the atlas.\n");
116  fprintf(stderr," <collisionFree> [optional] 1 if only the volume of the .\n");
117  fprintf(stderr," collisionFree part of the atlas is necessary.\n");
118 
119  }
120  return(EXIT_SUCCESS);
121 }
122 
void LoadAtlas(Tparameters *pr, Tfilename *fname, TAtlasBase *w, Tatlas *a)
Defines an atlas from the information on a file.
Definition: atlas.c:3869
#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 DeleteAtlas(Tatlas *a)
Destructor.
Definition: atlas.c:4561
#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.
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
int main(int argc, char **arg)
Main body of the cuikatlasvolume application.
double AtlasVolume(Tparameters *pr, boolean collisionFree, Tatlas *a)
Approximates the volume of the manifold.
Definition: atlas.c:3966
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
Auxiliary functions to deal with sets of samples.
Definition of the Tparameters type and the associated functions.