File indexing completed on 2026-09-21 09:10:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 extern G4GEOM_DLL G4Allocator<G4NavigationHistory>*& aNavigHistoryAllocator();
0032
0033
0034
0035
0036
0037 inline
0038 void* G4NavigationHistory::operator new(std::size_t)
0039 {
0040 if (aNavigHistoryAllocator() == nullptr)
0041 {
0042 aNavigHistoryAllocator() = new G4Allocator<G4NavigationHistory>;
0043 }
0044 return (void *) aNavigHistoryAllocator()->MallocSingle();
0045 }
0046
0047 inline
0048 void G4NavigationHistory::operator delete(void *aHistory)
0049 {
0050 aNavigHistoryAllocator()->FreeSingle((G4NavigationHistory *) aHistory);
0051 }
0052
0053 inline
0054 G4NavigationHistory&
0055 G4NavigationHistory::operator=(const G4NavigationHistory &h)
0056 {
0057 if (&h == this) { return *this; }
0058
0059
0060
0061 if( GetMaxDepth() != h.GetMaxDepth() )
0062 {
0063 fNavHistory->resize( h.GetMaxDepth() );
0064 }
0065
0066 for ( auto ilev=G4int(h.fStackDepth); ilev>=0; --ilev )
0067 {
0068 (*fNavHistory)[ilev] = (*h.fNavHistory)[ilev];
0069 }
0070 fStackDepth = h.fStackDepth;
0071
0072 return *this;
0073 }
0074
0075 inline
0076 void G4NavigationHistory::Reset()
0077 {
0078 fStackDepth=0;
0079 }
0080
0081 inline
0082 void G4NavigationHistory::Clear()
0083 {
0084 G4AffineTransform origin(G4ThreeVector(0.,0.,0.));
0085 G4NavigationLevel tmpNavLevel = G4NavigationLevel(nullptr, origin, kNormal, -1) ;
0086
0087 Reset();
0088 for (auto ilev=G4long(fNavHistory->size()-1); ilev>=0; --ilev)
0089 {
0090 (*fNavHistory)[ilev] = tmpNavLevel;
0091 }
0092 }
0093
0094 inline
0095 void G4NavigationHistory::SetFirstEntry(G4VPhysicalVolume* pVol)
0096 {
0097 G4ThreeVector translation(0.,0.,0.);
0098 G4int copyNo = -1;
0099
0100
0101
0102
0103 if( pVol != nullptr )
0104 {
0105 translation = pVol->GetTranslation();
0106 copyNo = pVol->GetCopyNo();
0107 }
0108 (*fNavHistory)[0] =
0109 G4NavigationLevel( pVol, G4AffineTransform(translation), kNormal, copyNo );
0110 }
0111
0112 inline
0113 const G4AffineTransform* G4NavigationHistory::GetPtrTopTransform() const
0114 {
0115 return (*fNavHistory)[fStackDepth].GetPtrTransform();
0116 }
0117
0118 inline
0119 const G4AffineTransform& G4NavigationHistory::GetTopTransform() const
0120 {
0121 return (*fNavHistory)[fStackDepth].GetTransform();
0122 }
0123
0124 inline
0125 G4int G4NavigationHistory::GetTopReplicaNo() const
0126 {
0127 return (*fNavHistory)[fStackDepth].GetReplicaNo();
0128 }
0129
0130 inline
0131 EVolume G4NavigationHistory::GetTopVolumeType() const
0132 {
0133 return (*fNavHistory)[fStackDepth].GetVolumeType();
0134 }
0135
0136 inline
0137 G4VPhysicalVolume* G4NavigationHistory::GetTopVolume() const
0138 {
0139 return (*fNavHistory)[fStackDepth].GetPhysicalVolume();
0140 }
0141
0142 inline
0143 std::size_t G4NavigationHistory::GetDepth() const
0144 {
0145 return fStackDepth;
0146 }
0147
0148 inline
0149 const G4AffineTransform&
0150 G4NavigationHistory::GetTransform(G4int n) const
0151 {
0152 return (*fNavHistory)[n].GetTransform();
0153 }
0154
0155 inline
0156 G4int G4NavigationHistory::GetReplicaNo(G4int n) const
0157 {
0158 return (*fNavHistory)[n].GetReplicaNo();
0159 }
0160
0161 inline
0162 EVolume G4NavigationHistory::GetVolumeType(G4int n) const
0163 {
0164 return (*fNavHistory)[n].GetVolumeType();
0165 }
0166
0167 inline
0168 G4VPhysicalVolume* G4NavigationHistory::GetVolume(G4int n) const
0169 {
0170 return (*fNavHistory)[n].GetPhysicalVolume();
0171 }
0172
0173 inline
0174 std::size_t G4NavigationHistory::GetMaxDepth() const
0175 {
0176 return fNavHistory->size();
0177 }
0178
0179 inline
0180 void G4NavigationHistory::BackLevel()
0181 {
0182 assert( fStackDepth>0 );
0183
0184
0185
0186
0187 --fStackDepth;
0188 }
0189
0190 inline
0191 void G4NavigationHistory::BackLevel(G4int n)
0192 {
0193 assert( n<=G4int(fStackDepth) );
0194 fStackDepth-=n;
0195 }
0196
0197 inline
0198 void G4NavigationHistory::EnlargeHistory()
0199 {
0200 std::size_t len = fNavHistory->size();
0201 if ( len == fStackDepth )
0202 {
0203
0204
0205 std::size_t nlen = len+kHistoryStride;
0206 fNavHistory->resize(nlen);
0207 }
0208 }
0209
0210
0211 inline
0212 void G4NavigationHistory::NewLevel( G4VPhysicalVolume* pNewMother,
0213 EVolume vType,
0214 G4int nReplica )
0215 {
0216 ++fStackDepth;
0217 EnlargeHistory();
0218 (*fNavHistory)[fStackDepth] =
0219 G4NavigationLevel( pNewMother,
0220 (*fNavHistory)[fStackDepth-1].GetTransform(),
0221 G4AffineTransform(pNewMother->GetRotation(),
0222 pNewMother->GetTranslation()),
0223 vType,
0224 nReplica );
0225
0226 }