61 : fVoxelAxis(
kUndefined), fVoxelNoSlices(0), fVoxelSliceWidth(0.),
62 fVoxelNodeNo(0), fVoxelHeader(0)
81 const G4double currentProposedStepLength,
89 G4int& blockedReplicaNo)
96 G4double ourStep=currentProposedStepLength, ourSafety;
98 G4bool motherValidExitNormal=
false;
103 G4bool initialNode, noStep;
105 G4int curNoVolumes, contentNo;
117 motherSolid = motherLogical->
GetSolid();
124 ourSafety = motherSafety;
129 if( motherSafety < 0.0 )
132 std::ostringstream message;
133 message <<
"Negative Safety In Voxel Navigation !" <<
G4endl
134 <<
" Current solid " << motherSolid->
GetName()
135 <<
" gave negative safety: " << motherSafety <<
G4endl
136 <<
" for the current (local) point " << localPoint;
137 G4Exception(
"G4ParameterisedNavigation::ComputeStep()",
142 std::ostringstream message;
143 message <<
"Point is outside Current Volume !" <<
G4endl
144 <<
" Point " << localPoint
145 <<
" is outside current volume " << motherPhysical->
GetName()
148 G4cout <<
" Estimated isotropic distance to solid (distToIn)= "
150 if( estDistToSolid > 100.0 * motherSolid->
GetTolerance() )
153 G4Exception(
"G4ParameterisedNavigation::ComputeStep()",
155 "Point is far outside Current Volume !");
158 G4Exception(
"G4ParameterisedNavigation::ComputeStep()",
160 "Point is a little outside Current Volume.");
171 &motherValidExitNormal,
174 if( (motherStep >=
kInfinity) || (motherStep < 0.0) )
180 ourStep = motherStep = 0.0;
185 validExitNormal = motherValidExitNormal;
186 exitNormal = motherExitNormal;
188 *pBlockedPhysical= 0;
210 if (exiting && (*pBlockedPhysical==samplePhysical) && validExitNormal)
232 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
234 sampleNo = curVoxelNode->
GetVolume(contentNo);
241 sampleSolid = IdentifyAndPlaceSolid( sampleNo, samplePhysical,
247 const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
249 if ( sampleSafety<ourSafety )
251 ourSafety = sampleSafety;
253 if ( sampleSafety<=ourStep )
255 sampleDirection = sampleTf.TransformAxis(localDirection);
257 sampleSolid->
DistanceToIn(samplePoint, sampleDirection);
258 if ( sampleStep<=ourStep )
260 ourStep = sampleStep;
263 *pBlockedPhysical = samplePhysical;
264 blockedReplicaNo = sampleNo;
273 intersectionPoint= samplePoint + sampleStep * sampleDirection;
278 std::ostringstream message;
279 message <<
"Navigator gets conflicting response from Solid."
281 <<
" Inaccurate solid DistanceToIn"
283 <<
" Solid gave DistanceToIn = "
284 << sampleStep <<
" yet returns " ;
286 message <<
"-kInside-";
288 message <<
"-kOutside-";
290 message <<
"-kSurface-";
291 message <<
" for this point !" <<
G4endl
292 <<
" Point = " << intersectionPoint
295 message <<
" DistanceToIn(p) = "
298 message <<
" DistanceToOut(p) = "
300 G4Exception(
"G4ParameterisedNavigation::ComputeStep()",
302 G4cout.precision(oldcoutPrec);
314 voxelSafety = ComputeVoxelSafety(localPoint,axis);
315 if ( voxelSafety<ourSafety )
317 ourSafety = voxelSafety;
319 if ( currentProposedStepLength<ourSafety )
326 *pBlockedPhysical = 0;
333 if ( motherSafety<=ourStep )
340 &motherValidExitNormal,
344 if( ( motherStep < 0.0 ) || ( motherStep >=
kInfinity) )
349 ourStep = motherStep = 0.0;
355 if( motherValidExitNormal && (
fCheck || (motherStep<=ourStep)) )
358 localPoint, localDirection,
359 motherStep, motherSolid,
360 "From motherSolid::DistanceToOut");
363 if ( motherStep<=ourStep )
365 ourStep = motherStep;
368 if ( validExitNormal )
379 validExitNormal =
false;
387 noStep = LocateNextVoxel(localPoint, localDirection, ourStep, axis);
406 G4VSolid *motherSolid, *sampleSolid;
408 G4int sampleNo, curVoxelNodeNo;
411 G4int curNoVolumes, contentNo;
423 motherSolid = motherLogical->
GetSolid();
430 ourSafety = motherSafety;
441 width, offset, consuming);
452 curVoxelNodeNo =
G4int((localPoint(fVoxelAxis)
455 fVoxelNodeNo = curVoxelNodeNo;
460 for ( contentNo=curNoVolumes-1; contentNo>=0; contentNo-- )
462 sampleNo = curVoxelNode->
GetVolume(contentNo);
466 sampleSolid= IdentifyAndPlaceSolid( sampleNo,samplePhysical,sampleParam );
471 const G4ThreeVector samplePoint = sampleTf.TransformPoint(localPoint);
473 if ( sampleSafety<ourSafety )
475 ourSafety = sampleSafety;
479 voxelSafety = ComputeVoxelSafety(localPoint,axis);
480 if ( voxelSafety<ourSafety )
482 ourSafety=voxelSafety;
495 G4double G4ParameterisedNavigation::
497 const EAxis pAxis)
const
507 G4double voxelSafety, plusVoxelSafety, minusVoxelSafety;
508 G4double curNodeOffset, minCurCommonDelta, maxCurCommonDelta;
509 G4int minCurNodeNoDelta, maxCurNodeNoDelta;
514 curNodeOffset = fVoxelNodeNo*fVoxelSliceWidth;
515 minCurCommonDelta = localPoint(fVoxelAxis)
519 maxCurCommonDelta = fVoxelSliceWidth-minCurCommonDelta;
520 plusVoxelSafety = minCurNodeNoDelta*fVoxelSliceWidth+minCurCommonDelta;
521 minusVoxelSafety = maxCurNodeNoDelta*fVoxelSliceWidth+maxCurCommonDelta;
522 voxelSafety =
std::min(plusVoxelSafety,minusVoxelSafety);
543 G4bool G4ParameterisedNavigation::
561 G4double minVal, maxVal, curMinExtent, curCoord;
564 curCoord = localPoint(fVoxelAxis)+currentStep*localDirection(fVoxelAxis);
568 if ( minVal<=curCoord )
570 maxVal = curMinExtent
572 if ( maxVal<curCoord )
575 if ( newNodeNo<fVoxelHeader->GetNoSlices() )
577 fVoxelNodeNo = newNodeNo;
592 fVoxelNodeNo = newNodeNo;
607 const G4int blockedNum,
610 const G4bool pLocatedOnEdge,
620 G4int voxelNoDaughters, replicaNo;
631 if ( voxelNoDaughters==0 ) {
return false; }
643 for (
G4int sampleNo=voxelNoDaughters-1; sampleNo>=0; sampleNo-- )
645 replicaNo = motherVoxelNode->
GetVolume(sampleNo);
646 if ( (replicaNo!=blockedNum) || (pPhysical!=blockedVol) )
650 pSolid = IdentifyAndPlaceSolid( replicaNo, pPhysical, pParam );
665 localPoint = samplePoint;
676 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)
static const G4double kInfinity
void UpdateMaterial(G4Material *pMaterial)
double dot(const Hep3Vector &) const
G4int GetVolume(G4int pVolumeNo) const
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) const
G4VSolid * GetSolid() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4double GetTolerance() const
void SetSolid(G4VSolid *pSolid)
G4SmartVoxelNode * ParamVoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
const G4RotationMatrix * GetRotation() const
G4int GetNoContained() const
HepRotation inverse() const
G4int GetMaxEquivalentSliceNo() const
void ReportOutsideMother(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4VPhysicalVolume *motherPV, G4double tDist=30.0 *CLHEP::cm) 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)
G4bool CheckAndReportBadNormal(const G4ThreeVector &unitNormal, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, G4double step, const G4VSolid *solid, const char *msg) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
static const double kMinExitingNormalCosine
G4NavigationLogger * fLogger
~G4ParameterisedNavigation()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
const G4ThreeVector & GetTranslation() const
void NewLevel(G4VPhysicalVolume *pNewMother, EVolume vType=kNormal, G4int nReplica=-1)
G4LogicalVolume * GetLogicalVolume() const
G4SmartVoxelNode * GetNode() 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
void Enlarge(const G4int nv)