Import Geant4 6.0.0 source tree
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * DISCLAIMER *
|
||||
// * *
|
||||
// * The following disclaimer summarizes all the specific disclaimers *
|
||||
// * of contributors to this software. The specific disclaimers,which *
|
||||
// * govern, are listed with their locations in: *
|
||||
// * http://cern.ch/geant4/license *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. *
|
||||
// * *
|
||||
// * This code implementation is the intellectual property of the *
|
||||
// * GEANT4 collaboration. *
|
||||
// * By copying, distributing or modifying the Program (or any work *
|
||||
// * based on the Program) you indicate your acceptance of this *
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ParameterisedNavigation.icc,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-06-00 $
|
||||
//
|
||||
//
|
||||
// class G4ParameterisedNavigation Inline implementation
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// ********************************************************************
|
||||
// ParamVoxelLocate
|
||||
// ********************************************************************
|
||||
//
|
||||
inline
|
||||
G4SmartVoxelNode*
|
||||
G4ParameterisedNavigation::ParamVoxelLocate( G4SmartVoxelHeader* pHead,
|
||||
const G4ThreeVector& localPoint )
|
||||
{
|
||||
// If no parameterisation axis is specified, adopt default
|
||||
// location strategy as for placements
|
||||
//
|
||||
if ( pHead->GetParamAxis()==kUndefined )
|
||||
{
|
||||
fVoxelNode = G4VoxelNavigation::VoxelLocate(pHead,localPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4double targetHeaderMin, targetHeaderNodeWidth;
|
||||
G4int targetHeaderNoSlices, targetNodeNo;
|
||||
EAxis targetHeaderAxis;
|
||||
|
||||
targetHeaderAxis = pHead->GetAxis();
|
||||
targetHeaderNoSlices = pHead->GetNoSlices();
|
||||
targetHeaderMin = pHead->GetMinExtent();
|
||||
targetHeaderNodeWidth = (pHead->GetMaxExtent()-targetHeaderMin)
|
||||
/ targetHeaderNoSlices;
|
||||
targetNodeNo = G4int ( (localPoint(targetHeaderAxis)-targetHeaderMin)
|
||||
/ targetHeaderNodeWidth );
|
||||
// Rounding protection
|
||||
//
|
||||
if ( targetNodeNo<0 )
|
||||
{
|
||||
targetNodeNo = 0;
|
||||
}
|
||||
else if ( targetNodeNo>=targetHeaderNoSlices )
|
||||
{
|
||||
targetNodeNo = targetHeaderNoSlices-1;
|
||||
}
|
||||
fVoxelAxis = targetHeaderAxis;
|
||||
fVoxelNoSlices = targetHeaderNoSlices;
|
||||
fVoxelSliceWidth = targetHeaderNodeWidth;
|
||||
fVoxelNodeNo = targetNodeNo;
|
||||
fVoxelHeader = pHead;
|
||||
fVoxelNode = pHead->GetSlice(targetNodeNo)->GetNode();
|
||||
}
|
||||
return fVoxelNode;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// LevelLocate
|
||||
// ********************************************************************
|
||||
//
|
||||
inline
|
||||
G4bool
|
||||
G4ParameterisedNavigation::LevelLocate( G4NavigationHistory& history,
|
||||
const G4VPhysicalVolume* blockedVol,
|
||||
const G4int blockedNum,
|
||||
const G4ThreeVector& globalPoint,
|
||||
const G4ThreeVector* globalDirection,
|
||||
const G4bool pLocatedOnEdge,
|
||||
G4ThreeVector& localPoint )
|
||||
{
|
||||
G4SmartVoxelHeader *motherVoxelHeader;
|
||||
G4SmartVoxelNode *motherVoxelNode;
|
||||
G4VPhysicalVolume *motherPhysical, *pPhysical;
|
||||
G4VPVParameterisation *pParam;
|
||||
G4LogicalVolume *motherLogical;
|
||||
G4VSolid *pSolid;
|
||||
G4ThreeVector samplePoint;
|
||||
G4int voxelNoDaughters, replicaNo;
|
||||
|
||||
motherPhysical = history.GetTopVolume();
|
||||
motherLogical = motherPhysical->GetLogicalVolume();
|
||||
motherVoxelHeader = motherLogical->GetVoxelHeader();
|
||||
|
||||
// Find the voxel containing the point
|
||||
//
|
||||
motherVoxelNode = ParamVoxelLocate(motherVoxelHeader,localPoint);
|
||||
|
||||
voxelNoDaughters = motherVoxelNode->GetNoContained();
|
||||
if ( voxelNoDaughters==0 ) return false;
|
||||
|
||||
pPhysical = motherLogical->GetDaughter(0);
|
||||
pParam = pPhysical->GetParameterisation();
|
||||
|
||||
// Search replicated daughter volume
|
||||
//
|
||||
for ( register int sampleNo=voxelNoDaughters-1; sampleNo>=0; sampleNo-- )
|
||||
{
|
||||
replicaNo = motherVoxelNode->GetVolume(sampleNo);
|
||||
if ( (replicaNo!=blockedNum) || (pPhysical!=blockedVol) )
|
||||
{
|
||||
// Obtain solid (as it can vary) and obtain its parameters
|
||||
//
|
||||
pSolid = pParam->ComputeSolid(replicaNo, pPhysical);
|
||||
pSolid->ComputeDimensions(pParam, replicaNo, pPhysical);
|
||||
pParam->ComputeTransformation(replicaNo, pPhysical);
|
||||
|
||||
// Setup history
|
||||
//
|
||||
history.NewLevel(pPhysical, kParameterised, replicaNo);
|
||||
samplePoint = history.GetTopTransform().TransformPoint(globalPoint);
|
||||
if ( !G4AuxiliaryNavServices::CheckPointOnSurface(pSolid,
|
||||
samplePoint, globalDirection,
|
||||
history.GetTopTransform(), pLocatedOnEdge) )
|
||||
{
|
||||
history.BackLevel();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enter this daughter
|
||||
//
|
||||
localPoint = samplePoint;
|
||||
|
||||
// Set the correct copy number in physical
|
||||
//
|
||||
pPhysical->SetCopyNo(replicaNo);
|
||||
|
||||
// Set the correct solid and material in Logical Volume
|
||||
//
|
||||
G4LogicalVolume *pLogical = pPhysical->GetLogicalVolume();
|
||||
pLogical->SetSolid(pSolid);
|
||||
pLogical->SetMaterial(pParam->ComputeMaterial(replicaNo, pPhysical));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user