G4NavigationHistory.icc

Go to the documentation of this file.
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 //
00030 // class G4NavigationHistory Inline implementation
00031 //
00032 // ----------------------------------------------------------------------
00033 
00034 inline
00035 G4NavigationHistory&
00036 G4NavigationHistory::operator=(const G4NavigationHistory &h)
00037 {
00038   if (&h == this)  { return *this; }
00039 
00040   // fNavHistory=h.fNavHistory;   // This works, but is very slow.
00041 
00042   if( this->GetMaxDepth() < h.fStackDepth )
00043   {
00044     fNavHistory.resize( h.fStackDepth ); 
00045   }
00046   for ( register G4int ilev=h.fStackDepth; ilev>=0; ilev-- )
00047   { 
00048     fNavHistory[ilev] = h.fNavHistory[ilev]; 
00049   } 
00050   fStackDepth=h.fStackDepth;
00051 
00052   return *this;
00053 }
00054 
00055 inline
00056 void G4NavigationHistory::Reset()
00057 {
00058   fStackDepth=0;
00059 }
00060 
00061 inline
00062 void G4NavigationHistory::Clear()
00063 {
00064   G4AffineTransform origin(G4ThreeVector(0.,0.,0.));
00065   G4NavigationLevel tmpNavLevel = G4NavigationLevel(0, origin, kNormal, -1) ;
00066 
00067   Reset();
00068   for (register G4int ilev=fNavHistory.size()-1; ilev>=0; ilev--)
00069   {
00070      fNavHistory[ilev] = tmpNavLevel;
00071   }
00072 }
00073 
00074 inline
00075 void G4NavigationHistory::SetFirstEntry(G4VPhysicalVolume* pVol)
00076 {
00077   G4ThreeVector translation(0.,0.,0.);
00078   G4int copyNo = -1;
00079 
00080   // Protection needed in case pVol=null 
00081   // so that a touchable-history can signal OutOfWorld 
00082   //
00083   if( pVol!=0 )
00084   {
00085     translation = pVol->GetTranslation();
00086     copyNo = pVol->GetCopyNo();
00087   }
00088   fNavHistory[0] =
00089     G4NavigationLevel( pVol, G4AffineTransform(translation), kNormal, copyNo );
00090 }
00091 
00092 inline
00093 const G4AffineTransform* G4NavigationHistory::GetPtrTopTransform() const
00094 {
00095   return fNavHistory[fStackDepth].GetPtrTransform();
00096 }
00097 
00098 inline
00099 const G4AffineTransform& G4NavigationHistory::GetTopTransform() const
00100 {
00101   return fNavHistory[fStackDepth].GetTransform();
00102 }
00103 
00104 inline
00105 G4int G4NavigationHistory::GetTopReplicaNo() const
00106 {
00107   return fNavHistory[fStackDepth].GetReplicaNo();
00108 }
00109 
00110 inline
00111 EVolume G4NavigationHistory::GetTopVolumeType() const
00112 {
00113   return fNavHistory[fStackDepth].GetVolumeType();
00114 }
00115 
00116 inline
00117 G4VPhysicalVolume* G4NavigationHistory::GetTopVolume() const
00118 {
00119   return fNavHistory[fStackDepth].GetPhysicalVolume();
00120 }
00121 
00122 inline
00123 G4int G4NavigationHistory::GetDepth() const
00124 {
00125   return fStackDepth;
00126 }
00127 
00128 inline
00129 const G4AffineTransform&
00130 G4NavigationHistory::GetTransform(G4int n) const
00131 {
00132   return fNavHistory[n].GetTransform();
00133 }
00134 
00135 inline
00136 G4int G4NavigationHistory::GetReplicaNo(G4int n) const
00137 {
00138   return fNavHistory[n].GetReplicaNo();
00139 }
00140 
00141 inline
00142 EVolume G4NavigationHistory::GetVolumeType(G4int n) const
00143 {
00144   return fNavHistory[n].GetVolumeType();
00145 }
00146 
00147 inline
00148 G4VPhysicalVolume* G4NavigationHistory::GetVolume(G4int n) const
00149 {
00150   return fNavHistory[n].GetPhysicalVolume();
00151 }
00152 
00153 inline
00154 G4int G4NavigationHistory::GetMaxDepth() const
00155 {
00156   return fNavHistory.size();
00157 }
00158 
00159 inline
00160 void G4NavigationHistory::BackLevel()
00161 {
00162   assert( fStackDepth>0 );
00163 
00164   // Tell  the  level  that I am forgetting it
00165   // delete fNavHistory(fStackDepth);
00166   //
00167   fStackDepth--;
00168 }
00169 
00170 inline
00171 void G4NavigationHistory::BackLevel(G4int n)
00172 {
00173   assert( n<=fStackDepth );
00174   fStackDepth-=n;
00175 }
00176 
00177 inline
00178 void G4NavigationHistory::EnlargeHistory()
00179 {
00180   G4int len = fNavHistory.size();
00181   if ( len==fStackDepth )
00182   {
00183     // Note: Resize operation clears additional entries
00184     //
00185     G4int nlen = len+kHistoryStride;
00186     fNavHistory.resize(nlen);
00187   }  
00188 }
00189 
00190 
00191 inline
00192 void G4NavigationHistory::NewLevel( G4VPhysicalVolume *pNewMother,
00193                                     EVolume vType,
00194                                     G4int nReplica )
00195 {
00196   fStackDepth++;
00197   EnlargeHistory();  // Enlarge if required
00198   fNavHistory[fStackDepth] =
00199     G4NavigationLevel( pNewMother, 
00200                        fNavHistory[fStackDepth-1].GetTransform(),
00201                        G4AffineTransform(pNewMother->GetRotation(),
00202                        pNewMother->GetTranslation()),
00203                        vType,
00204                        nReplica ); 
00205   // The constructor computes the new global->local transform
00206 }

Generated on Mon May 27 17:48:56 2013 for Geant4 by  doxygen 1.4.7