G4VIntersectionLocator.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 G4VIntersectionLocator inline methods
00031 //
00032 // 27.10.07 - John Apostolakis, Tatiana Nikitina
00033 // ---------------------------------------------------------------------------
00034 
00035 inline G4double G4VIntersectionLocator::GetDeltaIntersectionFor()
00036 {
00037   return fiDeltaIntersection;
00038 } 
00039 
00040 inline G4double G4VIntersectionLocator::GetEpsilonStepFor()
00041 {
00042   return fiEpsilonStep;
00043 }
00044 
00045 inline G4Navigator* G4VIntersectionLocator::GetNavigatorFor()
00046 {
00047   return fiNavigator;
00048 }
00049 
00050 inline G4ChordFinder* G4VIntersectionLocator::GetChordFinderFor()
00051 {
00052   return fiChordFinder;
00053 }
00054 
00055 inline G4int G4VIntersectionLocator::GetVerboseFor()
00056 {
00057   return fVerboseLevel;
00058 }
00059 
00060 inline G4bool G4VIntersectionLocator::GetAdjustementOfFoundIntersection()
00061 {
00062   return fUseNormalCorrection;
00063 }
00064 
00065 inline void G4VIntersectionLocator::
00066 AddAdjustementOfFoundIntersection(G4bool UseCorrection )
00067 {
00068   fUseNormalCorrection=UseCorrection;
00069 }
00070 
00071 inline void G4VIntersectionLocator::SetEpsilonStepFor( G4double EpsilonStep )
00072 {
00073   fiEpsilonStep=EpsilonStep;
00074 }
00075 
00076 inline void G4VIntersectionLocator::
00077 SetDeltaIntersectionFor( G4double deltaIntersection )
00078 {
00079   fiDeltaIntersection=deltaIntersection;
00080 }
00081 
00082 inline void G4VIntersectionLocator::SetNavigatorFor( G4Navigator *fNavigator )
00083 {
00084   fiNavigator=fNavigator;
00085 }
00086 
00087 inline void G4VIntersectionLocator::SetChordFinderFor(G4ChordFinder *fCFinder )
00088 {
00089   fiChordFinder=fCFinder;
00090 }
00091 
00092 inline void G4VIntersectionLocator::SetSafetyParametersFor(G4bool UseSafety )
00093 {
00094   fiUseSafety=UseSafety;
00095 }
00096 
00097 inline void G4VIntersectionLocator::SetVerboseFor(G4int fVerbose)
00098 {
00099   fVerboseLevel=fVerbose;
00100 }
00101 
00102 inline G4bool
00103 G4VIntersectionLocator::IntersectChord( const G4ThreeVector&  StartPointA,
00104                                         const G4ThreeVector&  EndPointB,
00105                                         G4double      &NewSafety,
00106                                         G4double      &PreviousSafety,
00107                                         G4ThreeVector &PreviousSftOrigin,
00108                                         G4double      &LinearStepLength,
00109                                         G4ThreeVector &IntersectionPoint,
00110                                         G4bool        *ptrCalledNavigator )
00111 {
00112   G4bool CalledNavigator = false; 
00113 
00114   // Calculate the direction and length of the chord AB
00115 
00116   G4ThreeVector  ChordAB_Vector = EndPointB - StartPointA;
00117   G4double       ChordAB_Length = ChordAB_Vector.mag();  // Magnitude (norm)
00118   G4ThreeVector  ChordAB_Dir =    ChordAB_Vector.unit();
00119   G4bool intersects;
00120   G4ThreeVector OriginShift = StartPointA -  PreviousSftOrigin ;
00121   G4double      MagSqShift  = OriginShift.mag2() ;
00122   G4double      currentSafety;
00123 
00124   if( MagSqShift >= sqr(PreviousSafety) )
00125   {
00126     currentSafety = 0.0 ;
00127   }
00128   else
00129   {
00130     currentSafety = PreviousSafety - std::sqrt(MagSqShift) ;
00131   }
00132 
00133   if( fiUseSafety && (ChordAB_Length <= currentSafety) )
00134   {
00135     // The Step is guaranteed to be taken
00136 
00137     LinearStepLength = ChordAB_Length;
00138     intersects = false;
00139     NewSafety= currentSafety;
00140     CalledNavigator= false;
00141     // G4cout << " IntersectChord> Step 'guaranteed' taken:  safety= " << currentSafety << " chordAB-len= " << ChordAB_Length << G4endl;
00142   }
00143   else
00144   {
00145     // G4cout << " IntersectChord> Step asking Navigator:    safety= " << currentSafety << " chordAB-len= " << ChordAB_Length << G4endl;
00146     
00147     // Check whether any volumes are encountered by the chord AB
00148 
00149     LinearStepLength = GetNavigatorFor()->ComputeStep( StartPointA,
00150                                  ChordAB_Dir, ChordAB_Length, NewSafety );
00151     intersects = (LinearStepLength <= ChordAB_Length); 
00152        // G4Navigator contracts to return k_infinity if len==asked
00153        // and it did not find a surface boundary at that length
00154     
00155     // G4cout << "G4VIntersectionLocator:  intersect= " << intersects
00156     //       << " step= " << LinearStepLength << " Chord length= " << ChordAB_Length;
00157 
00158     LinearStepLength = std::min( LinearStepLength, ChordAB_Length);
00159     CalledNavigator = true; 
00160 
00161     // Save the last calculated safety!
00162 
00163     PreviousSftOrigin = StartPointA;
00164     PreviousSafety    = NewSafety;
00165 
00166     if( intersects )
00167     {
00168        // Intersection Point of chord AB and either volume A's surface 
00169        //                                or a daughter volume's surface ..
00170        IntersectionPoint = StartPointA + LinearStepLength * ChordAB_Dir;
00171     }
00172   }
00173   if( ptrCalledNavigator )
00174   { 
00175     *ptrCalledNavigator = CalledNavigator; 
00176   }
00177 
00178   return intersects;
00179 }

Generated on Mon May 27 17:50:14 2013 for Geant4 by  doxygen 1.4.7