Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes
G4VoxelNavigation Class Reference

#include <G4VoxelNavigation.hh>

Inheritance diagram for G4VoxelNavigation:
G4ParameterisedNavigation

Public Member Functions

 G4VoxelNavigation ()
 
virtual ~G4VoxelNavigation ()
 
G4SmartVoxelNodeVoxelLocate (G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
 
virtual G4bool LevelLocate (G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
 
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)
 
virtual G4double ComputeSafety (const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
 
G4int GetVerboseLevel () const
 
void SetVerboseLevel (G4int level)
 
void CheckMode (G4bool mode)
 
void EnableBestSafety (G4bool flag=false)
 

Protected Member Functions

G4double ComputeVoxelSafety (const G4ThreeVector &localPoint) const
 
G4bool LocateNextVoxel (const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentStep)
 
G4SmartVoxelNodeVoxelLocateLight (G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint) const
 

Protected Attributes

G4BlockingList fBList
 
G4int fVoxelDepth
 
std::vector< EAxisfVoxelAxisStack
 
std::vector< G4intfVoxelNoSlicesStack
 
std::vector< G4doublefVoxelSliceWidthStack
 
std::vector< G4intfVoxelNodeNoStack
 
std::vector< G4SmartVoxelHeader * > fVoxelHeaderStack
 
G4SmartVoxelNodefVoxelNode
 
G4VoxelSafetyfpVoxelSafety
 
G4bool fCheck
 
G4bool fBestSafety
 
G4NavigationLoggerfLogger
 

Detailed Description

Definition at line 67 of file G4VoxelNavigation.hh.

Constructor & Destructor Documentation

G4VoxelNavigation::G4VoxelNavigation ( )

Definition at line 44 of file G4VoxelNavigation.cc.

References fLogger, and fpVoxelSafety.

45  : fBList(), fVoxelDepth(-1),
46  fVoxelAxisStack(kNavigatorVoxelStackMax,kXAxis),
47  fVoxelNoSlicesStack(kNavigatorVoxelStackMax,0),
48  fVoxelSliceWidthStack(kNavigatorVoxelStackMax,0.),
49  fVoxelNodeNoStack(kNavigatorVoxelStackMax,0),
50  fVoxelHeaderStack(kNavigatorVoxelStackMax,(G4SmartVoxelHeader*)0),
51  fVoxelNode(0), fpVoxelSafety(0), fCheck(false), fBestSafety(false)
52 {
53  fLogger = new G4NavigationLogger("G4VoxelNavigation");
54  fpVoxelSafety = new G4VoxelSafety ();
55 }
std::vector< G4SmartVoxelHeader * > fVoxelHeaderStack
std::vector< EAxis > fVoxelAxisStack
std::vector< G4double > fVoxelSliceWidthStack
G4BlockingList fBList
std::vector< G4int > fVoxelNodeNoStack
std::vector< G4int > fVoxelNoSlicesStack
G4NavigationLogger * fLogger
G4VoxelSafety * fpVoxelSafety
G4SmartVoxelNode * fVoxelNode
G4VoxelNavigation::~G4VoxelNavigation ( )
virtual

Definition at line 61 of file G4VoxelNavigation.cc.

References fLogger, and fpVoxelSafety.

62 {
63  delete fpVoxelSafety;
64  delete fLogger;
65 }
G4NavigationLogger * fLogger
G4VoxelSafety * fpVoxelSafety

Member Function Documentation

void G4VoxelNavigation::CheckMode ( G4bool  mode)
inline
G4double G4VoxelNavigation::ComputeSafety ( const G4ThreeVector globalpoint,
const G4NavigationHistory history,
const G4double  pMaxLength = DBL_MAX 
)
virtual

Reimplemented in G4ParameterisedNavigation.

Definition at line 547 of file G4VoxelNavigation.cc.

References G4VoxelSafety::ComputeSafety(), G4NavigationLogger::ComputeSafetyLog(), ComputeVoxelSafety(), G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), fBestSafety, fCheck, fLogger, fpVoxelSafety, fVoxelNode, G4endl, G4Exception(), G4VPhysicalVolume::GetCopyNo(), G4LogicalVolume::GetDaughter(), G4VSolid::GetEntityType(), G4VPhysicalVolume::GetLogicalVolume(), G4VSolid::GetName(), G4VPhysicalVolume::GetName(), G4SmartVoxelNode::GetNoContained(), G4VPhysicalVolume::GetRotation(), G4LogicalVolume::GetSolid(), G4NavigationHistory::GetTopVolume(), G4VPhysicalVolume::GetTranslation(), G4SmartVoxelNode::GetVolume(), G4VSolid::Inside(), G4AffineTransform::Invert(), JustWarning, kInside, and kOutside.

Referenced by G4Navigator::ComputeSafety(), and G4ITNavigator::ComputeSafety().

550 {
551  G4VPhysicalVolume *motherPhysical, *samplePhysical;
552  G4LogicalVolume *motherLogical;
553  G4VSolid *motherSolid;
554  G4double motherSafety, ourSafety;
555  G4int sampleNo;
556  G4SmartVoxelNode *curVoxelNode;
557  G4int curNoVolumes, contentNo;
558  G4double voxelSafety;
559 
560  motherPhysical = history.GetTopVolume();
561  motherLogical = motherPhysical->GetLogicalVolume();
562  motherSolid = motherLogical->GetSolid();
563 
564  if( fBestSafety )
565  {
566  return fpVoxelSafety->ComputeSafety( localPoint,*motherPhysical,maxLength );
567  }
568 
569  //
570  // Compute mother safety
571  //
572 
573  motherSafety = motherSolid->DistanceToOut(localPoint);
574  ourSafety = motherSafety; // Working isotropic safety
575 
576  if( motherSafety == 0.0 )
577  {
578 #ifdef G4DEBUG_NAVIGATION
579  // Check that point is inside mother volume
580  EInside insideMother= motherSolid->Inside(localPoint);
581 
582  if( insideMother == kOutside )
583  {
584  G4ExceptionDescription message;
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: "
589  << motherSolid->DistanceToIn( localPoint ) << G4endl;
590  message << " Problem occurred with physical volume: "
591  << " Name: " << motherPhysical->GetName()
592  << " Copy No: " << motherPhysical->GetCopyNo() << G4endl
593  << " Local Point = " << localPoint << G4endl;
594  message << " Description of solid: " << G4endl
595  << *motherSolid << G4endl;
596  G4Exception("G4VoxelNavigation::ComputeSafety()", "GeomNav0003",
597  JustWarning, // FatalException,
598  message);
599  }
600 
601  // Following check is NOT for an issue - it is only for information
602  // It is allowed that a solid gives approximate safety - even zero.
603  //
604  if( insideMother == kInside ) // && fVerbose )
605  {
606  G4ExceptionDescription messageIn;
607 
608  messageIn << " Point is Inside, but safety is Zero ." << G4endl;
609  messageIn << " Inexact safety for volume " << motherPhysical->GetName() << G4endl
610  << " Solid: Name= " << motherSolid->GetName()
611  << " Type= " << motherSolid->GetEntityType() << G4endl;
612  messageIn << " Local point= " << localPoint << G4endl;
613  messageIn << " Solid parameters: " << G4endl << *motherSolid << G4endl;
614  G4Exception("G4VoxelNavigation::ComputeSafety()", "GeomNav0003",
615  JustWarning, messageIn);
616  }
617 #endif
618  // if( insideMother != kInside )
619  return 0.0;
620  }
621 
622 #ifdef G4VERBOSE
623  if( fCheck )
624  {
625  fLogger->ComputeSafetyLog (motherSolid, localPoint, motherSafety, true);
626  }
627 #endif
628  //
629  // Compute daughter safeties
630  //
631  // Look only inside the current Voxel only (in the first version).
632  //
633  curVoxelNode = fVoxelNode;
634  curNoVolumes = curVoxelNode->GetNoContained();
635 
636  for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
637  {
638  sampleNo = curVoxelNode->GetVolume(contentNo);
639  samplePhysical = motherLogical->GetDaughter(sampleNo);
640 
641  G4AffineTransform sampleTf(samplePhysical->GetRotation(),
642  samplePhysical->GetTranslation());
643  sampleTf.Invert();
644  const G4ThreeVector samplePoint =
645  sampleTf.TransformPoint(localPoint);
646  const G4VSolid *sampleSolid =
647  samplePhysical->GetLogicalVolume()->GetSolid();
648  G4double sampleSafety = sampleSolid->DistanceToIn(samplePoint);
649  if ( sampleSafety<ourSafety )
650  {
651  ourSafety = sampleSafety;
652  }
653 #ifdef G4VERBOSE
654  if( fCheck )
655  {
656  fLogger->ComputeSafetyLog (sampleSolid,samplePoint,sampleSafety,false);
657  }
658 #endif
659  }
660  voxelSafety = ComputeVoxelSafety(localPoint);
661  if ( voxelSafety<ourSafety )
662  {
663  ourSafety = voxelSafety;
664  }
665  return ourSafety;
666 }
G4String GetName() const
G4VPhysicalVolume * GetTopVolume() const
const G4ThreeVector & GetTranslation() const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4int GetVolume(G4int pVolumeNo) const
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) 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 &currentPhysical, G4double maxLength=DBL_MAX)
virtual G4GeometryType GetEntityType() const =0
int G4int
Definition: G4Types.hh:78
G4int GetNoContained() const
G4AffineTransform & Invert()
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
G4NavigationLogger * fLogger
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4LogicalVolume * GetLogicalVolume() const
EInside
Definition: geomdefs.hh:58
virtual G4int GetCopyNo() const =0
const G4RotationMatrix * GetRotation() const
G4VoxelSafety * fpVoxelSafety
G4SmartVoxelNode * fVoxelNode
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4VSolid * GetSolid() const
G4double G4VoxelNavigation::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 
)
virtual

Reimplemented in G4ParameterisedNavigation.

Definition at line 72 of file G4VoxelNavigation.cc.

References G4NavigationLogger::AlongComputeStepLog(), G4BlockingList::BlockVolume(), ComputeVoxelSafety(), G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), CLHEP::Hep3Vector::dot(), G4BlockingList::Enlarge(), fBList, fCheck, fLogger, fVoxelNode, G4LogicalVolume::GetDaughter(), G4VPhysicalVolume::GetLogicalVolume(), G4SmartVoxelNode::GetNoContained(), G4LogicalVolume::GetNoDaughters(), G4VPhysicalVolume::GetRotation(), G4LogicalVolume::GetSolid(), G4NavigationHistory::GetTopVolume(), G4VPhysicalVolume::GetTranslation(), G4SmartVoxelNode::GetVolume(), CLHEP::HepRotation::inverse(), G4AffineTransform::Invert(), G4BlockingList::IsBlocked(), LocateNextVoxel(), G4NavigationLogger::PostComputeStepLog(), G4NavigationLogger::PreComputeStepLog(), G4NavigationLogger::PrintDaughterLog(), and G4BlockingList::Reset().

Referenced by G4Navigator::ComputeStep(), and G4ITNavigator::ComputeStep().

83 {
84  G4VPhysicalVolume *motherPhysical, *samplePhysical, *blockedExitedVol=0;
85  G4LogicalVolume *motherLogical;
86  G4VSolid *motherSolid;
87  G4ThreeVector sampleDirection;
88  G4double ourStep=currentProposedStepLength, motherSafety, ourSafety;
89  G4int localNoDaughters, sampleNo;
90 
91  G4bool initialNode, noStep;
92  G4SmartVoxelNode *curVoxelNode;
93  G4int curNoVolumes, contentNo;
94  G4double voxelSafety;
95 
96  motherPhysical = history.GetTopVolume();
97  motherLogical = motherPhysical->GetLogicalVolume();
98  motherSolid = motherLogical->GetSolid();
99 
100  //
101  // Compute mother safety
102  //
103 
104  motherSafety = motherSolid->DistanceToOut(localPoint);
105  ourSafety = motherSafety; // Working isotropic safety
106 
107 #ifdef G4VERBOSE
108  if ( fCheck )
109  {
110  fLogger->PreComputeStepLog (motherPhysical, motherSafety, localPoint);
111  }
112 #endif
113 
114  //
115  // Compute daughter safeties & intersections
116  //
117 
118  // Exiting normal optimisation
119  //
120  if ( exiting && validExitNormal )
121  {
122  if ( localDirection.dot(exitNormal)>=kMinExitingNormalCosine )
123  {
124  // Block exited daughter volume
125  //
126  blockedExitedVol = *pBlockedPhysical;
127  ourSafety = 0;
128  }
129  }
130  exiting = false;
131  entering = false;
132 
133  localNoDaughters = motherLogical->GetNoDaughters();
134 
135  fBList.Enlarge(localNoDaughters);
136  fBList.Reset();
137 
138  initialNode = true;
139  noStep = true;
140 
141  while (noStep)
142  {
143  curVoxelNode = fVoxelNode;
144  curNoVolumes = curVoxelNode->GetNoContained();
145  for (contentNo=curNoVolumes-1; contentNo>=0; contentNo--)
146  {
147  sampleNo = curVoxelNode->GetVolume(contentNo);
148  if ( !fBList.IsBlocked(sampleNo) )
149  {
150  fBList.BlockVolume(sampleNo);
151  samplePhysical = motherLogical->GetDaughter(sampleNo);
152  if ( samplePhysical!=blockedExitedVol )
153  {
154  G4AffineTransform sampleTf(samplePhysical->GetRotation(),
155  samplePhysical->GetTranslation());
156  sampleTf.Invert();
157  const G4ThreeVector samplePoint =
158  sampleTf.TransformPoint(localPoint);
159  const G4VSolid *sampleSolid =
160  samplePhysical->GetLogicalVolume()->GetSolid();
161  const G4double sampleSafety =
162  sampleSolid->DistanceToIn(samplePoint);
163 #ifdef G4VERBOSE
164  if( fCheck )
165  {
166  fLogger->PrintDaughterLog(sampleSolid,samplePoint,sampleSafety,0);
167  }
168 #endif
169  if ( sampleSafety<ourSafety )
170  {
171  ourSafety = sampleSafety;
172  }
173  if ( sampleSafety<=ourStep )
174  {
175  sampleDirection = sampleTf.TransformAxis(localDirection);
176  G4double sampleStep =
177  sampleSolid->DistanceToIn(samplePoint, sampleDirection);
178 #ifdef G4VERBOSE
179  if( fCheck )
180  {
181  fLogger->PrintDaughterLog(sampleSolid, samplePoint,
182  sampleSafety, sampleStep);
183  }
184 #endif
185  if ( sampleStep<=ourStep )
186  {
187  ourStep = sampleStep;
188  entering = true;
189  exiting = false;
190  *pBlockedPhysical = samplePhysical;
191  blockedReplicaNo = -1;
192 #ifdef G4VERBOSE
193  // Check to see that the resulting point is indeed in/on volume.
194  // This check could eventually be made only for successful
195  // candidate.
196 
197  if ( fCheck )
198  {
199  fLogger->AlongComputeStepLog (sampleSolid, samplePoint,
200  sampleDirection, localDirection, sampleSafety, sampleStep);
201  }
202 #endif
203  }
204  }
205  }
206  }
207  }
208  if (initialNode)
209  {
210  initialNode = false;
211  voxelSafety = ComputeVoxelSafety(localPoint);
212  if ( voxelSafety<ourSafety )
213  {
214  ourSafety = voxelSafety;
215  }
216  if ( currentProposedStepLength<ourSafety )
217  {
218  // Guaranteed physics limited
219  //
220  noStep = false;
221  entering = false;
222  exiting = false;
223  *pBlockedPhysical = 0;
224  ourStep = kInfinity;
225  }
226  else
227  {
228  //
229  // Compute mother intersection if required
230  //
231  if ( motherSafety<=ourStep )
232  {
233  G4double motherStep =
234  motherSolid->DistanceToOut(localPoint,
235  localDirection,
236  true, &validExitNormal, &exitNormal);
237 #ifdef G4VERBOSE
238  if ( fCheck )
239  {
240  fLogger->PostComputeStepLog(motherSolid, localPoint, localDirection,
241  motherStep, motherSafety);
242  }
243 #endif
244  if ( motherStep<=ourStep )
245  {
246  ourStep = motherStep;
247  exiting = true;
248  entering = false;
249  if ( validExitNormal )
250  {
251  const G4RotationMatrix *rot = motherPhysical->GetRotation();
252  if (rot)
253  {
254  exitNormal *= rot->inverse();
255  }
256  }
257  }
258  else
259  {
260  validExitNormal = false;
261  }
262  }
263  }
264  newSafety = ourSafety;
265  }
266  if (noStep)
267  {
268  noStep = LocateNextVoxel(localPoint, localDirection, ourStep);
269  }
270  } // end -while (noStep)- loop
271 
272  return ourStep;
273 }
void AlongComputeStepLog(const G4VSolid *sampleSolid, const G4ThreeVector &samplePoint, const G4ThreeVector &sampleDirection, const G4ThreeVector &localDirection, G4double sampleSafety, G4double sampleStep) const
G4VPhysicalVolume * GetTopVolume() const
const G4ThreeVector & GetTranslation() 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
G4VPhysicalVolume * GetDaughter(const G4int i) const
int G4int
Definition: G4Types.hh:78
G4int GetNoContained() const
HepRotation inverse() const
G4AffineTransform & Invert()
G4BlockingList fBList
bool G4bool
Definition: G4Types.hh:79
G4bool LocateNextVoxel(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentStep)
void BlockVolume(const G4int v)
G4bool IsBlocked(const G4int v) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
G4NavigationLogger * fLogger
G4int GetNoDaughters() const
G4LogicalVolume * GetLogicalVolume() const
void PreComputeStepLog(const G4VPhysicalVolume *motherPhysical, G4double motherSafety, const G4ThreeVector &localPoint) const
const G4RotationMatrix * GetRotation() const
G4SmartVoxelNode * fVoxelNode
void PostComputeStepLog(const G4VSolid *motherSolid, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double motherStep, G4double motherSafety) const
double G4double
Definition: G4Types.hh:76
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4VSolid * GetSolid() const
void Enlarge(const G4int nv)
G4double G4VoxelNavigation::ComputeVoxelSafety ( const G4ThreeVector localPoint) const
protected

Definition at line 285 of file G4VoxelNavigation.cc.

References fVoxelAxisStack, fVoxelDepth, fVoxelHeaderStack, fVoxelNode, fVoxelNodeNoStack, fVoxelSliceWidthStack, G4SmartVoxelNode::GetMaxEquivalentSliceNo(), G4SmartVoxelNode::GetMinEquivalentSliceNo(), G4SmartVoxelHeader::GetMinExtent(), and G4INCL::Math::min().

Referenced by ComputeSafety(), and ComputeStep().

286 {
287  G4SmartVoxelHeader *curHeader;
288  G4double voxelSafety, curNodeWidth;
289  G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
290  G4int minCurNodeNoDelta, maxCurNodeNoDelta;
291  G4int localVoxelDepth, curNodeNo;
292  EAxis curHeaderAxis;
293 
294  localVoxelDepth = fVoxelDepth;
295 
296  curHeader = fVoxelHeaderStack[localVoxelDepth];
297  curHeaderAxis = fVoxelAxisStack[localVoxelDepth];
298  curNodeNo = fVoxelNodeNoStack[localVoxelDepth];
299  curNodeWidth = fVoxelSliceWidthStack[localVoxelDepth];
300 
301  // Compute linear intersection distance to boundaries of max/min
302  // to collected nodes at current level
303  //
304  curNodeOffset = curNodeNo*curNodeWidth;
305  maxCurNodeNoDelta = fVoxelNode->GetMaxEquivalentSliceNo()-curNodeNo;
306  minCurNodeNoDelta = curNodeNo-fVoxelNode->GetMinEquivalentSliceNo();
307  minCurCommonDelta = localPoint(curHeaderAxis)
308  - curHeader->GetMinExtent() - curNodeOffset;
309  maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
310 
311  if ( minCurNodeNoDelta<maxCurNodeNoDelta )
312  {
313  voxelSafety = minCurNodeNoDelta*curNodeWidth;
314  voxelSafety += minCurCommonDelta;
315  }
316  else if (maxCurNodeNoDelta < minCurNodeNoDelta)
317  {
318  voxelSafety = maxCurNodeNoDelta*curNodeWidth;
319  voxelSafety += maxCurCommonDelta;
320  }
321  else // (maxCurNodeNoDelta == minCurNodeNoDelta)
322  {
323  voxelSafety = minCurNodeNoDelta*curNodeWidth;
324  voxelSafety += std::min(minCurCommonDelta,maxCurCommonDelta);
325  }
326 
327  // Compute isotropic safety to boundaries of previous levels
328  // [NOT to collected boundaries]
329  //
330  while ( (localVoxelDepth>0) && (voxelSafety>0) )
331  {
332  localVoxelDepth--;
333  curHeader = fVoxelHeaderStack[localVoxelDepth];
334  curHeaderAxis = fVoxelAxisStack[localVoxelDepth];
335  curNodeNo = fVoxelNodeNoStack[localVoxelDepth];
336  curNodeWidth = fVoxelSliceWidthStack[localVoxelDepth];
337  curNodeOffset = curNodeNo*curNodeWidth;
338  minCurCommonDelta = localPoint(curHeaderAxis)
339  - curHeader->GetMinExtent() - curNodeOffset;
340  maxCurCommonDelta = curNodeWidth-minCurCommonDelta;
341 
342  if ( minCurCommonDelta<voxelSafety )
343  {
344  voxelSafety = minCurCommonDelta;
345  }
346  if ( maxCurCommonDelta<voxelSafety )
347  {
348  voxelSafety = maxCurCommonDelta;
349  }
350  }
351  if ( voxelSafety<0 )
352  {
353  voxelSafety = 0;
354  }
355 
356  return voxelSafety;
357 }
G4int GetMinEquivalentSliceNo() const
std::vector< G4SmartVoxelHeader * > fVoxelHeaderStack
int G4int
Definition: G4Types.hh:78
std::vector< EAxis > fVoxelAxisStack
G4int GetMaxEquivalentSliceNo() const
std::vector< G4double > fVoxelSliceWidthStack
G4double GetMinExtent() const
std::vector< G4int > fVoxelNodeNoStack
EAxis
Definition: geomdefs.hh:54
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4SmartVoxelNode * fVoxelNode
double G4double
Definition: G4Types.hh:76
void G4VoxelNavigation::EnableBestSafety ( G4bool  flag = false)
inline
G4int G4VoxelNavigation::GetVerboseLevel ( ) const
inline
virtual G4bool G4VoxelNavigation::LevelLocate ( G4NavigationHistory history,
const G4VPhysicalVolume blockedVol,
const G4int  blockedNum,
const G4ThreeVector globalPoint,
const G4ThreeVector globalDirection,
const G4bool  pLocatedOnEdge,
G4ThreeVector localPoint 
)
virtual
G4bool G4VoxelNavigation::LocateNextVoxel ( const G4ThreeVector localPoint,
const G4ThreeVector localDirection,
const G4double  currentStep 
)
protected

Definition at line 373 of file G4VoxelNavigation.cc.

References fVoxelAxisStack, fVoxelDepth, fVoxelHeaderStack, fVoxelNode, fVoxelNodeNoStack, fVoxelNoSlicesStack, fVoxelSliceWidthStack, G4SmartVoxelHeader::GetAxis(), G4SmartVoxelProxy::GetHeader(), G4GeometryTolerance::GetInstance(), G4SmartVoxelNode::GetMaxEquivalentSliceNo(), G4SmartVoxelNode::GetMinEquivalentSliceNo(), G4SmartVoxelHeader::GetMinExtent(), G4SmartVoxelProxy::GetNode(), G4GeometryTolerance::GetSurfaceTolerance(), and G4SmartVoxelProxy::IsNode().

Referenced by ComputeStep().

376 {
377  G4SmartVoxelHeader *workHeader=0, *newHeader=0;
378  G4SmartVoxelProxy *newProxy=0;
379  G4SmartVoxelNode *newVoxelNode=0;
380  G4ThreeVector targetPoint, voxelPoint;
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;
386  G4bool isNewVoxel=false;
387 
388  G4double currentDistance = currentStep;
389  static const G4double sigma = 0.5*G4GeometryTolerance::GetInstance()
391 
392  // Determine if end of Step within current voxel
393  //
394  for (depth=0; depth<fVoxelDepth; depth++)
395  {
396  targetPoint = localPoint+localDirection*currentDistance;
397  newDistance = currentDistance;
398  workHeader = fVoxelHeaderStack[depth];
399  workHeaderAxis = fVoxelAxisStack[depth];
400  workNodeNo = fVoxelNodeNoStack[depth];
401  workNodeWidth = fVoxelSliceWidthStack[depth];
402  workMinExtent = workHeader->GetMinExtent();
403  workCoord = targetPoint(workHeaderAxis);
404  minVal = workMinExtent+workNodeNo*workNodeWidth;
405 
406  if ( minVal<=workCoord+sigma )
407  {
408  maxVal = minVal+workNodeWidth;
409  if ( maxVal<=workCoord-sigma )
410  {
411  // Must consider next voxel
412  //
413  newNodeNo = workNodeNo+1;
414  newHeader = workHeader;
415  newDistance = (maxVal-localPoint(workHeaderAxis))
416  / localDirection(workHeaderAxis);
417  isNewVoxel = true;
418  newDepth = depth;
419  }
420  }
421  else
422  {
423  newNodeNo = workNodeNo-1;
424  newHeader = workHeader;
425  newDistance = (minVal-localPoint(workHeaderAxis))
426  / localDirection(workHeaderAxis);
427  isNewVoxel = true;
428  newDepth = depth;
429  }
430  currentDistance = newDistance;
431  }
432  targetPoint = localPoint+localDirection*currentDistance;
433 
434  // Check if end of Step within collected boundaries of current voxel
435  //
436  depth = fVoxelDepth;
437  {
438  workHeader = fVoxelHeaderStack[depth];
439  workHeaderAxis = fVoxelAxisStack[depth];
440  workNodeNo = fVoxelNodeNoStack[depth];
441  workNodeWidth = fVoxelSliceWidthStack[depth];
442  workMinExtent = workHeader->GetMinExtent();
443  workCoord = targetPoint(workHeaderAxis);
444  minVal = workMinExtent+fVoxelNode->GetMinEquivalentSliceNo()*workNodeWidth;
445 
446  if ( minVal<=workCoord+sigma )
447  {
448  maxVal = workMinExtent+(fVoxelNode->GetMaxEquivalentSliceNo()+1)
449  *workNodeWidth;
450  if ( maxVal<=workCoord-sigma )
451  {
452  newNodeNo = fVoxelNode->GetMaxEquivalentSliceNo()+1;
453  newHeader = workHeader;
454  newDistance = (maxVal-localPoint(workHeaderAxis))
455  / localDirection(workHeaderAxis);
456  isNewVoxel = true;
457  newDepth = depth;
458  }
459  }
460  else
461  {
462  newNodeNo = fVoxelNode->GetMinEquivalentSliceNo()-1;
463  newHeader = workHeader;
464  newDistance = (minVal-localPoint(workHeaderAxis))
465  / localDirection(workHeaderAxis);
466  isNewVoxel = true;
467  newDepth = depth;
468  }
469  currentDistance = newDistance;
470  }
471  if (isNewVoxel)
472  {
473  // Compute new voxel & adjust voxel stack
474  //
475  // newNodeNo=Candidate node no at
476  // newDepth =refinement depth of crossed voxel boundary
477  // newHeader=Header for crossed voxel
478  // newDistance=distance to crossed voxel boundary (along the track)
479  //
480  if ( (newNodeNo<0) || (newNodeNo>=newHeader->GetNoSlices()))
481  {
482  // Leaving mother volume
483  //
484  isNewVoxel = false;
485  }
486  else
487  {
488  // Compute intersection point on the least refined
489  // voxel boundary that is hit
490  //
491  voxelPoint = localPoint+localDirection*newDistance;
492  fVoxelNodeNoStack[newDepth] = newNodeNo;
493  fVoxelDepth = newDepth;
494  newVoxelNode = 0;
495  while ( !newVoxelNode )
496  {
497  newProxy = newHeader->GetSlice(newNodeNo);
498  if (newProxy->IsNode())
499  {
500  newVoxelNode = newProxy->GetNode();
501  }
502  else
503  {
504  fVoxelDepth++;
505  newHeader = newProxy->GetHeader();
506  newHeaderAxis = newHeader->GetAxis();
507  newHeaderNoSlices = newHeader->GetNoSlices();
508  newHeaderMin = newHeader->GetMinExtent();
509  newHeaderNodeWidth = (newHeader->GetMaxExtent()-newHeaderMin)
510  / newHeaderNoSlices;
511  newNodeNo = G4int( (voxelPoint(newHeaderAxis)-newHeaderMin)
512  / newHeaderNodeWidth );
513  // Rounding protection
514  //
515  if ( newNodeNo<0 )
516  {
517  newNodeNo=0;
518  }
519  else if ( newNodeNo>=newHeaderNoSlices )
520  {
521  newNodeNo = newHeaderNoSlices-1;
522  }
523  // Stack info for stepping
524  //
525  fVoxelAxisStack[fVoxelDepth] = newHeaderAxis;
526  fVoxelNoSlicesStack[fVoxelDepth] = newHeaderNoSlices;
527  fVoxelSliceWidthStack[fVoxelDepth] = newHeaderNodeWidth;
528  fVoxelNodeNoStack[fVoxelDepth] = newNodeNo;
529  fVoxelHeaderStack[fVoxelDepth] = newHeader;
530  }
531  }
532  fVoxelNode = newVoxelNode;
533  }
534  }
535  return isNewVoxel;
536 }
G4SmartVoxelHeader * GetHeader() const
G4int GetMinEquivalentSliceNo() const
G4double GetSurfaceTolerance() const
std::vector< G4SmartVoxelHeader * > fVoxelHeaderStack
int G4int
Definition: G4Types.hh:78
std::vector< EAxis > fVoxelAxisStack
G4int GetMaxEquivalentSliceNo() const
G4bool IsNode() const
std::vector< G4double > fVoxelSliceWidthStack
EAxis GetAxis() const
G4double GetMinExtent() const
bool G4bool
Definition: G4Types.hh:79
std::vector< G4int > fVoxelNodeNoStack
std::vector< G4int > fVoxelNoSlicesStack
G4SmartVoxelNode * GetNode() const
EAxis
Definition: geomdefs.hh:54
G4SmartVoxelNode * fVoxelNode
double G4double
Definition: G4Types.hh:76
static G4GeometryTolerance * GetInstance()
void G4VoxelNavigation::SetVerboseLevel ( G4int  level)

Definition at line 672 of file G4VoxelNavigation.cc.

References fLogger, fpVoxelSafety, G4VoxelSafety::SetVerboseLevel(), and G4NavigationLogger::SetVerboseLevel().

673 {
674  if( fLogger ) fLogger->SetVerboseLevel(level);
676 }
void SetVerboseLevel(G4int level)
G4NavigationLogger * fLogger
void SetVerboseLevel(G4int level)
G4VoxelSafety * fpVoxelSafety
G4SmartVoxelNode* G4VoxelNavigation::VoxelLocate ( G4SmartVoxelHeader pHead,
const G4ThreeVector localPoint 
)
G4SmartVoxelNode* G4VoxelNavigation::VoxelLocateLight ( G4SmartVoxelHeader pHead,
const G4ThreeVector localPoint 
) const
protected

Field Documentation

G4bool G4VoxelNavigation::fBestSafety
protected

Definition at line 187 of file G4VoxelNavigation.hh.

Referenced by ComputeSafety().

G4BlockingList G4VoxelNavigation::fBList
protected

Definition at line 150 of file G4VoxelNavigation.hh.

Referenced by G4ParameterisedNavigation::ComputeStep(), and ComputeStep().

G4bool G4VoxelNavigation::fCheck
protected
G4NavigationLogger* G4VoxelNavigation::fLogger
protected
G4VoxelSafety* G4VoxelNavigation::fpVoxelSafety
protected
std::vector<EAxis> G4VoxelNavigation::fVoxelAxisStack
protected

Definition at line 161 of file G4VoxelNavigation.hh.

Referenced by ComputeVoxelSafety(), and LocateNextVoxel().

G4int G4VoxelNavigation::fVoxelDepth
protected

Definition at line 157 of file G4VoxelNavigation.hh.

Referenced by ComputeVoxelSafety(), and LocateNextVoxel().

std::vector<G4SmartVoxelHeader*> G4VoxelNavigation::fVoxelHeaderStack
protected

Definition at line 173 of file G4VoxelNavigation.hh.

Referenced by ComputeVoxelSafety(), and LocateNextVoxel().

G4SmartVoxelNode* G4VoxelNavigation::fVoxelNode
protected
std::vector<G4int> G4VoxelNavigation::fVoxelNodeNoStack
protected

Definition at line 170 of file G4VoxelNavigation.hh.

Referenced by ComputeVoxelSafety(), and LocateNextVoxel().

std::vector<G4int> G4VoxelNavigation::fVoxelNoSlicesStack
protected

Definition at line 164 of file G4VoxelNavigation.hh.

Referenced by LocateNextVoxel().

std::vector<G4double> G4VoxelNavigation::fVoxelSliceWidthStack
protected

Definition at line 167 of file G4VoxelNavigation.hh.

Referenced by ComputeVoxelSafety(), and LocateNextVoxel().


The documentation for this class was generated from the following files: