Geant4  10.00.p01
G4NavigationHistory.icc
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: G4NavigationHistory.icc 66356 2012-12-18 09:02:32Z gcosmo $
28 //
29 //
30 // class G4NavigationHistory Inline implementation
31 //
32 // ----------------------------------------------------------------------
33 
34 inline
35 G4NavigationHistory&
36 G4NavigationHistory::operator=(const G4NavigationHistory &h)
37 {
38  if (&h == this) { return *this; }
39 
40  // fNavHistory=h.fNavHistory; // This works, but is very slow.
41 
42  if( this->GetMaxDepth() < h.fStackDepth )
43  {
44  fNavHistory.resize( h.fStackDepth );
45  }
46  for ( register G4int ilev=h.fStackDepth; ilev>=0; ilev-- )
47  {
48  fNavHistory[ilev] = h.fNavHistory[ilev];
49  }
50  fStackDepth=h.fStackDepth;
51 
52  return *this;
53 }
54 
55 inline
56 void G4NavigationHistory::Reset()
57 {
58  fStackDepth=0;
59 }
60 
61 inline
62 void G4NavigationHistory::Clear()
63 {
64  G4AffineTransform origin(G4ThreeVector(0.,0.,0.));
65  G4NavigationLevel tmpNavLevel = G4NavigationLevel(0, origin, kNormal, -1) ;
66 
67  Reset();
68  for (register G4int ilev=fNavHistory.size()-1; ilev>=0; ilev--)
69  {
70  fNavHistory[ilev] = tmpNavLevel;
71  }
72 }
73 
74 inline
75 void G4NavigationHistory::SetFirstEntry(G4VPhysicalVolume* pVol)
76 {
77  G4ThreeVector translation(0.,0.,0.);
78  G4int copyNo = -1;
79 
80  // Protection needed in case pVol=null
81  // so that a touchable-history can signal OutOfWorld
82  //
83  if( pVol!=0 )
84  {
85  translation = pVol->GetTranslation();
86  copyNo = pVol->GetCopyNo();
87  }
88  fNavHistory[0] =
89  G4NavigationLevel( pVol, G4AffineTransform(translation), kNormal, copyNo );
90 }
91 
92 inline
93 const G4AffineTransform* G4NavigationHistory::GetPtrTopTransform() const
94 {
95  return fNavHistory[fStackDepth].GetPtrTransform();
96 }
97 
98 inline
99 const G4AffineTransform& G4NavigationHistory::GetTopTransform() const
100 {
101  return fNavHistory[fStackDepth].GetTransform();
102 }
103 
104 inline
105 G4int G4NavigationHistory::GetTopReplicaNo() const
106 {
107  return fNavHistory[fStackDepth].GetReplicaNo();
108 }
109 
110 inline
111 EVolume G4NavigationHistory::GetTopVolumeType() const
112 {
113  return fNavHistory[fStackDepth].GetVolumeType();
114 }
115 
116 inline
117 G4VPhysicalVolume* G4NavigationHistory::GetTopVolume() const
118 {
119  return fNavHistory[fStackDepth].GetPhysicalVolume();
120 }
121 
122 inline
123 G4int G4NavigationHistory::GetDepth() const
124 {
125  return fStackDepth;
126 }
127 
128 inline
129 const G4AffineTransform&
130 G4NavigationHistory::GetTransform(G4int n) const
131 {
132  return fNavHistory[n].GetTransform();
133 }
134 
135 inline
136 G4int G4NavigationHistory::GetReplicaNo(G4int n) const
137 {
138  return fNavHistory[n].GetReplicaNo();
139 }
140 
141 inline
142 EVolume G4NavigationHistory::GetVolumeType(G4int n) const
143 {
144  return fNavHistory[n].GetVolumeType();
145 }
146 
147 inline
148 G4VPhysicalVolume* G4NavigationHistory::GetVolume(G4int n) const
149 {
150  return fNavHistory[n].GetPhysicalVolume();
151 }
152 
153 inline
154 G4int G4NavigationHistory::GetMaxDepth() const
155 {
156  return fNavHistory.size();
157 }
158 
159 inline
160 void G4NavigationHistory::BackLevel()
161 {
162  assert( fStackDepth>0 );
163 
164  // Tell the level that I am forgetting it
165  // delete fNavHistory(fStackDepth);
166  //
167  fStackDepth--;
168 }
169 
170 inline
171 void G4NavigationHistory::BackLevel(G4int n)
172 {
173  assert( n<=fStackDepth );
174  fStackDepth-=n;
175 }
176 
177 inline
178 void G4NavigationHistory::EnlargeHistory()
179 {
180  G4int len = fNavHistory.size();
181  if ( len==fStackDepth )
182  {
183  // Note: Resize operation clears additional entries
184  //
185  G4int nlen = len+kHistoryStride;
186  fNavHistory.resize(nlen);
187  }
188 }
189 
190 
191 inline
192 void G4NavigationHistory::NewLevel( G4VPhysicalVolume *pNewMother,
193  EVolume vType,
194  G4int nReplica )
195 {
196  fStackDepth++;
197  EnlargeHistory(); // Enlarge if required
198  fNavHistory[fStackDepth] =
199  G4NavigationLevel( pNewMother,
200  fNavHistory[fStackDepth-1].GetTransform(),
201  G4AffineTransform(pNewMother->GetRotation(),
202  pNewMother->GetTranslation()),
203  vType,
204  nReplica );
205  // The constructor computes the new global->local transform
206 }