45 : fVoxelAxisStack(kNavigatorVoxelStackMax,
kXAxis),
46 fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
47 fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.),
48 fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
55#ifdef G4DEBUG_NAVIGATION
90 const G4double currentProposedStepLength,
98 G4int& blockedReplicaNo )
104 G4double ourStep=currentProposedStepLength, ourSafety;
106 G4int localNoDaughters, sampleNo;
108 G4bool initialNode, noStep;
110 G4long curNoVolumes, contentNo;
115 motherSolid = motherLogical->
GetSolid();
122 ourSafety = motherSafety;
137 if ( exiting && validExitNormal )
139 if ( localDirection.
dot(exitNormal)>=kMinExitingNormalCosine )
143 blockedExitedVol = *pBlockedPhysical;
151 G4bool motherValidExitNormal =
false;
162 &motherValidExitNormal,
179 for (contentNo=curNoVolumes-1; contentNo>=0; contentNo--)
185 samplePhysical = motherLogical->
GetDaughter(sampleNo);
186 if ( samplePhysical!=blockedExitedVol )
198 if ( sampleSafety<ourSafety )
200 ourSafety = sampleSafety;
202 if ( sampleSafety<=ourStep )
206 sampleSolid->
DistanceToIn(samplePoint, sampleDirection);
212 sampleDirection, sampleStep);
215 if ( sampleStep<=ourStep )
217 ourStep = sampleStep;
220 *pBlockedPhysical = samplePhysical;
221 blockedReplicaNo = -1;
228 sampleDirection, localDirection, sampleSafety, sampleStep);
233 if (
fCheck && ( sampleStep < kInfinity )
234 && ( sampleStep >= motherStep ) )
239 samplePoint, sampleDirection,
241 localPoint, localDirection,
242 motherStep, sampleStep);
264 if ( voxelSafety<ourSafety )
266 ourSafety = voxelSafety;
268 if ( currentProposedStepLength<ourSafety )
275 *pBlockedPhysical =
nullptr;
283 if ( motherSafety<=ourStep )
286 motherStep = motherSolid->
DistanceToOut(localPoint, localDirection,
287 true, &motherValidExitNormal, &motherExitNormal);
292 motherStep, motherSafety);
293 if( motherValidExitNormal )
296 localPoint, localDirection,
297 motherStep, motherSolid,
298 "From motherSolid::DistanceToOut" );
302 if( (motherStep >= kInfinity) || (motherStep < 0.0) )
320 validExitNormal=
false;
322 *pBlockedPhysical =
nullptr;
323 blockedReplicaNo = 0;
329 if ( motherStep<=ourStep )
331 ourStep = motherStep;
337 validExitNormal = motherValidExitNormal;
338 exitNormal = motherExitNormal;
340 if ( validExitNormal )
352 "From RotationMatrix" );
360 validExitNormal =
false;
364 newSafety = ourSafety;
389 G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
390 G4int minCurNodeNoDelta, maxCurNodeNoDelta;
391 G4int localVoxelDepth, curNodeNo;
404 curNodeOffset = curNodeNo*curNodeWidth;
407 minCurCommonDelta = localPoint(curHeaderAxis)
409 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
411 if ( minCurNodeNoDelta<maxCurNodeNoDelta )
413 voxelSafety = minCurNodeNoDelta*curNodeWidth;
414 voxelSafety += minCurCommonDelta;
416 else if (maxCurNodeNoDelta < minCurNodeNoDelta)
418 voxelSafety = maxCurNodeNoDelta*curNodeWidth;
419 voxelSafety += maxCurCommonDelta;
423 voxelSafety = minCurNodeNoDelta*curNodeWidth;
424 voxelSafety += std::min(minCurCommonDelta,maxCurCommonDelta);
431 while ( (localVoxelDepth>0) && (voxelSafety>0) )
438 curNodeOffset = curNodeNo*curNodeWidth;
439 minCurCommonDelta = localPoint(curHeaderAxis)
441 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
443 if ( minCurCommonDelta<voxelSafety )
445 voxelSafety = minCurCommonDelta;
447 if ( maxCurCommonDelta<voxelSafety )
449 voxelSafety = maxCurCommonDelta;
482 G4double workNodeWidth, workMinExtent, workCoord;
483 G4double minVal, maxVal, newDistance=0.;
484 G4double newHeaderMin, newHeaderNodeWidth;
485 G4int depth=0, newDepth=0, workNodeNo=0, newNodeNo=0, newHeaderNoSlices=0;
486 EAxis workHeaderAxis, newHeaderAxis;
487 G4bool isNewVoxel =
false;
489 G4double currentDistance = currentStep;
495 targetPoint = localPoint+localDirection*currentDistance;
496 newDistance = currentDistance;
502 workCoord = targetPoint(workHeaderAxis);
503 minVal = workMinExtent+workNodeNo*workNodeWidth;
507 maxVal = minVal+workNodeWidth;
512 newNodeNo = workNodeNo+1;
513 newHeader = workHeader;
514 newDistance = (maxVal-localPoint(workHeaderAxis))
515 / localDirection(workHeaderAxis);
522 newNodeNo = workNodeNo-1;
523 newHeader = workHeader;
524 newDistance = (minVal-localPoint(workHeaderAxis))
525 / localDirection(workHeaderAxis);
529 currentDistance = newDistance;
531 targetPoint = localPoint+localDirection*currentDistance;
542 workCoord = targetPoint(workHeaderAxis);
552 newHeader = workHeader;
553 newDistance = (maxVal-localPoint(workHeaderAxis))
554 / localDirection(workHeaderAxis);
562 newHeader = workHeader;
563 newDistance = (minVal-localPoint(workHeaderAxis))
564 / localDirection(workHeaderAxis);
568 currentDistance = newDistance;
579 if ( (newNodeNo<0) || (newNodeNo>=
G4int(newHeader->GetNoSlices())))
590 voxelPoint = localPoint+localDirection*newDistance;
593 newVoxelNode =
nullptr;
594 while ( newVoxelNode ==
nullptr )
596 newProxy = newHeader->GetSlice(newNodeNo);
599 newVoxelNode = newProxy->
GetNode();
605 newHeaderAxis = newHeader->
GetAxis();
606 newHeaderNoSlices = (
G4int)newHeader->GetNoSlices();
607 newHeaderMin = newHeader->GetMinExtent();
608 newHeaderNodeWidth = (newHeader->GetMaxExtent()-newHeaderMin)
610 newNodeNo =
G4int( (voxelPoint(newHeaderAxis)-newHeaderMin)
611 / newHeaderNodeWidth );
618 else if ( newNodeNo>=newHeaderNoSlices )
620 newNodeNo = newHeaderNoSlices-1;
656 G4long curNoVolumes, contentNo;
661 motherSolid = motherLogical->
GetSolid();
673 ourSafety = motherSafety;
675 if( motherSafety == 0.0 )
677#ifdef G4DEBUG_NAVIGATION
684 message <<
"Safety method called for location outside current Volume." <<
G4endl
685 <<
"Location for safety is Outside this volume. " <<
G4endl
686 <<
"The approximate distance to the solid "
687 <<
"(safety from outside) is: "
689 message <<
" Problem occurred with physical volume: "
690 <<
" Name: " << motherPhysical->
GetName()
692 <<
" Local Point = " << localPoint <<
G4endl;
693 message <<
" Description of solid: " <<
G4endl
694 << *motherSolid <<
G4endl;
695 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
706 messageIn <<
" Point is Inside, but safety is Zero ." <<
G4endl;
707 messageIn <<
" Inexact safety for volume " << motherPhysical->
GetName() <<
G4endl
708 <<
" Solid: Name= " << motherSolid->
GetName()
710 messageIn <<
" Local point= " << localPoint <<
G4endl;
711 messageIn <<
" Solid parameters: " <<
G4endl << *motherSolid <<
G4endl;
712 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
734 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
737 samplePhysical = motherLogical->
GetDaughter(sampleNo);
745 if ( sampleSafety<ourSafety )
747 ourSafety = sampleSafety;
753 sampleSafety,
false, 0);
758 if ( voxelSafety<ourSafety )
760 ourSafety = voxelSafety;
770 assert(motherLogical !=
nullptr);
772 if (
auto pVoxelHeader = motherLogical->GetVoxelHeader() )
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
std::size_t GetNoDaughters() const
G4VPhysicalVolume * GetDaughter(const std::size_t 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
std::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
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX) override
virtual void SetVerboseLevel(G4int level) override
G4NavigationLogger * fLogger
std::vector< G4double > fVoxelSliceWidthStack
std::vector< EAxis > fVoxelAxisStack
G4VoxelSafety * fpVoxelSafety
G4SmartVoxelNode * fVoxelNode
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) override
G4bool LocateNextVoxel(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentStep)
G4SmartVoxelNode * VoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
virtual void RelocateWithinVolume(G4VPhysicalVolume *motherPhysical, const G4ThreeVector &localPoint) override
virtual ~G4VoxelNavigation()
std::vector< G4int > fVoxelNodeNoStack
std::vector< G4SmartVoxelHeader * > fVoxelHeaderStack
std::vector< G4int > fVoxelNoSlicesStack
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) const
void SetVerboseLevel(G4int level)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4VPhysicalVolume ¤tPhysical, G4double maxLength=DBL_MAX)