729{
734
735 static G4int sNavCScalls=0;
736 sNavCScalls++;
737
738 fLastTriedStepComputation= true;
739
740#ifdef G4VERBOSE
742 {
743 G4cout <<
"*** G4ITNavigator::ComputeStep: ***" <<
G4endl;
745 << " - Proposed step length = " << pCurrentProposedStepLength
747#ifdef G4DEBUG_NAVIGATION
749 {
751 <<
" Globalpoint = " << std::setw(25) << pGlobalpoint <<
G4endl
752 <<
" Direction = " << std::setw(25) << pDirection <<
G4endl;
755 }
756#endif
757 }
758#endif
759
761 if( newLocalPoint != fLastLocatedPointLocal )
762 {
763
764
766 G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
767
769 {
770#ifdef G4VERBOSE
771 ComputeStepLog(pGlobalpoint, moveLenSq);
772#endif
773
774
776 fLastTriedStepComputation= true;
777 }
778 }
780 {
782 {
785 {
786 Step = fvoxelNav.
ComputeStep(fLastLocatedPointLocal,
787 localDirection,
788 pCurrentProposedStepLength,
789 pNewSafety,
791 fValidExitNormal,
792 fExitNormal,
793 fExiting,
794 fEntering,
795 &fBlockedPhysicalVolume,
796 fBlockedReplicaNo);
797
798 }
799 else
800 {
802 {
803 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
804 localDirection,
805 pCurrentProposedStepLength,
806 pNewSafety,
808 fValidExitNormal,
809 fExitNormal,
810 fExiting,
811 fEntering,
812 &fBlockedPhysicalVolume,
813 fBlockedReplicaNo);
814 }
815 else
816 {
818 fLastTriedStepComputation= true;
819
820
821
822
823
824
825
826
827
828
830 {
833 "Point is relocated in voxels, while it should be outside!");
834 Step = fnormalNav.
ComputeStep(fLastLocatedPointLocal,
835 localDirection,
836 pCurrentProposedStepLength,
837 pNewSafety,
839 fValidExitNormal,
840 fExitNormal,
841 fExiting,
842 fEntering,
843 &fBlockedPhysicalVolume,
844 fBlockedReplicaNo);
845 }
846 else
847 {
848 Step = fregularNav.
849 ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
850 localDirection,
851 pCurrentProposedStepLength,
852 pNewSafety,
854 fValidExitNormal,
855 fExitNormal,
856 fExiting,
857 fEntering,
858 &fBlockedPhysicalVolume,
859 fBlockedReplicaNo,
860 motherPhysical);
861 }
862 }
863 }
864 break;
867 {
868 Step = fparamNav.
ComputeStep(fLastLocatedPointLocal,
869 localDirection,
870 pCurrentProposedStepLength,
871 pNewSafety,
873 fValidExitNormal,
874 fExitNormal,
875 fExiting,
876 fEntering,
877 &fBlockedPhysicalVolume,
878 fBlockedReplicaNo);
879 }
880 else
881 {
882 Step = fregularNav.
ComputeStep(fLastLocatedPointLocal,
883 localDirection,
884 pCurrentProposedStepLength,
885 pNewSafety,
887 fValidExitNormal,
888 fExitNormal,
889 fExiting,
890 fEntering,
891 &fBlockedPhysicalVolume,
892 fBlockedReplicaNo);
893 }
894 break;
896 G4Exception(
"G4ITNavigator::ComputeStep()",
"GeomNav0001",
898 break;
899 }
900 }
901 else
902 {
903
904
905
907 G4bool calculatedExitNormal=
false;
908
910 pDirection,
911 fLastLocatedPointLocal,
912 localDirection,
913 pCurrentProposedStepLength,
914 pNewSafety,
916 fValidExitNormal,
917 calculatedExitNormal,
918 fExitNormal,
919 exitingReplica,
920 fEntering,
921 &fBlockedPhysicalVolume,
922 fBlockedReplicaNo);
923 fExiting= exitingReplica;
924 }
925
926
927
928 fPreviousSftOrigin = pGlobalpoint;
929 fPreviousSafety = pNewSafety;
930
931
932
933
934
935
936
937
938
939
940
941 fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
942 fLastStepWasZero = (Step==0.0);
943 if (fPushed) fPushed = fLastStepWasZero;
944
945
946
947 if ( fLastStepWasZero )
948 {
949 fNumberZeroSteps++;
950#ifdef G4DEBUG_NAVIGATION
951 if( fNumberZeroSteps > 1 )
952 {
953 G4cout <<
"G4ITNavigator::ComputeStep(): another zero step, # "
954 << fNumberZeroSteps
955 << " at " << pGlobalpoint
956 <<
" in volume " << motherPhysical->
GetName()
957 << " nav-comp-step calls # " << sNavCScalls
959 }
960#endif
961 if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
962 {
963
964
966#ifdef G4VERBOSE
967 if ((!fPushed) && (fWarnPush))
968 {
969 std::ostringstream message;
970 message <<
"Track stuck or not moving." <<
G4endl
971 << " Track stuck, not moving for "
972 << fNumberZeroSteps <<
" steps" <<
G4endl
973 <<
" in volume -" << motherPhysical->
GetName()
974 <<
"- at point " << pGlobalpoint <<
G4endl
975 <<
" direction: " << pDirection <<
"." <<
G4endl
976 << " Potential geometry or navigation problem !"
978 << " Trying pushing it of " << Step << " mm ...";
979 G4Exception(
"G4ITNavigator::ComputeStep()",
"GeomNav1002",
980 JustWarning, message,
"Potential overlap in geometry!");
981 }
982#endif
983 fPushed = true;
984 }
985 if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
986 {
987
988
989 std::ostringstream message;
990 message << "Stuck Track: potential geometry or navigation problem."
992 << " Track stuck, not moving for "
993 << fNumberZeroSteps <<
" steps" <<
G4endl
994 <<
" in volume -" << motherPhysical->
GetName()
995 <<
"- at point " << pGlobalpoint <<
G4endl
996 << " direction: " << pDirection << ".";
998 G4Exception(
"G4ITNavigator::ComputeStep()",
"GeomNav0003",
1000 }
1001 }
1002 else
1003 {
1004 if (!fPushed) fNumberZeroSteps = 0;
1005 }
1006
1009
1012
1013 if( fExiting )
1014 {
1015#ifdef G4DEBUG_NAVIGATION
1017 {
1018 G4cout <<
" At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1019 <<
" fValidExitNormal = " << fValidExitNormal <<
G4endl;
1021 }
1022#endif
1023
1024 if(fValidExitNormal)
1025 {
1026
1027
1028 fGrandMotherExitNormal= fExitNormal;
1029 }
1030 else
1031 {
1032
1033
1035 fLastLocatedPointLocal + localDirection*Step;
1036
1037
1038
1039 fGrandMotherExitNormal =
1041
1043 if( mRot )
1044 {
1045 fGrandMotherExitNormal *= (*mRot).inverse();
1046 }
1047
1048 }
1049 }
1051
1052 if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1053 {
1054
1055
1056
1057 Step = kInfinity;
1058 }
1059
1060#ifdef G4VERBOSE
1062 {
1064 {
1067 }
1069 if( Step == kInfinity )
1070 {
1071 G4cout <<
" Original proposed step = "
1072 << pCurrentProposedStepLength <<
G4endl;
1073 }
1075 }
1076#endif
1077
1078 return Step;
1079}
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4VSolid * GetSolid() const
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)
const G4RotationMatrix * GetRotation() const
virtual G4int GetRegularStructureId() const =0
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true)
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)