G4PhysicalVolumeStore Class Reference

#include <G4PhysicalVolumeStore.hh>


Public Member Functions

G4VPhysicalVolumeGetVolume (const G4String &name, G4bool verbose=true) const
virtual ~G4PhysicalVolumeStore ()

Static Public Member Functions

static void Register (G4VPhysicalVolume *pSolid)
static void DeRegister (G4VPhysicalVolume *pSolid)
static G4PhysicalVolumeStoreGetInstance ()
static void SetNotifier (G4VStoreNotifier *pNotifier)
static void Clean ()

Protected Member Functions

 G4PhysicalVolumeStore ()


Detailed Description

Definition at line 62 of file G4PhysicalVolumeStore.hh.


Constructor & Destructor Documentation

G4PhysicalVolumeStore::~G4PhysicalVolumeStore (  )  [virtual]

Definition at line 65 of file G4PhysicalVolumeStore.cc.

References Clean().

00066 {
00067   Clean();
00068 }

G4PhysicalVolumeStore::G4PhysicalVolumeStore (  )  [protected]

Definition at line 55 of file G4PhysicalVolumeStore.cc.

00056   : std::vector<G4VPhysicalVolume*>()
00057 {
00058   reserve(100);
00059 }


Member Function Documentation

void G4PhysicalVolumeStore::Clean (  )  [static]

Definition at line 74 of file G4PhysicalVolumeStore.cc.

References G4cout, G4endl, GetInstance(), and G4GeometryManager::GetInstance().

Referenced by G4GDMLMessenger::SetNewValue(), and ~G4PhysicalVolumeStore().

00075 {
00076   // Do nothing if geometry is closed
00077   //
00078   if (G4GeometryManager::GetInstance()->IsGeometryClosed())
00079   {
00080     G4cout << "WARNING - Attempt to delete the physical volume store"
00081            << " while geometry closed !" << G4endl;
00082     return;
00083   }
00084 
00085   // Locks store for deletion of volumes. De-registration will be
00086   // performed at this stage. G4VPhysicalVolumes will not de-register
00087   // themselves.
00088   //
00089   locked = true;
00090 
00091   size_t i=0;
00092   G4PhysicalVolumeStore* store = GetInstance();
00093   std::vector<G4VPhysicalVolume*>::iterator pos;
00094 
00095 #ifdef G4GEOMETRY_VOXELDEBUG
00096   G4cout << "Deleting Physical Volumes ... ";
00097 #endif
00098 
00099   for(pos=store->begin(); pos!=store->end(); pos++)
00100   {
00101     if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
00102     if (*pos) { delete *pos; }
00103     i++;
00104   }
00105 
00106 #ifdef G4GEOMETRY_VOXELDEBUG
00107   if (store->size() < i-1)
00108     { G4cout << "No volumes deleted. Already deleted by user ?" << G4endl; }
00109   else
00110     { G4cout << i-1 << " volumes deleted !" << G4endl; }
00111 #endif
00112 
00113   locked = false;
00114   store->clear();
00115 }

void G4PhysicalVolumeStore::DeRegister ( G4VPhysicalVolume pSolid  )  [static]

Definition at line 142 of file G4PhysicalVolumeStore.cc.

References GetInstance(), G4VPhysicalVolume::GetMotherLogical(), and G4LogicalVolume::RemoveDaughter().

Referenced by G4VPhysicalVolume::~G4VPhysicalVolume().

00143 {
00144   if (!locked)    // Do not de-register if locked !
00145   {
00146     if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
00147     G4LogicalVolume* motherLogical = pVolume->GetMotherLogical();
00148     if (motherLogical) { motherLogical->RemoveDaughter(pVolume); }
00149     for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
00150     {
00151       if (**i==*pVolume)
00152       {
00153         GetInstance()->erase(i);
00154         break;
00155       }
00156     }
00157   }
00158 }

G4PhysicalVolumeStore * G4PhysicalVolumeStore::GetInstance (  )  [static]

Definition at line 187 of file G4PhysicalVolumeStore.cc.

Referenced by G4AdjointCrossSurfChecker::AddanExtSurfaceOfAvolume(), G4AdjointCrossSurfChecker::AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume(), Clean(), G4SPSPosDistribution::ConfineSourceToVolume(), G4AdjointPosOnPhysVolGenerator::DefinePhysicalVolume(), DeRegister(), G4GDMLReadStructure::GetPhysvol(), G4tgbGeometryDumper::GetTopPhysVol(), GetVolume(), Register(), SetNotifier(), G4RegionStore::SetWorldVolume(), and G4GDMLRead::StripNames().

00188 {
00189   static G4PhysicalVolumeStore worldStore;
00190   if (!fgInstance)
00191   {
00192     fgInstance = &worldStore;
00193   }
00194   return fgInstance;
00195 }

G4VPhysicalVolume * G4PhysicalVolumeStore::GetVolume ( const G4String name,
G4bool  verbose = true 
) const

Definition at line 165 of file G4PhysicalVolumeStore.cc.

References G4endl, G4Exception(), GetInstance(), and JustWarning.

Referenced by G4GDMLReadStructure::GetPhysvol().

00166 {
00167   for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
00168   {
00169     if ((*i)->GetName() == name) { return *i; }
00170   }
00171   if (verbose)
00172   {
00173      std::ostringstream message;
00174      message << "Volume NOT found in store !" << G4endl
00175             << "        Volume " << name << " NOT found in store !" << G4endl
00176             << "        Returning NULL pointer.";
00177      G4Exception("G4PhysicalVolumeStore::GetVolume()",
00178                  "GeomMgt1001", JustWarning, message);
00179   }
00180   return 0;
00181 }

void G4PhysicalVolumeStore::Register ( G4VPhysicalVolume pSolid  )  [static]

Definition at line 131 of file G4PhysicalVolumeStore.cc.

References GetInstance(), and G4VNotifier::NotifyRegistration().

Referenced by G4VPhysicalVolume::G4VPhysicalVolume().

00132 {
00133   GetInstance()->push_back(pVolume);
00134   if (fgNotifier) { fgNotifier->NotifyRegistration(); }
00135 }

void G4PhysicalVolumeStore::SetNotifier ( G4VStoreNotifier pNotifier  )  [static]

Definition at line 121 of file G4PhysicalVolumeStore.cc.

References GetInstance().

00122 {
00123   GetInstance();
00124   fgNotifier = pNotifier;
00125 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:54 2013 for Geant4 by  doxygen 1.4.7