[831] | 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 $ |
---|
[1058] | 28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
[831] | 29 | // |
---|
| 30 | // |
---|
| 31 | // class G4NavigationHistory Inline implementation |
---|
| 32 | // |
---|
| 33 | // ---------------------------------------------------------------------- |
---|
| 34 | |
---|
| 35 | inline |
---|
| 36 | G4NavigationHistory& |
---|
| 37 | G4NavigationHistory::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 | |
---|
| 56 | inline |
---|
| 57 | void G4NavigationHistory::Reset() |
---|
| 58 | { |
---|
| 59 | fStackDepth=0; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | inline |
---|
| 63 | void 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 | |
---|
| 75 | inline |
---|
| 76 | void 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 | |
---|
| 93 | inline |
---|
| 94 | const G4AffineTransform* G4NavigationHistory::GetPtrTopTransform() const |
---|
| 95 | { |
---|
| 96 | return fNavHistory[fStackDepth].GetPtrTransform(); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | inline |
---|
| 100 | const G4AffineTransform& G4NavigationHistory::GetTopTransform() const |
---|
| 101 | { |
---|
| 102 | return fNavHistory[fStackDepth].GetTransform(); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | inline |
---|
| 106 | G4int G4NavigationHistory::GetTopReplicaNo() const |
---|
| 107 | { |
---|
| 108 | return fNavHistory[fStackDepth].GetReplicaNo(); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | inline |
---|
| 112 | EVolume G4NavigationHistory::GetTopVolumeType() const |
---|
| 113 | { |
---|
| 114 | return fNavHistory[fStackDepth].GetVolumeType(); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | inline |
---|
| 118 | G4VPhysicalVolume* G4NavigationHistory::GetTopVolume() const |
---|
| 119 | { |
---|
| 120 | return fNavHistory[fStackDepth].GetPhysicalVolume(); |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | inline |
---|
| 124 | G4int G4NavigationHistory::GetDepth() const |
---|
| 125 | { |
---|
| 126 | return fStackDepth; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | inline |
---|
| 130 | const G4AffineTransform& |
---|
| 131 | G4NavigationHistory::GetTransform(G4int n) const |
---|
| 132 | { |
---|
| 133 | return fNavHistory[n].GetTransform(); |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | inline |
---|
| 137 | G4int G4NavigationHistory::GetReplicaNo(G4int n) const |
---|
| 138 | { |
---|
| 139 | return fNavHistory[n].GetReplicaNo(); |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | inline |
---|
| 143 | EVolume G4NavigationHistory::GetVolumeType(G4int n) const |
---|
| 144 | { |
---|
| 145 | return fNavHistory[n].GetVolumeType(); |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | inline |
---|
| 149 | G4VPhysicalVolume* G4NavigationHistory::GetVolume(G4int n) const |
---|
| 150 | { |
---|
| 151 | return fNavHistory[n].GetPhysicalVolume(); |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | inline |
---|
| 155 | G4int G4NavigationHistory::GetMaxDepth() const |
---|
| 156 | { |
---|
| 157 | return fNavHistory.size(); |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | inline |
---|
| 161 | void 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 | |
---|
| 171 | inline |
---|
| 172 | void G4NavigationHistory::BackLevel(G4int n) |
---|
| 173 | { |
---|
| 174 | assert( n<=fStackDepth ); |
---|
| 175 | fStackDepth-=n; |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | inline |
---|
| 179 | void 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 | |
---|
| 192 | inline |
---|
| 193 | void 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 | } |
---|