Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SolidStore Class Reference

#include <G4SolidStore.hh>

+ Inheritance diagram for G4SolidStore:

Public Member Functions

G4VSolidGetSolid (const G4String &name, G4bool verbose=true) const
 
virtual ~G4SolidStore ()
 

Static Public Member Functions

static void Register (G4VSolid *pSolid)
 
static void DeRegister (G4VSolid *pSolid)
 
static G4SolidStoreGetInstance ()
 
static void SetNotifier (G4VStoreNotifier *pNotifier)
 
static void Clean ()
 

Protected Member Functions

 G4SolidStore ()
 

Detailed Description

Definition at line 62 of file G4SolidStore.hh.

Constructor & Destructor Documentation

◆ ~G4SolidStore()

G4SolidStore::~G4SolidStore ( )
virtual

Definition at line 64 of file G4SolidStore.cc.

65{
66 Clean();
67}
static void Clean()
Definition: G4SolidStore.cc:73

◆ G4SolidStore()

G4SolidStore::G4SolidStore ( )
protected

Definition at line 54 of file G4SolidStore.cc.

55 : std::vector<G4VSolid*>()
56{
57 reserve(100);
58}

Member Function Documentation

◆ Clean()

void G4SolidStore::Clean ( )
static

Definition at line 73 of file G4SolidStore.cc.

74{
75 // Do nothing if geometry is closed
76 //
77 if (G4GeometryManager::GetInstance()->IsGeometryClosed())
78 {
79 G4cout << "WARNING - Attempt to delete the solid store"
80 << " while geometry closed !" << G4endl;
81 return;
82 }
83
84 // Locks store for deletion of solids. De-registration will be
85 // performed at this stage. G4VSolids will not de-register themselves.
86 //
87 locked = true;
88
89 size_t i=0;
90 G4SolidStore* store = GetInstance();
91
92#ifdef G4GEOMETRY_VOXELDEBUG
93 G4cout << "Deleting Solids ... ";
94#endif
95
96 for(iterator pos=store->begin(); pos!=store->end(); pos++)
97 {
98 if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
99 if (*pos) { delete *pos; }
100 i++;
101 }
102
103#ifdef G4GEOMETRY_VOXELDEBUG
104 if (store->size() < i-1)
105 { G4cout << "No solids deleted. Already deleted by user ?" << G4endl; }
106 else
107 { G4cout << i-1 << " solids deleted !" << G4endl; }
108#endif
109
110 locked = false;
111 store->clear();
112}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
static G4GeometryManager * GetInstance()
static G4SolidStore * GetInstance()
virtual void NotifyDeRegistration()=0

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

◆ DeRegister()

void G4SolidStore::DeRegister ( G4VSolid pSolid)
static

Definition at line 138 of file G4SolidStore.cc.

139{
140 if (!locked) // Do not de-register if locked !
141 {
142 if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
143 for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
144 {
145 if (**i==*pSolid)
146 {
147 GetInstance()->erase(i);
148 break;
149 }
150 }
151 }
152}

Referenced by G4SurfaceVoxelizer::G4SurfaceVoxelizer(), and G4VSolid::~G4VSolid().

◆ GetInstance()

G4SolidStore * G4SolidStore::GetInstance ( )
static

Definition at line 179 of file G4SolidStore.cc.

180{
181 static G4SolidStore worldStore;
182 if (!fgInstance)
183 {
184 fgInstance = &worldStore;
185 }
186 return fgInstance;
187}

Referenced by Clean(), DeRegister(), G4SurfaceVoxelizer::G4SurfaceVoxelizer(), G4VSolid::G4VSolid(), G4GDMLReadSolids::GetSolid(), GetSolid(), Register(), SetNotifier(), G4GeometryManager::SetWorldMaximumExtent(), G4GDMLRead::StripNames(), and G4VSolid::~G4VSolid().

◆ GetSolid()

G4VSolid * G4SolidStore::GetSolid ( const G4String name,
G4bool  verbose = true 
) const

Definition at line 158 of file G4SolidStore.cc.

159{
160 for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
161 {
162 if ((*i)->GetName() == name) { return *i; }
163 }
164 if (verbose)
165 {
166 std::ostringstream message;
167 message << "Solid " << name << " not found in store !" << G4endl
168 << "Returning NULL pointer.";
169 G4Exception("G4SolidStore::GetSolid()",
170 "GeomMgt1001", JustWarning, message);
171 }
172 return 0;
173}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G4GDMLReadSolids::GetSolid().

◆ Register()

void G4SolidStore::Register ( G4VSolid pSolid)
static

Definition at line 128 of file G4SolidStore.cc.

129{
130 GetInstance()->push_back(pSolid);
131 if (fgNotifier) { fgNotifier->NotifyRegistration(); }
132}
virtual void NotifyRegistration()=0

Referenced by G4VSolid::G4VSolid().

◆ SetNotifier()

void G4SolidStore::SetNotifier ( G4VStoreNotifier pNotifier)
static

Definition at line 118 of file G4SolidStore.cc.

119{
120 GetInstance();
121 fgNotifier = pNotifier;
122}

The documentation for this class was generated from the following files: