55 #ifdef G4DEBUG_NAVIGATION
77 const G4double currentProposedStepLength,
85 G4int& blockedReplicaNo )
91 G4double ourStep=currentProposedStepLength, ourSafety;
93 G4int localNoDaughters, sampleNo;
95 G4bool initialNode, noStep;
97 G4int curNoVolumes, contentNo;
102 motherSolid = motherLogical->
GetSolid();
109 ourSafety = motherSafety;
124 if ( exiting && validExitNormal )
130 blockedExitedVol = *pBlockedPhysical;
138 G4bool motherValidExitNormal =
false;
149 &motherValidExitNormal,
153 motherStep, motherSafety);
155 if( (motherStep >=
kInfinity) || (motherStep < 0.0) )
171 validExitNormal =
false;
173 *pBlockedPhysical =
nullptr;
174 blockedReplicaNo = 0;
194 for (contentNo=curNoVolumes-1; contentNo>=0; contentNo--)
196 sampleNo = curVoxelNode->
GetVolume(contentNo);
200 samplePhysical = motherLogical->
GetDaughter(sampleNo);
201 if ( samplePhysical!=blockedExitedVol )
207 sampleTf.TransformPoint(localPoint);
213 if ( sampleSafety<ourSafety )
215 ourSafety = sampleSafety;
217 if ( sampleSafety<=ourStep )
219 sampleDirection = sampleTf.TransformAxis(localDirection);
221 sampleSolid->
DistanceToIn(samplePoint, sampleDirection);
227 sampleDirection, sampleStep);
230 if ( sampleStep<=ourStep )
232 ourStep = sampleStep;
235 *pBlockedPhysical = samplePhysical;
236 blockedReplicaNo = -1;
243 sampleDirection, localDirection, sampleSafety, sampleStep);
249 && ( sampleStep >= motherStep ) )
254 samplePoint, sampleDirection,
256 localPoint, localDirection,
257 motherStep, sampleStep);
279 if ( voxelSafety<ourSafety )
281 ourSafety = voxelSafety;
283 if ( currentProposedStepLength<ourSafety )
290 *pBlockedPhysical =
nullptr;
298 if ( motherSafety<=ourStep )
302 motherStep = motherSolid->
DistanceToOut(localPoint, localDirection,
303 true, &motherValidExitNormal, &motherExitNormal);
312 motherStep, motherSafety);
313 if( motherValidExitNormal )
316 localPoint, localDirection,
317 motherStep, motherSolid,
318 "From motherSolid::DistanceToOut" );
322 if( (motherStep >=
kInfinity) || (motherStep < 0.0) )
340 validExitNormal=
false;
342 *pBlockedPhysical =
nullptr;
343 blockedReplicaNo = 0;
349 if ( motherStep<=ourStep )
351 ourStep = motherStep;
357 validExitNormal = motherValidExitNormal;
358 exitNormal = motherExitNormal;
360 if ( validExitNormal )
371 "From RotationMatrix" );
378 validExitNormal =
false;
382 newSafety = ourSafety;
407 G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
408 G4int minCurNodeNoDelta, maxCurNodeNoDelta;
409 G4int localVoxelDepth, curNodeNo;
422 curNodeOffset = curNodeNo*curNodeWidth;
425 minCurCommonDelta = localPoint(curHeaderAxis)
427 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
429 if ( minCurNodeNoDelta<maxCurNodeNoDelta )
431 voxelSafety = minCurNodeNoDelta*curNodeWidth;
432 voxelSafety += minCurCommonDelta;
434 else if (maxCurNodeNoDelta < minCurNodeNoDelta)
436 voxelSafety = maxCurNodeNoDelta*curNodeWidth;
437 voxelSafety += maxCurCommonDelta;
441 voxelSafety = minCurNodeNoDelta*curNodeWidth;
442 voxelSafety +=
std::min(minCurCommonDelta,maxCurCommonDelta);
449 while ( (localVoxelDepth>0) && (voxelSafety>0) )
456 curNodeOffset = curNodeNo*curNodeWidth;
457 minCurCommonDelta = localPoint(curHeaderAxis)
459 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
461 if ( minCurCommonDelta<voxelSafety )
463 voxelSafety = minCurCommonDelta;
465 if ( maxCurCommonDelta<voxelSafety )
467 voxelSafety = maxCurCommonDelta;
500 G4double workNodeWidth, workMinExtent, workCoord;
501 G4double minVal, maxVal, newDistance=0.;
502 G4double newHeaderMin, newHeaderNodeWidth;
503 G4int depth=0, newDepth=0, workNodeNo=0, newNodeNo=0, newHeaderNoSlices=0;
504 EAxis workHeaderAxis, newHeaderAxis;
505 G4bool isNewVoxel =
false;
507 G4double currentDistance = currentStep;
513 targetPoint = localPoint+localDirection*currentDistance;
514 newDistance = currentDistance;
520 workCoord = targetPoint(workHeaderAxis);
521 minVal = workMinExtent+workNodeNo*workNodeWidth;
525 maxVal = minVal+workNodeWidth;
530 newNodeNo = workNodeNo+1;
531 newHeader = workHeader;
532 newDistance = (maxVal-localPoint(workHeaderAxis))
533 / localDirection(workHeaderAxis);
540 newNodeNo = workNodeNo-1;
541 newHeader = workHeader;
542 newDistance = (minVal-localPoint(workHeaderAxis))
543 / localDirection(workHeaderAxis);
547 currentDistance = newDistance;
549 targetPoint = localPoint+localDirection*currentDistance;
560 workCoord = targetPoint(workHeaderAxis);
570 newHeader = workHeader;
571 newDistance = (maxVal-localPoint(workHeaderAxis))
572 / localDirection(workHeaderAxis);
580 newHeader = workHeader;
581 newDistance = (minVal-localPoint(workHeaderAxis))
582 / localDirection(workHeaderAxis);
586 currentDistance = newDistance;
597 if ( (newNodeNo<0) || (newNodeNo>=
G4int(newHeader->GetNoSlices())))
608 voxelPoint = localPoint+localDirection*newDistance;
610 fVoxelDepth = newDepth;
612 while ( !newVoxelNode )
614 newProxy = newHeader->GetSlice(newNodeNo);
617 newVoxelNode = newProxy->
GetNode();
623 newHeaderAxis = newHeader->
GetAxis();
624 newHeaderNoSlices = newHeader->GetNoSlices();
625 newHeaderMin = newHeader->GetMinExtent();
626 newHeaderNodeWidth = (newHeader->GetMaxExtent()-newHeaderMin)
628 newNodeNo =
G4int( (voxelPoint(newHeaderAxis)-newHeaderMin)
629 / newHeaderNodeWidth );
636 else if ( newNodeNo>=newHeaderNoSlices )
638 newNodeNo = newHeaderNoSlices-1;
674 G4int curNoVolumes, contentNo;
679 motherSolid = motherLogical->
GetSolid();
691 ourSafety = motherSafety;
693 if( motherSafety == 0.0 )
695 #ifdef G4DEBUG_NAVIGATION
702 message <<
"Safety method called for location outside current Volume." <<
G4endl
703 <<
"Location for safety is Outside this volume. " <<
G4endl
704 <<
"The approximate distance to the solid "
705 <<
"(safety from outside) is: "
707 message <<
" Problem occurred with physical volume: "
708 <<
" Name: " << motherPhysical->
GetName()
710 <<
" Local Point = " << localPoint <<
G4endl;
711 message <<
" Description of solid: " << G4endl
712 << *motherSolid <<
G4endl;
713 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
724 messageIn <<
" Point is Inside, but safety is Zero ." <<
G4endl;
725 messageIn <<
" Inexact safety for volume " << motherPhysical->
GetName() << G4endl
726 <<
" Solid: Name= " << motherSolid->
GetName()
728 messageIn <<
" Local point= " << localPoint <<
G4endl;
729 messageIn <<
" Solid parameters: " << G4endl << *motherSolid <<
G4endl;
730 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
752 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
754 sampleNo = curVoxelNode->
GetVolume(contentNo);
755 samplePhysical = motherLogical->
GetDaughter(sampleNo);
760 const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
763 if ( sampleSafety<ourSafety )
765 ourSafety = sampleSafety;
771 sampleSafety,
false,
false);
776 if ( voxelSafety<ourSafety )
778 ourSafety = voxelSafety;