NMPB08 Shared Libraries
|
00001 #ifndef _RAILWAYEMISSION_INCLUDED_ 00002 00003 #include "RailwayEmissionNMPB08.h" 00004 #include "RailwayDatabase.h" 00005 #include "math.h" 00006 #include <vector> 00007 00008 // on Unix-like systems there is no way to hide local classes ant to prevent them from 00009 // being replaced by other classes with similar names in other libraries. The use of 00010 // unusual names may help preventing name clashes. 00011 00012 #ifndef _WIN32 00013 #define RailwaySourceModel _Local_RWEMN8_RailwaySourceModel_ 00014 #endif 00015 00016 extern RailwayDatabase _shared_db ; 00017 00022 class RailwaySourceModel 00023 { 00024 public: 00025 00029 RailwaySourceModel (void) 00030 : db(), traffic(), emission(), options(), maxInteractions(), nbInteractions(), difInteraction() 00031 { 00032 db = &_shared_db ; 00033 options = 0 ; 00034 createEmission() ; 00035 createTraffic() ; 00036 } 00037 00041 virtual ~RailwaySourceModel (void) 00042 { 00043 deleteEmission() ; 00044 deleteTraffic() ; 00045 } 00046 00052 bool CreateTraffic (double hours) 00053 { 00054 if (traffic.nbComponents > 0) ClearTraffic() ; 00055 traffic.nbHours = hours ; 00056 return true ; 00057 } 00058 00062 bool ClearTraffic (void) 00063 { 00064 for (unsigned int i = 0 ; i < traffic.nbComponents ; i++) free (traffic.component[i].id) ; 00065 traffic.nbComponents = 0 ; 00066 return true ; 00067 } 00068 00072 bool SetRailCorrection (NMPB_RailCorrectionType corr) 00073 { 00074 traffic.railCorrection = corr ; 00075 return true ; 00076 } 00077 00081 NMPB_RailCorrectionType GetRailCorrection (void) 00082 { 00083 return traffic.railCorrection ; 00084 } 00085 00095 bool AddTraffic (const char* name, double nb, double speed); 00096 00104 bool SetEmissionAngles (double sin_h, double sin_v) 00105 { 00106 int err = 0 ; 00107 if (fabs(sin_h) <= 1.0) emission.sin_h = sin_h ; else err++ ; 00108 if (fabs(sin_v) <= 1.0) emission.sin_v = sin_v ; else err++ ; 00109 return (err == 0) ; 00110 } ; 00111 00116 class InvalidHeight { } ; 00117 00130 RailwayEmission const* GetEmission (ScreenBodyInteraction* screenBodyInteraction) ; 00131 00138 RailwayTraffic const* GetTraffic (void) 00139 { 00140 return &traffic ; 00141 } 00142 00152 unsigned int SetOptions (unsigned int option, bool on_off) 00153 { 00154 if (on_off) 00155 options |= option ; 00156 else 00157 options &= ~option ; 00158 return options ; 00159 } 00160 00168 unsigned int GetOptions (unsigned int option) 00169 { 00170 return options & option ; 00171 } 00172 00173 private : 00174 00179 void createEmission (void) ; 00180 00184 void deleteEmission (void) ; 00185 00189 void createTraffic (void) ; 00190 00194 void deleteTraffic (void) ; 00195 00199 void prepareEmission (void) ; 00203 void addTraffic (RailwayTraffic const& traffic) ; 00207 void addTrain (RailwayTrain const& train, double speed, double flow) ; 00211 void addUnit (RailwayUnit const& unit, double speed, double flow) ; 00215 void addSource (RailwaySource const& source, double speed, double flow) ; 00220 void finaliseEmission (void) ; 00221 00225 struct SourceDistribution 00226 { 00227 int index ; 00228 double weight ; 00229 } ; 00238 int getSourceDistribution (RailwaySource const& source, std::vector<SourceDistribution>& distrib) ; 00239 00243 double getHorizontalDirectivity (int model, double sin_h, double freq) ; 00247 double getVerticalDirectivity (int model, double sin_v, double freq) ; 00248 00252 double getDiffraction (double delta, double freq) ; 00253 00260 void prepareScreenBodyCorrection (ScreenBodyInteraction*) ; 00261 00262 typedef std::vector<std::vector<std::vector<double> > > DifInteraction ; 00263 00264 RailwayDatabase* db ; 00265 RailwayTraffic traffic ; 00266 RailwayEmission emission ; 00267 unsigned int options ; 00268 int maxInteractions ; 00269 int nbInteractions ; 00270 DifInteraction difInteraction ; 00271 } ; 00272 00273 #endif 00274