33 #include "G4GeometryManager.hh"
34 #include "G4LogicalVolume.hh"
36 #include "G4AutoLock.hh"
40 G4Mutex mapMutex = G4MUTEX_INITIALIZER;
57 : std::
vector<G4VPhysicalVolume*>()
69 G4VPhysicalVolume::Clean();
80 if (G4GeometryManager::IsGeometryClosed())
82 G4cout <<
"WARNING - Attempt to delete the physical volume store"
83 <<
" while geometry closed !" << G4endl;
96 #ifdef G4GEOMETRY_VOXELDEBUG
97 G4cout <<
"Deleting Physical Volumes ... ";
100 for(
auto pos=store->cbegin();
pos!=store->cend(); ++
pos)
106 #ifdef G4GEOMETRY_VOXELDEBUG
107 if (store->size() < i-1)
108 { G4cout <<
"No volumes deleted. Already deleted by user ?" << G4endl; }
110 { G4cout << i-1 <<
" volumes deleted !" << G4endl; }
134 G4AutoLock l(&mapMutex);
139 const G4String& vol_name = (*pos)->GetName();
140 auto it =
bmap.find(vol_name);
143 it->second.push_back(*
pos);
147 std::vector<G4VPhysicalVolume*> vol_vec { *
pos };
148 bmap.insert(std::make_pair(vol_name, vol_vec));
162 store->push_back(pVolume);
163 const G4String& vol_name = pVolume->GetName();
164 auto it = store->
bmap.find(vol_name);
165 if (
it != store->
bmap.cend())
167 it->second.push_back(pVolume);
171 std::vector<G4VPhysicalVolume*> vol_vec { pVolume };
172 store->
bmap.insert(std::make_pair(vol_name, vol_vec));
189 G4LogicalVolume* motherLogical = pVolume->GetMotherLogical();
190 if (motherLogical !=
nullptr) { motherLogical->RemoveDaughter(pVolume); }
191 for (
auto i=store->cbegin(); i!=store->cend(); ++i)
199 const G4String& vol_name = pVolume->GetName();
200 auto it = store->
bmap.find(vol_name);
201 if (
it != store->
bmap.cend())
203 if (
it->second.size() > 1)
205 for (
auto i=
it->second.cbegin(); i!=
it->second.cend(); ++i)
228 G4bool reverseSearch)
const
232 auto pos = store->
bmap.find(name);
235 if ((verbose) && (
pos->second.size()>1))
237 std::ostringstream message;
238 message <<
"There exists more than ONE physical volume in store named: "
239 << name <<
"!" << G4endl
240 <<
"Returning the first found.";
241 G4Exception(
"G4PhysicalVolumeStore::GetVolume()",
242 "GeomMgt1001", JustWarning, message);
246 return pos->second[
pos->second.size()-1];
250 return pos->second[0];
255 std::ostringstream message;
256 message <<
"Volume NOT found in store !" << G4endl
257 <<
" Volume " << name <<
" NOT found in store !" << G4endl
258 <<
" Returning NULL pointer.";
259 G4Exception(
"G4PhysicalVolumeStore::GetVolume()",
260 "GeomMgt1001", JustWarning, message);