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