Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G3VolTableEntry.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id$
28//
29// modified by I.Hrivnacova, 13.10.99
30
31#include "globals.hh"
32#include "G3VolTableEntry.hh"
33#include "G3VolTable.hh"
34#include "G3RotTable.hh"
35#include "G4LogicalVolume.hh"
36#include "G4SubtractionSolid.hh"
37#include "G3Pos.hh"
38#include "G3toG4.hh"
39
41 G4double* rpar, G4int npar, G4int nmed,
42 G4VSolid* solid, G4bool hasNegPars)
43 : fVname(vname), fShape(shape), fRpar(0), fNpar(npar), fNmed(nmed),
44 fSolid(solid), fLV(0), fHasNegPars(hasNegPars), fHasMANY(false),
45 fDivision(0)
46{
47 if (npar>0 && rpar!=0) {
48 fRpar = new G4double[npar];
49 for (G4int i=0; i<npar; i++) fRpar[i] = rpar[i];
50 }
51 fClones.push_back(this);
52}
53
55 if (fRpar!=0) delete [] fRpar;
56 delete fDivision;
57}
58
59inline G4bool
61 return (this==&lv) ? true : false;
62}
63
64void
66
67 // insert this position to the vector
69 fG3Pos.push_back(aG3Pos);
70
71 // pass MANY info
72 G4String vonly = aG3Pos->GetOnly();
73 if (vonly == "MANY") SetHasMANY(true);
74}
75
76void
78 if (FindDaughter(aDaughter->GetName()) == 0) {
79 fDaughters.push_back(aDaughter);
80 }
81}
82
83void
85 if (FindMother(itsMother->GetName()) == 0) {
86 fMothers.push_back(itsMother);
87 }
88}
89
90void
92 if (FindClone(itsClone->GetName()) == 0) {
93 fClones.push_back(itsClone);
94 }
95}
96
97void
99 fOverlaps.push_back(overlap);
100}
101
102void
104 G3VolTableEntry* vteNew)
105{
106 G4int index = -1;
107 for (G4int i=0; i<GetNoDaughters(); i++){
108 if (fDaughters[i]->GetName() == vteOld->GetName()) index = i;
109 }
110 if (index<0) {
111 G4String err_message = "Old daughter " + vteOld->GetName()
112 + " does not exist.";
113 G4Exception("G3VolTableEntry::ReplaceDaughter()", "G3toG40007",
114 FatalException, err_message);
115 return;
116 }
117 fDaughters[index] = vteNew;
118}
119
120void
122 G3VolTableEntry* vteNew)
123{
124 G4int index = -1;
125 for (G4int i=0; i<GetNoMothers(); i++){
126 if (fMothers[i]->GetName() == vteOld->GetName()) index = i;
127 }
128 if (index<0) {
129 G4String err_message = "Old mother " + vteOld->GetName()
130 + " does not exist.";
131 G4Exception("G3VolTableEntry::ReplaceMother()", "G3toG40008",
132 FatalException, err_message);
133 return;
134 }
135 fMothers[index] = vteNew;
136}
137
140 for (G4int idau=0; idau<GetNoDaughters(); idau++){
141 if (GetDaughter(idau)->GetName() == Dname) return GetDaughter(idau);
142 }
143 return 0;
144}
145
148 for (G4int i=0; i<GetNoMothers(); i++){
149 G3VolTableEntry* mvte = GetMother(i);
150 if (mvte->GetName() == Mname) return mvte;
151 }
152 return 0;
153}
154
157 for (G4int i=0; i<GetNoClones(); i++){
158 G3VolTableEntry* cvte = GetClone(i);
159 if (cvte->GetName() == Cname) return cvte;
160 }
161 return 0;
162}
163
165// only parameters related to solid definition
166// are printed
167 G4cout << "VTE: " << fVname << " " << this << G4endl;
168 G4cout << "Solid: " << fSolid << G4endl;
169 G4cout << "Parameters (npar = " << fNpar << ") fRpar: ";
170 for (G4int i=0; i<fNpar; i++) G4cout << fRpar[i] << " ";
171 G4cout << G4endl;
172 G4cout << "HasNegPars: " << fHasNegPars << G4endl;
173 G4cout << "HasMANY: " << fHasMANY << G4endl;
174 G4cout << "================================= " << G4endl;
175}
176
177void
179 fVname = name;
180}
181
182void
184 fLV = lv;
185}
186
187void
189 fSolid = solid;
190}
191
193 fNmed = nmed;
194}
195
197 if (npar != fNpar) {
198 fNpar = npar;
199 delete [] fRpar;
200 fRpar = new G4double[fNpar];
201 }
202 for (G4int i=0; i<fNpar; i++) fRpar[i] = rpar[i];
203}
204
206 fHasNegPars = hasNegPars;
207}
208
210 fHasMANY = hasMANY;
211}
212
214 if (fG3Pos.size()>0 && copy>=0 && copy<G4int(fG3Pos.size())) {
215 std::vector<G3Pos*>::iterator it=fG3Pos.begin();
216 for(G4int j=0;j<copy;j++) it++;
217 if(it!=fG3Pos.end()) {
218 fG3Pos.erase(it);
219 }
220 }
221}
222
224 delete fDivision;
225 fDivision = 0;
226}
227
230 return fVname;
231}
232
235 return fShape;
236}
237
238G4int
240 return fNmed;
241}
242
243G4int
245 return fNpar;
246}
247
248G4double*
250 return fRpar;
251}
252
253G4int
255 return fG3Pos.size();
256}
257
258G3Pos*
260 if (fG3Pos.size()>0 && copy>=0)
261 return fG3Pos[copy];
262 else
263 return 0;
264}
265
266G4bool
268 return fHasNegPars;
269}
270
271G4bool
273 return fHasMANY;
274}
275
278 return fSolid;
279}
280
283 return fLV;
284}
285
286G4int
288 return fDaughters.size();
289}
290
291G4int
293 return fMothers.size();
294}
295
296G4int
298 return fClones.size();
299}
300
301G4int
303 return fOverlaps.size();
304}
305
308 if (i<G4int(fDaughters.size()) && i>=0)
309 return fDaughters[i];
310 else
311 return 0;
312}
313
316 if (i<G4int(fMothers.size()) && i>=0)
317 return fMothers[i];
318 else
319 return 0;
320}
321
322// to be removed
325 if (fMothers.size()>0)
326 return fMothers[0];
327 else
328 return 0;
329}
330
333 if (i<G4int(fClones.size()) && i>=0)
334 return fClones[i];
335 else
336 return 0;
337}
338
341 G3VolTableEntry* master;
342 G4String name = fVname;
343 if (name.contains(gSeparator)) {
344 name = name(0, name.first(gSeparator));
345 master = G3Vol.GetVTE(name);
346 }
347 else
348 master = this;
349
350 return master;
351}
352
353std::vector<G3VolTableEntry*>*
355 return &fOverlaps;
356}
G3G4DLL_API G3VolTable G3Vol
Definition: clparse.cc:54
G3G4DLL_API char gSeparator
@ FatalException
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
Definition: G3Pos.hh:44
G4String & GetOnly()
Definition: G3Pos.cc:78
void AddClone(G3VolTableEntry *aDaughter)
void AddMother(G3VolTableEntry *aDaughter)
std::vector< G3VolTableEntry * > * GetOverlaps()
void SetName(G4String name)
void SetNmed(G4int nmed)
G3VolTableEntry * FindMother(const G4String &vname)
G3VolTableEntry * GetMasterClone()
G4VSolid * GetSolid()
G3VolTableEntry * FindClone(const G4String &vname)
G3VolTableEntry(G4String &vname, G4String &shape, G4double *rpar, G4int npar, G4int nmed, G4VSolid *solid, G4bool hasNegPars)
G3VolTableEntry * FindDaughter(const G4String &vname)
G3VolTableEntry * GetClone(G4int i)
void ReplaceDaughter(G3VolTableEntry *vteOld, G3VolTableEntry *vteNew)
void ReplaceMother(G3VolTableEntry *vteOld, G3VolTableEntry *vteNew)
void AddG3Pos(G3Pos *aG3Pos)
G4bool operator==(const G3VolTableEntry &vte) const
void SetHasNegPars(G4bool hasNegPars)
G4double * GetRpar()
void SetNRpar(G4int npar, G4double *Rpar)
void AddOverlap(G3VolTableEntry *aOverlap)
void ClearG3PosCopy(G4int copy)
void AddDaughter(G3VolTableEntry *aDaughter)
G4LogicalVolume * GetLV()
virtual ~G3VolTableEntry()
void SetSolid(G4VSolid *solid)
G3VolTableEntry * GetMother()
void SetLV(G4LogicalVolume *lv)
G3Pos * GetG3PosCopy(G4int copy=0)
G3VolTableEntry * GetDaughter(G4int i)
void SetHasMANY(G4bool hasMANY)
void CountG3Pos()
Definition: G3VolTable.cc:92
G3VolTableEntry * GetVTE(const G4String &Vname)
Definition: G3VolTable.cc:54
G4bool contains(const std::string &) const
G4int first(char) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41