00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "G4tgrLineProcessor.hh"
00035
00036 #include "G4SystemOfUnits.hh"
00037 #include "G4tgrParameterMgr.hh"
00038 #include "G4tgrFileIn.hh"
00039 #include "G4tgrElementSimple.hh"
00040 #include "G4tgrElementFromIsotopes.hh"
00041 #include "G4tgrVolume.hh"
00042 #include "G4tgrVolumeDivision.hh"
00043 #include "G4tgrVolumeAssembly.hh"
00044 #include "G4tgrPlaceDivRep.hh"
00045 #include "G4tgrPlaceParameterisation.hh"
00046 #include "G4tgrVolumeMgr.hh"
00047 #include "G4tgrUtils.hh"
00048 #include "G4tgrMaterialFactory.hh"
00049 #include "G4tgrRotationMatrixFactory.hh"
00050 #include "G4tgrMessenger.hh"
00051
00052
00053
00054 G4tgrLineProcessor::G4tgrLineProcessor()
00055 {
00056 volmgr = G4tgrVolumeMgr::GetInstance();
00057 }
00058
00059
00060
00061 G4tgrLineProcessor::~G4tgrLineProcessor()
00062 {
00063 }
00064
00065
00066
00067 G4bool G4tgrLineProcessor::ProcessLine( const std::vector<G4String>& wl )
00068 {
00069 #ifdef G4VERBOSE
00070 if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00071 {
00072 G4tgrUtils::DumpVS(wl, "@@@ Processing input line");
00073 }
00074 #endif
00075
00076 G4String wl0 = wl[0];
00077 for( size_t ii = 0; ii < wl0.length(); ii++ )
00078 {
00079 wl0[ii] = toupper( wl0[ii] );
00080 }
00081
00082
00083 if( wl0 == ":P" )
00084 {
00085 G4tgrParameterMgr::GetInstance()->AddParameterNumber( wl );
00086
00087
00088 }
00089 else if( wl0 == ":PS" )
00090 {
00091 G4tgrParameterMgr::GetInstance()->AddParameterString( wl );
00092
00093
00094 }
00095 else if( wl0 == ":ISOT" )
00096 {
00097 G4tgrIsotope* isot = G4tgrMaterialFactory::GetInstance()
00098 ->AddIsotope( wl );
00099 volmgr->RegisterMe( isot );
00100
00101
00102 }
00103 else if( wl0 == ":ELEM" )
00104 {
00105 G4tgrElementSimple* elem = G4tgrMaterialFactory::GetInstance()
00106 ->AddElementSimple( wl );
00107 volmgr->RegisterMe( elem );
00108
00109
00110 }
00111 else if( wl0 == ":ELEM_FROM_ISOT" )
00112 {
00113
00114 G4tgrElementFromIsotopes* elem = G4tgrMaterialFactory::GetInstance()
00115 ->AddElementFromIsotopes( wl );
00116 volmgr->RegisterMe( elem );
00117
00118
00119 }
00120 else if( wl0 == ":MATE" )
00121 {
00122
00123 G4tgrMaterialSimple* mate = G4tgrMaterialFactory::GetInstance()
00124 ->AddMaterialSimple( wl );
00125 volmgr->RegisterMe( mate );
00126
00127
00128 }
00129 else if( (wl0 == ":MIXT") || (wl0 == ":MIXT_BY_WEIGHT") )
00130 {
00131 G4tgrMaterialMixture* mate = G4tgrMaterialFactory::GetInstance()
00132 ->AddMaterialMixture( wl, "MaterialMixtureByWeight" );
00133 volmgr->RegisterMe( mate );
00134
00135
00136 }
00137 else if( wl0 == ":MIXT_BY_NATOMS" )
00138 {
00139 G4tgrMaterialMixture* mate = G4tgrMaterialFactory::GetInstance()
00140 ->AddMaterialMixture(wl, "MaterialMixtureByNoAtoms");
00141 volmgr->RegisterMe( mate );
00142
00143
00144 }
00145 else if( wl0 == ":MIXT_BY_VOLUME" )
00146 {
00147 G4tgrMaterialMixture* mate = G4tgrMaterialFactory::GetInstance()
00148 ->AddMaterialMixture( wl, "MaterialMixtureByVolume" );
00149 volmgr->RegisterMe( mate );
00150
00151
00152
00153 }
00154 else if( wl0 == ":MATE_MEE" )
00155 {
00156 G4tgrMaterial* mate = G4tgrMaterialFactory::GetInstance()
00157 ->FindMaterial( G4tgrUtils::GetString( wl[1] ) );
00158 if( mate == 0 )
00159 {
00160 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found",
00161 FatalException, G4tgrUtils::GetString( wl[1] ) );
00162 return false;
00163 }
00164 mate->SetIonisationMeanExcitationEnergy( G4tgrUtils::GetDouble( wl[2] ) );
00165
00166
00167 }
00168 else if( wl0 == ":MATE_STATE" )
00169 {
00170 G4tgrMaterial* mate = G4tgrMaterialFactory::GetInstance()
00171 ->FindMaterial( G4tgrUtils::GetString( wl[1] ) );
00172 if( mate == 0 )
00173 {
00174 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found",
00175 FatalException, wl[1] );
00176 }
00177 mate->SetState( wl[2] );
00178
00179
00180 }
00181 else if( wl0 == ":MATE_TEMPERATURE" )
00182 {
00183 G4tgrMaterial* mate = G4tgrMaterialFactory::GetInstance()
00184 ->FindMaterial( G4tgrUtils::GetString( wl[1] ) );
00185 if( mate == 0 )
00186 {
00187 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found",
00188 FatalException, wl[1] );
00189 }
00190 mate->SetTemperature( G4tgrUtils::GetDouble( wl[2], kelvin ) );
00191
00192
00193 }
00194 else if( wl0 == ":MATE_PRESSURE" )
00195 {
00196 G4tgrMaterial* mate = G4tgrMaterialFactory::GetInstance()
00197 ->FindMaterial( G4tgrUtils::GetString( wl[1] ) );
00198 if( mate == 0 )
00199 {
00200 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found",
00201 FatalException, wl[1] );
00202 }
00203 mate->SetPressure( G4tgrUtils::GetDouble( wl[2], atmosphere ) );
00204
00205
00206 }
00207 else if( wl0 == ":SOLID" )
00208 {
00209 volmgr->CreateSolid( wl, 0 );
00210
00211
00212 }
00213 else if( wl0 == ":VOLU" )
00214 {
00215 G4tgrVolume* vol = new G4tgrVolume( wl );
00216 volmgr->RegisterMe( vol );
00217
00218
00219 }
00220 else if( wl0 == ":PLACE" )
00221 {
00222 G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
00223 G4tgrPlace* vpl = vol->AddPlace( wl );
00224 volmgr->RegisterMe( vpl );
00225
00226
00227 }
00228 else if( wl0 == ":PLACE_PARAM" )
00229 {
00230 G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
00231 G4tgrPlaceParameterisation* vpl = vol->AddPlaceParam( wl );
00232 volmgr->RegisterMe( vpl );
00233
00234
00235 }
00236 else if( (wl0 == ":DIV_NDIV") || (wl0 == ":DIV_WIDTH")
00237 || (wl0 == ":DIV_NDIV_WIDTH") )
00238 {
00239
00240 G4tgrVolumeDivision* vol = new G4tgrVolumeDivision( wl );
00241 volmgr->RegisterMe( vol );
00242
00243
00244 }
00245 else if( wl0 == ":REPL" )
00246 {
00247 G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
00248 G4tgrPlaceDivRep* vpl = vol->AddPlaceReplica( wl );
00249 volmgr->RegisterMe( vpl );
00250
00251
00252 }
00253 else if( wl0 == ":VOLU_ASSEMBLY" )
00254 {
00255 G4tgrVolumeAssembly* vol = new G4tgrVolumeAssembly( wl );
00256 volmgr->RegisterMe( vol );
00257
00258
00259 }
00260 else if( wl0 == ":PLACE_ASSEMBLY" )
00261 {
00262 G4tgrVolume* vol = FindVolume( G4tgrUtils::GetString( wl[1] ) );
00263 G4tgrPlace* vpl = vol->AddPlace( wl );
00264 volmgr->RegisterMe( vpl );
00265
00266
00267 }
00268 else if( wl0 == ":ROTM" )
00269 {
00270
00271
00272 G4tgrRotationMatrix* rm = G4tgrRotationMatrixFactory::GetInstance()
00273 ->AddRotMatrix( wl );
00274 volmgr->RegisterMe( rm );
00275
00276
00277 }
00278 else if( wl0 == ":VIS" )
00279 {
00280 std::vector<G4tgrVolume*> vols =
00281 volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
00282 for( size_t ii = 0; ii < vols.size(); ii++ )
00283 {
00284 vols[ii]->AddVisibility( wl );
00285 }
00286
00287
00288 }
00289 else if( (wl0 == ":COLOUR") || (wl0 == ":COLOR") )
00290 {
00291 std::vector<G4tgrVolume*> vols =
00292 volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
00293 for( size_t ii = 0; ii < vols.size(); ii++ )
00294 {
00295 vols[ii]->AddRGBColour( wl );
00296 }
00297
00298
00299 }
00300 else if( wl0 == ":CHECK_OVERLAPS" )
00301 {
00302 std::vector<G4tgrVolume*> vols =
00303 volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
00304 for( size_t ii = 0; ii < vols.size(); ii++ )
00305 {
00306 vols[ii]->AddCheckOverlaps( wl );
00307 }
00308
00309 }
00310 else
00311 {
00312 return 0;
00313 }
00314
00315 return 1;
00316 }
00317
00318
00319
00320 G4tgrVolume* G4tgrLineProcessor::FindVolume( const G4String& volname )
00321 {
00322 G4tgrVolume* vol = volmgr->FindVolume( volname, 1);
00323
00324 if( vol->GetType() == "VOLDivision" )
00325 {
00326 G4Exception("G4tgrLineProcessor::FindVolume()",
00327 "InvalidSetup", FatalException,
00328 "Using 'PLACE' for a volume created by a division !");
00329 }
00330
00331 return vol;
00332 }