| 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| 27 | // $Id: G4VIntersectionLocator.icc,v 1.3 2008/11/14 18:26:35 gcosmo Exp $
|
|---|
| 28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // Class G4VIntersectionLocator inline methods
|
|---|
| 32 | //
|
|---|
| 33 | // 27.10.07 - John Apostolakis, Tatiana Nikitina
|
|---|
| 34 | // ---------------------------------------------------------------------------
|
|---|
| 35 |
|
|---|
| 36 | inline G4double G4VIntersectionLocator::GetDeltaIntersectionFor()
|
|---|
| 37 | {
|
|---|
| 38 | return fiDeltaIntersection;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | inline G4double G4VIntersectionLocator::GetEpsilonStepFor()
|
|---|
| 42 | {
|
|---|
| 43 | return fiEpsilonStep;
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | inline G4Navigator* G4VIntersectionLocator::GetNavigatorFor()
|
|---|
| 47 | {
|
|---|
| 48 | return fiNavigator;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | inline G4ChordFinder* G4VIntersectionLocator::GetChordFinderFor()
|
|---|
| 52 | {
|
|---|
| 53 | return fiChordFinder;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | inline G4int G4VIntersectionLocator::GetVerboseFor()
|
|---|
| 57 | {
|
|---|
| 58 | return fVerboseLevel;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | inline G4bool G4VIntersectionLocator::GetAdjustementOfFoundIntersection()
|
|---|
| 62 | {
|
|---|
| 63 | return fUseNormalCorrection;
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | inline void G4VIntersectionLocator::
|
|---|
| 67 | AddAdjustementOfFoundIntersection(G4bool UseCorrection )
|
|---|
| 68 | {
|
|---|
| 69 | fUseNormalCorrection=UseCorrection;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | inline void G4VIntersectionLocator::SetEpsilonStepFor( G4double EpsilonStep )
|
|---|
| 73 | {
|
|---|
| 74 | fiEpsilonStep=EpsilonStep;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | inline void G4VIntersectionLocator::
|
|---|
| 78 | SetDeltaIntersectionFor( G4double deltaIntersection )
|
|---|
| 79 | {
|
|---|
| 80 | fiDeltaIntersection=deltaIntersection;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | inline void G4VIntersectionLocator::SetNavigatorFor( G4Navigator *fNavigator )
|
|---|
| 84 | {
|
|---|
| 85 | fiNavigator=fNavigator;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | inline void G4VIntersectionLocator::SetChordFinderFor(G4ChordFinder *fCFinder )
|
|---|
| 89 | {
|
|---|
| 90 | fiChordFinder=fCFinder;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | inline void G4VIntersectionLocator::SetSafetyParametersFor(G4bool UseSafety )
|
|---|
| 94 | {
|
|---|
| 95 | fiUseSafety=UseSafety;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | inline void G4VIntersectionLocator::SetVerboseFor(G4int fVerbose)
|
|---|
| 99 | {
|
|---|
| 100 | fVerboseLevel=fVerbose;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | inline G4bool
|
|---|
| 104 | G4VIntersectionLocator::IntersectChord( G4ThreeVector StartPointA,
|
|---|
| 105 | G4ThreeVector EndPointB,
|
|---|
| 106 | G4double &NewSafety,
|
|---|
| 107 | G4double &fPreviousSafety,
|
|---|
| 108 | G4ThreeVector &fPreviousSftOrigin,
|
|---|
| 109 | G4double &LinearStepLength,
|
|---|
| 110 | G4ThreeVector &IntersectionPoint )
|
|---|
| 111 | {
|
|---|
| 112 | // Calculate the direction and length of the chord AB
|
|---|
| 113 |
|
|---|
| 114 | G4ThreeVector ChordAB_Vector = EndPointB - StartPointA;
|
|---|
| 115 | G4double ChordAB_Length = ChordAB_Vector.mag(); // Magnitude (norm)
|
|---|
| 116 | G4ThreeVector ChordAB_Dir = ChordAB_Vector.unit();
|
|---|
| 117 | G4bool intersects;
|
|---|
| 118 | G4ThreeVector OriginShift = StartPointA - fPreviousSftOrigin ;
|
|---|
| 119 | G4double MagSqShift = OriginShift.mag2() ;
|
|---|
| 120 | G4double currentSafety;
|
|---|
| 121 | G4bool doCallNav= false;
|
|---|
| 122 |
|
|---|
| 123 | if( MagSqShift >= sqr(fPreviousSafety) )
|
|---|
| 124 | {
|
|---|
| 125 | currentSafety = 0.0 ;
|
|---|
| 126 | }
|
|---|
| 127 | else
|
|---|
| 128 | {
|
|---|
| 129 | currentSafety = fPreviousSafety - std::sqrt(MagSqShift) ;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | if( fiUseSafety && (ChordAB_Length <= currentSafety) )
|
|---|
| 133 | {
|
|---|
| 134 | // The Step is guaranteed to be taken
|
|---|
| 135 |
|
|---|
| 136 | LinearStepLength = ChordAB_Length;
|
|---|
| 137 | intersects = false;
|
|---|
| 138 | NewSafety= currentSafety;
|
|---|
| 139 | }
|
|---|
| 140 | else
|
|---|
| 141 | {
|
|---|
| 142 | doCallNav= true;
|
|---|
| 143 | // Check whether any volumes are encountered by the chord AB
|
|---|
| 144 |
|
|---|
| 145 | LinearStepLength = GetNavigatorFor()->ComputeStep( StartPointA,
|
|---|
| 146 | ChordAB_Dir, ChordAB_Length, NewSafety );
|
|---|
| 147 | intersects = (LinearStepLength <= ChordAB_Length);
|
|---|
| 148 |
|
|---|
| 149 | // G4Navigator contracts to return k_infinity if len==asked
|
|---|
| 150 | // and it did not find a surface boundary at that length
|
|---|
| 151 |
|
|---|
| 152 | LinearStepLength = std::min( LinearStepLength, ChordAB_Length);
|
|---|
| 153 |
|
|---|
| 154 | // Save the last calculated safety!
|
|---|
| 155 |
|
|---|
| 156 | fPreviousSftOrigin = StartPointA;
|
|---|
| 157 | fPreviousSafety= NewSafety;
|
|---|
| 158 |
|
|---|
| 159 | if( intersects )
|
|---|
| 160 | {
|
|---|
| 161 | // Intersection Point of chord AB and either volume A's surface
|
|---|
| 162 | // or a daughter volume's surface ..
|
|---|
| 163 | IntersectionPoint = StartPointA + LinearStepLength * ChordAB_Dir;
|
|---|
| 164 | }
|
|---|
| 165 | }
|
|---|
| 166 | return intersects;
|
|---|
| 167 | }
|
|---|