00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 inline
00039 G4SmartVoxelNode*
00040 G4VoxelNavigation::VoxelLocate( G4SmartVoxelHeader* pHead,
00041 const G4ThreeVector& localPoint )
00042 {
00043 G4SmartVoxelHeader *targetVoxelHeader=pHead;
00044 G4SmartVoxelNode *targetVoxelNode=0;
00045 G4SmartVoxelProxy *sampleProxy;
00046 EAxis targetHeaderAxis;
00047 G4double targetHeaderMin, targetHeaderNodeWidth;
00048 G4int targetHeaderNoSlices, targetNodeNo;
00049
00050 fVoxelDepth = 0;
00051
00052 while ( !targetVoxelNode )
00053 {
00054 targetHeaderAxis = targetVoxelHeader->GetAxis();
00055 targetHeaderNoSlices = targetVoxelHeader->GetNoSlices();
00056 targetHeaderMin = targetVoxelHeader->GetMinExtent();
00057 targetHeaderNodeWidth = (targetVoxelHeader->GetMaxExtent()-targetHeaderMin)
00058 / targetHeaderNoSlices;
00059 targetNodeNo = G4int( (localPoint(targetHeaderAxis)-targetHeaderMin)
00060 / targetHeaderNodeWidth);
00061
00062
00063 if ( targetNodeNo<0 )
00064 {
00065 targetNodeNo = 0;
00066 }
00067 else if ( targetNodeNo>=targetHeaderNoSlices )
00068 {
00069 targetNodeNo = targetHeaderNoSlices-1;
00070 }
00071
00072
00073 fVoxelAxisStack[fVoxelDepth] = targetHeaderAxis;
00074 fVoxelNoSlicesStack[fVoxelDepth] = targetHeaderNoSlices;
00075 fVoxelSliceWidthStack[fVoxelDepth] = targetHeaderNodeWidth;
00076 fVoxelNodeNoStack[fVoxelDepth] = targetNodeNo;
00077 fVoxelHeaderStack[fVoxelDepth] = targetVoxelHeader;
00078 sampleProxy = targetVoxelHeader->GetSlice(targetNodeNo);
00079
00080 if ( sampleProxy->IsNode() )
00081 {
00082 targetVoxelNode = sampleProxy->GetNode();
00083 }
00084 else
00085 {
00086 targetVoxelHeader = sampleProxy->GetHeader();
00087 fVoxelDepth++;
00088 }
00089 }
00090 fVoxelNode = targetVoxelNode;
00091 return targetVoxelNode;
00092 }
00093
00094
00095
00096
00097
00098 inline
00099 G4bool
00100 G4VoxelNavigation::LevelLocate( G4NavigationHistory& history,
00101 const G4VPhysicalVolume* blockedVol,
00102 const G4int,
00103 const G4ThreeVector& globalPoint,
00104 const G4ThreeVector* globalDirection,
00105 const G4bool pLocatedOnEdge,
00106 G4ThreeVector& localPoint )
00107 {
00108 G4SmartVoxelHeader *targetVoxelHeader;
00109 G4SmartVoxelNode *targetVoxelNode;
00110 G4VPhysicalVolume *targetPhysical, *samplePhysical;
00111 G4LogicalVolume *targetLogical;
00112 G4VSolid *sampleSolid;
00113 G4ThreeVector samplePoint;
00114 G4int targetNoDaughters;
00115
00116 targetPhysical = history.GetTopVolume();
00117 targetLogical = targetPhysical->GetLogicalVolume();
00118 targetVoxelHeader = targetLogical->GetVoxelHeader();
00119
00120
00121
00122 targetVoxelNode = VoxelLocate(targetVoxelHeader,localPoint);
00123
00124 targetNoDaughters=targetVoxelNode->GetNoContained();
00125 if ( targetNoDaughters==0 ) return false;
00126
00127
00128
00129
00130
00131 for ( register int sampleNo=targetNoDaughters-1; sampleNo>=0; sampleNo-- )
00132 {
00133 samplePhysical = targetLogical->
00134 GetDaughter(targetVoxelNode->GetVolume(sampleNo));
00135 if ( samplePhysical!=blockedVol )
00136 {
00137
00138
00139 history.NewLevel(samplePhysical, kNormal, samplePhysical->GetCopyNo());
00140 sampleSolid = samplePhysical->GetLogicalVolume()->GetSolid();
00141 samplePoint = history.GetTopTransform().TransformPoint(globalPoint);
00142
00143 if( G4AuxiliaryNavServices::CheckPointOnSurface(sampleSolid,
00144 samplePoint,
00145 globalDirection,
00146 history.GetTopTransform(),
00147 pLocatedOnEdge) )
00148 {
00149
00150
00151 localPoint = samplePoint;
00152 return true;
00153 }
00154 else
00155 {
00156 history.BackLevel();
00157 }
00158 }
00159 }
00160 return false;
00161 }
00162
00163
00164
00165
00166
00167 inline
00168 G4int G4VoxelNavigation::GetVerboseLevel() const
00169 {
00170 return fLogger->GetVerboseLevel();
00171 }
00172
00173
00174
00175
00176
00177 inline
00178 void G4VoxelNavigation::CheckMode(G4bool mode)
00179 {
00180 fCheck = mode;
00181 }
00182
00183
00184
00185
00186
00187 inline
00188 void G4VoxelNavigation::EnableBestSafety(G4bool flag)
00189 {
00190 fBestSafety = flag;
00191 }