45 : fBList(), fVoxelDepth(-1),
46 fVoxelAxisStack(kNavigatorVoxelStackMax,
kXAxis),
47 fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
48 fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.),
49 fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
51 fVoxelNode(0), fpVoxelSafety(0), fCheck(false), fBestSafety(false)
74 const G4double currentProposedStepLength,
82 G4int& blockedReplicaNo )
88 G4double ourStep=currentProposedStepLength, motherSafety, ourSafety;
89 G4int localNoDaughters, sampleNo;
91 G4bool initialNode, noStep;
93 G4int curNoVolumes, contentNo;
98 motherSolid = motherLogical->
GetSolid();
105 ourSafety = motherSafety;
120 if ( exiting && validExitNormal )
122 if ( localDirection.
dot(exitNormal)>=kMinExitingNormalCosine )
126 blockedExitedVol = *pBlockedPhysical;
145 for (contentNo=curNoVolumes-1; contentNo>=0; contentNo--)
147 sampleNo = curVoxelNode->
GetVolume(contentNo);
151 samplePhysical = motherLogical->
GetDaughter(sampleNo);
152 if ( samplePhysical!=blockedExitedVol )
158 sampleTf.TransformPoint(localPoint);
169 if ( sampleSafety<ourSafety )
171 ourSafety = sampleSafety;
173 if ( sampleSafety<=ourStep )
175 sampleDirection = sampleTf.TransformAxis(localDirection);
177 sampleSolid->
DistanceToIn(samplePoint, sampleDirection);
182 sampleSafety, sampleStep);
185 if ( sampleStep<=ourStep )
187 ourStep = sampleStep;
190 *pBlockedPhysical = samplePhysical;
191 blockedReplicaNo = -1;
200 sampleDirection, localDirection, sampleSafety, sampleStep);
212 if ( voxelSafety<ourSafety )
214 ourSafety = voxelSafety;
216 if ( currentProposedStepLength<ourSafety )
223 *pBlockedPhysical = 0;
231 if ( motherSafety<=ourStep )
236 true, &validExitNormal, &exitNormal);
241 motherStep, motherSafety);
244 if ( motherStep<=ourStep )
246 ourStep = motherStep;
249 if ( validExitNormal )
260 validExitNormal =
false;
264 newSafety = ourSafety;
289 G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
290 G4int minCurNodeNoDelta, maxCurNodeNoDelta;
291 G4int localVoxelDepth, curNodeNo;
304 curNodeOffset = curNodeNo*curNodeWidth;
307 minCurCommonDelta = localPoint(curHeaderAxis)
309 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
311 if ( minCurNodeNoDelta<maxCurNodeNoDelta )
313 voxelSafety = minCurNodeNoDelta*curNodeWidth;
314 voxelSafety += minCurCommonDelta;
316 else if (maxCurNodeNoDelta < minCurNodeNoDelta)
318 voxelSafety = maxCurNodeNoDelta*curNodeWidth;
319 voxelSafety += maxCurCommonDelta;
323 voxelSafety = minCurNodeNoDelta*curNodeWidth;
324 voxelSafety +=
std::min(minCurCommonDelta,maxCurCommonDelta);
330 while ( (localVoxelDepth>0) && (voxelSafety>0) )
337 curNodeOffset = curNodeNo*curNodeWidth;
338 minCurCommonDelta = localPoint(curHeaderAxis)
340 maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
342 if ( minCurCommonDelta<voxelSafety )
344 voxelSafety = minCurCommonDelta;
346 if ( maxCurCommonDelta<voxelSafety )
348 voxelSafety = maxCurCommonDelta;
381 G4double workNodeWidth, workMinExtent, workCoord;
382 G4double minVal, maxVal, newDistance=0.;
383 G4double newHeaderMin, newHeaderNodeWidth;
384 G4int depth=0, newDepth=0, workNodeNo=0, newNodeNo=0, newHeaderNoSlices=0;
385 EAxis workHeaderAxis, newHeaderAxis;
388 G4double currentDistance = currentStep;
396 targetPoint = localPoint+localDirection*currentDistance;
397 newDistance = currentDistance;
403 workCoord = targetPoint(workHeaderAxis);
404 minVal = workMinExtent+workNodeNo*workNodeWidth;
406 if ( minVal<=workCoord+sigma )
408 maxVal = minVal+workNodeWidth;
409 if ( maxVal<=workCoord-sigma )
413 newNodeNo = workNodeNo+1;
414 newHeader = workHeader;
415 newDistance = (maxVal-localPoint(workHeaderAxis))
416 / localDirection(workHeaderAxis);
423 newNodeNo = workNodeNo-1;
424 newHeader = workHeader;
425 newDistance = (minVal-localPoint(workHeaderAxis))
426 / localDirection(workHeaderAxis);
430 currentDistance = newDistance;
432 targetPoint = localPoint+localDirection*currentDistance;
443 workCoord = targetPoint(workHeaderAxis);
446 if ( minVal<=workCoord+sigma )
450 if ( maxVal<=workCoord-sigma )
453 newHeader = workHeader;
454 newDistance = (maxVal-localPoint(workHeaderAxis))
455 / localDirection(workHeaderAxis);
463 newHeader = workHeader;
464 newDistance = (minVal-localPoint(workHeaderAxis))
465 / localDirection(workHeaderAxis);
469 currentDistance = newDistance;
480 if ( (newNodeNo<0) || (newNodeNo>=newHeader->GetNoSlices()))
491 voxelPoint = localPoint+localDirection*newDistance;
493 fVoxelDepth = newDepth;
495 while ( !newVoxelNode )
497 newProxy = newHeader->GetSlice(newNodeNo);
500 newVoxelNode = newProxy->
GetNode();
506 newHeaderAxis = newHeader->
GetAxis();
507 newHeaderNoSlices = newHeader->GetNoSlices();
508 newHeaderMin = newHeader->GetMinExtent();
509 newHeaderNodeWidth = (newHeader->GetMaxExtent()-newHeaderMin)
511 newNodeNo =
G4int( (voxelPoint(newHeaderAxis)-newHeaderMin)
512 / newHeaderNodeWidth );
519 else if ( newNodeNo>=newHeaderNoSlices )
521 newNodeNo = newHeaderNoSlices-1;
557 G4int curNoVolumes, contentNo;
562 motherSolid = motherLogical->
GetSolid();
574 ourSafety = motherSafety;
576 if( motherSafety == 0.0 )
578 #ifdef G4DEBUG_NAVIGATION
585 message <<
"Safety method called for location outside current Volume." <<
G4endl
586 <<
"Location for safety is Outside this volume. " <<
G4endl
587 <<
"The approximate distance to the solid "
588 <<
"(safety from outside) is: "
590 message <<
" Problem occurred with physical volume: "
591 <<
" Name: " << motherPhysical->
GetName()
593 <<
" Local Point = " << localPoint <<
G4endl;
594 message <<
" Description of solid: " << G4endl
595 << *motherSolid <<
G4endl;
596 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
608 messageIn <<
" Point is Inside, but safety is Zero ." <<
G4endl;
609 messageIn <<
" Inexact safety for volume " << motherPhysical->
GetName() << G4endl
610 <<
" Solid: Name= " << motherSolid->
GetName()
612 messageIn <<
" Local point= " << localPoint <<
G4endl;
613 messageIn <<
" Solid parameters: " << G4endl << *motherSolid <<
G4endl;
614 G4Exception(
"G4VoxelNavigation::ComputeSafety()",
"GeomNav0003",
636 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
638 sampleNo = curVoxelNode->
GetVolume(contentNo);
639 samplePhysical = motherLogical->
GetDaughter(sampleNo);
645 sampleTf.TransformPoint(localPoint);
649 if ( sampleSafety<ourSafety )
651 ourSafety = sampleSafety;
661 if ( voxelSafety<ourSafety )
663 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
const G4ThreeVector & GetTranslation() const
std::ostringstream G4ExceptionDescription
double dot(const Hep3Vector &) const
void PrintDaughterLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, G4double sampleSafety, G4double sampleStep) const
G4int GetVolume(G4int pVolumeNo) const
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) const
G4double GetSurfaceTolerance() const
void ComputeSafetyLog(const G4VSolid *solid, const G4ThreeVector &point, G4double safety, G4bool banner) 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
HepRotation inverse() const
G4int GetMaxEquivalentSliceNo() 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
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
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 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
G4SmartVoxelNode * fVoxelNode
void PostComputeStepLog(const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double motherSafety) 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)