48 : fBList(), fVoxelDepth(-1),
54 fVoxelNode(0), fpVoxelSafety(0), fCheck(false), fBestSafety(false)
60 #ifdef G4DEBUG_NAVIGATION
82 const G4double currentProposedStepLength,
90 G4int& blockedReplicaNo )
96 G4double ourStep=currentProposedStepLength, ourSafety;
98 G4int localNoDaughters, sampleNo;
100 G4bool initialNode, noStep;
102 G4int curNoVolumes, contentNo;
107 motherSolid = motherLogical->
GetSolid();
114 ourSafety = motherSafety;
129 if ( exiting && validExitNormal )
135 blockedExitedVol = *pBlockedPhysical;
143 G4bool motherValidExitNormal=
false;
154 &motherValidExitNormal,
158 motherStep, motherSafety);
160 if( (motherStep >=
kInfinity) || (motherStep < 0.0) )
176 validExitNormal=
false;
178 *pBlockedPhysical= 0;
199 for (contentNo=curNoVolumes-1; contentNo>=0; contentNo--)
201 sampleNo = curVoxelNode->
GetVolume(contentNo);
205 samplePhysical = motherLogical->
GetDaughter(sampleNo);
206 if ( samplePhysical!=blockedExitedVol )
218 if ( sampleSafety<ourSafety )
220 ourSafety = sampleSafety;
222 if ( sampleSafety<=ourStep )
224 sampleDirection = sampleTf.TransformAxis(localDirection);
226 sampleSolid->
DistanceToIn(samplePoint, sampleDirection);
232 sampleDirection, sampleStep);
235 if ( sampleStep<=ourStep )
237 ourStep = sampleStep;
240 *pBlockedPhysical = samplePhysical;
241 blockedReplicaNo = -1;
248 sampleDirection, localDirection, sampleSafety, sampleStep);
254 && ( sampleStep >= motherStep ) )
259 samplePoint, sampleDirection,
261 localPoint, localDirection,
262 motherStep, sampleStep);
284 if ( voxelSafety<ourSafety )
286 ourSafety = voxelSafety;
288 if ( currentProposedStepLength<ourSafety )
295 *pBlockedPhysical = 0;
303 if ( motherSafety<=ourStep )
307 motherStep = motherSolid->
DistanceToOut(localPoint, localDirection,
308 true, &motherValidExitNormal, &motherExitNormal);
317 motherStep, motherSafety);
318 if( motherValidExitNormal )
321 localPoint, localDirection,
322 motherStep, motherSolid,
323 "From motherSolid::DistanceToOut" );
327 if( (motherStep >=
kInfinity) || (motherStep < 0.0) )
345 validExitNormal=
false;
347 *pBlockedPhysical= 0;
354 if ( motherStep<=ourStep )
356 ourStep = motherStep;
362 validExitNormal= motherValidExitNormal;
363 exitNormal= motherExitNormal;
365 if ( validExitNormal )
370 exitNormal *= rot->inverse();
377 "From RotationMatrix" );
384 validExitNormal =
false;
388 newSafety = ourSafety;
413 G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
414 G4int minCurNodeNoDelta, maxCurNodeNoDelta;
415 G4int localVoxelDepth, curNodeNo;
428 curNodeOffset = curNodeNo*curNodeWidth;
431 minCurCommonDelta = localPoint(curHeaderAxis)
433 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
435 if ( minCurNodeNoDelta<maxCurNodeNoDelta )
437 voxelSafety = minCurNodeNoDelta*curNodeWidth;
438 voxelSafety += minCurCommonDelta;
440 else if (maxCurNodeNoDelta < minCurNodeNoDelta)
442 voxelSafety = maxCurNodeNoDelta*curNodeWidth;
443 voxelSafety += maxCurCommonDelta;
447 voxelSafety = minCurNodeNoDelta*curNodeWidth;
448 voxelSafety +=
std::min(minCurCommonDelta,maxCurCommonDelta);
454 while ( (localVoxelDepth>0) && (voxelSafety>0) )
461 curNodeOffset = curNodeNo*curNodeWidth;
462 minCurCommonDelta = localPoint(curHeaderAxis)
464 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
466 if ( minCurCommonDelta<voxelSafety )
468 voxelSafety = minCurCommonDelta;
470 if ( maxCurCommonDelta<voxelSafety )
472 voxelSafety = maxCurCommonDelta;
505 G4double workNodeWidth, workMinExtent, workCoord;
506 G4double minVal, maxVal, newDistance=0.;
507 G4double newHeaderMin, newHeaderNodeWidth;
508 G4int depth=0, newDepth=0, workNodeNo=0, newNodeNo=0, newHeaderNoSlices=0;
509 EAxis workHeaderAxis, newHeaderAxis;
512 G4double currentDistance = currentStep;
518 targetPoint = localPoint+localDirection*currentDistance;
519 newDistance = currentDistance;
525 workCoord = targetPoint(workHeaderAxis);
526 minVal = workMinExtent+workNodeNo*workNodeWidth;
530 maxVal = minVal+workNodeWidth;
535 newNodeNo = workNodeNo+1;
536 newHeader = workHeader;
537 newDistance = (maxVal-localPoint(workHeaderAxis))
538 / localDirection(workHeaderAxis);
545 newNodeNo = workNodeNo-1;
546 newHeader = workHeader;
547 newDistance = (minVal-localPoint(workHeaderAxis))
548 / localDirection(workHeaderAxis);
552 currentDistance = newDistance;
554 targetPoint = localPoint+localDirection*currentDistance;
565 workCoord = targetPoint(workHeaderAxis);
575 newHeader = workHeader;
576 newDistance = (maxVal-localPoint(workHeaderAxis))
577 / localDirection(workHeaderAxis);
585 newHeader = workHeader;
586 newDistance = (minVal-localPoint(workHeaderAxis))
587 / localDirection(workHeaderAxis);
591 currentDistance = newDistance;
602 if ( (newNodeNo<0) || (newNodeNo>=newHeader->GetNoSlices()))
613 voxelPoint = localPoint+localDirection*newDistance;
615 fVoxelDepth = newDepth;
617 while ( !newVoxelNode )
619 newProxy = newHeader->GetSlice(newNodeNo);
622 newVoxelNode = newProxy->
GetNode();
628 newHeaderAxis = newHeader->
GetAxis();
629 newHeaderNoSlices = newHeader->GetNoSlices();
630 newHeaderMin = newHeader->GetMinExtent();
631 newHeaderNodeWidth = (newHeader->GetMaxExtent()-newHeaderMin)
633 newNodeNo =
G4int( (voxelPoint(newHeaderAxis)-newHeaderMin)
634 / newHeaderNodeWidth );
641 else if ( newNodeNo>=newHeaderNoSlices )
643 newNodeNo = newHeaderNoSlices-1;
679 G4int curNoVolumes, contentNo;
684 motherSolid = motherLogical->
GetSolid();
696 ourSafety = motherSafety;
698 if( motherSafety == 0.0 )
700 #ifdef G4DEBUG_NAVIGATION
707 message <<
"Safety method called for location outside current Volume." <<
G4endl
708 <<
"Location for safety is Outside this volume. " <<
G4endl
709 <<
"The approximate distance to the solid "
710 <<
"(safety from outside) is: "
712 message <<
" Problem occurred with physical volume: "
713 <<
" Name: " << motherPhysical->
GetName()
715 <<
" Local Point = " << localPoint <<
G4endl;
716 message <<
" Description of solid: " << G4endl
717 << *motherSolid <<
G4endl;
718 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
730 messageIn <<
" Point is Inside, but safety is Zero ." <<
G4endl;
731 messageIn <<
" Inexact safety for volume " << motherPhysical->
GetName() << G4endl
732 <<
" Solid: Name= " << motherSolid->
GetName()
734 messageIn <<
" Local point= " << localPoint <<
G4endl;
735 messageIn <<
" Solid parameters: " << G4endl << *motherSolid <<
G4endl;
736 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
758 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
760 sampleNo = curVoxelNode->
GetVolume(contentNo);
761 samplePhysical = motherLogical->
GetDaughter(sampleNo);
771 if ( sampleSafety<ourSafety )
773 ourSafety = sampleSafety;
783 if ( voxelSafety<ourSafety )
785 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)