Geant4  10.00.p01
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: G3VolTableEntry.cc 67982 2013-03-13 10:36:03Z gcosmo $
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 
59 inline G4bool
61  return (this==&lv) ? true : false;
62 }
63 
64 void
66 
67  // insert this position to the vector
68  G3Vol.CountG3Pos();
69  fG3Pos.push_back(aG3Pos);
70 
71  // pass MANY info
72  G4String vonly = aG3Pos->GetOnly();
73  if (vonly == "MANY") SetHasMANY(true);
74 }
75 
76 void
78  if (FindDaughter(aDaughter->GetName()) == 0) {
79  fDaughters.push_back(aDaughter);
80  }
81 }
82 
83 void
85  if (FindMother(itsMother->GetName()) == 0) {
86  fMothers.push_back(itsMother);
87  }
88 }
89 
90 void
92  if (FindClone(itsClone->GetName()) == 0) {
93  fClones.push_back(itsClone);
94  }
95 }
96 
97 void
99  fOverlaps.push_back(overlap);
100 }
101 
102 void
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 
120 void
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 
177 void
179  fVname = name;
180 }
181 
182 void
184  fLV = lv;
185 }
186 
187 void
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 
228 G4String
230  return fVname;
231 }
232 
233 G4String
235  return fShape;
236 }
237 
238 G4int
240  return fNmed;
241 }
242 
243 G4int
245  return fNpar;
246 }
247 
248 G4double*
250  return fRpar;
251 }
252 
253 G4int
255  return fG3Pos.size();
256 }
257 
258 G3Pos*
260  if (fG3Pos.size()>0 && copy>=0)
261  return fG3Pos[copy];
262  else
263  return 0;
264 }
265 
266 G4bool
268  return fHasNegPars;
269 }
270 
271 G4bool
273  return fHasMANY;
274 }
275 
276 G4VSolid*
278  return fSolid;
279 }
280 
283  return fLV;
284 }
285 
286 G4int
288  return fDaughters.size();
289 }
290 
291 G4int
293  return fMothers.size();
294 }
295 
296 G4int
298  return fClones.size();
299 }
300 
301 G4int
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 
353 std::vector<G3VolTableEntry*>*
355  return &fOverlaps;
356 }
G3Pos * GetG3PosCopy(G4int copy=0)
G4double * fRpar
void ClearG3PosCopy(G4int copy)
std::vector< G3Pos * > fG3Pos
G3VolTableEntry * GetMasterClone()
G4int first(char) const
G4int GetNoMothers()
Definition: G3Pos.hh:43
G3VolTableEntry * FindClone(const G4String &vname)
G3VolTableEntry * GetMother()
G4String name
Definition: TRTMaterials.hh:40
G4LogicalVolume * GetLV()
G4int fNpar
void SetHasMANY(G4bool hasMANY)
G4String GetShape()
G4VSolid * fSolid
void SetLV(G4LogicalVolume *lv)
G4double * GetRpar()
G4bool HasMANY()
void AddOverlap(G3VolTableEntry *aOverlap)
std::vector< G3VolTableEntry * > fOverlaps
G4int NPCopies()
G4int fNmed
G3VolTableEntry * GetClone(G4int i)
G3VolTableEntry(G4String &vname, G4String &shape, G4double *rpar, G4int npar, G4int nmed, G4VSolid *solid, G4bool hasNegPars)
int G4int
Definition: G4Types.hh:78
G3VolTableEntry * GetVTE(const G4String &Vname)
Definition: G3VolTable.cc:54
std::vector< G3VolTableEntry * > * GetOverlaps()
G4int GetNoClones()
void copy(std::vector< T > &main, const std::vector< T > &data)
Definition: DicomRun.hh:91
void SetName(G4String name)
G3VolTableEntry * GetDaughter(G4int i)
G4int GetNoDaughters()
std::vector< G3VolTableEntry * > fDaughters
G4int GetNpar()
G3VolTableEntry * FindMother(const G4String &vname)
G4GLOB_DLL std::ostream G4cout
void PrintSolidInfo()
G4VSolid * GetSolid()
G4int GetNoOverlaps()
bool G4bool
Definition: G4Types.hh:79
void SetNRpar(G4int npar, G4double *Rpar)
void SetHasNegPars(G4bool hasNegPars)
G3VolTableEntry * FindDaughter(const G4String &vname)
void SetSolid(G4VSolid *solid)
void CountG3Pos()
Definition: G3VolTable.cc:92
G4bool fHasMANY
G4int GetNmed()
std::vector< G3VolTableEntry * > fMothers
std::vector< G3VolTableEntry * > fClones
G4String fShape
void ClearDivision()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4LogicalVolume * fLV
G4bool operator==(const G3VolTableEntry &vte) const
G4bool contains(const std::string &) const
void AddG3Pos(G3Pos *aG3Pos)
void AddMother(G3VolTableEntry *aDaughter)
G4String GetName()
G4String & GetOnly()
Definition: G3Pos.cc:78
G4bool fHasNegPars
G4bool HasNegPars()
G3Division * fDivision
G4String fVname
void AddClone(G3VolTableEntry *aDaughter)
G3G4DLL_API char gSeparator
#define G4endl
Definition: G4ios.hh:61
void ReplaceMother(G3VolTableEntry *vteOld, G3VolTableEntry *vteNew)
virtual ~G3VolTableEntry()
void ReplaceDaughter(G3VolTableEntry *vteOld, G3VolTableEntry *vteNew)
double G4double
Definition: G4Types.hh:76
void SetNmed(G4int nmed)
G3G4DLL_API G3VolTable G3Vol
Definition: clparse.cc:54
void AddDaughter(G3VolTableEntry *aDaughter)