Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // class G4VoxelNavigation Implementation 26 // class G4VoxelNavigation Implementation 27 // 27 // 28 // Author: P.Kent, 1996 28 // Author: P.Kent, 1996 29 // 29 // 30 // ------------------------------------------- 30 // -------------------------------------------------------------------- >> 31 #include <ostream> >> 32 31 #include "G4VoxelNavigation.hh" 33 #include "G4VoxelNavigation.hh" 32 #include "G4GeometryTolerance.hh" 34 #include "G4GeometryTolerance.hh" 33 #include "G4VoxelSafety.hh" 35 #include "G4VoxelSafety.hh" 34 36 35 #include "G4AuxiliaryNavServices.hh" 37 #include "G4AuxiliaryNavServices.hh" 36 38 37 #include <cassert> << 38 #include <ostream> << 39 << 40 // ******************************************* 39 // ******************************************************************** 41 // Constructor 40 // Constructor 42 // ******************************************* 41 // ******************************************************************** 43 // 42 // 44 G4VoxelNavigation::G4VoxelNavigation() 43 G4VoxelNavigation::G4VoxelNavigation() 45 : fVoxelAxisStack(kNavigatorVoxelStackMax,kX << 44 : fBList(), >> 45 fVoxelAxisStack(kNavigatorVoxelStackMax,kXAxis), 46 fVoxelNoSlicesStack(kNavigatorVoxelStackMa 46 fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0), 47 fVoxelSliceWidthStack(kNavigatorVoxelStack 47 fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.), 48 fVoxelNodeNoStack(kNavigatorVoxelStackMax, 48 fVoxelNodeNoStack(kNavigatorVoxelStackMax,0), 49 fVoxelHeaderStack(kNavigatorVoxelStackMax, 49 fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)nullptr) 50 { 50 { 51 fLogger= new G4NavigationLogger("G4VoxelNavi 51 fLogger= new G4NavigationLogger("G4VoxelNavigation"); 52 fpVoxelSafety= new G4VoxelSafety(); 52 fpVoxelSafety= new G4VoxelSafety(); 53 fHalfTolerance= 0.5*G4GeometryTolerance::Get 53 fHalfTolerance= 0.5*G4GeometryTolerance::GetInstance()->GetSurfaceTolerance(); 54 54 55 #ifdef G4DEBUG_NAVIGATION 55 #ifdef G4DEBUG_NAVIGATION 56 SetVerboseLevel(5); // Reports most about 56 SetVerboseLevel(5); // Reports most about daughter volumes 57 #endif 57 #endif 58 } 58 } 59 59 60 // ******************************************* 60 // ******************************************************************** 61 // Destructor 61 // Destructor 62 // ******************************************* 62 // ******************************************************************** 63 // 63 // 64 G4VoxelNavigation::~G4VoxelNavigation() 64 G4VoxelNavigation::~G4VoxelNavigation() 65 { 65 { 66 delete fpVoxelSafety; 66 delete fpVoxelSafety; 67 delete fLogger; 67 delete fLogger; 68 } 68 } 69 69 70 // ------------------------------------------- 70 // -------------------------------------------------------------------------- 71 // Input: 71 // Input: 72 // exiting: : last step exited 72 // exiting: : last step exited 73 // blockedPhysical : phys volume last exit 73 // blockedPhysical : phys volume last exited (if exiting) 74 // blockedReplicaNo : copy/replica number o 74 // blockedReplicaNo : copy/replica number of exited 75 // Output: 75 // Output: 76 // entering : if true, found candid 76 // entering : if true, found candidate volume to enter 77 // blockedPhysical : candidate phys volume 77 // blockedPhysical : candidate phys volume to enter - if entering 78 // blockedReplicaNo : copy/replica number 78 // blockedReplicaNo : copy/replica number - if entering 79 // exiting: : will exit current (mo 79 // exiting: : will exit current (mother) volume 80 // In/Out 80 // In/Out 81 // ------------------------------------------- 81 // -------------------------------------------------------------------------- 82 82 83 // ******************************************* 83 // ******************************************************************** 84 // ComputeStep 84 // ComputeStep 85 // ******************************************* 85 // ******************************************************************** 86 // 86 // 87 G4double 87 G4double 88 G4VoxelNavigation::ComputeStep( const G4ThreeV 88 G4VoxelNavigation::ComputeStep( const G4ThreeVector& localPoint, 89 const G4ThreeV 89 const G4ThreeVector& localDirection, 90 const G4double 90 const G4double currentProposedStepLength, 91 G4double 91 G4double& newSafety, 92 /* const */ G4Naviga 92 /* const */ G4NavigationHistory& history, 93 G4bool& 93 G4bool& validExitNormal, 94 G4ThreeV 94 G4ThreeVector& exitNormal, 95 G4bool& 95 G4bool& exiting, 96 G4bool& 96 G4bool& entering, 97 G4VPhysi 97 G4VPhysicalVolume* (*pBlockedPhysical), 98 G4int& b 98 G4int& blockedReplicaNo ) 99 { 99 { 100 G4VPhysicalVolume *motherPhysical, *samplePh 100 G4VPhysicalVolume *motherPhysical, *samplePhysical, *blockedExitedVol=nullptr; 101 G4LogicalVolume *motherLogical; 101 G4LogicalVolume *motherLogical; 102 G4VSolid *motherSolid; 102 G4VSolid *motherSolid; 103 G4ThreeVector sampleDirection; 103 G4ThreeVector sampleDirection; 104 G4double ourStep=currentProposedStepLength, 104 G4double ourStep=currentProposedStepLength, ourSafety; 105 G4double motherSafety, motherStep = DBL_MAX; 105 G4double motherSafety, motherStep = DBL_MAX; 106 G4int localNoDaughters, sampleNo; 106 G4int localNoDaughters, sampleNo; 107 107 108 G4bool initialNode, noStep; 108 G4bool initialNode, noStep; 109 G4SmartVoxelNode *curVoxelNode; 109 G4SmartVoxelNode *curVoxelNode; 110 G4long curNoVolumes, contentNo; << 110 G4int curNoVolumes, contentNo; 111 G4double voxelSafety; 111 G4double voxelSafety; 112 112 113 motherPhysical = history.GetTopVolume(); 113 motherPhysical = history.GetTopVolume(); 114 motherLogical = motherPhysical->GetLogicalVo 114 motherLogical = motherPhysical->GetLogicalVolume(); 115 motherSolid = motherLogical->GetSolid(); 115 motherSolid = motherLogical->GetSolid(); 116 116 117 // 117 // 118 // Compute mother safety 118 // Compute mother safety 119 // 119 // 120 120 121 motherSafety = motherSolid->DistanceToOut(lo 121 motherSafety = motherSolid->DistanceToOut(localPoint); 122 ourSafety = motherSafety; // 122 ourSafety = motherSafety; // Working isotropic safety 123 123 124 #ifdef G4VERBOSE 124 #ifdef G4VERBOSE 125 if ( fCheck ) 125 if ( fCheck ) 126 { 126 { 127 fLogger->PreComputeStepLog (motherPhysical 127 fLogger->PreComputeStepLog (motherPhysical, motherSafety, localPoint); 128 } 128 } 129 #endif 129 #endif 130 130 131 // 131 // 132 // Compute daughter safeties & intersections 132 // Compute daughter safeties & intersections 133 // 133 // 134 134 135 // Exiting normal optimisation 135 // Exiting normal optimisation 136 // 136 // 137 if ( exiting && validExitNormal ) 137 if ( exiting && validExitNormal ) 138 { 138 { 139 if ( localDirection.dot(exitNormal)>=kMinE 139 if ( localDirection.dot(exitNormal)>=kMinExitingNormalCosine ) 140 { 140 { 141 // Block exited daughter volume 141 // Block exited daughter volume 142 // 142 // 143 blockedExitedVol = *pBlockedPhysical; 143 blockedExitedVol = *pBlockedPhysical; 144 ourSafety = 0; 144 ourSafety = 0; 145 } 145 } 146 } 146 } 147 exiting = false; 147 exiting = false; 148 entering = false; 148 entering = false; 149 149 150 // For extra checking, get the distance to 150 // For extra checking, get the distance to Mother early !! 151 G4bool motherValidExitNormal = false; 151 G4bool motherValidExitNormal = false; 152 G4ThreeVector motherExitNormal(0.0, 0.0, 0.0 152 G4ThreeVector motherExitNormal(0.0, 0.0, 0.0); 153 153 154 #ifdef G4VERBOSE 154 #ifdef G4VERBOSE 155 if ( fCheck ) 155 if ( fCheck ) 156 { 156 { 157 // Compute early -- a) for validity 157 // Compute early -- a) for validity 158 // b) to check against an 158 // b) to check against answer of daughters! 159 motherStep = motherSolid->DistanceToOut(lo 159 motherStep = motherSolid->DistanceToOut(localPoint, 160 lo 160 localDirection, 161 tr 161 true, 162 &mo 162 &motherValidExitNormal, 163 &mo 163 &motherExitNormal); 164 } 164 } 165 #endif 165 #endif 166 166 167 localNoDaughters = (G4int)motherLogical->Get << 167 localNoDaughters = motherLogical->GetNoDaughters(); 168 168 169 fBList.Enlarge(localNoDaughters); 169 fBList.Enlarge(localNoDaughters); 170 fBList.Reset(); 170 fBList.Reset(); 171 171 172 initialNode = true; 172 initialNode = true; 173 noStep = true; 173 noStep = true; 174 174 175 while (noStep) 175 while (noStep) 176 { 176 { 177 curVoxelNode = fVoxelNode; 177 curVoxelNode = fVoxelNode; 178 curNoVolumes = curVoxelNode->GetNoContaine 178 curNoVolumes = curVoxelNode->GetNoContained(); 179 for (contentNo=curNoVolumes-1; contentNo>= 179 for (contentNo=curNoVolumes-1; contentNo>=0; contentNo--) 180 { 180 { 181 sampleNo = curVoxelNode->GetVolume((G4in << 181 sampleNo = curVoxelNode->GetVolume(contentNo); 182 if ( !fBList.IsBlocked(sampleNo) ) 182 if ( !fBList.IsBlocked(sampleNo) ) 183 { 183 { 184 fBList.BlockVolume(sampleNo); 184 fBList.BlockVolume(sampleNo); 185 samplePhysical = motherLogical->GetDau 185 samplePhysical = motherLogical->GetDaughter(sampleNo); 186 if ( samplePhysical!=blockedExitedVol 186 if ( samplePhysical!=blockedExitedVol ) 187 { 187 { 188 G4AffineTransform sampleTf(samplePhy 188 G4AffineTransform sampleTf(samplePhysical->GetRotation(), 189 samplePhy 189 samplePhysical->GetTranslation()); 190 sampleTf.Invert(); 190 sampleTf.Invert(); 191 const G4ThreeVector samplePoint = 191 const G4ThreeVector samplePoint = 192 sampleTf.TransformPoint(l 192 sampleTf.TransformPoint(localPoint); 193 const G4VSolid *sampleSolid = 193 const G4VSolid *sampleSolid = 194 samplePhysical->GetLogica 194 samplePhysical->GetLogicalVolume()->GetSolid(); 195 const G4double sampleSafety = 195 const G4double sampleSafety = 196 sampleSolid->DistanceToIn 196 sampleSolid->DistanceToIn(samplePoint); 197 197 198 if ( sampleSafety<ourSafety ) 198 if ( sampleSafety<ourSafety ) 199 { 199 { 200 ourSafety = sampleSafety; 200 ourSafety = sampleSafety; 201 } 201 } 202 if ( sampleSafety<=ourStep ) 202 if ( sampleSafety<=ourStep ) 203 { 203 { 204 sampleDirection = sampleTf.Transfo 204 sampleDirection = sampleTf.TransformAxis(localDirection); 205 G4double sampleStep = 205 G4double sampleStep = 206 sampleSolid->DistanceToIn 206 sampleSolid->DistanceToIn(samplePoint, sampleDirection); 207 #ifdef G4VERBOSE 207 #ifdef G4VERBOSE 208 if( fCheck ) 208 if( fCheck ) 209 { 209 { 210 fLogger->PrintDaughterLog(sample 210 fLogger->PrintDaughterLog(sampleSolid, samplePoint, 211 sample 211 sampleSafety, true, 212 sample 212 sampleDirection, sampleStep); 213 } 213 } 214 #endif 214 #endif 215 if ( sampleStep<=ourStep ) 215 if ( sampleStep<=ourStep ) 216 { 216 { 217 ourStep = sampleStep; 217 ourStep = sampleStep; 218 entering = true; 218 entering = true; 219 exiting = false; 219 exiting = false; 220 *pBlockedPhysical = samplePhysic 220 *pBlockedPhysical = samplePhysical; 221 blockedReplicaNo = -1; 221 blockedReplicaNo = -1; 222 #ifdef G4VERBOSE 222 #ifdef G4VERBOSE 223 // Check to see that the resulti 223 // Check to see that the resulting point is indeed in/on volume. 224 // This could be done only for s 224 // This could be done only for successful candidate. 225 if ( fCheck ) 225 if ( fCheck ) 226 { 226 { 227 fLogger->AlongComputeStepLog ( 227 fLogger->AlongComputeStepLog (sampleSolid, samplePoint, 228 sampleDirection, localDirect 228 sampleDirection, localDirection, sampleSafety, sampleStep); 229 } 229 } 230 #endif 230 #endif 231 } 231 } 232 #ifdef G4VERBOSE 232 #ifdef G4VERBOSE 233 if ( fCheck && ( sampleStep < kInf 233 if ( fCheck && ( sampleStep < kInfinity ) 234 && ( sampleStep >= mot 234 && ( sampleStep >= motherStep ) ) 235 { 235 { 236 // The intersection point with 236 // The intersection point with the daughter is after the exit 237 // point from the mother volume 237 // point from the mother volume. Double check this !! 238 fLogger->CheckDaughterEntryPoin 238 fLogger->CheckDaughterEntryPoint(sampleSolid, 239 239 samplePoint, sampleDirection, 240 240 motherSolid, 241 241 localPoint, localDirection, 242 242 motherStep, sampleStep); 243 } 243 } 244 #endif 244 #endif 245 } 245 } 246 #ifdef G4VERBOSE 246 #ifdef G4VERBOSE 247 else // ie if sampleSafety > outStep 247 else // ie if sampleSafety > outStep 248 { 248 { 249 if( fCheck ) 249 if( fCheck ) 250 { 250 { 251 fLogger->PrintDaughterLog(sample 251 fLogger->PrintDaughterLog(sampleSolid, samplePoint, 252 sample 252 sampleSafety, false, 253 G4Thre 253 G4ThreeVector(0.,0.,0.), -1.0 ); 254 } 254 } 255 } 255 } 256 #endif 256 #endif 257 } 257 } 258 } 258 } 259 } 259 } 260 if (initialNode) 260 if (initialNode) 261 { 261 { 262 initialNode = false; 262 initialNode = false; 263 voxelSafety = ComputeVoxelSafety(localPo 263 voxelSafety = ComputeVoxelSafety(localPoint); 264 if ( voxelSafety<ourSafety ) 264 if ( voxelSafety<ourSafety ) 265 { 265 { 266 ourSafety = voxelSafety; 266 ourSafety = voxelSafety; 267 } 267 } 268 if ( currentProposedStepLength<ourSafety 268 if ( currentProposedStepLength<ourSafety ) 269 { 269 { 270 // Guaranteed physics limited 270 // Guaranteed physics limited 271 // 271 // 272 noStep = false; 272 noStep = false; 273 entering = false; 273 entering = false; 274 exiting = false; 274 exiting = false; 275 *pBlockedPhysical = nullptr; 275 *pBlockedPhysical = nullptr; 276 ourStep = kInfinity; 276 ourStep = kInfinity; 277 } 277 } 278 else 278 else 279 { 279 { 280 // 280 // 281 // Compute mother intersection if requ 281 // Compute mother intersection if required 282 // 282 // 283 if ( motherSafety<=ourStep ) 283 if ( motherSafety<=ourStep ) 284 { 284 { 285 // In case of check mode this is a d 285 // In case of check mode this is a duplicate call -- acceptable 286 motherStep = motherSolid->DistanceTo 286 motherStep = motherSolid->DistanceToOut(localPoint, localDirection, 287 true, &motherVal 287 true, &motherValidExitNormal, &motherExitNormal); 288 #ifdef G4VERBOSE 288 #ifdef G4VERBOSE 289 if ( fCheck ) 289 if ( fCheck ) 290 { 290 { 291 fLogger->PostComputeStepLog(mother 291 fLogger->PostComputeStepLog(motherSolid, localPoint, localDirection, 292 mother 292 motherStep, motherSafety); 293 if( motherValidExitNormal ) 293 if( motherValidExitNormal ) 294 { 294 { 295 fLogger->CheckAndReportBadNormal 295 fLogger->CheckAndReportBadNormal(motherExitNormal, 296 296 localPoint, localDirection, 297 297 motherStep, motherSolid, 298 "From 298 "From motherSolid::DistanceToOut" ); 299 } 299 } 300 } 300 } 301 #endif 301 #endif 302 if( (motherStep >= kInfinity) || (mo 302 if( (motherStep >= kInfinity) || (motherStep < 0.0) ) 303 { 303 { 304 #ifdef G4VERBOSE 304 #ifdef G4VERBOSE 305 if( fCheck ) // Error - indication 305 if( fCheck ) // Error - indication of being outside solid !! 306 { 306 { 307 fLogger->ReportOutsideMother(loc 307 fLogger->ReportOutsideMother(localPoint, localDirection, 308 mot 308 motherPhysical); 309 } 309 } 310 #endif 310 #endif 311 motherStep = 0.0; 311 motherStep = 0.0; 312 ourStep = 0.0; 312 ourStep = 0.0; 313 exiting = true; 313 exiting = true; 314 entering = false; 314 entering = false; 315 315 316 // validExitNormal= motherValidExi 316 // validExitNormal= motherValidExitNormal; 317 // exitNormal= motherExitNormal; 317 // exitNormal= motherExitNormal; 318 // Useful only if the point is ver 318 // Useful only if the point is very close to surface 319 // => but it would need to be rota 319 // => but it would need to be rotated to grand-mother ref frame ! 320 validExitNormal= false; 320 validExitNormal= false; 321 321 322 *pBlockedPhysical = nullptr; // or 322 *pBlockedPhysical = nullptr; // or motherPhysical ? 323 blockedReplicaNo = 0; // or mothe 323 blockedReplicaNo = 0; // or motherReplicaNumber ? 324 324 325 newSafety = 0.0; 325 newSafety = 0.0; 326 return ourStep; 326 return ourStep; 327 } 327 } 328 328 329 if ( motherStep<=ourStep ) 329 if ( motherStep<=ourStep ) 330 { 330 { 331 ourStep = motherStep; 331 ourStep = motherStep; 332 exiting = true; 332 exiting = true; 333 entering = false; 333 entering = false; 334 334 335 // Exit normal: Natural location t 335 // Exit normal: Natural location to set these;confirmed short step 336 // 336 // 337 validExitNormal = motherValidExitN 337 validExitNormal = motherValidExitNormal; 338 exitNormal = motherExitNormal; 338 exitNormal = motherExitNormal; 339 339 340 if ( validExitNormal ) 340 if ( validExitNormal ) 341 { 341 { 342 const G4RotationMatrix *rot = mo 342 const G4RotationMatrix *rot = motherPhysical->GetRotation(); 343 if (rot != nullptr) << 343 if (rot) 344 { 344 { 345 exitNormal *= rot->inverse(); 345 exitNormal *= rot->inverse(); 346 #ifdef G4VERBOSE 346 #ifdef G4VERBOSE 347 if( fCheck ) 347 if( fCheck ) 348 { << 348 fLogger->CheckAndReportBadNormal(exitNormal, // rotated 349 fLogger->CheckAndReportBadNo << 349 motherExitNormal, // original 350 << 350 *rot, 351 << 351 "From RotationMatrix" ); 352 << 353 } << 354 #endif 352 #endif 355 } 353 } 356 } 354 } 357 } 355 } 358 else 356 else 359 { 357 { 360 validExitNormal = false; 358 validExitNormal = false; 361 } 359 } 362 } 360 } 363 } 361 } 364 newSafety = ourSafety; 362 newSafety = ourSafety; 365 } 363 } 366 if (noStep) 364 if (noStep) 367 { 365 { 368 noStep = LocateNextVoxel(localPoint, loc 366 noStep = LocateNextVoxel(localPoint, localDirection, ourStep); 369 } 367 } 370 } // end -while (noStep)- loop 368 } // end -while (noStep)- loop 371 369 372 return ourStep; 370 return ourStep; 373 } 371 } 374 372 375 // ******************************************* 373 // ******************************************************************** 376 // ComputeVoxelSafety 374 // ComputeVoxelSafety 377 // 375 // 378 // Computes safety from specified point to vox 376 // Computes safety from specified point to voxel boundaries 379 // using already located point 377 // using already located point 380 // o collected boundaries for most derived lev 378 // o collected boundaries for most derived level 381 // o adjacent boundaries for previous levels 379 // o adjacent boundaries for previous levels 382 // ******************************************* 380 // ******************************************************************** 383 // 381 // 384 G4double 382 G4double 385 G4VoxelNavigation::ComputeVoxelSafety(const G4 383 G4VoxelNavigation::ComputeVoxelSafety(const G4ThreeVector& localPoint) const 386 { 384 { 387 G4SmartVoxelHeader *curHeader; 385 G4SmartVoxelHeader *curHeader; 388 G4double voxelSafety, curNodeWidth; 386 G4double voxelSafety, curNodeWidth; 389 G4double curNodeOffset, minCurCommonDelta, m 387 G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta; 390 G4int minCurNodeNoDelta, maxCurNodeNoDelta; 388 G4int minCurNodeNoDelta, maxCurNodeNoDelta; 391 G4int localVoxelDepth, curNodeNo; 389 G4int localVoxelDepth, curNodeNo; 392 EAxis curHeaderAxis; 390 EAxis curHeaderAxis; 393 391 394 localVoxelDepth = fVoxelDepth; 392 localVoxelDepth = fVoxelDepth; 395 393 396 curHeader = fVoxelHeaderStack[localVoxelDept 394 curHeader = fVoxelHeaderStack[localVoxelDepth]; 397 curHeaderAxis = fVoxelAxisStack[localVoxelDe 395 curHeaderAxis = fVoxelAxisStack[localVoxelDepth]; 398 curNodeNo = fVoxelNodeNoStack[localVoxelDept 396 curNodeNo = fVoxelNodeNoStack[localVoxelDepth]; 399 curNodeWidth = fVoxelSliceWidthStack[localVo 397 curNodeWidth = fVoxelSliceWidthStack[localVoxelDepth]; 400 398 401 // Compute linear intersection distance to b 399 // Compute linear intersection distance to boundaries of max/min 402 // to collected nodes at current level 400 // to collected nodes at current level 403 // 401 // 404 curNodeOffset = curNodeNo*curNodeWidth; 402 curNodeOffset = curNodeNo*curNodeWidth; 405 maxCurNodeNoDelta = fVoxelNode->GetMaxEquiva 403 maxCurNodeNoDelta = fVoxelNode->GetMaxEquivalentSliceNo()-curNodeNo; 406 minCurNodeNoDelta = curNodeNo-fVoxelNode->Ge 404 minCurNodeNoDelta = curNodeNo-fVoxelNode->GetMinEquivalentSliceNo(); 407 minCurCommonDelta = localPoint(curHeaderAxis 405 minCurCommonDelta = localPoint(curHeaderAxis) 408 - curHeader->GetMinExten 406 - curHeader->GetMinExtent() - curNodeOffset; 409 maxCurCommonDelta = curNodeWidth-minCurCommo 407 maxCurCommonDelta = curNodeWidth-minCurCommonDelta; 410 408 411 if ( minCurNodeNoDelta<maxCurNodeNoDelta ) 409 if ( minCurNodeNoDelta<maxCurNodeNoDelta ) 412 { 410 { 413 voxelSafety = minCurNodeNoDelta*curNodeWid 411 voxelSafety = minCurNodeNoDelta*curNodeWidth; 414 voxelSafety += minCurCommonDelta; 412 voxelSafety += minCurCommonDelta; 415 } 413 } 416 else if (maxCurNodeNoDelta < minCurNodeNoDel 414 else if (maxCurNodeNoDelta < minCurNodeNoDelta) 417 { 415 { 418 voxelSafety = maxCurNodeNoDelta*curNodeWid 416 voxelSafety = maxCurNodeNoDelta*curNodeWidth; 419 voxelSafety += maxCurCommonDelta; 417 voxelSafety += maxCurCommonDelta; 420 } 418 } 421 else // (maxCurNodeNoDelta == minCurNodeN 419 else // (maxCurNodeNoDelta == minCurNodeNoDelta) 422 { 420 { 423 voxelSafety = minCurNodeNoDelta*curNodeWid 421 voxelSafety = minCurNodeNoDelta*curNodeWidth; 424 voxelSafety += std::min(minCurCommonDelta, 422 voxelSafety += std::min(minCurCommonDelta,maxCurCommonDelta); 425 } 423 } 426 424 427 // Compute isotropic safety to boundaries of 425 // Compute isotropic safety to boundaries of previous levels 428 // [NOT to collected boundaries] 426 // [NOT to collected boundaries] 429 427 430 // Loop checking, 07.10.2016, JA 428 // Loop checking, 07.10.2016, JA 431 while ( (localVoxelDepth>0) && (voxelSafety> 429 while ( (localVoxelDepth>0) && (voxelSafety>0) ) 432 { 430 { 433 localVoxelDepth--; 431 localVoxelDepth--; 434 curHeader = fVoxelHeaderStack[localVoxelDe 432 curHeader = fVoxelHeaderStack[localVoxelDepth]; 435 curHeaderAxis = fVoxelAxisStack[localVoxel 433 curHeaderAxis = fVoxelAxisStack[localVoxelDepth]; 436 curNodeNo = fVoxelNodeNoStack[localVoxelDe 434 curNodeNo = fVoxelNodeNoStack[localVoxelDepth]; 437 curNodeWidth = fVoxelSliceWidthStack[local 435 curNodeWidth = fVoxelSliceWidthStack[localVoxelDepth]; 438 curNodeOffset = curNodeNo*curNodeWidth; 436 curNodeOffset = curNodeNo*curNodeWidth; 439 minCurCommonDelta = localPoint(curHeaderAx 437 minCurCommonDelta = localPoint(curHeaderAxis) 440 - curHeader->GetMinExt 438 - curHeader->GetMinExtent() - curNodeOffset; 441 maxCurCommonDelta = curNodeWidth-minCurCom 439 maxCurCommonDelta = curNodeWidth-minCurCommonDelta; 442 440 443 if ( minCurCommonDelta<voxelSafety ) 441 if ( minCurCommonDelta<voxelSafety ) 444 { 442 { 445 voxelSafety = minCurCommonDelta; 443 voxelSafety = minCurCommonDelta; 446 } 444 } 447 if ( maxCurCommonDelta<voxelSafety ) 445 if ( maxCurCommonDelta<voxelSafety ) 448 { 446 { 449 voxelSafety = maxCurCommonDelta; 447 voxelSafety = maxCurCommonDelta; 450 } 448 } 451 } 449 } 452 if ( voxelSafety<0 ) 450 if ( voxelSafety<0 ) 453 { 451 { 454 voxelSafety = 0; 452 voxelSafety = 0; 455 } 453 } 456 454 457 return voxelSafety; 455 return voxelSafety; 458 } 456 } 459 457 460 // ******************************************* 458 // ******************************************************************** 461 // LocateNextVoxel 459 // LocateNextVoxel 462 // 460 // 463 // Finds the next voxel from the current voxel 461 // Finds the next voxel from the current voxel and point 464 // in the specified direction 462 // in the specified direction 465 // 463 // 466 // Returns false if all voxels considered 464 // Returns false if all voxels considered 467 // [current Step ends inside same 465 // [current Step ends inside same voxel or leaves all voxels] 468 // true otherwise 466 // true otherwise 469 // [the information on the next v 467 // [the information on the next voxel is put into the set of 470 // fVoxel* variables & "stacks"] 468 // fVoxel* variables & "stacks"] 471 // ******************************************* 469 // ******************************************************************** 472 // 470 // 473 G4bool 471 G4bool 474 G4VoxelNavigation::LocateNextVoxel(const G4Thr 472 G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint, 475 const G4Thr 473 const G4ThreeVector& localDirection, 476 const G4dou 474 const G4double currentStep) 477 { 475 { 478 G4SmartVoxelHeader *workHeader=nullptr, *new 476 G4SmartVoxelHeader *workHeader=nullptr, *newHeader=nullptr; 479 G4SmartVoxelProxy *newProxy=nullptr; 477 G4SmartVoxelProxy *newProxy=nullptr; 480 G4SmartVoxelNode *newVoxelNode=nullptr; 478 G4SmartVoxelNode *newVoxelNode=nullptr; 481 G4ThreeVector targetPoint, voxelPoint; 479 G4ThreeVector targetPoint, voxelPoint; 482 G4double workNodeWidth, workMinExtent, workC 480 G4double workNodeWidth, workMinExtent, workCoord; 483 G4double minVal, maxVal, newDistance=0.; 481 G4double minVal, maxVal, newDistance=0.; 484 G4double newHeaderMin, newHeaderNodeWidth; 482 G4double newHeaderMin, newHeaderNodeWidth; 485 G4int depth=0, newDepth=0, workNodeNo=0, new 483 G4int depth=0, newDepth=0, workNodeNo=0, newNodeNo=0, newHeaderNoSlices=0; 486 EAxis workHeaderAxis, newHeaderAxis; 484 EAxis workHeaderAxis, newHeaderAxis; 487 G4bool isNewVoxel = false; 485 G4bool isNewVoxel = false; 488 486 489 G4double currentDistance = currentStep; 487 G4double currentDistance = currentStep; 490 488 491 // Determine if end of Step within current v 489 // Determine if end of Step within current voxel 492 // 490 // 493 for (depth=0; depth<fVoxelDepth; ++depth) 491 for (depth=0; depth<fVoxelDepth; ++depth) 494 { 492 { 495 targetPoint = localPoint+localDirection*cu 493 targetPoint = localPoint+localDirection*currentDistance; 496 newDistance = currentDistance; 494 newDistance = currentDistance; 497 workHeader = fVoxelHeaderStack[depth]; 495 workHeader = fVoxelHeaderStack[depth]; 498 workHeaderAxis = fVoxelAxisStack[depth]; 496 workHeaderAxis = fVoxelAxisStack[depth]; 499 workNodeNo = fVoxelNodeNoStack[depth]; 497 workNodeNo = fVoxelNodeNoStack[depth]; 500 workNodeWidth = fVoxelSliceWidthStack[dept 498 workNodeWidth = fVoxelSliceWidthStack[depth]; 501 workMinExtent = workHeader->GetMinExtent() 499 workMinExtent = workHeader->GetMinExtent(); 502 workCoord = targetPoint(workHeaderAxis); 500 workCoord = targetPoint(workHeaderAxis); 503 minVal = workMinExtent+workNodeNo*workNode 501 minVal = workMinExtent+workNodeNo*workNodeWidth; 504 502 505 if ( minVal<=workCoord+fHalfTolerance ) 503 if ( minVal<=workCoord+fHalfTolerance ) 506 { 504 { 507 maxVal = minVal+workNodeWidth; 505 maxVal = minVal+workNodeWidth; 508 if ( maxVal<=workCoord-fHalfTolerance ) 506 if ( maxVal<=workCoord-fHalfTolerance ) 509 { 507 { 510 // Must consider next voxel 508 // Must consider next voxel 511 // 509 // 512 newNodeNo = workNodeNo+1; 510 newNodeNo = workNodeNo+1; 513 newHeader = workHeader; 511 newHeader = workHeader; 514 newDistance = (maxVal-localPoint(workH 512 newDistance = (maxVal-localPoint(workHeaderAxis)) 515 / localDirection(workHeade 513 / localDirection(workHeaderAxis); 516 isNewVoxel = true; 514 isNewVoxel = true; 517 newDepth = depth; 515 newDepth = depth; 518 } 516 } 519 } 517 } 520 else 518 else 521 { 519 { 522 newNodeNo = workNodeNo-1; 520 newNodeNo = workNodeNo-1; 523 newHeader = workHeader; 521 newHeader = workHeader; 524 newDistance = (minVal-localPoint(workHea 522 newDistance = (minVal-localPoint(workHeaderAxis)) 525 / localDirection(workHeaderA 523 / localDirection(workHeaderAxis); 526 isNewVoxel = true; 524 isNewVoxel = true; 527 newDepth = depth; 525 newDepth = depth; 528 } 526 } 529 currentDistance = newDistance; 527 currentDistance = newDistance; 530 } 528 } 531 targetPoint = localPoint+localDirection*curr 529 targetPoint = localPoint+localDirection*currentDistance; 532 530 533 // Check if end of Step within collected bou 531 // Check if end of Step within collected boundaries of current voxel 534 // 532 // 535 depth = fVoxelDepth; 533 depth = fVoxelDepth; 536 { 534 { 537 workHeader = fVoxelHeaderStack[depth]; 535 workHeader = fVoxelHeaderStack[depth]; 538 workHeaderAxis = fVoxelAxisStack[depth]; 536 workHeaderAxis = fVoxelAxisStack[depth]; 539 workNodeNo = fVoxelNodeNoStack[depth]; 537 workNodeNo = fVoxelNodeNoStack[depth]; 540 workNodeWidth = fVoxelSliceWidthStack[dept 538 workNodeWidth = fVoxelSliceWidthStack[depth]; 541 workMinExtent = workHeader->GetMinExtent() 539 workMinExtent = workHeader->GetMinExtent(); 542 workCoord = targetPoint(workHeaderAxis); 540 workCoord = targetPoint(workHeaderAxis); 543 minVal = workMinExtent+fVoxelNode->GetMinE 541 minVal = workMinExtent+fVoxelNode->GetMinEquivalentSliceNo()*workNodeWidth; 544 542 545 if ( minVal<=workCoord+fHalfTolerance ) 543 if ( minVal<=workCoord+fHalfTolerance ) 546 { 544 { 547 maxVal = workMinExtent+(fVoxelNode->GetM 545 maxVal = workMinExtent+(fVoxelNode->GetMaxEquivalentSliceNo()+1) 548 *workNodeWidth; 546 *workNodeWidth; 549 if ( maxVal<=workCoord-fHalfTolerance ) 547 if ( maxVal<=workCoord-fHalfTolerance ) 550 { 548 { 551 newNodeNo = fVoxelNode->GetMaxEquivale 549 newNodeNo = fVoxelNode->GetMaxEquivalentSliceNo()+1; 552 newHeader = workHeader; 550 newHeader = workHeader; 553 newDistance = (maxVal-localPoint(workH 551 newDistance = (maxVal-localPoint(workHeaderAxis)) 554 / localDirection(workHeade 552 / localDirection(workHeaderAxis); 555 isNewVoxel = true; 553 isNewVoxel = true; 556 newDepth = depth; 554 newDepth = depth; 557 } 555 } 558 } 556 } 559 else 557 else 560 { 558 { 561 newNodeNo = fVoxelNode->GetMinEquivalent 559 newNodeNo = fVoxelNode->GetMinEquivalentSliceNo()-1; 562 newHeader = workHeader; 560 newHeader = workHeader; 563 newDistance = (minVal-localPoint(workHea 561 newDistance = (minVal-localPoint(workHeaderAxis)) 564 / localDirection(workHeaderA 562 / localDirection(workHeaderAxis); 565 isNewVoxel = true; 563 isNewVoxel = true; 566 newDepth = depth; 564 newDepth = depth; 567 } 565 } 568 currentDistance = newDistance; 566 currentDistance = newDistance; 569 } 567 } 570 if (isNewVoxel) 568 if (isNewVoxel) 571 { 569 { 572 // Compute new voxel & adjust voxel stack 570 // Compute new voxel & adjust voxel stack 573 // 571 // 574 // newNodeNo=Candidate node no at 572 // newNodeNo=Candidate node no at 575 // newDepth =refinement depth of crossed v 573 // newDepth =refinement depth of crossed voxel boundary 576 // newHeader=Header for crossed voxel 574 // newHeader=Header for crossed voxel 577 // newDistance=distance to crossed voxel b 575 // newDistance=distance to crossed voxel boundary (along the track) 578 // 576 // 579 if ( (newNodeNo<0) || (newNodeNo>=G4int(ne 577 if ( (newNodeNo<0) || (newNodeNo>=G4int(newHeader->GetNoSlices()))) 580 { 578 { 581 // Leaving mother volume 579 // Leaving mother volume 582 // 580 // 583 isNewVoxel = false; 581 isNewVoxel = false; 584 } 582 } 585 else 583 else 586 { 584 { 587 // Compute intersection point on the lea 585 // Compute intersection point on the least refined 588 // voxel boundary that is hit 586 // voxel boundary that is hit 589 // 587 // 590 voxelPoint = localPoint+localDirection*n 588 voxelPoint = localPoint+localDirection*newDistance; 591 fVoxelNodeNoStack[newDepth] = newNodeNo; 589 fVoxelNodeNoStack[newDepth] = newNodeNo; 592 fVoxelDepth = newDepth; 590 fVoxelDepth = newDepth; 593 newVoxelNode = nullptr; << 591 newVoxelNode = 0; 594 while ( newVoxelNode == nullptr ) << 592 while ( !newVoxelNode ) 595 { 593 { 596 newProxy = newHeader->GetSlice(newNode 594 newProxy = newHeader->GetSlice(newNodeNo); 597 if (newProxy->IsNode()) 595 if (newProxy->IsNode()) 598 { 596 { 599 newVoxelNode = newProxy->GetNode(); 597 newVoxelNode = newProxy->GetNode(); 600 } 598 } 601 else 599 else 602 { 600 { 603 ++fVoxelDepth; 601 ++fVoxelDepth; 604 newHeader = newProxy->GetHeader(); 602 newHeader = newProxy->GetHeader(); 605 newHeaderAxis = newHeader->GetAxis() 603 newHeaderAxis = newHeader->GetAxis(); 606 newHeaderNoSlices = (G4int)newHeader << 604 newHeaderNoSlices = newHeader->GetNoSlices(); 607 newHeaderMin = newHeader->GetMinExte 605 newHeaderMin = newHeader->GetMinExtent(); 608 newHeaderNodeWidth = (newHeader->Get 606 newHeaderNodeWidth = (newHeader->GetMaxExtent()-newHeaderMin) 609 / newHeaderNoSlic 607 / newHeaderNoSlices; 610 newNodeNo = G4int( (voxelPoint(newHe 608 newNodeNo = G4int( (voxelPoint(newHeaderAxis)-newHeaderMin) 611 / newHeaderNodeWi 609 / newHeaderNodeWidth ); 612 // Rounding protection 610 // Rounding protection 613 // 611 // 614 if ( newNodeNo<0 ) 612 if ( newNodeNo<0 ) 615 { 613 { 616 newNodeNo=0; 614 newNodeNo=0; 617 } 615 } 618 else if ( newNodeNo>=newHeaderNoSlic 616 else if ( newNodeNo>=newHeaderNoSlices ) 619 { 617 { 620 newNodeNo = newHeaderNoSlices-1; 618 newNodeNo = newHeaderNoSlices-1; 621 } 619 } 622 // Stack info for stepping 620 // Stack info for stepping 623 // 621 // 624 fVoxelAxisStack[fVoxelDepth] = newHe 622 fVoxelAxisStack[fVoxelDepth] = newHeaderAxis; 625 fVoxelNoSlicesStack[fVoxelDepth] = n 623 fVoxelNoSlicesStack[fVoxelDepth] = newHeaderNoSlices; 626 fVoxelSliceWidthStack[fVoxelDepth] = 624 fVoxelSliceWidthStack[fVoxelDepth] = newHeaderNodeWidth; 627 fVoxelNodeNoStack[fVoxelDepth] = new 625 fVoxelNodeNoStack[fVoxelDepth] = newNodeNo; 628 fVoxelHeaderStack[fVoxelDepth] = new 626 fVoxelHeaderStack[fVoxelDepth] = newHeader; 629 } 627 } 630 } 628 } 631 fVoxelNode = newVoxelNode; 629 fVoxelNode = newVoxelNode; 632 } 630 } 633 } 631 } 634 return isNewVoxel; 632 return isNewVoxel; 635 } 633 } 636 634 637 // ******************************************* 635 // ******************************************************************** 638 // ComputeSafety 636 // ComputeSafety 639 // 637 // 640 // Calculates the isotropic distance to the ne 638 // Calculates the isotropic distance to the nearest boundary from the 641 // specified point in the local coordinate sys 639 // specified point in the local coordinate system. 642 // The localpoint utilised must be within the 640 // The localpoint utilised must be within the current volume. 643 // ******************************************* 641 // ******************************************************************** 644 // 642 // 645 G4double 643 G4double 646 G4VoxelNavigation::ComputeSafety(const G4Three 644 G4VoxelNavigation::ComputeSafety(const G4ThreeVector& localPoint, 647 const G4Navig 645 const G4NavigationHistory& history, 648 const G4doubl 646 const G4double maxLength) 649 { 647 { 650 G4VPhysicalVolume *motherPhysical, *samplePh 648 G4VPhysicalVolume *motherPhysical, *samplePhysical; 651 G4LogicalVolume *motherLogical; 649 G4LogicalVolume *motherLogical; 652 G4VSolid *motherSolid; 650 G4VSolid *motherSolid; 653 G4double motherSafety, ourSafety; 651 G4double motherSafety, ourSafety; 654 G4int sampleNo; 652 G4int sampleNo; 655 G4SmartVoxelNode *curVoxelNode; 653 G4SmartVoxelNode *curVoxelNode; 656 G4long curNoVolumes, contentNo; << 654 G4int curNoVolumes, contentNo; 657 G4double voxelSafety; 655 G4double voxelSafety; 658 656 659 motherPhysical = history.GetTopVolume(); 657 motherPhysical = history.GetTopVolume(); 660 motherLogical = motherPhysical->GetLogicalVo 658 motherLogical = motherPhysical->GetLogicalVolume(); 661 motherSolid = motherLogical->GetSolid(); 659 motherSolid = motherLogical->GetSolid(); 662 660 663 if( fBestSafety ) 661 if( fBestSafety ) 664 { 662 { 665 return fpVoxelSafety->ComputeSafety( local 663 return fpVoxelSafety->ComputeSafety( localPoint,*motherPhysical,maxLength ); 666 } 664 } 667 665 668 // 666 // 669 // Compute mother safety 667 // Compute mother safety 670 // 668 // 671 669 672 motherSafety = motherSolid->DistanceToOut(lo 670 motherSafety = motherSolid->DistanceToOut(localPoint); 673 ourSafety = motherSafety; // 671 ourSafety = motherSafety; // Working isotropic safety 674 672 675 if( motherSafety == 0.0 ) 673 if( motherSafety == 0.0 ) 676 { 674 { 677 #ifdef G4DEBUG_NAVIGATION 675 #ifdef G4DEBUG_NAVIGATION 678 // Check that point is inside mother volum 676 // Check that point is inside mother volume 679 EInside insideMother = motherSolid->Insid 677 EInside insideMother = motherSolid->Inside(localPoint); 680 678 681 if( insideMother == kOutside ) 679 if( insideMother == kOutside ) 682 { 680 { 683 G4ExceptionDescription message; 681 G4ExceptionDescription message; 684 message << "Safety method called for loc 682 message << "Safety method called for location outside current Volume." << G4endl 685 << "Location for safety is Outside th 683 << "Location for safety is Outside this volume. " << G4endl 686 << "The approximate distance to the s 684 << "The approximate distance to the solid " 687 << "(safety from outside) is: " 685 << "(safety from outside) is: " 688 << motherSolid->DistanceToIn( localPo 686 << motherSolid->DistanceToIn( localPoint ) << G4endl; 689 message << " Problem occurred with phys 687 message << " Problem occurred with physical volume: " 690 << " Name: " << motherPhysical->GetNa 688 << " Name: " << motherPhysical->GetName() 691 << " Copy No: " << motherPhysical->Ge 689 << " Copy No: " << motherPhysical->GetCopyNo() << G4endl 692 << " Local Point = " << localPoint 690 << " Local Point = " << localPoint << G4endl; 693 message << " Description of solid: " << 691 message << " Description of solid: " << G4endl 694 << *motherSolid << G4endl; 692 << *motherSolid << G4endl; 695 G4Exception("G4VoxelNavigation::ComputeS 693 G4Exception("G4VoxelNavigation::ComputeSafety()", "GeomNav0003", 696 JustWarning, message); 694 JustWarning, message); 697 } 695 } 698 696 699 // Following check is NOT for an issue - i 697 // Following check is NOT for an issue - it is only for information 700 // It is allowed that a solid gives appro 698 // It is allowed that a solid gives approximate safety - even zero. 701 // 699 // 702 if( insideMother == kInside ) // && fVerbo 700 if( insideMother == kInside ) // && fVerbose ) 703 { 701 { 704 G4ExceptionDescription messageIn; 702 G4ExceptionDescription messageIn; 705 703 706 messageIn << " Point is Inside, but safe 704 messageIn << " Point is Inside, but safety is Zero ." << G4endl; 707 messageIn << " Inexact safety for volume 705 messageIn << " Inexact safety for volume " << motherPhysical->GetName() << G4endl 708 << " Solid: Name= " << motherSol 706 << " Solid: Name= " << motherSolid->GetName() 709 << " Type= " << motherSolid->Ge 707 << " Type= " << motherSolid->GetEntityType() << G4endl; 710 messageIn << " Local point= " << localP 708 messageIn << " Local point= " << localPoint << G4endl; 711 messageIn << " Solid parameters: " << G 709 messageIn << " Solid parameters: " << G4endl << *motherSolid << G4endl; 712 G4Exception("G4VoxelNavigation::ComputeS 710 G4Exception("G4VoxelNavigation::ComputeSafety()", "GeomNav0003", 713 JustWarning, messageIn); 711 JustWarning, messageIn); 714 } 712 } 715 #endif 713 #endif 716 // if( insideMother != kInside ) 714 // if( insideMother != kInside ) 717 return 0.0; 715 return 0.0; 718 } 716 } 719 717 720 #ifdef G4VERBOSE 718 #ifdef G4VERBOSE 721 if( fCheck ) 719 if( fCheck ) 722 { 720 { 723 fLogger->ComputeSafetyLog (motherSolid,loc << 721 fLogger->ComputeSafetyLog (motherSolid,localPoint,motherSafety,true,true); 724 } 722 } 725 #endif 723 #endif 726 // 724 // 727 // Compute daughter safeties 725 // Compute daughter safeties 728 // 726 // 729 // Look only inside the current Voxel only ( 727 // Look only inside the current Voxel only (in the first version). 730 // 728 // 731 curVoxelNode = fVoxelNode; 729 curVoxelNode = fVoxelNode; 732 curNoVolumes = curVoxelNode->GetNoContained( 730 curNoVolumes = curVoxelNode->GetNoContained(); 733 731 734 for ( contentNo=curNoVolumes-1; contentNo>=0 732 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- ) 735 { 733 { 736 sampleNo = curVoxelNode->GetVolume((G4int) << 734 sampleNo = curVoxelNode->GetVolume(contentNo); 737 samplePhysical = motherLogical->GetDaughte 735 samplePhysical = motherLogical->GetDaughter(sampleNo); 738 736 739 G4AffineTransform sampleTf(samplePhysical- 737 G4AffineTransform sampleTf(samplePhysical->GetRotation(), 740 samplePhysical- 738 samplePhysical->GetTranslation()); 741 sampleTf.Invert(); 739 sampleTf.Invert(); 742 const G4ThreeVector samplePoint = sampleTf 740 const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint); 743 const G4VSolid* sampleSolid= samplePhysica 741 const G4VSolid* sampleSolid= samplePhysical->GetLogicalVolume()->GetSolid(); 744 G4double sampleSafety = sampleSolid->Dista 742 G4double sampleSafety = sampleSolid->DistanceToIn(samplePoint); 745 if ( sampleSafety<ourSafety ) 743 if ( sampleSafety<ourSafety ) 746 { 744 { 747 ourSafety = sampleSafety; 745 ourSafety = sampleSafety; 748 } 746 } 749 #ifdef G4VERBOSE 747 #ifdef G4VERBOSE 750 if( fCheck ) 748 if( fCheck ) 751 { 749 { 752 fLogger->ComputeSafetyLog(sampleSolid, s 750 fLogger->ComputeSafetyLog(sampleSolid, samplePoint, 753 sampleSafety, << 751 sampleSafety, false, false); 754 } 752 } 755 #endif 753 #endif 756 } 754 } 757 voxelSafety = ComputeVoxelSafety(localPoint) 755 voxelSafety = ComputeVoxelSafety(localPoint); 758 if ( voxelSafety<ourSafety ) 756 if ( voxelSafety<ourSafety ) 759 { 757 { 760 ourSafety = voxelSafety; 758 ourSafety = voxelSafety; 761 } 759 } 762 return ourSafety; 760 return ourSafety; 763 } 761 } 764 762 765 void G4VoxelNavigation::RelocateWithinVolume( << 766 << 767 { << 768 auto motherLogical = motherPhysical->GetLogi << 769 << 770 assert(motherLogical != nullptr); << 771 << 772 if ( auto pVoxelHeader = motherLogical->GetV << 773 VoxelLocate( pVoxelHeader, localPoint ); << 774 } << 775 << 776 // ******************************************* 763 // ******************************************************************** 777 // SetVerboseLevel 764 // SetVerboseLevel 778 // ******************************************* 765 // ******************************************************************** 779 // 766 // 780 void G4VoxelNavigation::SetVerboseLevel(G4int 767 void G4VoxelNavigation::SetVerboseLevel(G4int level) 781 { 768 { 782 if( fLogger != nullptr ) { fLogger->SetVerbo << 769 if( fLogger ) fLogger->SetVerboseLevel(level); 783 if( fpVoxelSafety != nullptr) { fpVoxelSafet << 770 if( fpVoxelSafety) fpVoxelSafety->SetVerboseLevel(level); 784 } 771 } 785 772