59 : fVoxelAxis(
kUndefined), fVoxelNoSlices(0), fVoxelSliceWidth(0.),
60 fVoxelNodeNo(0), fVoxelHeader(0)
79 const G4double currentProposedStepLength,
87 G4int& blockedReplicaNo)
94 G4double ourStep=currentProposedStepLength, motherSafety, ourSafety;
97 G4bool initialNode, noStep;
99 G4int curNoVolumes, contentNo;
111 motherSolid = motherLogical->
GetSolid();
118 ourSafety = motherSafety;
123 if( motherSafety < 0.0 )
126 std::ostringstream message;
127 message <<
"Negative Safety In Voxel Navigation !" <<
G4endl
128 <<
" Current solid " << motherSolid->
GetName()
129 <<
" gave negative safety: " << motherSafety <<
G4endl
130 <<
" for the current (local) point " << localPoint;
131 G4Exception(
"G4ParameterisedNavigation::ComputeStep()",
136 std::ostringstream message;
137 message <<
"Point is outside Current Volume !" <<
G4endl
138 <<
" Point " << localPoint
139 <<
" is outside current volume " << motherPhysical->
GetName()
142 G4cout <<
" Estimated isotropic distance to solid (distToIn)= "
144 if( estDistToSolid > 100.0 * motherSolid->
GetTolerance() )
147 G4Exception(
"G4ParameterisedNavigation::ComputeStep()",
149 "Point is far outside Current Volume !");
152 G4Exception(
"G4ParameterisedNavigation::ComputeStep()",
154 "Point is a little outside Current Volume.");
176 if (exiting && (*pBlockedPhysical==samplePhysical) && validExitNormal)
178 if (localDirection.
dot(exitNormal)>=kMinExitingNormalCosine)
196 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
198 sampleNo = curVoxelNode->
GetVolume(contentNo);
205 sampleSolid = IdentifyAndPlaceSolid( sampleNo, samplePhysical,
211 const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
213 if ( sampleSafety<ourSafety )
215 ourSafety = sampleSafety;
217 if ( sampleSafety<=ourStep )
219 sampleDirection = sampleTf.TransformAxis(localDirection);
221 sampleSolid->
DistanceToIn(samplePoint, sampleDirection);
222 if ( sampleStep<=ourStep )
224 ourStep = sampleStep;
227 *pBlockedPhysical = samplePhysical;
228 blockedReplicaNo = sampleNo;
234 if ( (
fCheck ) && ( sampleStep < kInfinity ) )
237 intersectionPoint= samplePoint + sampleStep * sampleDirection;
242 std::ostringstream message;
243 message <<
"Navigator gets conflicting response from Solid."
245 <<
" Inaccurate solid DistanceToIn"
247 <<
" Solid gave DistanceToIn = "
248 << sampleStep <<
" yet returns " ;
250 message <<
"-kInside-";
252 message <<
"-kOutside-";
254 message <<
"-kSurface-";
255 message <<
" for this point !" <<
G4endl
256 <<
" Point = " << intersectionPoint
259 message <<
" DistanceToIn(p) = "
262 message <<
" DistanceToOut(p) = "
264 G4Exception(
"G4ParameterisedNavigation::ComputeStep()",
266 G4cout.precision(oldcoutPrec);
278 voxelSafety = ComputeVoxelSafety(localPoint,axis);
279 if ( voxelSafety<ourSafety )
281 ourSafety = voxelSafety;
283 if ( currentProposedStepLength<ourSafety )
290 *pBlockedPhysical = 0;
298 if ( motherSafety<=ourStep )
307 if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) )
311 std::ostringstream message;
312 message <<
"Current point is outside the current solid !"
314 <<
" Problem in Navigation" <<
G4endl
315 <<
" Point (local coordinates): "
317 <<
" Local Direction: "
318 << localDirection <<
G4endl
319 <<
" Solid: " << motherSolid->
GetName();
321 G4Exception(
"G4ParameterisedNavigation::ComputeStep()",
323 G4cout.precision(oldPrOut);
324 G4cerr.precision(oldPrErr);
327 if ( motherStep<=ourStep )
329 ourStep = motherStep;
332 if ( validExitNormal )
343 validExitNormal =
false;
351 noStep = LocateNextVoxel(localPoint, localDirection, ourStep, axis);
370 G4VSolid *motherSolid, *sampleSolid;
372 G4int sampleNo, curVoxelNodeNo;
375 G4int curNoVolumes, contentNo;
387 motherSolid = motherLogical->
GetSolid();
394 ourSafety = motherSafety;
405 width, offset, consuming);
416 curVoxelNodeNo =
G4int((localPoint(fVoxelAxis)
419 fVoxelNodeNo = curVoxelNodeNo;
424 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
426 sampleNo = curVoxelNode->
GetVolume(contentNo);
430 sampleSolid= IdentifyAndPlaceSolid( sampleNo,samplePhysical,sampleParam );
435 const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
437 if ( sampleSafety<ourSafety )
439 ourSafety = sampleSafety;
443 voxelSafety = ComputeVoxelSafety(localPoint,axis);
444 if ( voxelSafety<ourSafety )
446 ourSafety=voxelSafety;
459 G4double G4ParameterisedNavigation::
461 const EAxis pAxis)
const
471 G4double voxelSafety, plusVoxelSafety, minusVoxelSafety;
472 G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
473 G4int minCurNodeNoDelta, maxCurNodeNoDelta;
478 curNodeOffset = fVoxelNodeNo*fVoxelSliceWidth;
479 minCurCommonDelta = localPoint(fVoxelAxis)
483 maxCurCommonDelta = fVoxelSliceWidth-minCurCommonDelta;
484 plusVoxelSafety = minCurNodeNoDelta*fVoxelSliceWidth+minCurCommonDelta;
485 minusVoxelSafety = maxCurNodeNoDelta*fVoxelSliceWidth+maxCurCommonDelta;
486 voxelSafety = std::min(plusVoxelSafety,minusVoxelSafety);
507 G4bool G4ParameterisedNavigation::
525 G4double minVal, maxVal, curMinExtent, curCoord;
528 curCoord = localPoint(fVoxelAxis)+currentStep*localDirection(fVoxelAxis);
532 if ( minVal<=curCoord )
534 maxVal = curMinExtent
536 if ( maxVal<curCoord )
539 if ( newNodeNo<fVoxelHeader->GetNoSlices() )
541 fVoxelNodeNo = newNodeNo;
556 fVoxelNodeNo = newNodeNo;
571 const G4int blockedNum,
574 const G4bool pLocatedOnEdge,
584 G4int voxelNoDaughters, replicaNo;
595 if ( voxelNoDaughters==0 ) {
return false; }
607 for (
register int sampleNo=voxelNoDaughters-1; sampleNo>=0; sampleNo-- )
609 replicaNo = motherVoxelNode->
GetVolume(sampleNo);
610 if ( (replicaNo!=blockedNum) || (pPhysical!=blockedVol) )
614 pSolid = IdentifyAndPlaceSolid( replicaNo, pPhysical, pParam );
629 localPoint = samplePoint;
640 pPhysical, &parentTouchable) );