Geant4  10.00.p01
G4NavigationHistory.hh
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.hh 75578 2013-11-04 12:03:33Z gcosmo $
28 //
29 // class G4NavigationHistory
30 //
31 // Class description:
32 //
33 // Responsible for maintenance of the history of the path taken through
34 // the geometrical hierarchy. Principally a utility class for use by the
35 // G4Navigator.
36 
37 // History:
38 //
39 // 25.07.96 P.Kent Initial version. Services derived from
40 // requirements of G4Navigator.
41 // ----------------------------------------------------------------------
42 #ifndef G4NAVIGATIONHISTORY_HH
43 #define G4NAVIGATIONHISTORY_HH
44 
45 #include <assert.h>
46 #include <vector>
47 #include <iostream>
48 
49 #include "geomdefs.hh"
50 #include "G4AffineTransform.hh"
51 #include "G4VPhysicalVolume.hh"
52 #include "G4NavigationLevel.hh"
53 
54 #if (defined(G4MULTITHREADED) || !defined(WIN32))
55  #include "G4EnhancedVecAllocator.hh"
56 #endif
57 
59 {
60 
61  public: // with description
62 
63  friend std::ostream&
64  operator << (std::ostream &os, const G4NavigationHistory &h);
65 
67  // Constructor: sizes history lists & resets histories.
68 
70  // Destructor.
71 
73  // Copy constructor.
74 
76  // Assignment operator.
77 
78  inline void Reset();
79  // Resets history. It now does clear most entries.
80  // Level 0 is preserved.
81 
82  inline void Clear();
83  // Clears entries, zeroing transforms, matrices & negating
84  // replica history.
85 
86  inline void SetFirstEntry(G4VPhysicalVolume* pVol);
87  // Setup initial entry in stack: copies through volume transform & matrix.
88  // The volume is assumed to be unrotated.
89 
90  inline const G4AffineTransform& GetTopTransform() const;
91  // Returns topmost transform.
92 
93  inline const G4AffineTransform* GetPtrTopTransform() const;
94  // Returns pointer to topmost transform.
95 
96  inline G4int GetTopReplicaNo() const;
97  // Returns topmost replica no record.
98 
99  inline EVolume GetTopVolumeType() const;
100  // Returns topmost volume type.
101 
102  inline G4VPhysicalVolume* GetTopVolume() const;
103  // Returns topmost physical volume pointer.
104 
105  inline G4int GetDepth() const;
106  // Returns current history depth.
107 
108  inline G4int GetMaxDepth() const;
109  // Returns current maximum size of history.
110  // Note: MaxDepth of 16 mean history entries [0..15] inclusive.
111 
112  inline const G4AffineTransform& GetTransform(G4int n) const;
113  // Returns specified transformation.
114 
115  inline G4int GetReplicaNo(G4int n) const;
116  // Returns specified replica no record.
117 
118  inline EVolume GetVolumeType(G4int n) const;
119  // Returns specified volume type.
120 
121  inline G4VPhysicalVolume* GetVolume(G4int n) const;
122  // Returns specified physical volume pointer.
123 
124  inline void NewLevel(G4VPhysicalVolume *pNewMother,
125  EVolume vType=kNormal,
126  G4int nReplica=-1);
127  // Changes navigation level to that of the new mother.
128 
129  inline void BackLevel();
130  // Back up one level in history: from mother to grandmother.
131  // It does not erase history record of current mother.
132 
133  inline void BackLevel(G4int n);
134  // Back up specified number of levels in history.
135 
136  private:
137 
138  inline void EnlargeHistory();
139  // Enlarge history if required: increase size by kHistoryStride.
140  // Note that additional history entries are `dirty' (non zero) apart
141  // from the volume history.
142 
143  private:
144 
145 #if defined(WIN32)
146  std::vector<G4NavigationLevel> fNavHistory;
147 #else
148  std::vector<G4NavigationLevel,
150  // The geometrical tree; uses specialized allocator to optimize memory
151  // handling, reduce possible fragmentation and use of malloc in MT mode
152 #endif
153 
155  // Depth of stack: effectively depth in geometrical tree
156 
157 };
158 
159 #include "G4NavigationHistory.icc"
160 
161 #endif
G4VPhysicalVolume * GetTopVolume() const
std::vector< G4NavigationLevel, G4EnhancedVecAllocator< G4NavigationLevel > > fNavHistory
const G4AffineTransform * GetPtrTopTransform() const
G4int GetDepth() const
EVolume GetVolumeType(G4int n) const
G4int GetMaxDepth() const
int G4int
Definition: G4Types.hh:78
G4int GetTopReplicaNo() const
friend std::ostream & operator<<(std::ostream &os, const G4NavigationHistory &h)
EVolume GetTopVolumeType() const
G4int GetReplicaNo(G4int n) const
const G4int n
void SetFirstEntry(G4VPhysicalVolume *pVol)
void NewLevel(G4VPhysicalVolume *pNewMother, EVolume vType=kNormal, G4int nReplica=-1)
const G4AffineTransform & GetTransform(G4int n) const
const G4AffineTransform & GetTopTransform() const
EVolume
Definition: geomdefs.hh:68
G4VPhysicalVolume * GetVolume(G4int n) const
G4NavigationHistory & operator=(const G4NavigationHistory &h)