Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: G4ITTransportationManager.cc 87061 2014-11-24 11:43:34Z gcosmo $ 26 // 27 // 27 /// \brief {Duplicated version of G4Transporta 28 /// \brief {Duplicated version of G4TransportationManager. 28 /// This class just contains the point 29 /// This class just contains the pointer to the navigator object of the 29 /// simulation.} 30 /// simulation.} 30 // 31 // 31 // History: 32 // History: 32 // ----------- 33 // ----------- 33 // 34 // 34 // ------------------------------------------- 35 // ------------------------------------------------------------------- 35 36 36 #include "G4ITTransportationManager.hh" 37 #include "G4ITTransportationManager.hh" 37 #include "G4TransportationManager.hh" 38 #include "G4TransportationManager.hh" 38 #include "G4ITNavigator.hh" 39 #include "G4ITNavigator.hh" 39 #include "G4ITSafetyHelper.hh" 40 #include "G4ITSafetyHelper.hh" 40 #include "G4PVPlacement.hh" 41 #include "G4PVPlacement.hh" 41 42 42 G4ThreadLocal G4ITTransportationManager* 43 G4ThreadLocal G4ITTransportationManager* 43 G4ITTransportationManager::fpInstance(nullptr) << 44 G4ITTransportationManager::fpInstance(0); 44 45 45 G4ITTransportationManager::G4ITTransportationM 46 G4ITTransportationManager::G4ITTransportationManager() 46 { 47 { 47 Initialize(); 48 Initialize(); 48 } 49 } 49 50 50 G4ITTransportationManager::~G4ITTransportation 51 G4ITTransportationManager::~G4ITTransportationManager() 51 { 52 { 52 ClearNavigators(); 53 ClearNavigators(); 53 delete fpSafetyHelper; << 54 if (fpSafetyHelper) delete fpSafetyHelper; 54 } 55 } 55 56 56 void G4ITTransportationManager::DeleteInstance 57 void G4ITTransportationManager::DeleteInstance() 57 { 58 { 58 if (fpInstance != nullptr) << 59 if (fpInstance) 59 { 60 { 60 delete fpInstance; 61 delete fpInstance; 61 fpInstance = nullptr; << 62 fpInstance = 0; 62 } 63 } 63 } 64 } 64 65 65 // ------------------------------------------- 66 // ---------------------------------------------------------------------------- 66 // ClearNavigators() 67 // ClearNavigators() 67 // 68 // 68 // Clear collection of navigators and delete a 69 // Clear collection of navigators and delete allocated objects. 69 // Called only by the class destructor. 70 // Called only by the class destructor. 70 // 71 // 71 void G4ITTransportationManager::ClearNavigator 72 void G4ITTransportationManager::ClearNavigators() 72 { 73 { 73 std::vector<G4ITNavigator*>::iterator pNav; 74 std::vector<G4ITNavigator*>::iterator pNav; 74 for (pNav = fNavigators.begin(); pNav != fNa 75 for (pNav = fNavigators.begin(); pNav != fNavigators.end(); pNav++) 75 { 76 { 76 delete *pNav; 77 delete *pNav; 77 } 78 } 78 fNavigators.clear(); 79 fNavigators.clear(); 79 fActiveNavigators.clear(); 80 fActiveNavigators.clear(); 80 fWorlds.clear(); 81 fWorlds.clear(); 81 } 82 } 82 83 83 void G4ITTransportationManager::Initialize() 84 void G4ITTransportationManager::Initialize() 84 { 85 { 85 // Create the navigator for tracking and act 86 // Create the navigator for tracking and activate it; add to collections 86 // 87 // 87 auto trackingNavigator = new G4ITNavigator( << 88 G4ITNavigator* trackingNavigator = new G4ITNavigator(); 88 trackingNavigator->Activate(true); 89 trackingNavigator->Activate(true); 89 G4Navigator* navForTracking = 90 G4Navigator* navForTracking = 90 G4TransportationManager::GetTransportati 91 G4TransportationManager::GetTransportationManager() 91 ->GetNavigatorForTracking(); 92 ->GetNavigatorForTracking(); 92 G4VPhysicalVolume* world = navForTracking->G 93 G4VPhysicalVolume* world = navForTracking->GetWorldVolume(); 93 trackingNavigator->SetWorldVolume(world); 94 trackingNavigator->SetWorldVolume(world); 94 fNavigators.push_back(trackingNavigator); 95 fNavigators.push_back(trackingNavigator); 95 fActiveNavigators.push_back(trackingNavigato 96 fActiveNavigators.push_back(trackingNavigator); 96 //fWorlds.push_back(world); // NULL register 97 //fWorlds.push_back(world); // NULL registered 97 98 98 size_t n_worlds = G4TransportationManager::G 99 size_t n_worlds = G4TransportationManager::GetTransportationManager() 99 ->GetNoWorlds(); 100 ->GetNoWorlds(); 100 auto it = << 101 std::vector<G4VPhysicalVolume*>::iterator it = 101 G4TransportationManager::GetTransportati 102 G4TransportationManager::GetTransportationManager()->GetWorldsIterator(); 102 103 103 for (size_t i = 0; i < n_worlds; i++, it++) 104 for (size_t i = 0; i < n_worlds; i++, it++) 104 { 105 { 105 fWorlds.push_back(*it); 106 fWorlds.push_back(*it); 106 } 107 } 107 fpSafetyHelper = new G4ITSafetyHelper(); 108 fpSafetyHelper = new G4ITSafetyHelper(); 108 } 109 } 109 110 110 G4ITTransportationManager* G4ITTransportationM 111 G4ITTransportationManager* G4ITTransportationManager::GetTransportationManager() 111 { 112 { 112 if (fpInstance == nullptr) fpInstance = new << 113 if (fpInstance == 0) fpInstance = new G4ITTransportationManager; 113 return fpInstance; 114 return fpInstance; 114 } 115 } 115 116 116 // ------------------------------------------- 117 // ---------------------------------------------------------------------------- 117 // GetParallelWorld() 118 // GetParallelWorld() 118 // 119 // 119 // Provided the name of a world volume, return 120 // Provided the name of a world volume, returns the associated world pointer. 120 // If not existing, create (allocate) and regi 121 // If not existing, create (allocate) and register it in the collection. 121 // 122 // 122 G4VPhysicalVolume* 123 G4VPhysicalVolume* 123 G4ITTransportationManager::GetParallelWorld(co 124 G4ITTransportationManager::GetParallelWorld(const G4String& worldName) 124 { 125 { 125 G4VPhysicalVolume* wPV = IsWorldExisting(wor 126 G4VPhysicalVolume* wPV = IsWorldExisting(worldName); 126 if (wPV == nullptr) << 127 if (!wPV) 127 { 128 { 128 wPV = GetNavigatorForTracking()->GetWorldV 129 wPV = GetNavigatorForTracking()->GetWorldVolume(); 129 G4LogicalVolume* wLV = wPV->GetLogicalVolu 130 G4LogicalVolume* wLV = wPV->GetLogicalVolume(); 130 wLV = new G4LogicalVolume(wLV->GetSolid(), << 131 wLV = new G4LogicalVolume(wLV->GetSolid(), 0, worldName); 131 wPV = new G4PVPlacement(wPV->GetRotation() 132 wPV = new G4PVPlacement(wPV->GetRotation(), wPV->GetTranslation(), wLV, 132 worldName, nullptr << 133 worldName, 0, false, 0); 133 RegisterWorld(wPV); 134 RegisterWorld(wPV); 134 } 135 } 135 return wPV; 136 return wPV; 136 } 137 } 137 138 138 // ------------------------------------------- 139 // ---------------------------------------------------------------------------- 139 // GetNavigator() 140 // GetNavigator() 140 // 141 // 141 // Provided the name of a world volume, return 142 // Provided the name of a world volume, returns the associated navigator. 142 // If not existing, create it and register it 143 // If not existing, create it and register it in the collection, throw an 143 // exception if the associated parallel world 144 // exception if the associated parallel world does not exist. 144 // 145 // 145 G4ITNavigator* G4ITTransportationManager::GetN 146 G4ITNavigator* G4ITTransportationManager::GetNavigator(const G4String& worldName) 146 { 147 { 147 // If already existing, return the stored po 148 // If already existing, return the stored pointer to the navigator 148 // 149 // 149 std::vector<G4ITNavigator*>::iterator pNav; 150 std::vector<G4ITNavigator*>::iterator pNav; 150 for (pNav = fNavigators.begin(); pNav != fNa 151 for (pNav = fNavigators.begin(); pNav != fNavigators.end(); pNav++) 151 { 152 { 152 if ((*pNav)->GetWorldVolume()->GetName() = 153 if ((*pNav)->GetWorldVolume()->GetName() == worldName) 153 { 154 { 154 return *pNav; 155 return *pNav; 155 } 156 } 156 } 157 } 157 158 158 // Check if world of that name already exist 159 // Check if world of that name already exists, 159 // create a navigator and register it 160 // create a navigator and register it 160 // 161 // 161 G4ITNavigator* aNavigator = nullptr; << 162 G4ITNavigator* aNavigator = 0; 162 G4VPhysicalVolume* aWorld = IsWorldExisting( 163 G4VPhysicalVolume* aWorld = IsWorldExisting(worldName); 163 if (aWorld != nullptr) << 164 if (aWorld) 164 { 165 { 165 aNavigator = new G4ITNavigator(); 166 aNavigator = new G4ITNavigator(); 166 aNavigator->SetWorldVolume(aWorld); 167 aNavigator->SetWorldVolume(aWorld); 167 fNavigators.push_back(aNavigator); 168 fNavigators.push_back(aNavigator); 168 } 169 } 169 else 170 else 170 { 171 { 171 G4String message = "World volume with name 172 G4String message = "World volume with name -" 172 + worldName 173 + worldName 173 + "- does not exist. Create it first b 174 + "- does not exist. Create it first by GetParallelWorld() method!"; 174 G4Exception("G4ITTransportationManager::Ge 175 G4Exception("G4ITTransportationManager::GetNavigator(name)", "GeomNav0002", 175 FatalException, message); 176 FatalException, message); 176 } 177 } 177 178 178 return aNavigator; 179 return aNavigator; 179 } 180 } 180 181 181 // ------------------------------------------- 182 // ---------------------------------------------------------------------------- 182 // GetNavigator() 183 // GetNavigator() 183 // 184 // 184 // Provided a pointer to a world volume, retur 185 // Provided a pointer to a world volume, returns the associated navigator. 185 // Create it in case not existing and add it t 186 // Create it in case not existing and add it to the collection. 186 // If world volume not existing, issue an exce 187 // If world volume not existing, issue an exception. 187 // 188 // 188 G4ITNavigator* G4ITTransportationManager::GetN 189 G4ITNavigator* G4ITTransportationManager::GetNavigator(G4VPhysicalVolume* aWorld) 189 { 190 { 190 std::vector<G4ITNavigator*>::iterator pNav; 191 std::vector<G4ITNavigator*>::iterator pNav; 191 for (pNav = fNavigators.begin(); pNav != fNa 192 for (pNav = fNavigators.begin(); pNav != fNavigators.end(); pNav++) 192 { 193 { 193 if ((*pNav)->GetWorldVolume() == aWorld) 194 if ((*pNav)->GetWorldVolume() == aWorld) 194 { 195 { 195 return *pNav; 196 return *pNav; 196 } 197 } 197 } 198 } 198 G4ITNavigator* aNavigator = nullptr; << 199 G4ITNavigator* aNavigator = 0; 199 auto pWorld = std::find(fWorlds.begin(), << 200 std::vector<G4VPhysicalVolume*>::iterator pWorld = std::find(fWorlds.begin(), 200 201 fWorlds.end(), 201 202 aWorld); 202 if (pWorld != fWorlds.end()) 203 if (pWorld != fWorlds.end()) 203 { 204 { 204 aNavigator = new G4ITNavigator(); 205 aNavigator = new G4ITNavigator(); 205 aNavigator->SetWorldVolume(aWorld); 206 aNavigator->SetWorldVolume(aWorld); 206 fNavigators.push_back(aNavigator); 207 fNavigators.push_back(aNavigator); 207 } 208 } 208 else 209 else 209 { 210 { 210 G4String message = "World volume with name 211 G4String message = "World volume with name -" 211 + aWorld->GetName() 212 + aWorld->GetName() 212 + "- does not exist. Create it first b 213 + "- does not exist. Create it first by GetParallelWorld() method!"; 213 G4Exception("G4ITTransportationManager::Ge 214 G4Exception("G4ITTransportationManager::GetNavigator(pointer)", 214 "GeomNav0002", FatalException, 215 "GeomNav0002", FatalException, message); 215 } 216 } 216 217 217 return aNavigator; 218 return aNavigator; 218 } 219 } 219 220 220 // ------------------------------------------- 221 // ---------------------------------------------------------------------------- 221 // DeRegisterNavigator() 222 // DeRegisterNavigator() 222 // 223 // 223 // Provided a pointer to an already allocated 224 // Provided a pointer to an already allocated navigator object, removes the 224 // associated entry in the navigators collecti 225 // associated entry in the navigators collection (remove pair) but does not 225 // delete the actual pointed object, which is 226 // delete the actual pointed object, which is still owned by the caller. 226 // The navigator for tracking -cannot- be dere 227 // The navigator for tracking -cannot- be deregistered. 227 // 228 // 228 void G4ITTransportationManager::DeRegisterNavi 229 void G4ITTransportationManager::DeRegisterNavigator(G4ITNavigator* aNavigator) 229 { 230 { 230 if (aNavigator == fNavigators[0]) 231 if (aNavigator == fNavigators[0]) 231 { 232 { 232 G4Exception("G4ITTransportationManager::De 233 G4Exception("G4ITTransportationManager::DeRegisterNavigator()", 233 "GeomNav0003", FatalException, 234 "GeomNav0003", FatalException, 234 "The navigator for tracking CA 235 "The navigator for tracking CANNOT be deregistered!"); 235 } 236 } 236 auto pNav = std::find(fNavigators.begin(), << 237 std::vector<G4ITNavigator*>::iterator pNav = std::find(fNavigators.begin(), 237 238 fNavigators.end(), 238 239 aNavigator); 239 if (pNav != fNavigators.end()) 240 if (pNav != fNavigators.end()) 240 { 241 { 241 // Deregister associated world volume 242 // Deregister associated world volume 242 // 243 // 243 DeRegisterWorld((*pNav)->GetWorldVolume()) 244 DeRegisterWorld((*pNav)->GetWorldVolume()); 244 245 245 // Deregister the navigator 246 // Deregister the navigator 246 // 247 // 247 fNavigators.erase(pNav); 248 fNavigators.erase(pNav); 248 } 249 } 249 else 250 else 250 { 251 { 251 G4String message = "Navigator for volume - 252 G4String message = "Navigator for volume -" 252 + aNavigator->GetWorldVolume()->GetNam 253 + aNavigator->GetWorldVolume()->GetName() + "- not found in memory!"; 253 G4Exception("G4ITTransportationManager::De 254 G4Exception("G4ITTransportationManager::DeRegisterNavigator()", 254 "GeomNav1002", JustWarning, me 255 "GeomNav1002", JustWarning, message); 255 } 256 } 256 } 257 } 257 258 258 // ------------------------------------------- 259 // ---------------------------------------------------------------------------- 259 // ActivateNavigator() 260 // ActivateNavigator() 260 // 261 // 261 // Provided a pointer to an already allocated 262 // Provided a pointer to an already allocated navigator object, set to 'true' 262 // the associated activation flag for the navi 263 // the associated activation flag for the navigator in the collection. 263 // If the provided navigator is not already re 264 // If the provided navigator is not already registered, issue a warning 264 // Return the index of the activated navigator 265 // Return the index of the activated navigator. This index should be used for 265 // ComputeStep() method of G4PathFinder. 266 // ComputeStep() method of G4PathFinder. 266 // 267 // 267 G4int G4ITTransportationManager::ActivateNavig 268 G4int G4ITTransportationManager::ActivateNavigator(G4ITNavigator* aNavigator) 268 { 269 { 269 auto pNav = std::find(fNavigators.begin(), << 270 std::vector<G4ITNavigator*>::iterator pNav = std::find(fNavigators.begin(), 270 271 fNavigators.end(), 271 272 aNavigator); 272 if (pNav == fNavigators.end()) 273 if (pNav == fNavigators.end()) 273 { 274 { 274 G4String message = "Navigator for volume - 275 G4String message = "Navigator for volume -" 275 + aNavigator->GetWorldVolume()->GetNam 276 + aNavigator->GetWorldVolume()->GetName() + "- not found in memory!"; 276 G4Exception("G4ITTransportationManager::Ac 277 G4Exception("G4ITTransportationManager::ActivateNavigator()", "GeomNav1002", 277 JustWarning, message); 278 JustWarning, message); 278 return -1; 279 return -1; 279 } 280 } 280 281 281 aNavigator->Activate(true); 282 aNavigator->Activate(true); 282 G4int id = 0; 283 G4int id = 0; 283 std::vector<G4ITNavigator*>::iterator pActiv 284 std::vector<G4ITNavigator*>::iterator pActiveNav; 284 for (pActiveNav = fActiveNavigators.begin(); 285 for (pActiveNav = fActiveNavigators.begin(); 285 pActiveNav != fActiveNavigators.end(); p 286 pActiveNav != fActiveNavigators.end(); pActiveNav++) 286 { 287 { 287 if (*pActiveNav == aNavigator) 288 if (*pActiveNav == aNavigator) 288 { 289 { 289 return id; 290 return id; 290 } 291 } 291 id++; 292 id++; 292 } 293 } 293 294 294 fActiveNavigators.push_back(aNavigator); 295 fActiveNavigators.push_back(aNavigator); 295 return id; 296 return id; 296 } 297 } 297 298 298 // ------------------------------------------- 299 // ---------------------------------------------------------------------------- 299 // DeActivateNavigator() 300 // DeActivateNavigator() 300 // 301 // 301 // Provided a pointer to an already allocated 302 // Provided a pointer to an already allocated navigator object, set to 'false' 302 // the associated activation flag in the navig 303 // the associated activation flag in the navigators collection. 303 // If the provided navigator is not already re 304 // If the provided navigator is not already registered, issue a warning. 304 // 305 // 305 void G4ITTransportationManager::DeActivateNavi 306 void G4ITTransportationManager::DeActivateNavigator(G4ITNavigator* aNavigator) 306 { 307 { 307 auto pNav = std::find(fNavigators.begin(), << 308 std::vector<G4ITNavigator*>::iterator pNav = std::find(fNavigators.begin(), 308 309 fNavigators.end(), 309 310 aNavigator); 310 if (pNav != fNavigators.end()) 311 if (pNav != fNavigators.end()) 311 { 312 { 312 (*pNav)->Activate(false); 313 (*pNav)->Activate(false); 313 } 314 } 314 else 315 else 315 { 316 { 316 G4String message = "Navigator for volume - 317 G4String message = "Navigator for volume -" 317 + aNavigator->GetWorldVolume()->GetNam 318 + aNavigator->GetWorldVolume()->GetName() + "- not found in memory!"; 318 G4Exception("G4ITTransportationManager::De 319 G4Exception("G4ITTransportationManager::DeActivateNavigator()", 319 "GeomNav1002", JustWarning, me 320 "GeomNav1002", JustWarning, message); 320 } 321 } 321 322 322 auto pActiveNav = std::find( << 323 std::vector<G4ITNavigator*>::iterator pActiveNav = std::find( 323 fActiveNavigators.begin(), fActiveNaviga 324 fActiveNavigators.begin(), fActiveNavigators.end(), aNavigator); 324 if (pActiveNav != fActiveNavigators.end()) 325 if (pActiveNav != fActiveNavigators.end()) 325 { 326 { 326 fActiveNavigators.erase(pActiveNav); 327 fActiveNavigators.erase(pActiveNav); 327 } 328 } 328 } 329 } 329 330 330 // ------------------------------------------- 331 // ---------------------------------------------------------------------------- 331 // InactivateAll() 332 // InactivateAll() 332 // 333 // 333 // Inactivate all the navigators except for th 334 // Inactivate all the navigators except for the tracking one, and clear the 334 // store of active navigators. 335 // store of active navigators. 335 // 336 // 336 void G4ITTransportationManager::InactivateAll( 337 void G4ITTransportationManager::InactivateAll() 337 { 338 { 338 std::vector<G4ITNavigator*>::iterator pNav; 339 std::vector<G4ITNavigator*>::iterator pNav; 339 for (pNav = fActiveNavigators.begin(); pNav 340 for (pNav = fActiveNavigators.begin(); pNav != fActiveNavigators.end(); 340 pNav++) 341 pNav++) 341 { 342 { 342 (*pNav)->Activate(false); 343 (*pNav)->Activate(false); 343 } 344 } 344 fActiveNavigators.clear(); 345 fActiveNavigators.clear(); 345 346 346 // Restore status for the navigator for trac 347 // Restore status for the navigator for tracking 347 // 348 // 348 fNavigators[0]->Activate(true); 349 fNavigators[0]->Activate(true); 349 fActiveNavigators.push_back(fNavigators[0]); 350 fActiveNavigators.push_back(fNavigators[0]); 350 } 351 } 351 352 352 // ------------------------------------------- 353 // ---------------------------------------------------------------------------- 353 // IsWorldExisting() 354 // IsWorldExisting() 354 // 355 // 355 // Verify existance or not of an istance of th 356 // Verify existance or not of an istance of the world volume with 356 // same name in the collection. Return the wor 357 // same name in the collection. Return the world pointer if existing. 357 // 358 // 358 G4VPhysicalVolume* 359 G4VPhysicalVolume* 359 G4ITTransportationManager::IsWorldExisting(con 360 G4ITTransportationManager::IsWorldExisting(const G4String& name) 360 { 361 { 361 auto pWorld = fWorlds.begin(); << 362 std::vector<G4VPhysicalVolume*>::iterator pWorld = fWorlds.begin(); 362 if (*pWorld == 0) 363 if (*pWorld == 0) 363 { 364 { 364 *pWorld = fNavigators[0]->GetWorldVolume() 365 *pWorld = fNavigators[0]->GetWorldVolume(); 365 } 366 } 366 367 367 for (pWorld = fWorlds.begin(); pWorld != fWo 368 for (pWorld = fWorlds.begin(); pWorld != fWorlds.end(); pWorld++) 368 { 369 { 369 if ((*pWorld)->GetName() == name) 370 if ((*pWorld)->GetName() == name) 370 { 371 { 371 return *pWorld; 372 return *pWorld; 372 } 373 } 373 } 374 } 374 return nullptr; << 375 return 0; 375 } 376 } 376 377 377 // ------------------------------------------- 378 // ---------------------------------------------------------------------------- 378 // RegisterWorld() 379 // RegisterWorld() 379 // 380 // 380 // Provided a pointer to an already allocated 381 // Provided a pointer to an already allocated world object, check and add the 381 // associated entry in the worlds collection. 382 // associated entry in the worlds collection. Return 'true' if registration 382 // succeeds and the new entry is created. 383 // succeeds and the new entry is created. 383 // 384 // 384 G4bool G4ITTransportationManager::RegisterWorl 385 G4bool G4ITTransportationManager::RegisterWorld(G4VPhysicalVolume* aWorld) 385 { 386 { 386 G4bool done = false; 387 G4bool done = false; 387 388 388 auto pWorld = std::find(fWorlds.begin(), << 389 std::vector<G4VPhysicalVolume*>::iterator pWorld = std::find(fWorlds.begin(), 389 390 fWorlds.end(), 390 391 aWorld); 391 if (pWorld == fWorlds.end()) 392 if (pWorld == fWorlds.end()) 392 { 393 { 393 fWorlds.push_back(aWorld); 394 fWorlds.push_back(aWorld); 394 done = true; 395 done = true; 395 } 396 } 396 return done; 397 return done; 397 } 398 } 398 399 399 // ------------------------------------------- 400 // ---------------------------------------------------------------------------- 400 // DeRegisterWorld() 401 // DeRegisterWorld() 401 // 402 // 402 // Provided a pointer to an already allocated 403 // Provided a pointer to an already allocated world object, removes the 403 // associated entry in the worlds collection b 404 // associated entry in the worlds collection but does not delete the actual 404 // pointed object, which is still owned by the 405 // pointed object, which is still owned by the caller. 405 // 406 // 406 void G4ITTransportationManager::DeRegisterWorl 407 void G4ITTransportationManager::DeRegisterWorld(G4VPhysicalVolume* aWorld) 407 { 408 { 408 auto pWorld = std::find(fWorlds.begin(), << 409 std::vector<G4VPhysicalVolume*>::iterator pWorld = std::find(fWorlds.begin(), 409 410 fWorlds.end(), 410 411 aWorld); 411 if (pWorld != fWorlds.end()) 412 if (pWorld != fWorlds.end()) 412 { 413 { 413 fWorlds.erase(pWorld); 414 fWorlds.erase(pWorld); 414 } 415 } 415 else 416 else 416 { 417 { 417 G4String message = "World volume -" + aWor 418 G4String message = "World volume -" + aWorld->GetName() 418 + "- not found in memor 419 + "- not found in memory!"; 419 G4Exception("G4ITTransportationManager::De 420 G4Exception("G4ITTransportationManager::DeRegisterWorld()", "GeomNav1002", 420 JustWarning, message); 421 JustWarning, message); 421 } 422 } 422 } 423 } 423 424