760{
761#ifdef G4DEBUG_NAVIGATION
763 ++sNavCScalls;
764#endif
765
770
771
772
774
775 fChangedGrandMotherRefFrame = false;
776
778 fCalculatedExitNormal = false;
779
780
781#ifdef G4VERBOSE
783 {
784 G4cout <<
"*** G4Navigator::ComputeStep: ***" <<
G4endl;
786 << " - Proposed step length = " << pCurrentProposedStepLength
788#ifdef G4DEBUG_NAVIGATION
790 {
792 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
793 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
795 {
798 }
799 }
800#endif
801 }
802#endif
803
805
806 if( newLocalPoint != fLastLocatedPointLocal )
807 {
808
809
811 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
812
813 if ( moveLenSq >=
fSqTol )
814 {
815#ifdef G4VERBOSE
816 ComputeStepLog(pGlobalpoint, moveLenSq);
817#endif
818
819
821 }
822 }
824 {
826 {
829 {
830 Step = GetVoxelNavigator().
ComputeStep(fLastLocatedPointLocal,
831 localDirection,
832 pCurrentProposedStepLength,
833 pNewSafety,
835 fValidExitNormal,
836 fExitNormal,
837 fExiting,
838 fEntering,
839 &fBlockedPhysicalVolume,
840 fBlockedReplicaNo);
841
842 }
843 else
844 {
846 {
847 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
848 localDirection,
849 pCurrentProposedStepLength,
850 pNewSafety,
852 fValidExitNormal,
853 fExitNormal,
854 fExiting,
855 fEntering,
856 &fBlockedPhysicalVolume,
857 fBlockedReplicaNo);
858 }
859 else
860 {
862
863
864
865
866
867
868
869
870
871
873 {
876 "Point is relocated in voxels, while it should be outside!");
877 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
878 localDirection,
879 pCurrentProposedStepLength,
880 pNewSafety,
882 fValidExitNormal,
883 fExitNormal,
884 fExiting,
885 fEntering,
886 &fBlockedPhysicalVolume,
887 fBlockedReplicaNo);
888 }
889 else
890 {
891 Step = fregularNav.
892 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
893 localDirection,
894 pCurrentProposedStepLength,
895 pNewSafety,
897 fValidExitNormal,
898 fExitNormal,
899 fExiting,
900 fEntering,
901 &fBlockedPhysicalVolume,
902 fBlockedReplicaNo,
903 motherPhysical);
904 }
905 }
906 }
907 break;
910 {
911 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
912 localDirection,
913 pCurrentProposedStepLength,
914 pNewSafety,
916 fValidExitNormal,
917 fExitNormal,
918 fExiting,
919 fEntering,
920 &fBlockedPhysicalVolume,
921 fBlockedReplicaNo);
922 }
923 else
924 {
925 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
926 localDirection,
927 pCurrentProposedStepLength,
928 pNewSafety,
930 fValidExitNormal,
931 fExitNormal,
932 fExiting,
933 fEntering,
934 &fBlockedPhysicalVolume,
935 fBlockedReplicaNo);
936 }
937 break;
939 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0001",
941 break;
943 Step = fpExternalNav->
ComputeStep(fLastLocatedPointLocal,
944 localDirection,
945 pCurrentProposedStepLength,
946 pNewSafety,
948 fValidExitNormal,
949 fExitNormal,
950 fExiting,
951 fEntering,
952 &fBlockedPhysicalVolume,
953 fBlockedReplicaNo);
954 break;
955 }
956 }
957 else
958 {
959
960
961
964 pDirection,
965 fLastLocatedPointLocal,
966 localDirection,
967 pCurrentProposedStepLength,
968 pNewSafety,
970 fValidExitNormal,
971 fCalculatedExitNormal,
972 fExitNormal,
973 fExiting,
974 fEntering,
975 &fBlockedPhysicalVolume,
976 fBlockedReplicaNo);
977 }
978
979
980
981 fPreviousSftOrigin = pGlobalpoint;
982 fPreviousSafety = pNewSafety;
983
984
985
986
987
988
989
990
991
992
993
994 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
997
998
999
1000 if ( fLastStepWasZero )
1001 {
1002 ++fNumberZeroSteps;
1003
1004 G4bool act = fNumberZeroSteps >= fActionThreshold_NoZeroSteps;
1005 G4bool actAndReport =
false;
1006 G4bool abandon = fNumberZeroSteps >= fAbandonThreshold_NoZeroSteps;
1008#ifdef G4VERBOSE
1009 actAndReport = act && (!fPushed) && fWarnPush;
1010#endif
1011#ifdef G4DEBUG_NAVIGATION
1012 inform = fNumberZeroSteps > 1;
1013#endif
1014
1015 if ( act || inform )
1016 {
1017 if( act && !abandon )
1018 {
1019
1020
1022 fPushed = true;
1023 }
1024
1025 if( actAndReport || abandon || inform )
1026 {
1027 std::ostringstream message;
1028
1029 message.precision(16);
1030 message << "Stuck Track: potential geometry or navigation problem."
1032 message << " Track stuck, not moving for "
1033 << fNumberZeroSteps <<
" steps." <<
G4endl
1034 <<
" Current phys volume: '" << motherPhysical->
GetName()
1036 <<
" - at position : " << pGlobalpoint <<
G4endl
1037 <<
" in direction: " << pDirection <<
G4endl
1038 <<
" (local position: " << newLocalPoint <<
")" <<
G4endl
1039 <<
" (local direction: " << localDirection <<
")." <<
G4endl
1040 << " Previous phys volume: '"
1041 << ( fLastMotherPhys ? fLastMotherPhys->
GetName() :
"" )
1043 if( actAndReport || abandon )
1044 {
1045 message << " Likely geometry overlap - else navigation problem !"
1047 }
1048 if( abandon )
1049 {
1050
1051#ifdef G4VERBOSE
1053#endif
1054 message << " Track *abandoned* due to excessive number of Zero steps."
1056 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1058 }
1059 else
1060 {
1061#ifdef G4VERBOSE
1062 if ( actAndReport )
1063 {
1064 message << " *** Trying to get *unstuck* using a push"
1065 << " - expanding step to " << Step << " (mm) ..."
1066 <<
" Potential overlap in geometry !" <<
G4endl;
1067 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav1002",
1069 }
1070#endif
1071#ifdef G4DEBUG_NAVIGATION
1072 else
1073 {
1074 if( fNumberZeroSteps > 1 )
1075 {
1076 message << ", nav-comp-step calls # " << sNavCScalls
1077 <<
", Step= " << Step <<
G4endl;
1079 }
1080 }
1081#endif
1082 }
1083 }
1084 }
1085 }
1086 else
1087 {
1088 if (!fPushed) { fNumberZeroSteps = 0; }
1089 }
1090 fLastMotherPhys = motherPhysical;
1091
1094
1096 + std::min(Step,pCurrentProposedStepLength) * pDirection;
1098
1099 if( fExiting )
1100 {
1101#ifdef G4DEBUG_NAVIGATION
1103 {
1104 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1105 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1107 }
1108#endif
1109
1110 if ( fValidExitNormal || fCalculatedExitNormal )
1111 {
1112
1113 fGrandMotherExitNormal = fExitNormal;
1114 }
1115 else
1116 {
1117
1118
1120 + localDirection*Step;
1121
1123 {
1124
1125
1128
1129
1130
1132 if( mRot )
1133 {
1134 fChangedGrandMotherRefFrame = true;
1135 fGrandMotherExitNormal = (*mRot).inverse() * exitNormalMotherFrame;
1136 }
1137 else
1138 {
1139 fGrandMotherExitNormal = exitNormalMotherFrame;
1140 }
1141
1142
1143
1144 }
1145 else
1146 {
1147 fCalculatedExitNormal = false;
1148
1149
1150
1151
1152
1153
1154#ifdef G4DEBUG_NAVIGATION
1156
1157 desc << "Problem in ComputeStep: Replica Navigation did not provide"
1158 <<
" valid exit Normal. " <<
G4endl;
1159 desc <<
" Do not know how calculate it in this case." <<
G4endl;
1160 desc <<
" Location = " << finalLocalPoint <<
G4endl;
1161 desc <<
" Volume name = " << motherPhysical->
GetName()
1163 G4Exception(
"G4Navigator::ComputeStep()",
"GeomNav0003",
1164 JustWarning, desc,
"Normal not available for exiting.");
1165#endif
1166 }
1167 }
1168
1170 fCalculatedExitNormal = true;
1171
1172
1173
1174 if( fValidExitNormal || fCalculatedExitNormal )
1175 {
1177 if( depth > 0 )
1178 {
1181 }
1182 else
1183 {
1184 fExitNormalGlobalFrame = fGrandMotherExitNormal;
1185 }
1186 }
1187 else
1188 {
1190 }
1191 }
1192
1193 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1194 {
1195
1196
1197
1198 Step = kInfinity;
1199 }
1200
1201#ifdef G4VERBOSE
1203 {
1205 {
1208 }
1209 G4cout <<
" Returned step= " << Step;
1211 if( Step == kInfinity )
1212 {
1213 G4cout <<
" Requested step= " << pCurrentProposedStepLength ;
1215 }
1217 }
1218#endif
1219
1220 fLastTriedStepComputation = true;
1221
1222 return Step;
1223}
std::ostringstream G4ExceptionDescription
G4VSolid * GetSolid() const
std::size_t GetDepth() const
const G4AffineTransform & GetTransform(G4int n) const
G4bool CheckOverlapsIterative(G4VPhysicalVolume *vol)
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4double ComputeStep(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4bool &calculatedExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
virtual G4double ComputeStep(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume **pBlockedPhysical, G4int &blockedReplicaNo)=0
const G4RotationMatrix * GetRotation() const
virtual G4int GetCopyNo() const =0
virtual G4int GetRegularStructureId() const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)