source: trunk/source/geometry/volumes/include/G4NavigationHistory.icc@ 1147

Last change on this file since 1147 was 1058, checked in by garnier, 17 years ago

file release beta

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