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 )
212 sampleTf.TransformPoint(localPoint);
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 )
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);
455 while ( (localVoxelDepth>0) && (voxelSafety>0) )
462 curNodeOffset = curNodeNo*curNodeWidth;
463 minCurCommonDelta = localPoint(curHeaderAxis)
465 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
467 if ( minCurCommonDelta<voxelSafety )
469 voxelSafety = minCurCommonDelta;
471 if ( maxCurCommonDelta<voxelSafety )
473 voxelSafety = maxCurCommonDelta;
506 G4double workNodeWidth, workMinExtent, workCoord;
507 G4double minVal, maxVal, newDistance=0.;
508 G4double newHeaderMin, newHeaderNodeWidth;
509 G4int depth=0, newDepth=0, workNodeNo=0, newNodeNo=0, newHeaderNoSlices=0;
510 EAxis workHeaderAxis, newHeaderAxis;
513 G4double currentDistance = currentStep;
519 targetPoint = localPoint+localDirection*currentDistance;
520 newDistance = currentDistance;
526 workCoord = targetPoint(workHeaderAxis);
527 minVal = workMinExtent+workNodeNo*workNodeWidth;
531 maxVal = minVal+workNodeWidth;
536 newNodeNo = workNodeNo+1;
537 newHeader = workHeader;
538 newDistance = (maxVal-localPoint(workHeaderAxis))
539 / localDirection(workHeaderAxis);
546 newNodeNo = workNodeNo-1;
547 newHeader = workHeader;
548 newDistance = (minVal-localPoint(workHeaderAxis))
549 / localDirection(workHeaderAxis);
553 currentDistance = newDistance;
555 targetPoint = localPoint+localDirection*currentDistance;
566 workCoord = targetPoint(workHeaderAxis);
576 newHeader = workHeader;
577 newDistance = (maxVal-localPoint(workHeaderAxis))
578 / localDirection(workHeaderAxis);
586 newHeader = workHeader;
587 newDistance = (minVal-localPoint(workHeaderAxis))
588 / localDirection(workHeaderAxis);
592 currentDistance = newDistance;
603 if ( (newNodeNo<0) || (newNodeNo>=newHeader->GetNoSlices()))
614 voxelPoint = localPoint+localDirection*newDistance;
616 fVoxelDepth = newDepth;
618 while ( !newVoxelNode )
620 newProxy = newHeader->GetSlice(newNodeNo);
623 newVoxelNode = newProxy->
GetNode();
629 newHeaderAxis = newHeader->
GetAxis();
630 newHeaderNoSlices = newHeader->GetNoSlices();
631 newHeaderMin = newHeader->GetMinExtent();
632 newHeaderNodeWidth = (newHeader->GetMaxExtent()-newHeaderMin)
634 newNodeNo =
G4int( (voxelPoint(newHeaderAxis)-newHeaderMin)
635 / newHeaderNodeWidth );
642 else if ( newNodeNo>=newHeaderNoSlices )
644 newNodeNo = newHeaderNoSlices-1;
680 G4int curNoVolumes, contentNo;
685 motherSolid = motherLogical->
GetSolid();
697 ourSafety = motherSafety;
699 if( motherSafety == 0.0 )
701 #ifdef G4DEBUG_NAVIGATION
708 message <<
"Safety method called for location outside current Volume." <<
G4endl
709 <<
"Location for safety is Outside this volume. " <<
G4endl
710 <<
"The approximate distance to the solid "
711 <<
"(safety from outside) is: "
713 message <<
" Problem occurred with physical volume: "
714 <<
" Name: " << motherPhysical->
GetName()
716 <<
" Local Point = " << localPoint <<
G4endl;
717 message <<
" Description of solid: " << G4endl
718 << *motherSolid <<
G4endl;
719 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
731 messageIn <<
" Point is Inside, but safety is Zero ." <<
G4endl;
732 messageIn <<
" Inexact safety for volume " << motherPhysical->
GetName() << G4endl
733 <<
" Solid: Name= " << motherSolid->
GetName()
735 messageIn <<
" Local point= " << localPoint <<
G4endl;
736 messageIn <<
" Solid parameters: " << G4endl << *motherSolid <<
G4endl;
737 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
759 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
761 sampleNo = curVoxelNode->
GetVolume(contentNo);
762 samplePhysical = motherLogical->
GetDaughter(sampleNo);
768 sampleTf.TransformPoint(localPoint);
772 if ( sampleSafety<ourSafety )
774 ourSafety = sampleSafety;
784 if ( voxelSafety<ourSafety )
786 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
static const G4double kInfinity
std::ostringstream G4ExceptionDescription
CLHEP::Hep3Vector G4ThreeVector
double dot(const Hep3Vector &) const
G4int GetVolume(G4int pVolumeNo) const
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) const
G4double GetSurfaceTolerance() const
G4VSolid * GetSolid() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4VPhysicalVolume ¤tPhysical, G4double maxLength=DBL_MAX)
const G4RotationMatrix * GetRotation() const
virtual G4GeometryType GetEntityType() const =0
std::vector< G4SmartVoxelHeader * > fVoxelHeaderStack
std::vector< EAxis > fVoxelAxisStack
G4int GetNoContained() const
HepRotation inverse() 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)
const G4ThreeVector & GetTranslation() const
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
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()
void Enlarge(const G4int nv)