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) );
G4SmartVoxelHeader * GetVoxelHeader() const
G4VPhysicalVolume * GetTopVolume() const
G4int GetMinEquivalentSliceNo() const
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
static G4bool CheckPointOnSurface(const G4VSolid *sampleSolid, const G4ThreeVector &localPoint, const G4ThreeVector *globalDirection, const G4AffineTransform &sampleTransform, const G4bool locatedOnEdge)
const G4ThreeVector & GetTranslation() const
void UpdateMaterial(G4Material *pMaterial)
double dot(const Hep3Vector &) const
G4int GetVolume(G4int pVolumeNo) const
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4double GetTolerance() const
void SetSolid(G4VSolid *pSolid)
G4SmartVoxelNode * ParamVoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
G4int GetNoContained() const
HepRotation inverse() const
G4int GetMaxEquivalentSliceNo() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
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)
G4bool LocateNextVoxel(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentStep)
void BlockVolume(const G4int v)
virtual G4VPVParameterisation * GetParameterisation() const =0
virtual void SetCopyNo(G4int CopyNo)=0
G4bool IsBlocked(const G4int v) const
G4ParameterisedNavigation()
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
~G4ParameterisedNavigation()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void NewLevel(G4VPhysicalVolume *pNewMother, EVolume vType=kNormal, G4int nReplica=-1)
G4LogicalVolume * GetLogicalVolume() const
G4SmartVoxelNode * GetNode() const
const G4RotationMatrix * GetRotation() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const =0
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
G4SmartVoxelNode * fVoxelNode
const G4AffineTransform & GetTopTransform() const
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)
G4GLOB_DLL std::ostream G4cerr