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: G4TouchableHistory.icc,v 1.13 2009/11/06 11:10:35 gcosmo Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
29 | // |
---|
30 | // |
---|
31 | // class G4TouchableHistory inline implementation |
---|
32 | // ---------------------------------------------------------------------- |
---|
33 | |
---|
34 | #if defined G4GEOM_ALLOC_EXPORT |
---|
35 | extern G4DLLEXPORT G4Allocator<G4TouchableHistory> aTouchableHistoryAllocator; |
---|
36 | #else |
---|
37 | extern G4DLLIMPORT G4Allocator<G4TouchableHistory> aTouchableHistoryAllocator; |
---|
38 | #endif |
---|
39 | |
---|
40 | inline |
---|
41 | void G4TouchableHistory::UpdateYourself( G4VPhysicalVolume* pPhysVol, |
---|
42 | const G4NavigationHistory* pHistory ) |
---|
43 | { |
---|
44 | fhistory = *pHistory; |
---|
45 | G4AffineTransform tf(fhistory.GetTopTransform().Inverse()); |
---|
46 | if( pPhysVol == 0 ) |
---|
47 | { |
---|
48 | // This means that the track has left the World Volume. |
---|
49 | // Since the Navigation History does not already reflect this, |
---|
50 | // we must correct this problem here. |
---|
51 | // |
---|
52 | fhistory.SetFirstEntry(pPhysVol); |
---|
53 | } |
---|
54 | ftlate = tf.NetTranslation(); |
---|
55 | frot = tf.NetRotation(); |
---|
56 | } |
---|
57 | |
---|
58 | inline |
---|
59 | G4int G4TouchableHistory::CalculateHistoryIndex( G4int stackDepth ) const |
---|
60 | { |
---|
61 | return (fhistory.GetDepth()-stackDepth); // was -1 |
---|
62 | } |
---|
63 | |
---|
64 | inline |
---|
65 | G4VPhysicalVolume* G4TouchableHistory::GetVolume( G4int depth ) const |
---|
66 | { |
---|
67 | return fhistory.GetVolume(CalculateHistoryIndex(depth)); |
---|
68 | } |
---|
69 | |
---|
70 | inline |
---|
71 | G4VSolid* G4TouchableHistory::GetSolid( G4int depth ) const |
---|
72 | { |
---|
73 | return fhistory.GetVolume(CalculateHistoryIndex(depth)) |
---|
74 | ->GetLogicalVolume()->GetSolid(); |
---|
75 | } |
---|
76 | |
---|
77 | inline |
---|
78 | G4int G4TouchableHistory::GetReplicaNumber( G4int depth ) const |
---|
79 | { |
---|
80 | return fhistory.GetReplicaNo(CalculateHistoryIndex(depth)); |
---|
81 | } |
---|
82 | |
---|
83 | inline |
---|
84 | G4int G4TouchableHistory::GetHistoryDepth() const |
---|
85 | { |
---|
86 | return fhistory.GetDepth(); |
---|
87 | } |
---|
88 | |
---|
89 | inline |
---|
90 | G4int G4TouchableHistory::MoveUpHistory( G4int num_levels ) |
---|
91 | { |
---|
92 | G4int maxLevelsMove = fhistory.GetDepth(); |
---|
93 | G4int minLevelsMove = 0; // Cannot redescend today! |
---|
94 | // Soon it will be possible |
---|
95 | // by adding a data member here |
---|
96 | // fCurrentDepth; |
---|
97 | if( num_levels > maxLevelsMove ) |
---|
98 | { |
---|
99 | num_levels = maxLevelsMove; |
---|
100 | } |
---|
101 | else if( num_levels < minLevelsMove ) |
---|
102 | { |
---|
103 | num_levels = minLevelsMove; |
---|
104 | } |
---|
105 | fhistory.BackLevel( num_levels ); |
---|
106 | |
---|
107 | return num_levels; |
---|
108 | } |
---|
109 | |
---|
110 | inline |
---|
111 | const G4NavigationHistory* G4TouchableHistory::GetHistory() const |
---|
112 | { |
---|
113 | return &fhistory; |
---|
114 | } |
---|
115 | |
---|
116 | // There is no provision in case this class is subclassed. |
---|
117 | // If it is subclassed, this will fail and may not give errors! |
---|
118 | // |
---|
119 | inline |
---|
120 | void* G4TouchableHistory::operator new(size_t) |
---|
121 | { |
---|
122 | return (void *) aTouchableHistoryAllocator.MallocSingle(); |
---|
123 | } |
---|
124 | |
---|
125 | inline |
---|
126 | void G4TouchableHistory::operator delete(void *aTH) |
---|
127 | { |
---|
128 | aTouchableHistoryAllocator.FreeSingle((G4TouchableHistory *) aTH); |
---|
129 | } |
---|
130 | |
---|