Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G3VolTable.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: G3VolTable.cc 67982 2013-03-13 10:36:03Z gcosmo $
28 //
29 // modified by I.Hrivnacova, 13.10.99
30 
31 #include <iomanip>
32 #include "globals.hh"
33 #include "G3VolTable.hh"
34 #include "G3Pos.hh"
35 
36 typedef std::map<G4String, G3VolTableEntry*, std::less<G4String> >
37 ::iterator VTDiterator;
38 
40  : G3toG4TopVTE(0), _FirstKey("UnDefined"), _NG3Pos(0){
41 }
42 
44  if (VTD.size()>0){
45  // G4cout << "Deleting VTD" << G4endl;
46  for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) {
47  delete (*i).second;
48  }
49  VTD.clear();
50  }
51 }
52 
55  VTDiterator i = VTD.find(Vname);
56  if (i == VTD.end()) return 0;
57  else return (*i).second;
58 }
59 
60 void
62  if (VTD.size()){
63  G4int i=0;
64  G4cout << "Dump of VTD - " << VTD.size() << " entries:" << G4endl;
65  VTEStat();
66  for (VTDiterator v=VTD.begin(); v != VTD.end(); v++){
67  G3VolTableEntry* VTE = (*v).second;
68  G4cout << "G3VolTable element " << std::setw(3) << i++ << " name "
69  << VTE->GetName() << " has " << VTE->GetNoDaughters()
70  << " daughters" << G4endl;
71  }
72  }
73 }
74 
77 
78  if (GetVTE(aG3VolTableEntry->GetName()) == 0 ){
79 
80  // create a hash key
81  G4String HashID = aG3VolTableEntry->GetName();
82 
83  if (_FirstKey == "UnDefined") _FirstKey = HashID;
84 
85  // insert into dictionary
86  VTD[HashID] = aG3VolTableEntry;
87  }
88  return GetVTE(aG3VolTableEntry->GetName());
89 }
90 
91 void
93  _NG3Pos++;
94 }
95 
96 void
98  G3toG4TopVTE = VTD[_FirstKey];
99 
100  if (G3toG4TopVTE->NPCopies() > 0) {
101  _FirstKey = G3toG4TopVTE->GetMother()->GetName();
102  SetFirstVTE();
103  }
104 }
105 
108  return G3toG4TopVTE;
109 }
110 
111 void
113  G4cout << "Instantiated " << VTD.size() <<
114  " volume table entries \n"
115  << " " << _NG3Pos << " positions." << G4endl;
116 }
117 
118 void
120  if (VTD.size()>0){
121  for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) {
122  delete (*i).second;
123  }
124  VTD.clear();
125  }
126  G3toG4TopVTE = 0;
127  _FirstKey = "UnDefined";
128  _NG3Pos = 0;
129 }
G3VolTableEntry * GetFirstVTE()
Definition: G3VolTable.cc:107
void Clear()
Definition: G3VolTable.cc:119
G4int NPCopies()
virtual ~G3VolTable()
Definition: G3VolTable.cc:43
int G4int
Definition: G4Types.hh:78
G3VolTableEntry * GetVTE(const G4String &Vname)
Definition: G3VolTable.cc:54
G3VolTableEntry * GetMother(G4int i)
void PrintAll()
Definition: G3VolTable.cc:61
G4int GetNoDaughters()
G4GLOB_DLL std::ostream G4cout
void CountG3Pos()
Definition: G3VolTable.cc:92
std::map< G4String, G3VolTableEntry *, std::less< G4String > >::iterator VTDiterator
Definition: G3VolTable.cc:37
G4String GetName()
void SetFirstVTE()
Definition: G3VolTable.cc:97
#define G4endl
Definition: G4ios.hh:61
G3VolTableEntry * PutVTE(G3VolTableEntry *aVTE)
Definition: G3VolTable.cc:76
void VTEStat()
Definition: G3VolTable.cc:112