source: trunk/source/g3tog4/src/G3VolTable.cc @ 1342

Last change on this file since 1342 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 3.9 KB
Line 
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,v 1.22 2006/06/29 18:13:20 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30// modified by I.Hrivnacova, 13.10.99
31
32#include <iomanip>
33#include "globals.hh"
34#include "G3VolTable.hh"
35#include "G3Pos.hh"
36
37typedef std::map<G4String, G3VolTableEntry*, std::less<G4String> >
38::iterator VTDiterator;
39
40G3VolTable::G3VolTable() 
41  : G3toG4TopVTE(0), _FirstKey("UnDefined"), _NG3Pos(0){
42}
43
44G3VolTable::~G3VolTable(){
45  if (VTD.size()>0){
46    //    G4cout << "Deleting VTD" << G4endl;
47    for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) {
48      delete (*i).second;
49    }
50    VTD.clear();
51  }
52}
53
54G3VolTableEntry*
55G3VolTable::GetVTE(const G4String& Vname) {
56  VTDiterator i = VTD.find(Vname);
57  if (i == VTD.end()) return 0;
58  else                return (*i).second;
59}
60
61void 
62G3VolTable::PrintAll(){
63  if (VTD.size()){
64    G4int i=0;
65    G4cout << "Dump of VTD - " << VTD.size() << " entries:" << G4endl;
66    VTEStat();
67    for (VTDiterator v=VTD.begin(); v != VTD.end(); v++){
68      G3VolTableEntry* VTE = (*v).second;
69      G4cout << "G3VolTable element " << std::setw(3) << i++ << " name "
70             << VTE->GetName() << " has " << VTE->GetNoDaughters() 
71             << " daughters" << G4endl;
72    }
73  }
74}
75
76G3VolTableEntry*
77G3VolTable::PutVTE(G3VolTableEntry* aG3VolTableEntry){
78 
79  if (GetVTE(aG3VolTableEntry->GetName()) == 0 ){
80   
81    // create a hash key
82    G4String HashID = aG3VolTableEntry->GetName();
83   
84    if (_FirstKey == "UnDefined") _FirstKey = HashID;
85   
86    // insert into dictionary
87    VTD[HashID] = aG3VolTableEntry;
88  }
89  return GetVTE(aG3VolTableEntry->GetName());
90}
91
92void 
93G3VolTable::CountG3Pos(){
94  _NG3Pos++;
95}
96
97void
98G3VolTable::SetFirstVTE(){
99  G3toG4TopVTE = VTD[_FirstKey];
100 
101  if (G3toG4TopVTE->NPCopies() > 0) {
102    _FirstKey = G3toG4TopVTE->GetMother()->GetName();
103    SetFirstVTE();
104  }
105}
106
107G3VolTableEntry*
108G3VolTable::GetFirstVTE() {
109  return G3toG4TopVTE;
110}
111
112void
113G3VolTable::VTEStat() {
114  G4cout << "Instantiated " << VTD.size() << 
115    " volume table entries \n" 
116         << "                      " << _NG3Pos << " positions." << G4endl;
117}
118
119void 
120G3VolTable::Clear() {
121  if (VTD.size()>0){
122    for (VTDiterator i=VTD.begin(); i != VTD.end(); i++) {
123      delete (*i).second;
124    }
125    VTD.clear();
126  }
127  G3toG4TopVTE = 0;
128  _FirstKey = "UnDefined";
129  _NG3Pos = 0;
130} 
Note: See TracBrowser for help on using the repository browser.