775 G4double ourStep=currentProposedStepLength;
777 G4double sampleStep, sampleSafety, motherStep, motherSafety;
778 G4int localNoDaughters, sampleNo;
783 calculatedExitNormal=
false;
787 if ( exiting&&validExitNormal )
793 blockedExitedVol = *pBlockedPhysical;
813 ourSafety =
std::min( ourSafety, sampleSafety);
815 if ( sampleSafety<ourStep )
823 if ( sampleStep<ourStep )
825 ourStep = sampleStep;
827 validExitNormal = normalOutStc.validConvex;
829 exitNormalStc= normalOutStc;
831 TransformAxis(normalOutStc.exitNormal);
832 calculatedExitNormal=
true;
835 const G4int secondDepth= topDepth;
848 if ( sampleSafety < ourSafety )
850 ourSafety = sampleSafety;
852 if ( sampleSafety < ourStep )
861 if ( sampleStep < ourStep )
863 ourStep = sampleStep;
872 exitNormalStc= normalOutStc;
874 calculatedExitNormal=
true;
887 motherPhysical = history.
GetVolume(depth);
892 motherStep = motherSolid->
DistanceToOut(repPoint,repDirection,
true,
893 &exitConvex,&exitVectorMother);
896 motherNormalStc =
G4ExitNormal( exitVectorMother,
true,
false,
898 calculatedExitNormal=
true;
902 G4bool motherDeterminedStep= (motherStep<ourStep);
904 if( (!exitConvex) && motherDeterminedStep )
907 motherNormalStc=
G4ExitNormal( exitVectorMother,
true,
false,
913 calculatedExitNormal=
true;
915 if( motherDeterminedStep)
920 exitNormalStc= motherNormalStc;
921 exitNormalStc.
exitNormal= globalExitNormalTop;
931 if ( ( (ourStep<fMinStep) && (sampleSafety<halfkCarTolerance) )
934 ourStep = 100*kCarTolerance;
937 if ( motherSafety<ourSafety )
939 ourSafety = motherSafety;
947 std::ostringstream message;
948 message <<
"Point outside volume !" <<
G4endl
949 <<
" Point " << localPoint
950 <<
" is outside current volume " << motherPhysical->
GetName()
953 message <<
" Estimated isotropic distance to solid (distToIn)= "
954 << estDistToSolid <<
G4endl;
955 if( estDistToSolid > 100.0 * kCarTolerance )
960 "Point is far outside Current Volume !" );
965 "Point is a little outside Current Volume.");
973 if( motherDeterminedStep)
975 ourStep = motherStep;
981 if ( calculatedExitNormal )
983 if ( motherDeterminedStep )
990 exitNormalVector= globalToLocalTop.
TransformAxis(exitNormalGlobal);
998 exitNormalVector *= rot->
inverse();
1004 validExitNormal =
false;
1008 if ( motherSafety<=ourStep )
1010 if ( motherStep<=ourStep )
1012 ourStep = motherStep;
1014 if ( validExitNormal )
1025 validExitNormal =
false;
1032 G4bool daughterDeterminedStep=
false;
1041 for ( sampleNo=localNoDaughters-1; sampleNo>=0; sampleNo-- )
1043 samplePhysical = repLogical->
GetDaughter(sampleNo);
1044 if ( samplePhysical!=blockedExitedVol )
1053 sampleTf.TransformPoint(localPoint);
1056 const G4double sampleSafetyDistance =
1058 if ( sampleSafetyDistance<ourSafety )
1060 ourSafety = sampleSafetyDistance;
1062 if ( sampleSafetyDistance<=ourStep )
1064 sampleDirection = sampleTf.TransformAxis(localDirection);
1065 const G4double sampleStepDistance =
1066 sampleSolid->
DistanceToIn(samplePoint,sampleDirection);
1067 if ( sampleStepDistance<=ourStep )
1069 daughterDeterminedStep=
true;
1071 ourStep = sampleStepDistance;
1074 *pBlockedPhysical = samplePhysical;
1075 blockedReplicaNo = sampleNo;
1077 #ifdef DAUGHTER_NORMAL_ALSO
1080 daughtNormRepCrd = sampleTf.Inverse().TransformAxis(localExitNorm);
1087 if ( ( fCheck ) && ( sampleStepDistance <
kInfinity ) )
1090 intersectionPoint= samplePoint
1091 + sampleStepDistance * sampleDirection;
1092 EInside insideIntPt= sampleSolid->
Inside(intersectionPoint);
1096 std::ostringstream message;
1097 message <<
"Navigator gets conflicting response from Solid."
1099 <<
" Inaccurate DistanceToIn for solid "
1100 << sampleSolid->
GetName() << G4endl
1101 <<
" Solid gave DistanceToIn = "
1102 << sampleStepDistance <<
" yet returns " ;
1104 message <<
"-kInside-";
1105 else if ( insideIntPt ==
kOutside )
1106 message <<
"-kOutside-";
1108 message <<
"-kSurface-";
1109 message <<
" for this point !" << G4endl
1110 <<
" Point = " << intersectionPoint <<
G4endl;
1112 message <<
" DistanceToIn(p) = "
1116 message <<
" DistanceToOut(p) = "
1120 G4cout.precision(oldcoutPrec);
1129 calculatedExitNormal &= (!daughterDeterminedStep);
1131 #ifdef DAUGHTER_NORMAL_ALSO
1132 if( daughterDeterminedStep )
1139 validExitNormal=
false;
1141 calculatedExitNormal=
true;
1146 newSafety = ourSafety;
G4VPhysicalVolume * GetTopVolume() const
static const G4double kInfinity
double dot(const Hep3Vector &) const
G4VSolid * GetSolid() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
const G4RotationMatrix * GetRotation() const
EVolume GetVolumeType(G4int n) const
G4double DistanceToOut(const G4VPhysicalVolume *pVol, const G4int replicaNo, const G4ThreeVector &localPoint) const
HepRotation inverse() const
G4int GetTopReplicaNo() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
G4int GetReplicaNo(G4int n) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
static const double kMinExitingNormalCosine
G4int GetNoDaughters() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
const G4ThreeVector & GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const
const G4AffineTransform & GetTransform(G4int n) const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
const G4AffineTransform & GetTopTransform() const
G4VPhysicalVolume * GetVolume(G4int n) const
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0