00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // class G4NavigationHistory 00030 // 00031 // Class description: 00032 // 00033 // Responsible for maintenance of the history of the path taken through 00034 // the geometrical hierarchy. Principally a utility class for use by the 00035 // G4Navigator. 00036 00037 // History: 00038 // 00039 // 25.07.96 P.Kent Initial version. Services derived from 00040 // requirements of G4Navigator. 00041 // ---------------------------------------------------------------------- 00042 #ifndef G4NAVIGATIONHISTORY_HH 00043 #define G4NAVIGATIONHISTORY_HH 00044 00045 #include <assert.h> 00046 #include "geomdefs.hh" 00047 00048 #include "G4AffineTransform.hh" 00049 #include "G4VPhysicalVolume.hh" 00050 #include "G4NavigationLevel.hh" 00051 #include "G4EnhancedVecAllocator.hh" 00052 00053 #include <vector> 00054 #include <iostream> 00055 00056 class G4NavigationHistory 00057 { 00058 00059 public: // with description 00060 00061 friend std::ostream& 00062 operator << (std::ostream &os, const G4NavigationHistory &h); 00063 00064 G4NavigationHistory(); 00065 // Constructor: sizes history lists & resets histories. 00066 00067 ~G4NavigationHistory(); 00068 // Destructor. 00069 00070 G4NavigationHistory(const G4NavigationHistory &h); 00071 // Copy constructor. 00072 00073 G4NavigationHistory& operator=(const G4NavigationHistory &h); 00074 // Assignment operator. 00075 00076 inline void Reset(); 00077 // Resets history. It now does clear most entries. 00078 // Level 0 is preserved. 00079 00080 inline void Clear(); 00081 // Clears entries, zeroing transforms, matrices & negating 00082 // replica history. 00083 00084 inline void SetFirstEntry(G4VPhysicalVolume* pVol); 00085 // Setup initial entry in stack: copies through volume transform & matrix. 00086 // The volume is assumed to be unrotated. 00087 00088 inline const G4AffineTransform& GetTopTransform() const; 00089 // Returns topmost transform. 00090 00091 inline const G4AffineTransform* GetPtrTopTransform() const; 00092 // Returns pointer to topmost transform. 00093 00094 inline G4int GetTopReplicaNo() const; 00095 // Returns topmost replica no record. 00096 00097 inline EVolume GetTopVolumeType() const; 00098 // Returns topmost volume type. 00099 00100 inline G4VPhysicalVolume* GetTopVolume() const; 00101 // Returns topmost physical volume pointer. 00102 00103 inline G4int GetDepth() const; 00104 // Returns current history depth. 00105 00106 inline G4int GetMaxDepth() const; 00107 // Returns current maximum size of history. 00108 // Note: MaxDepth of 16 mean history entries [0..15] inclusive. 00109 00110 inline const G4AffineTransform& GetTransform(G4int n) const; 00111 // Returns specified transformation. 00112 00113 inline G4int GetReplicaNo(G4int n) const; 00114 // Returns specified replica no record. 00115 00116 inline EVolume GetVolumeType(G4int n) const; 00117 // Returns specified volume type. 00118 00119 inline G4VPhysicalVolume* GetVolume(G4int n) const; 00120 // Returns specified physical volume pointer. 00121 00122 inline void NewLevel(G4VPhysicalVolume *pNewMother, 00123 EVolume vType=kNormal, 00124 G4int nReplica=-1); 00125 // Changes navigation level to that of the new mother. 00126 00127 inline void BackLevel(); 00128 // Back up one level in history: from mother to grandmother. 00129 // It does not erase history record of current mother. 00130 00131 inline void BackLevel(G4int n); 00132 // Back up specified number of levels in history. 00133 00134 private: 00135 00136 inline void EnlargeHistory(); 00137 // Enlarge history if required: increase size by kHistoryStride. 00138 // Note that additional history entries are `dirty' (non zero) apart 00139 // from the volume history. 00140 00141 private: 00142 00143 #ifdef WIN32 00144 std::vector<G4NavigationLevel> fNavHistory; 00145 #else 00146 std::vector<G4NavigationLevel, 00147 G4EnhancedVecAllocator<G4NavigationLevel> > fNavHistory; 00148 // The geometrical tree; uses specialized allocator to optimize 00149 // memory handling and reduce possible fragmentation 00150 #endif 00151 00152 G4int fStackDepth; 00153 // Depth of stack: effectively depth in geometrical tree 00154 00155 }; 00156 00157 #include "G4NavigationHistory.icc" 00158 00159 #endif