33 #include "G4GeometryManager.hh"
35 #include "G4AutoLock.hh"
39 G4Mutex mapMutex = G4MUTEX_INITIALIZER;
56 : std::
vector<G4LogicalVolume*>()
68 G4LogicalVolume::Clean();
79 if (G4GeometryManager::IsGeometryClosed())
81 G4cout <<
"WARNING - Attempt to delete the logical volume store"
82 <<
" while geometry closed !" << G4endl;
94 #ifdef G4GEOMETRY_VOXELDEBUG
95 G4cout <<
"Deleting Logical Volumes ... ";
98 for(
auto pos=store->cbegin();
pos!=store->cend(); ++
pos)
101 if (*
pos !=
nullptr) { (*pos)->Lock();
delete *
pos; }
105 #ifdef G4GEOMETRY_VOXELDEBUG
106 if (store->size() < i-1)
107 { G4cout <<
"No volumes deleted. Already deleted by user ?" << G4endl; }
109 { G4cout << i-1 <<
" volumes deleted !" << G4endl; }
133 G4AutoLock l(&mapMutex);
138 const G4String& vol_name = (*pos)->GetName();
139 auto it =
bmap.find(vol_name);
142 it->second.push_back(*
pos);
146 std::vector<G4LogicalVolume*> vol_vec { *
pos };
147 bmap.insert(std::make_pair(vol_name, vol_vec));
161 store->push_back(pVolume);
162 const G4String& vol_name = pVolume->GetName();
163 auto it = store->
bmap.find(vol_name);
164 if (
it != store->
bmap.cend())
166 it->second.push_back(pVolume);
170 std::vector<G4LogicalVolume*> vol_vec { pVolume };
171 store->
bmap.insert(std::make_pair(vol_name, vol_vec));
187 for (
auto i=store->cbegin(); i!=store->cend(); ++i)
195 const G4String& vol_name = pVolume->GetName();
196 auto it = store->
bmap.find(vol_name);
197 if (
it != store->
bmap.cend())
199 if (
it->second.size() > 1)
201 for (
auto i=
it->second.cbegin(); i!=
it->second.cend(); ++i)
224 G4bool reverseSearch)
const
228 auto pos = store->
bmap.find(name);
231 if ((verbose) && (
pos->second.size()>1))
233 std::ostringstream message;
234 message <<
"There exists more than ONE logical volume in store named: "
235 << name <<
"!" << G4endl
236 <<
"Returning the first found.";
237 G4Exception(
"G4LogicalVolumeStore::GetVolume()",
238 "GeomMgt1001", JustWarning, message);
242 return pos->second[
pos->second.size()-1];
246 return pos->second[0];
251 std::ostringstream message;
252 message <<
"Volume NOT found in store !" << G4endl
253 <<
" Volume " << name <<
" NOT found in store !" << G4endl
254 <<
" Returning NULL pointer.";
255 G4Exception(
"G4LogicalVolumeStore::GetVolume()",
256 "GeomMgt1001", JustWarning, message);