00001
00002
00003
00004 #ifndef Setup_h
00005 #define Setup_h 1
00006
00007
00008 #include "Kalman/Base_VolumeB.h"
00009 #include "Kalman/Base_SurfaceB.h"
00010 #include "Kalman/Base_SurfaceServer.h"
00011 #include "Kalman/Base_LogicB.h"
00012 #include "Kalman/Base_TrajectoryEngine.h"
00013 #include "Kalman/Interface_IState.h"
00014
00015 class Setup
00016 {
00017 public:
00018
00019
00020 Setup(TrajectoryEngine* engine){
00021 m_engine = engine;
00022 m_defaultVolume = new VolumeB("default");
00023 m_logicName = "";
00024 }
00025
00026
00027 virtual ~Setup(){delete m_defaultVolume;}
00028
00029 public:
00030
00031
00032 virtual bool checkAllowedVolumeProperties(std::vector<std::string>& allowedProperties);
00033 virtual bool checkAllowedSurfaceTypes(std::vector<std::string>& allowedSurfaces);
00034
00035
00036
00037
00038
00039 virtual SurfaceServer& surfaceServer(std::string name="")
00040 {return *m_surfServerMap[name];};
00041
00042 virtual void addSurfaceServer(std::string name, SurfaceServer* ms)
00043 {m_surfServerMap[name]=ms;}
00044
00045
00046
00047 virtual void addSurface(std::string name, ISurface& is)
00048 {m_surfServerMap[name]->addSurface(is);}
00049
00050 virtual ISurface& surface(std::string name, int i)
00051 {return m_surfServerMap[name]->surface(i);}
00052
00053 virtual ISurface& surface(std::string name, double z)
00054 {return m_surfServerMap[name]->surface(z);}
00055
00056
00057 virtual int nSurfaces(std::string name)
00058 {return m_surfServerMap[name]->nSurfaces();}
00059
00060
00061
00062
00063
00064 virtual IVolume& volume(std::string name){
00065 if (name == "default") return *m_defaultVolume;
00066 else return *m_volumeMap[name];
00067 }
00068
00069
00070 virtual bool volumeExists(std::string name){
00071 if (m_volumeMap.count(name) != 0) return true;
00072 else return false;
00073 }
00074
00075
00076
00077
00078 virtual IVolume& fatherVolume(std::string name="")
00079 {return m_volumeMap[name]->father();}
00080
00081
00082
00083 virtual void addVolume(std::string name, IVolume& vol){
00084 vol.setFather(*m_defaultVolume);
00085 vol.setMainParameter(m_defaultVolume->mainParameterName(),
00086 m_defaultVolume->mainParameterVector(),
00087 m_defaultVolume->mainParameterComponent());
00088 m_volumeMap[name]=&vol;
00089 }
00090 virtual void addVolume(std::string name, std::string type, EVector pos, EVector size,
00091 EVector dir1)
00092 {addVolume(name, *(engine().newVolume(name, type, pos, size, dir1)));}
00093
00094 virtual void addVolume(std::string name, std::string type, EVector pos, EVector size,
00095 EVector dir1, EVector dir2)
00096 {addVolume(name, *(engine().newVolume(name, type, pos, size, dir1, dir2)));}
00097
00098
00099
00100
00101
00102 virtual void addVolumeCopy(std::string name, std::string type, EVector pos);
00103
00104
00105
00106 virtual void addVolumeToVolume(std::string father, IVolume& vol);
00107 virtual void addVolumeToVolume(std::string father, std::string name, std::string type,
00108 EVector pos, EVector size, EVector dir1);
00109 virtual void addVolumeToVolume(std::string father, std::string name, std::string type,
00110 EVector pos, EVector size, EVector dir1, EVector dir2);
00111
00112
00113
00114 virtual void addSurfaceToVolume(std::string volName, ISurface& surf);
00115 virtual void addSurfaceToVolume(std::string volName, std::string type,
00116 EVector pos, EVector size, EVector dir1)
00117 {addSurfaceToVolume(volName, *(new SurfaceB(type, pos, size, dir1)));}
00118 virtual void addSurfaceToVolume(std::string volName, std::string type,
00119 EVector pos, EVector size, EVector dir1, EVector dir2)
00120 {addSurfaceToVolume(volName, *(new SurfaceB(type, pos, size, dir1, dir2)));}
00121
00122
00123 virtual ISurface& surfaceInVolume(std::string name, int i)
00124 {return volume(name).childSurface(i);}
00125
00126
00127
00128
00129
00130
00131 virtual void setMainParameterInVolume(std::string volName, std::string name, std::string vectorName, int comp)
00132 {volume(volName).setMainParameter(name, vectorName, comp);}
00133
00134
00135 virtual std::string volumeAtMainParameter(double z);
00136
00137
00138 virtual std::string volumeAtPosition(double x, double y, double z);
00139
00140
00141 virtual void addVolumeProperty(std::string volName, std::string propName, int prop)
00142 {m_volumeMap[volName]->addProperty(propName, prop);}
00143 virtual void addVolumeProperty(std::string volName, std::string propName, double prop)
00144 {m_volumeMap[volName]->addProperty(propName, prop);}
00145 virtual void addVolumeProperty(std::string volName, std::string propName, EVector& prop)
00146 {m_volumeMap[volName]->addProperty(propName, prop);}
00147 virtual void addVolumeProperty(std::string volName, std::string propName, EMatrix& prop)
00148 {m_volumeMap[volName]->addProperty(propName, prop);}
00149 virtual void addVolumeProperty(std::string volName, std::string propName, std::string prop)
00150 {m_volumeMap[volName]->addProperty(propName, prop);}
00151
00152 virtual void addVolumePropertyPointer(std::string volName, std::string propName, void* prop)
00153 {m_volumeMap[volName]->addPropertyPointer(propName, prop);}
00154
00155
00156
00157
00158
00159
00160 virtual IVolume& volumeDefinition(std::string name)
00161 {return *m_volumeDefMap[name];}
00162
00163
00164 virtual bool volumeDefinitionExists(std::string name){
00165 if (m_volumeDefMap.count(name) != 0) return true;
00166 else return false;
00167 }
00168
00169
00170
00171 virtual void addVolumeDefinition(std::string name, IVolume& vol){
00172 vol.setMainParameter(m_defaultVolume->mainParameterName(),
00173 m_defaultVolume->mainParameterVector(),
00174 m_defaultVolume->mainParameterComponent());
00175 m_volumeDefMap[name]=&vol;
00176 }
00177 virtual void addVolumeDefinition(std::string name, std::string type, EVector size, EVector dir1)
00178 {addVolumeDefinition(name, *(new VolumeB("definition", name, type, size, dir1)));}
00179 virtual void addVolumeDefinition(std::string name, std::string type, EVector size,
00180 EVector dir1, EVector dir2)
00181 {addVolumeDefinition(name, *(new VolumeB("definition", name, type, size, dir1, dir2)));}
00182
00183
00184
00185 virtual void addVolumeToVolumeDefinition(std::string father, IVolume& vol);
00186 virtual void addVolumeToVolumeDefinition(std::string father, std::string name, std::string type,
00187 EVector pos, EVector size, EVector dir1)
00188 {addVolumeToVolumeDefinition(father, *engine().newVolume(name, type, pos, size, dir1));}
00189
00190 virtual void addVolumeToVolumeDefinition(std::string father, std::string name, std::string type,
00191 EVector pos, EVector size, EVector dir1, EVector dir2)
00192 {addVolumeToVolumeDefinition(father, *engine().newVolume(name, type, pos, size, dir1, dir2));}
00193
00194
00195
00196 virtual void addSurfaceToVolumeDefinition(std::string volName, ISurface& surf);
00197 virtual void addSurfaceToVolumeDefinition(std::string volName, std::string type,
00198 EVector pos, EVector size, EVector dir1)
00199 {addSurfaceToVolumeDefinition(volName, *(new SurfaceB(type, pos, size, dir1)));}
00200
00201 virtual void addSurfaceToVolumeDefinition(std::string volName, std::string type,
00202 EVector pos, EVector size, EVector dir1, EVector dir2)
00203 {addSurfaceToVolumeDefinition(volName, *(new SurfaceB(type, pos, size, dir1, dir2)));}
00204
00205
00206
00207 virtual void addVolumeDefinitionProperty(std::string volName, std::string propName, int prop)
00208 {m_volumeDefMap[volName]->addProperty(propName, prop);}
00209 virtual void addVolumeDefinitionProperty(std::string volName, std::string propName, double prop)
00210 {m_volumeDefMap[volName]->addProperty(propName, prop);}
00211 virtual void addVolumeDefinitionProperty(std::string volName, std::string propName, EVector& prop)
00212 {m_volumeDefMap[volName]->addProperty(propName, prop);}
00213 virtual void addVolumeDefinitionProperty(std::string volName, std::string propName, EMatrix& prop)
00214 {m_volumeDefMap[volName]->addProperty(propName, prop);}
00215 virtual void addVolumeDefinitionProperty(std::string volName, std::string propName, std::string prop)
00216 {m_volumeDefMap[volName]->addProperty(propName, prop);}
00217
00218 virtual void addVolumeDefinitionPropertyPointer(std::string volName, std::string propName, void* prop)
00219 {m_volumeDefMap[volName]->addPropertyPointer(propName, prop);}
00220
00221
00222
00223
00224 virtual IVolume& defaultVolume()
00225 {return *m_defaultVolume;}
00226
00227
00228 virtual void addDefaultProperty(std::string propName, double prop)
00229 {m_defaultVolume->addProperty(propName, prop);}
00230 virtual void addDefaultProperty(std::string propName, EVector& prop)
00231 {m_defaultVolume->addProperty(propName, prop);}
00232 virtual void addDefaultProperty(std::string propName, EMatrix& prop)
00233 {m_defaultVolume->addProperty(propName, prop);}
00234 virtual void addDefaultProperty(std::string propName, std::string prop)
00235 {m_defaultVolume->addProperty(propName, prop);}
00236
00237 virtual void addDefaultPropertyPointer(std::string propName, void* prop)
00238 {m_defaultVolume->addPropertyPointer(propName, prop);}
00239
00240
00241 virtual void setDefaultMainParameter(std::string name,
00242 std::string vectorName,
00243 int comp)
00244 {m_defaultVolume->setMainParameter(name, vectorName, comp);}
00245
00246
00247
00248
00249
00250
00251
00252 virtual void addLogic(std::string name, ILogic* p)
00253 {p->setName(name); m_logicMap[name]=p;}
00254
00255 virtual void addLogic(std::string name){
00256 m_logicMap[name] = new LogicB();
00257 m_logicMap[name]->setName(name);
00258 }
00259
00260
00261 virtual bool logicExists(std::string name){
00262 if (m_logicMap.count(name) != 0) return true;
00263 else return false;
00264 }
00265 virtual bool logicExists(){
00266 if (m_logicName != "") return true;
00267 else return false;
00268 }
00269
00270
00271 virtual bool loadLogic(std::string fileName);
00272
00273
00274 virtual std::string logicName() const {return m_logicName;}
00275
00276 virtual void setLogic(std::string name) {m_logicName=name;}
00277
00278
00279 virtual void addObjectToLogic(std::string logicName, std::string objName, std::string type, int i, int j,
00280 std::string inter, std::string noInter)
00281 {if (checkLogic(logicName, objName, inter, noInter ))
00282 logic(logicName).addLogicalObject(objName, type, i, j, inter, noInter);}
00283
00284 virtual void addObjectToLogic(std::string objName, std::string type, int i, int j,
00285 std::string inter, std::string noInter)
00286 {if (checkLogic(m_logicName, objName, inter, noInter ))
00287 logic().addLogicalObject(objName, type, i, j, inter, noInter);}
00288
00289
00290 virtual ILogic& logic() {return *m_logicMap[m_logicName];}
00291 virtual ILogic& logic(std::string name) {return *m_logicMap[name];}
00292
00293
00294 virtual ILogic& logicInVolume(std::string volName){
00295 if (volName == "default") return logic();
00296 else if (volumeExists(volName)) return volume(volName).logic();
00297 }
00298
00299 virtual bool checkLogic(std::string name, std::string vol, std::string inter, std::string noInter);
00300 virtual bool checkLogic(std::string name, std::string vol);
00301
00302
00303 virtual std::vector<std::string> nextVolumeVector(std::string thisVol, bool intersected, int sens, const IState& state);
00304
00305
00306
00307 virtual void setLogicalObjectName(std::string name)
00308 {m_logicalObjectName = name;}
00309
00310 virtual std::string logicalObjectName() const
00311 {return m_logicalObjectName;}
00312
00313
00314
00315
00316
00317
00318 virtual void addLogicInVolume(std::string volName, std::string name, ILogic* p)
00319 {volume(volName).addLogic(name, p);}
00320
00321 virtual void addLogicInVolume(std::string volName, std::string name)
00322 {volume(volName).addLogic(name);}
00323
00324
00325 virtual std::string logicNameInVolume(std::string volName)
00326 {return volume(volName).logicName();}
00327
00328 virtual void setLogicInVolume(std::string volName, std::string name)
00329 {volume(volName).setLogic(name);}
00330
00331
00332
00333 virtual void addObjectToLogicInVolume(std::string logicName, std::string volName, std::string objName,
00334 std::string type, int i, int j, std::string inter, std::string noInter)
00335 {volume(volName).addObjectToLogic(logicName, objName, type, i, j, inter, noInter);}
00336
00337
00338 virtual void addObjectToLogicInVolume(std::string volName, std::string objName, std::string type, int i, int j,
00339 std::string inter, std::string noInter)
00340 {volume(volName).addObjectToLogic(objName, type, i, j, inter, noInter);}
00341
00342
00343
00344
00345
00346 virtual const std::map<std::string, ILogicFunction*> logicFunctionMap() const {return m_logicFunctionMap;}
00347
00348
00349 virtual void addLogicFunction(std::string name, ILogicFunction* func)
00350 {m_logicFunctionMap[name] = func;}
00351
00352
00353 virtual ILogicFunction& logicFunction(std::string name) {return *m_logicFunctionMap[name];}
00354
00355
00356
00357 virtual bool logicFunctionExists(std::string name) const{
00358 if (m_logicFunctionMap.count(name) != 0) return true;
00359 else return false;
00360 }
00361
00362
00363
00364
00365
00366 virtual TrajectoryEngine& engine() {return *m_engine;}
00367
00368
00369 virtual void setName(std::string name) {m_name = name;}
00370 virtual std::string name() const {return m_name;}
00371
00372
00373 virtual void setVerbosity(int v){m_verbosity = v;}
00374
00375 virtual int verbosity() const {return m_verbosity;}
00376
00377
00378
00379 virtual void info(int verb) const;
00380 virtual void info() const {info(1);}
00381
00382
00383
00384 protected:
00385
00386 std::string m_name;
00387
00388 IVolume* m_defaultVolume;
00389
00390 map<std::string, IVolume*> m_volumeMap;
00391 map<std::string, IVolume*> m_volumeDefMap;
00392
00393 map<std::string, SurfaceServer*> m_surfServerMap;
00394
00395
00396
00397 std::string m_logicName;
00398 std::map<std::string, ILogic*> m_logicMap;
00399
00400
00401 std::map<std::string, ILogicFunction*> m_logicFunctionMap;
00402
00403
00404 TrajectoryEngine* m_engine;
00405
00406 int m_verbosity;
00407
00408 std::string m_logicalObjectName;
00409
00410 };
00411 #endif
00412