45 fVoxelAxisStack(kNavigatorVoxelStackMax,
kXAxis),
46 fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
47 fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.),
48 fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
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 )
126 if ( localDirection.
dot(exitNormal)>=kMinExitingNormalCosine )
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 )
213 if ( sampleSafety<ourSafety )
215 ourSafety = sampleSafety;
217 if ( sampleSafety<=ourStep )
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);
248 if (
fCheck && ( sampleStep < kInfinity )
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;
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);
763 if ( sampleSafety<ourSafety )
765 ourSafety = sampleSafety;
771 sampleSafety,
false,
false);
776 if ( voxelSafety<ourSafety )
778 ourSafety = voxelSafety;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
CLHEP::Hep3Vector G4ThreeVector
double dot(const Hep3Vector &) const
HepRotation inverse() const
void BlockVolume(const G4int v)
void Enlarge(const G4int nv)
G4bool IsBlocked(const G4int v) const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4VSolid * GetSolid() const
size_t GetNoDaughters() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4VPhysicalVolume * GetTopVolume() const
void SetVerboseLevel(G4int level)
void PreComputeStepLog(const G4VPhysicalVolume *motherPhysical, G4double motherSafety, const G4ThreeVector &localPoint) const
void CheckDaughterEntryPoint(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double sampleStep) const
void PrintDaughterLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, G4double sampleSafety, G4bool onlySafety, const G4ThreeVector &sampleDirection, G4double sampleStep) const
G4bool CheckAndReportBadNormal(const G4ThreeVector &unitNormal, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double step, const G4VSolid *solid, const char *msg) const
void ComputeSafetyLog(const G4VSolid *solid, const G4ThreeVector &point, G4double safety, G4bool isMotherVolume, G4int banner=-1) const
void PostComputeStepLog(const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double motherSafety) const
void ReportOutsideMother(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4VPhysicalVolume *motherPV, G4double tDist=30.0 *CLHEP::cm) const
void AlongComputeStepLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4ThreeVector &localDirection, G4double sampleSafety, G4double sampleStep) const
G4int GetMaxEquivalentSliceNo() const
G4int GetVolume(G4int pVolumeNo) const
size_t GetNoContained() const
G4int GetMinEquivalentSliceNo() const
G4SmartVoxelNode * GetNode() const
G4SmartVoxelHeader * GetHeader() const
const G4RotationMatrix * GetRotation() const
const G4ThreeVector GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
virtual G4GeometryType GetEntityType() const =0
G4NavigationLogger * fLogger
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
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)
std::vector< G4double > fVoxelSliceWidthStack
std::vector< EAxis > fVoxelAxisStack
G4VoxelSafety * fpVoxelSafety
G4SmartVoxelNode * fVoxelNode
G4bool LocateNextVoxel(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentStep)
virtual ~G4VoxelNavigation()
std::vector< G4int > fVoxelNodeNoStack
std::vector< G4SmartVoxelHeader * > fVoxelHeaderStack
std::vector< G4int > fVoxelNoSlicesStack
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) const
void SetVerboseLevel(G4int level)
void SetVerboseLevel(G4int level)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4VPhysicalVolume ¤tPhysical, G4double maxLength=DBL_MAX)