43 #ifdef G4DEBUG_NAVIGATION
44 static int debugVerboseLevel= 5;
52 : fBList(), fVoxelDepth(-1),
58 fVoxelNode(0), fpVoxelSafety(0), fCheck(false), fBestSafety(false)
63 #ifdef G4DEBUG_NAVIGATION
85 const G4double currentProposedStepLength,
93 G4int& blockedReplicaNo )
99 G4double ourStep=currentProposedStepLength, ourSafety;
101 G4int localNoDaughters, sampleNo;
103 G4bool initialNode, noStep;
105 G4int curNoVolumes, contentNo;
110 motherSolid = motherLogical->
GetSolid();
117 ourSafety = motherSafety;
132 if ( exiting && validExitNormal )
138 blockedExitedVol = *pBlockedPhysical;
146 G4bool motherValidExitNormal=
false;
157 &motherValidExitNormal,
161 motherStep, motherSafety);
163 if( (motherStep >=
kInfinity) || (motherStep < 0.0) )
178 validExitNormal=
false;
180 *pBlockedPhysical= 0;
201 for (contentNo=curNoVolumes-1; contentNo>=0; contentNo--)
203 sampleNo = curVoxelNode->
GetVolume(contentNo);
207 samplePhysical = motherLogical->
GetDaughter(sampleNo);
208 if ( samplePhysical!=blockedExitedVol )
220 if ( sampleSafety<ourSafety )
222 ourSafety = sampleSafety;
224 if ( sampleSafety<=ourStep )
226 sampleDirection = sampleTf.TransformAxis(localDirection);
228 sampleSolid->
DistanceToIn(samplePoint, sampleDirection);
234 sampleDirection, sampleStep);
237 if ( sampleStep<=ourStep )
239 ourStep = sampleStep;
242 *pBlockedPhysical = samplePhysical;
243 blockedReplicaNo = -1;
250 sampleDirection, localDirection, sampleSafety, sampleStep);
256 && ( sampleStep >= motherStep ) )
261 samplePoint, sampleDirection,
263 localPoint, localDirection,
264 motherStep, sampleStep);
286 if ( voxelSafety<ourSafety )
288 ourSafety = voxelSafety;
290 if ( currentProposedStepLength<ourSafety )
297 *pBlockedPhysical = 0;
305 if ( motherSafety<=ourStep )
309 motherStep = motherSolid->
DistanceToOut(localPoint, localDirection,
310 true, &motherValidExitNormal, &motherExitNormal);
319 motherStep, motherSafety);
320 if( motherValidExitNormal )
323 localPoint, localDirection,
324 motherStep, motherSolid,
325 "From motherSolid::DistanceToOut" );
329 if( (motherStep >=
kInfinity) || (motherStep < 0.0) )
344 validExitNormal=
false;
346 *pBlockedPhysical= 0;
353 if ( motherStep<=ourStep )
355 ourStep = motherStep;
361 validExitNormal= motherValidExitNormal;
362 exitNormal= motherExitNormal;
364 if ( validExitNormal )
369 exitNormal *= rot->inverse();
375 validExitNormal =
false;
379 newSafety = ourSafety;
404 G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
405 G4int minCurNodeNoDelta, maxCurNodeNoDelta;
406 G4int localVoxelDepth, curNodeNo;
419 curNodeOffset = curNodeNo*curNodeWidth;
422 minCurCommonDelta = localPoint(curHeaderAxis)
424 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
426 if ( minCurNodeNoDelta<maxCurNodeNoDelta )
428 voxelSafety = minCurNodeNoDelta*curNodeWidth;
429 voxelSafety += minCurCommonDelta;
431 else if (maxCurNodeNoDelta < minCurNodeNoDelta)
433 voxelSafety = maxCurNodeNoDelta*curNodeWidth;
434 voxelSafety += maxCurCommonDelta;
438 voxelSafety = minCurNodeNoDelta*curNodeWidth;
439 voxelSafety +=
std::min(minCurCommonDelta,maxCurCommonDelta);
445 while ( (localVoxelDepth>0) && (voxelSafety>0) )
452 curNodeOffset = curNodeNo*curNodeWidth;
453 minCurCommonDelta = localPoint(curHeaderAxis)
455 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
457 if ( minCurCommonDelta<voxelSafety )
459 voxelSafety = minCurCommonDelta;
461 if ( maxCurCommonDelta<voxelSafety )
463 voxelSafety = maxCurCommonDelta;
496 G4double workNodeWidth, workMinExtent, workCoord;
497 G4double minVal, maxVal, newDistance=0.;
498 G4double newHeaderMin, newHeaderNodeWidth;
499 G4int depth=0, newDepth=0, workNodeNo=0, newNodeNo=0, newHeaderNoSlices=0;
500 EAxis workHeaderAxis, newHeaderAxis;
503 G4double currentDistance = currentStep;
511 targetPoint = localPoint+localDirection*currentDistance;
512 newDistance = currentDistance;
518 workCoord = targetPoint(workHeaderAxis);
519 minVal = workMinExtent+workNodeNo*workNodeWidth;
521 if ( minVal<=workCoord+sigma )
523 maxVal = minVal+workNodeWidth;
524 if ( maxVal<=workCoord-sigma )
528 newNodeNo = workNodeNo+1;
529 newHeader = workHeader;
530 newDistance = (maxVal-localPoint(workHeaderAxis))
531 / localDirection(workHeaderAxis);
538 newNodeNo = workNodeNo-1;
539 newHeader = workHeader;
540 newDistance = (minVal-localPoint(workHeaderAxis))
541 / localDirection(workHeaderAxis);
545 currentDistance = newDistance;
547 targetPoint = localPoint+localDirection*currentDistance;
558 workCoord = targetPoint(workHeaderAxis);
561 if ( minVal<=workCoord+sigma )
565 if ( maxVal<=workCoord-sigma )
568 newHeader = workHeader;
569 newDistance = (maxVal-localPoint(workHeaderAxis))
570 / localDirection(workHeaderAxis);
578 newHeader = workHeader;
579 newDistance = (minVal-localPoint(workHeaderAxis))
580 / localDirection(workHeaderAxis);
584 currentDistance = newDistance;
595 if ( (newNodeNo<0) || (newNodeNo>=newHeader->GetNoSlices()))
606 voxelPoint = localPoint+localDirection*newDistance;
608 fVoxelDepth = newDepth;
610 while ( !newVoxelNode )
612 newProxy = newHeader->GetSlice(newNodeNo);
615 newVoxelNode = newProxy->
GetNode();
621 newHeaderAxis = newHeader->
GetAxis();
622 newHeaderNoSlices = newHeader->GetNoSlices();
623 newHeaderMin = newHeader->GetMinExtent();
624 newHeaderNodeWidth = (newHeader->GetMaxExtent()-newHeaderMin)
626 newNodeNo =
G4int( (voxelPoint(newHeaderAxis)-newHeaderMin)
627 / newHeaderNodeWidth );
634 else if ( newNodeNo>=newHeaderNoSlices )
636 newNodeNo = newHeaderNoSlices-1;
672 G4int curNoVolumes, contentNo;
677 motherSolid = motherLogical->
GetSolid();
689 ourSafety = motherSafety;
691 if( motherSafety == 0.0 )
693 #ifdef G4DEBUG_NAVIGATION
700 message <<
"Safety method called for location outside current Volume." <<
G4endl
701 <<
"Location for safety is Outside this volume. " <<
G4endl
702 <<
"The approximate distance to the solid "
703 <<
"(safety from outside) is: "
705 message <<
" Problem occurred with physical volume: "
706 <<
" Name: " << motherPhysical->
GetName()
708 <<
" Local Point = " << localPoint <<
G4endl;
709 message <<
" Description of solid: " << G4endl
710 << *motherSolid <<
G4endl;
711 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
723 messageIn <<
" Point is Inside, but safety is Zero ." <<
G4endl;
724 messageIn <<
" Inexact safety for volume " << motherPhysical->
GetName() << G4endl
725 <<
" Solid: Name= " << motherSolid->
GetName()
727 messageIn <<
" Local point= " << localPoint <<
G4endl;
728 messageIn <<
" Solid parameters: " << G4endl << *motherSolid <<
G4endl;
729 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
751 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
753 sampleNo = curVoxelNode->
GetVolume(contentNo);
754 samplePhysical = motherLogical->
GetDaughter(sampleNo);
764 if ( sampleSafety<ourSafety )
766 ourSafety = sampleSafety;
776 if ( voxelSafety<ourSafety )
778 ourSafety = voxelSafety;
void SetVerboseLevel(G4int level)
void AlongComputeStepLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4ThreeVector &localDirection, G4double sampleSafety, G4double sampleStep) const
G4SmartVoxelHeader * GetHeader() const
G4VPhysicalVolume * GetTopVolume() const
G4int GetMinEquivalentSliceNo() const
void PrintDaughterLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, G4double sampleSafety, G4bool onlySafety, const G4ThreeVector &sampleDirection, G4double sampleStep) const
const G4ThreeVector & GetTranslation() const
static const G4double kInfinity
std::ostringstream G4ExceptionDescription
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
G4int GetVolume(G4int pVolumeNo) const
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) const
G4double GetSurfaceTolerance() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4VPhysicalVolume ¤tPhysical, G4double maxLength=DBL_MAX)
virtual G4GeometryType GetEntityType() const =0
std::vector< G4SmartVoxelHeader * > fVoxelHeaderStack
std::vector< EAxis > fVoxelAxisStack
G4int GetNoContained() const
G4int GetMaxEquivalentSliceNo() const
void ReportOutsideMother(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4VPhysicalVolume *motherPV, G4double tDist=30.0 *CLHEP::cm) const
std::vector< G4double > fVoxelSliceWidthStack
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
G4bool LocateNextVoxel(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentStep)
std::vector< G4int > fVoxelNodeNoStack
void BlockVolume(const G4int v)
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
G4bool IsBlocked(const G4int v) const
std::vector< G4int > fVoxelNoSlicesStack
G4bool CheckAndReportBadNormal(const G4ThreeVector &unitNormal, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double step, const G4VSolid *solid, const char *msg) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
static const double kMinExitingNormalCosine
G4NavigationLogger * fLogger
G4int GetNoDaughters() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void SetVerboseLevel(G4int level)
virtual ~G4VoxelNavigation()
G4LogicalVolume * GetLogicalVolume() const
G4SmartVoxelNode * GetNode() const
void ComputeSafetyLog(const G4VSolid *solid, const G4ThreeVector &point, G4double safety, G4bool isMotherVolume, G4int banner=-1) const
void SetVerboseLevel(G4int level)
void PreComputeStepLog(const G4VPhysicalVolume *motherPhysical, G4double motherSafety, const G4ThreeVector &localPoint) const
virtual G4int GetCopyNo() const =0
const G4RotationMatrix * GetRotation() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4VoxelSafety * fpVoxelSafety
static const G4int kNavigatorVoxelStackMax
G4SmartVoxelNode * fVoxelNode
void PostComputeStepLog(const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double motherSafety) 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
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
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)
static G4GeometryTolerance * GetInstance()
G4VSolid * GetSolid() const
void Enlarge(const G4int nv)