Base_Setup.h

Go to the documentation of this file.
00001 //     Authors:
00002 // Anselmo Cervera, Juan J. Gomez-Cadenas and Jose Angel Hernando
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   //! default constructor
00020   Setup(TrajectoryEngine* engine){
00021     m_engine = engine; 
00022     m_defaultVolume = new VolumeB("default");
00023     m_logicName = "";
00024   }
00025   
00026   //! default destructor
00027   virtual ~Setup(){delete m_defaultVolume;}
00028   
00029  public:
00030 
00031   // TODO (what happens with const?
00032   virtual bool checkAllowedVolumeProperties(std::vector<std::string>& allowedProperties);
00033   virtual bool checkAllowedSurfaceTypes(std::vector<std::string>& allowedSurfaces);
00034 
00035 
00036   //-------------- SURFACE SERVER --------------------------
00037 
00038   //! Returns a reference to the server
00039   virtual SurfaceServer& surfaceServer(std::string name="")
00040      {return *m_surfServerMap[name];}; 
00041   //! set a Surface server with name
00042   virtual void addSurfaceServer(std::string name, SurfaceServer* ms) 
00043     {m_surfServerMap[name]=ms;}
00044 
00045 
00046   //! Add Surface to server
00047   virtual void addSurface(std::string name, ISurface& is)
00048     {m_surfServerMap[name]->addSurface(is);} 
00049   //! gets  Surface from server provided the server name and the surface index
00050   virtual ISurface& surface(std::string name, int i)
00051     {return m_surfServerMap[name]->surface(i);} 
00052   //! gets  Surface from server provided the server name and the surface mainParameter
00053   virtual ISurface& surface(std::string name, double z)
00054     {return m_surfServerMap[name]->surface(z);} 
00055 
00056   //! gets  the number of Surfaces in the server
00057   virtual int nSurfaces(std::string name) 
00058     {return m_surfServerMap[name]->nSurfaces();} 
00059 
00060 
00061   //------------  VOLUME MAP -----------------------------
00062 
00063   //! Returns a reference to the volume of name 
00064   virtual IVolume& volume(std::string name){
00065     if (name == "default") return *m_defaultVolume;
00066     else return *m_volumeMap[name]; 
00067   }
00068 
00069   //! Check if the volume has been defined 
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   //! Returns a reference to the father volume
00078   virtual IVolume& fatherVolume(std::string name="")
00079     {return m_volumeMap[name]->father();} 
00080 
00081 
00082   //! add a new volume 
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   //! add a real copy of a volume definition
00102   virtual void addVolumeCopy(std::string name, std::string type, EVector pos);
00103 
00104   
00105   //! add a child  volume  to an existing volume
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   //! add a child  surface  to an existing volume
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   //! gets  Surface from volume provided the volume name and the surface index
00123   virtual ISurface& surfaceInVolume(std::string name, int i)
00124     {return volume(name).childSurface(i);} 
00125   //! gets  Surface from volume provided the volume name and the surface name
00126   //  virtual ISurface& surfaceInVolume(std::string volName, std::string surfName)
00127   //    {return volume(volName).childSurface(surfName);} 
00128 
00129 
00130    //! main parameter of a volume
00131   virtual void setMainParameterInVolume(std::string volName, std::string name, std::string vectorName, int comp)
00132     {volume(volName).setMainParameter(name, vectorName, comp);}
00133 
00134   //! volume at  a given mainParameter
00135   virtual std::string volumeAtMainParameter(double z);
00136 
00137   //! volume at  a given position
00138   virtual std::string volumeAtPosition(double x, double y, double z);
00139 
00140  //! set properties of the volume in the case there is a choice
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   //------------ VOLUME DEFINITION ----------------------------
00158 
00159   //! Returns a reference to the volume of name 
00160   virtual IVolume& volumeDefinition(std::string name)
00161     {return *m_volumeDefMap[name];} 
00162   
00163   //! Returns a reference to the volume of name 
00164   virtual bool volumeDefinitionExists(std::string name){
00165     if (m_volumeDefMap.count(name) != 0) return true;
00166     else return false;
00167   } 
00168 
00169 
00170   //! add a new volume 
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   //! add a child  volume  to an existing volume 
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   //! add a child  surface  to an existing volume
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  //! set properties of the volume in the case there is a choice
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   //------------  DEFAULT VOLUME -----------------------------
00222 
00223   //! Returns a reference to the volume
00224     virtual IVolume& defaultVolume()
00225        {return *m_defaultVolume;} 
00226 
00227  //! set properties of the default volume 
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    //! default main parameter
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   //---------------- NAVIGATION LOGIC --------------------------------------
00249 
00250 
00251   //! add a logic to the list
00252   virtual void addLogic(std::string name, ILogic* p)
00253     {p->setName(name); m_logicMap[name]=p;}  
00254   //! add a logic to the list
00255   virtual void addLogic(std::string name){
00256     m_logicMap[name] = new LogicB();
00257     m_logicMap[name]->setName(name);
00258   }  
00259 
00260   //! Check that the logic exists
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   //! load logic file 
00271   virtual bool loadLogic(std::string fileName);
00272 
00273   //! returns the logic name
00274   virtual std::string logicName() const {return m_logicName;}
00275   //! set the navigation logic by name
00276   virtual void setLogic(std::string name) {m_logicName=name;}
00277 
00278   //! adds a new object to the logic
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   //! returns a reference to the logic
00290   virtual ILogic& logic() {return *m_logicMap[m_logicName];}
00291   virtual ILogic& logic(std::string name) {return *m_logicMap[name];}
00292 
00293   //! returns a reference to the in volume logic providing the volume name
00294   virtual ILogic& logicInVolume(std::string volName){
00295     if (volName == "default") return logic();    
00296     else if (volumeExists(volName)) return volume(volName).logic();
00297   }
00298   //! checks everything when adding a volume to the Logic
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   //! gets the vector with the names of the volumes in de logic
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   //---------------- NAVIGATION LOGIC IN VOLUME--------------------------------------
00315 
00316 
00317   //! add a logic to the list
00318   virtual void addLogicInVolume(std::string volName, std::string name, ILogic* p)
00319     {volume(volName).addLogic(name, p);}  
00320   //! add a logic to the list
00321   virtual void addLogicInVolume(std::string volName, std::string name)
00322     {volume(volName).addLogic(name);}  
00323 
00324   //! returns the logic name
00325   virtual std::string logicNameInVolume(std::string volName)  
00326     {return volume(volName).logicName();}
00327   //! set the navigation logic by name
00328   virtual void setLogicInVolume(std::string volName, std::string name) 
00329     {volume(volName).setLogic(name);}
00330 
00331 
00332   //! add child volume to the logic of the father volume  
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   //------------  LOGIC FUNCTIONS -----------------------
00344 
00345   //! returns the logic function Map
00346   virtual const std::map<std::string, ILogicFunction*> logicFunctionMap() const {return m_logicFunctionMap;}
00347 
00348   //! add a logic Function
00349   virtual void addLogicFunction(std::string name, ILogicFunction* func)
00350     {m_logicFunctionMap[name] = func;}
00351   
00352   //! gives the LogicalObject provided the logicalObject name
00353   virtual ILogicFunction& logicFunction(std::string name) {return *m_logicFunctionMap[name];}
00354   
00355   
00356   //! Check if the logic function has been defined 
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   //------------  GENERAL -----------------------------
00364   
00365   //! returns the trajectory engine
00366   virtual TrajectoryEngine& engine() {return *m_engine;}
00367 
00368   //!  The name of the setup
00369   virtual void setName(std::string name) {m_name = name;}
00370   virtual std::string name() const {return m_name;}  
00371 
00372   //! set setup verbosity 
00373   virtual void setVerbosity(int v){m_verbosity = v;}
00374   //! return setup verbosity 
00375   virtual int verbosity() const {return m_verbosity;}  
00376 
00377 
00378   //! Print information about the setup
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   // Navigation logics
00397   std::string m_logicName;
00398   std::map<std::string, ILogic*> m_logicMap;
00399 
00400   // Logic functions  
00401   std::map<std::string, ILogicFunction*> m_logicFunctionMap;
00402 
00403   // The Trajectory Engine
00404   TrajectoryEngine* m_engine;
00405 
00406   int m_verbosity;
00407 
00408   std::string m_logicalObjectName;
00409 
00410 };
00411 #endif
00412 

Generated on Mon Nov 23 08:01:44 2009 for MIPP(E907) by  doxygen 1.4.7