232   EAxis    targetHeaderAxis;
   233   G4double targetHeaderMin, targetHeaderMax, targetHeaderNodeWidth;
   234   G4int    targetHeaderNoSlices;
   239   unsigned int checkedNum= 0;
   244   targetHeaderAxis =      targetVoxelHeader->
GetAxis();
   245   targetHeaderNoSlices =  targetVoxelHeader->
GetNoSlices();
   249   targetHeaderNodeWidth = (targetHeaderMax-targetHeaderMin)
   250                           / targetHeaderNoSlices;
   252   G4double localCrd= localPoint(targetHeaderAxis);
   254   const G4int candNodeNo= 
G4int( (localCrd-targetHeaderMin)
   255                                 / targetHeaderNodeWidth );
   258 #ifdef G4DEBUG_VOXELISATION     259   if( candNodeNo < 0 || candNodeNo > targetHeaderNoSlices-1 )
   262      ed << 
" Potential ERROR."   263         << 
" Point is outside range of Voxel in current coordinate" << 
G4endl;
   264      ed << 
"  Node number of point " << localPoint
   265         << 
"is outside the range. " << 
G4endl;
   266      ed << 
"    Voxel node Num= " << candNodeNo << 
" versus  minimum= " << 0
   267         << 
" and maximum= " << targetHeaderNoSlices-1 << 
G4endl;
   268      ed << 
"    Axis = " << targetHeaderAxis
   269         << 
"  No of slices = " << targetHeaderNoSlices << 
G4endl;
   270      ed << 
"    Local coord = " << localCrd
   271         << 
"  Voxel Min = " << targetHeaderMin
   272         <<            
" Max = " << targetHeaderMax << 
G4endl;
   274      ed << 
"  Current volume (physical) = " << currentPhysical.
GetName()
   279      G4Exception(
"G4VoxelSafety::SafetyForVoxelHeader()", 
"GeomNav1003",
   281                  "Point is outside range of Voxel in current coordinate");
   285   const G4int pointNodeNo =
   292     G4cout << 
"**** G4VoxelSafety::SafetyForVoxelHeader  " << 
G4endl;
   294     G4cout << 
" Calculated pointNodeNo= " << pointNodeNo
   295            << 
"  from position= " <<  localPoint(targetHeaderAxis)
   296            << 
"  min= "    << targetHeaderMin
   297            << 
"  max= "    << targetHeaderMax
   298            << 
"  width= "  << targetHeaderNodeWidth 
   299            << 
"  no-slices= " << targetHeaderNoSlices
   300            << 
"  axis=  "  << targetHeaderAxis   << 
G4endl;
   305            << 
" Number of Slices = " << targetHeaderNoSlices
   306            << 
" Header (address) = " << targetVoxelHeader  << 
G4endl;
   318   G4int   trialUp= -1,     trialDown= -1;
   323   G4int nextUp=   pointNodeNo+1;
   324   G4int nextDown= pointNodeNo-1;
   326   G4int    nextNodeNo= pointNodeNo;
   330   G4bool nextIsInside= 
false;
   337   targetNodeNo= pointNodeNo;
   345      sampleProxy = targetVoxelHeader->
GetSlice(targetNodeNo);
   347 #ifdef G4DEBUG_NAVIGATION   348      assert( sampleProxy != 0);
   351        G4cout << 
" -Checking node " << targetNodeNo
   352               << 
" is proxy with address " << sampleProxy << 
G4endl;
   356      if ( sampleProxy == 0 )
   359        ed << 
" Problem for node number= " << targetNodeNo
   360           << 
"    Number of slides = " << targetHeaderNoSlices
   362        G4Exception( 
"G4VoxelSafety::SafetyForVoxelHeader()", 
"GeomNav0003",
   364                     "Problem sampleProxy is Zero. Failure in loop.");
   366      else if ( sampleProxy->
IsNode() )
   368        targetVoxelNode = sampleProxy->
GetNode();
   373 #ifdef G4DEBUG_NAVIGATION   376           G4cout << 
" -- It is a Node ";
   377           G4cout << 
"    its safety= " << nodeSafety
   378                  << 
" our level Saf = " << ourSafety
   379                  << 
"  MinSaf= " << minSafety << 
G4endl;
   382         ourSafety= 
std::min( ourSafety, nodeSafety );
   392         distCombined_Sq = distUpperDepth_Sq + distAxis*distAxis;
   394 #ifdef G4DEBUG_NAVIGATION   397           G4double distCombined= std::sqrt( distCombined_Sq );
   398           G4double distUpperDepth= std::sqrt ( distUpperDepth_Sq );
   400           G4cout << 
"  Recurse to deal with next level, fVoxelDepth= "    402           G4cout << 
"  Distances:  Upper= " << distUpperDepth
   403                  << 
" Axis= " << distAxis
   404                  << 
" Combined= " << distCombined << 
G4endl;
   411                                             maxLength, currentPhysical,
   412                                             distCombined_Sq, minSafety);
   413         ourSafety= 
std::min( ourSafety, headerSafety );
   415 #ifdef G4DEBUG_NAVIGATION   418           G4cout << 
"      >> Header safety = " << headerSafety
   419                  << 
" our level Saf = " << ourSafety << 
G4endl;
   425      minSafety= 
std::min( minSafety, ourSafety );
   431      if( targetNodeNo >= pointNodeNo )
   435         G4double lowerEdgeOfNext = targetHeaderMin
   436                                  + nextUp * targetHeaderNodeWidth;
   437         distUp = lowerEdgeOfNext-localCrd ;
   442 #ifdef G4DEBUG_NAVIGATION   450      if( targetNodeNo <= pointNodeNo ) 
   452          nextDown = trialDown;
   454          G4double upperEdgeOfNext = targetHeaderMin
   455                                   + (nextDown+1) * targetHeaderNodeWidth;
   456          distDown = localCrd-upperEdgeOfNext;
   461 #ifdef G4DEBUG_NAVIGATION   464          G4cout << 
" > Updated nextDown= " << nextDown << 
G4endl;
   469 #ifdef G4DEBUG_NAVIGATION   472        G4cout << 
" Node= " << pointNodeNo
   473               << 
" Up:   next= " << nextUp  << 
" d# "   474               << nextUp - pointNodeNo
   475               << 
" trialUp=  " << trialUp << 
" d# "   476               << trialUp - pointNodeNo
   477               << 
" Down: next= " << nextDown << 
" d# "   478               << targetNodeNo - nextDown
   479               << 
" trialDwn= " << trialDown << 
" d# "   480               << targetNodeNo - trialDown
   481               << 
" condition (next is Inside)= " << nextIsInside
   487      UpIsClosest= distUp < distDown;
   489      if( (nextUp < targetHeaderNoSlices)
   490          && (UpIsClosest || (nextDown < 0)) )
   499                  << 
"   Nodes: next= " << nextNodeNo
   500                  << 
" new nextUp=   " << nextUp
   501                  << 
" Dist = " << distAxis << 
G4endl;
   514                 << 
"  Nodes: next= " << nextNodeNo
   515                 << 
" new nextDown=  " << nextDown
   516                 << 
" Dist = " << distAxis << 
G4endl;
   521      nextIsInside = (nextNodeNo >= 0) && (nextNodeNo < targetHeaderNoSlices);
   524        targetNodeNo= nextNodeNo;
   526 #ifdef G4DEBUG_NAVIGATION   527        assert( targetVoxelHeader->
GetSlice(nextNodeNo) != 0 );
   533            G4cout << 
" Can skip remaining at depth " << targetHeaderAxis
   534                   << 
" >>  distAxis= " << distAxis
   535                   << 
" minSafety= " << minSafety << 
G4endl;
   542 #ifdef G4DEBUG_NAVIGATION   546          G4cout << 
" VoxSaf> No more candidates:  nodeDown= " << nextDown
   547                 << 
" nodeUp= " << nextUp
   548                 << 
" lastSlice= " << targetHeaderNoSlices << 
G4endl;
   555      distMaxInterest = 
std::min( minSafety, maxLength ); 
   557   } 
while ( nextIsInside && ( distAxis*distAxis + distUpperDepth_Sq
   558                             < distMaxInterest*distMaxInterest ) ); 
   563     G4cout << 
" Ended for targetNodeNo -- checked " << checkedNum << 
" out of "   564            << targetHeaderNoSlices << 
" slices." << 
G4endl;
   565     G4cout << 
" ===== Returning from SafetyForVoxelHeader "  
G4double SafetyForVoxelNode(const G4SmartVoxelNode *curVoxelNode, const G4ThreeVector &localPoint)
 
G4double SafetyForVoxelHeader(const G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint, G4double maxLength, const G4VPhysicalVolume ¤tPhysical, G4double distUpperDepth=0.0, G4double previousMinSafety=DBL_MAX)
 
std::ostringstream G4ExceptionDescription
 
std::vector< G4int > fVoxelNodeNoStack
 
G4SmartVoxelNode * GetNode() const
 
virtual G4GeometryType GetEntityType() const =0
 
G4GLOB_DLL std::ostream G4cout
 
std::vector< G4double > fVoxelSliceWidthStack
 
const G4String & GetName() const
 
std::vector< const G4SmartVoxelHeader * > fVoxelHeaderStack
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
static const G4double minSafety
 
std::vector< G4int > fVoxelNoSlicesStack
 
const G4String & GetName() const
 
G4SmartVoxelHeader * GetHeader() const
 
G4int GetMaxEquivalentSliceNo() const
 
G4LogicalVolume * GetLogicalVolume() const
 
G4int GetMinEquivalentSliceNo() const
 
G4VSolid * GetSolid() const
 
std::vector< EAxis > fVoxelAxisStack