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 measure. */
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