Import Geant4 5.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:57:27 +02:00
parent 330b82b769
commit 37fff30d2e
5733 changed files with 263867 additions and 74574 deletions
+346 -292
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Box.cc,v 1.17 2002/01/10 15:42:24 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
// $Id: G4Box.cc,v 1.19 2002/10/28 15:18:16 gcosmo Exp $
// GEANT4 tag $Name: geant4-05-00 $
//
//
//
@@ -35,8 +35,7 @@
// and information before exception in DistanceToOut(p,v,...)
// 15.11.00 - D.Williams, V.Grichine: bug fixed in CalculateExtent - change
// algorithm for rotated vertices
//
//
// ********************************************************************
#include "G4Box.hh"
@@ -56,10 +55,14 @@
// Constructor - check & set half widths
G4Box::G4Box(const G4String& pName,
G4double pX, G4double pY, G4double pZ)
G4double pX,
G4double pY,
G4double pZ)
: G4CSGSolid(pName)
{
if ( pX > 2*kCarTolerance && pY > 2*kCarTolerance&& pZ > 2*kCarTolerance)
if ( (pX > 2*kCarTolerance)
&& (pY > 2*kCarTolerance)
&& (pZ > 2*kCarTolerance) )
{
fDx = pX ;
fDy = pY ;
@@ -67,9 +70,14 @@ G4Box::G4Box(const G4String& pName,
}
else
{
G4Exception("G4Box::G4Box(...) - invalid dimensions");
}
G4cout << "ERROR - G4Box()::G4Box(): " << GetName() << G4endl
<< " Dimensions too small ! - "
<< pX << ", " << pY << ", " << pZ << G4endl;
G4cerr << "ERROR - G4Box()::G4Box(): " << GetName() << G4endl
<< " Dimensions too small ! - "
<< pX << ", " << pY << ", " << pZ << G4endl;
G4Exception("G4Box::G4Box() - invalid dimensions");
}
}
//////////////////////////////////////////////////////////////////////////
@@ -78,7 +86,6 @@ G4Box::G4Box(const G4String& pName,
G4Box::~G4Box()
{
;
}
//////////////////////////////////////////////////////////////////////////////
@@ -88,7 +95,15 @@ void G4Box::SetXHalfLength(G4double dx)
if(dx > 2*kCarTolerance)
fDx = dx;
else
G4Exception("G4Box::SetXHalfLength(...) - invalid dimensions");
{
G4cout << "ERROR - G4Box()::SetXHalfLength(): " << GetName() << G4endl
<< " Dimension X too small ! - "
<< dx << G4endl;
G4cerr << "ERROR - G4Box()::SetXHalfLength(): " << GetName() << G4endl
<< " Dimension X too small ! - "
<< dx << G4endl;
G4Exception("G4Box::SetXHalfLength() - invalid dimensions");
}
}
void G4Box::SetYHalfLength(G4double dy)
@@ -96,7 +111,15 @@ void G4Box::SetYHalfLength(G4double dy)
if(dy > 2*kCarTolerance)
fDy = dy;
else
G4Exception("G4Box::SetYHalfLength(...) - invalid dimensions");
{
G4cout << "ERROR - G4Box()::SetYHalfLength(): " << GetName() << G4endl
<< " Dimension Y too small ! - "
<< dy << G4endl;
G4cerr << "ERROR - G4Box()::SetYHalfLength(): " << GetName() << G4endl
<< " Dimension Y too small ! - "
<< dy << G4endl;
G4Exception("G4Box::SetYHalfLength() - invalid dimensions");
}
}
void G4Box::SetZHalfLength(G4double dz)
@@ -104,7 +127,15 @@ void G4Box::SetZHalfLength(G4double dz)
if(dz > 2*kCarTolerance)
fDz = dz;
else
G4Exception("G4Box::SetZHalfLength(...) - invalid dimensions");
{
G4cout << "ERROR - G4Box()::SetZHalfLength(): " << GetName() << G4endl
<< " Dimension Z too small ! - "
<< dz << G4endl;
G4cerr << "ERROR - G4Box()::SetZHalfLength(): " << GetName() << G4endl
<< " Dimension Z too small ! - "
<< dz << G4endl;
G4Exception("G4Box::SetZHalfLength() - invalid dimensions");
}
}
@@ -126,15 +157,15 @@ void G4Box::ComputeDimensions(G4VPVParameterisation* p,
// Calculate extent under transform and specified limit
G4bool G4Box::CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
{
if (!pTransform.IsRotated())
{
// Special case handling for unrotated boxes
// Compute x/y/z mins and maxs respecting limits, with early returns
// if outside limits. Then switch() on pAxis
// Special case handling for unrotated boxes
// Compute x/y/z mins and maxs respecting limits, with early returns
// if outside limits. Then switch() on pAxis
G4double xoffset,xMin,xMax;
G4double yoffset,yMin,yMax;
@@ -151,13 +182,13 @@ G4bool G4Box::CalculateExtent(const EAxis pAxis,
else
{
if (xMin < pVoxelLimit.GetMinXExtent())
{
xMin = pVoxelLimit.GetMinXExtent() ;
}
if (xMax > pVoxelLimit.GetMaxXExtent())
{
xMax = pVoxelLimit.GetMaxXExtent() ;
}
{
xMin = pVoxelLimit.GetMinXExtent() ;
}
if (xMax > pVoxelLimit.GetMaxXExtent())
{
xMax = pVoxelLimit.GetMaxXExtent() ;
}
}
}
yoffset = pTransform.NetTranslation().y() ;
@@ -167,17 +198,17 @@ G4bool G4Box::CalculateExtent(const EAxis pAxis,
if (pVoxelLimit.IsYLimited())
{
if ( yMin > pVoxelLimit.GetMaxYExtent()+kCarTolerance ||
yMax < pVoxelLimit.GetMinYExtent()-kCarTolerance ) return false ;
yMax < pVoxelLimit.GetMinYExtent()-kCarTolerance ) return false ;
else
{
if (yMin < pVoxelLimit.GetMinYExtent())
{
yMin = pVoxelLimit.GetMinYExtent() ;
}
if (yMax > pVoxelLimit.GetMaxYExtent())
{
yMax = pVoxelLimit.GetMaxYExtent() ;
}
{
yMin = pVoxelLimit.GetMinYExtent() ;
}
if (yMax > pVoxelLimit.GetMaxYExtent())
{
yMax = pVoxelLimit.GetMaxYExtent() ;
}
}
}
zoffset = pTransform.NetTranslation().z() ;
@@ -187,33 +218,33 @@ G4bool G4Box::CalculateExtent(const EAxis pAxis,
if (pVoxelLimit.IsZLimited())
{
if ( zMin > pVoxelLimit.GetMaxZExtent()+kCarTolerance ||
zMax < pVoxelLimit.GetMinZExtent()-kCarTolerance ) return false ;
zMax < pVoxelLimit.GetMinZExtent()-kCarTolerance ) return false ;
else
{
if (zMin < pVoxelLimit.GetMinZExtent())
{
zMin = pVoxelLimit.GetMinZExtent() ;
}
if (zMax > pVoxelLimit.GetMaxZExtent())
{
zMax = pVoxelLimit.GetMaxZExtent() ;
}
if (zMin < pVoxelLimit.GetMinZExtent())
{
zMin = pVoxelLimit.GetMinZExtent() ;
}
if (zMax > pVoxelLimit.GetMaxZExtent())
{
zMax = pVoxelLimit.GetMaxZExtent() ;
}
}
}
switch (pAxis)
{
case kXAxis:
pMin = xMin ;
pMax = xMax ;
break ;
pMin = xMin ;
pMax = xMax ;
break ;
case kYAxis:
pMin=yMin;
pMax=yMax;
break;
pMin=yMin;
pMax=yMax;
break;
case kZAxis:
pMin=zMin;
pMax=zMax;
break;
pMin=zMin;
pMax=zMax;
break;
default:
break;
}
@@ -230,7 +261,7 @@ G4bool G4Box::CalculateExtent(const EAxis pAxis,
pMin = +kInfinity ;
pMax = -kInfinity ;
// Calculate rotated vertex coordinates
// Calculate rotated vertex coordinates
vertices = CreateRotatedVertices(pTransform) ;
ClipCrossSection(vertices,0,pVoxelLimit,pAxis,pMin,pMax) ;
@@ -238,62 +269,64 @@ G4bool G4Box::CalculateExtent(const EAxis pAxis,
ClipBetweenSections(vertices,0,pVoxelLimit,pAxis,pMin,pMax) ;
if (pVoxelLimit.IsLimited(pAxis) == false)
{
{
if ( pMin != kInfinity || pMax != -kInfinity )
{
existsAfterClip = true ;
existsAfterClip = true ;
// Add 2*tolerance to avoid precision troubles
// Add 2*tolerance to avoid precision troubles
pMin -= kCarTolerance;
pMax += kCarTolerance;
pMin -= kCarTolerance;
pMax += kCarTolerance;
}
}
}
else
{
G4ThreeVector clipCentre(
( pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
( pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
( pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5);
( pVoxelLimit.GetMinXExtent()+pVoxelLimit.GetMaxXExtent())*0.5,
( pVoxelLimit.GetMinYExtent()+pVoxelLimit.GetMaxYExtent())*0.5,
( pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5);
if ( pMin != kInfinity || pMax != -kInfinity )
{
existsAfterClip = true ;
// Check to see if endpoints are in the solid
clipCentre(pAxis) = pVoxelLimit.GetMinExtent(pAxis);
clipCentre(pAxis) = pVoxelLimit.GetMinExtent(pAxis);
if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
pMin = pVoxelLimit.GetMinExtent(pAxis);
pMin = pVoxelLimit.GetMinExtent(pAxis);
}
else
else
{
pMin -= kCarTolerance;
pMin -= kCarTolerance;
}
clipCentre(pAxis) = pVoxelLimit.GetMaxExtent(pAxis);
clipCentre(pAxis) = pVoxelLimit.GetMaxExtent(pAxis);
if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
{
pMax = pVoxelLimit.GetMaxExtent(pAxis);
pMax = pVoxelLimit.GetMaxExtent(pAxis);
}
else
else
{
pMax += kCarTolerance;
}
}
// Check for case where completely enveloping clipping volume
// If point inside then we are confident that the solid completely
// envelopes the clipping volume. Hence set min/max extents according
// to clipping volume extents along the specified axis.
else if (Inside(pTransform.Inverse().TransformPoint(clipCentre)) != kOutside)
// Check for case where completely enveloping clipping volume
// If point inside then we are confident that the solid completely
// envelopes the clipping volume. Hence set min/max extents according
// to clipping volume extents along the specified axis.
else if (Inside(pTransform.Inverse().TransformPoint(clipCentre))
!= kOutside)
{
existsAfterClip = true ;
pMin = pVoxelLimit.GetMinExtent(pAxis) ;
pMax = pVoxelLimit.GetMaxExtent(pAxis) ;
existsAfterClip = true ;
pMin = pVoxelLimit.GetMinExtent(pAxis) ;
pMax = pVoxelLimit.GetMaxExtent(pAxis) ;
}
}
delete vertices;
@@ -342,7 +375,7 @@ G4ThreeVector G4Box::SurfaceNormal( const G4ThreeVector& p) const
G4double distx, disty, distz ;
G4ThreeVector norm ;
// Calculate distances as if in 1st octant
// Calculate distances as if in 1st octant
distx = fabs(fabs(p.x()) - fDx) ;
disty = fabs(fabs(p.y()) - fDy) ;
@@ -365,7 +398,6 @@ G4ThreeVector G4Box::SurfaceNormal( const G4ThreeVector& p) const
{
if ( disty <= distz ) // Closest to Y
{
if ( p.y() < 0 ) norm = G4ThreeVector(0,-1.0,0) ;
else norm = G4ThreeVector(0, 1.0,0) ;
}
@@ -401,109 +433,108 @@ G4ThreeVector G4Box::SurfaceNormal( const G4ThreeVector& p) const
G4double G4Box::DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const
{
G4double safx, safy, safz ;
G4double smin=0.0, sminy, sminz ; // , sminx ;
G4double smax=kInfinity, smaxy, smaxz ; // , smaxx ; // they always > 0
G4double stmp ;
G4double sOut=kInfinity, sOuty=kInfinity, sOutz=kInfinity ;
G4double safx, safy, safz ;
G4double smin=0.0, sminy, sminz ; // , sminx ;
G4double smax=kInfinity, smaxy, smaxz ; // , smaxx ; // they always > 0
G4double stmp ;
G4double sOut=kInfinity, sOuty=kInfinity, sOutz=kInfinity ;
safx = fabs(p.x()) - fDx ; // minimum distance to x surface of shape
safy = fabs(p.y()) - fDy ;
safz = fabs(p.z()) - fDz ;
safx = fabs(p.x()) - fDx ; // minimum distance to x surface of shape
safy = fabs(p.y()) - fDy ;
safz = fabs(p.z()) - fDz ;
// Will we intersect?
// If safx/y/z is >-tol/2 the point is outside/on the box's x/y/z extent.
// If both p.x/y/z and v.x/y/z repectively are both positive/negative,
// travel is in a direction away from the shape.
// Will we intersect?
// If safx/y/z is >-tol/2 the point is outside/on the box's x/y/z extent.
// If both p.x/y/z and v.x/y/z repectively are both positive/negative,
// travel is in a direction away from the shape.
if ( ((p.x()*v.x() >= 0.0) && safx > -kCarTolerance*0.5)
|| ((p.y()*v.y() >= 0.0) && safy > -kCarTolerance*0.5)
|| ((p.z()*v.z() >= 0.0) && safz > -kCarTolerance*0.5) )
{
return kInfinity ; // travel away or parallel within tolerance
}
if ( ((p.x()*v.x() >= 0.0) && safx > -kCarTolerance*0.5)
|| ((p.y()*v.y() >= 0.0) && safy > -kCarTolerance*0.5)
|| ((p.z()*v.z() >= 0.0) && safz > -kCarTolerance*0.5) )
{
return kInfinity ; // travel away or parallel within tolerance
}
// Compute min / max distances for x/y/z travel:
// X Planes
// Compute min / max distances for x/y/z travel:
// X Planes
if ( v.x())
{
stmp = 1.0/fabs(v.x()) ;
if ( v.x())
{
stmp = 1.0/fabs(v.x()) ;
if (safx >= 0.0)
if (safx >= 0.0)
{
smin = safx*stmp ;
smax = (fDx+fabs(p.x()))*stmp ;
}
else
{
if (v.x() > 0) sOut = (fDx - p.x())*stmp ;
if (v.x() < 0) sOut = (fDx + p.x())*stmp ;
}
}
// Y Planes
if ( v.y())
{
stmp = 1.0/fabs(v.y()) ;
if (safy >= 0.0)
{
sminy = safy*stmp ;
smaxy = (fDy+fabs(p.y()))*stmp ;
if (sminy > smin) smin=sminy ;
if (smaxy < smax) smax=smaxy ;
if (smin >= smax-kCarTolerance*0.5)
{
smin = safx*stmp ;
smax = (fDx+fabs(p.x()))*stmp ;
return kInfinity ; // touch XY corner
}
else
{
if (v.x() > 0) sOut = (fDx - p.x())*stmp ;
if (v.x() < 0) sOut = (fDx + p.x())*stmp ;
}
else
{
if (v.y() > 0) sOuty = (fDy - p.y())*stmp ;
if (v.y() < 0) sOuty = (fDy + p.y())*stmp ;
if( sOuty < sOut ) sOut = sOuty ;
}
}
// Z planes
if ( v.z() )
{
stmp = 1.0/fabs(v.z()) ;
if ( safz >= 0.0)
{
sminz = safz*stmp ;
smaxz = (fDz+fabs(p.z()))*stmp ;
if (sminz > smin) smin = sminz ;
if (smaxz < smax) smax = smaxz ;
if (smin >= smax-kCarTolerance*0.5)
{
return kInfinity ; // touch ZX or ZY corners
}
}
}
else
{
if (v.z() > 0) sOutz = (fDz - p.z())*stmp ;
if (v.z() < 0) sOutz = (fDz + p.z())*stmp ;
if( sOutz < sOut ) sOut = sOutz ;
}
}
// Y Planes
if ( sOut <= smin + 0.5*kCarTolerance) // travel over edge
{
return kInfinity ;
}
if (smin < 0.5*kCarTolerance) smin = 0.0 ;
if ( v.y())
{
stmp = 1.0/fabs(v.y()) ;
if (safy >= 0.0)
{
sminy = safy*stmp ;
smaxy = (fDy+fabs(p.y()))*stmp ;
if (sminy > smin) smin=sminy ;
if (smaxy < smax) smax=smaxy ;
if (smin >= smax-kCarTolerance*0.5)
{
return kInfinity ; // touch XY corner
}
}
else
{
if (v.y() > 0) sOuty = (fDy - p.y())*stmp ;
if (v.y() < 0) sOuty = (fDy + p.y())*stmp ;
if( sOuty < sOut ) sOut = sOuty ;
}
}
// Z planes
if ( v.z() )
{
stmp = 1.0/fabs(v.z()) ;
if ( safz >= 0.0)
{
sminz = safz*stmp ;
smaxz = (fDz+fabs(p.z()))*stmp ;
if (sminz > smin) smin = sminz ;
if (smaxz < smax) smax = smaxz ;
if (smin >= smax-kCarTolerance*0.5)
{
return kInfinity ; // touch ZX or ZY corners
}
}
else
{
if (v.z() > 0) sOutz = (fDz - p.z())*stmp ;
if (v.z() < 0) sOutz = (fDz + p.z())*stmp ;
if( sOutz < sOut ) sOut = sOutz ;
}
}
if ( sOut <= smin + 0.5*kCarTolerance) // travel over edge
{
return kInfinity ;
}
if (smin < 0.5*kCarTolerance) smin = 0.0 ;
return smin ;
return smin ;
}
//////////////////////////////////////////////////////////////////////////
@@ -537,8 +568,8 @@ G4double G4Box::DistanceToIn(const G4ThreeVector& p) const
// - when leaving a surface & v.close, return 0
G4double G4Box::DistanceToOut( const G4ThreeVector& p,const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,G4ThreeVector *n) const
const G4bool calcNorm,
G4bool *validNorm,G4ThreeVector *n) const
{
ESide side = kUndefined ;
G4double pdist,stmp,snxt;
@@ -547,145 +578,142 @@ G4double G4Box::DistanceToOut( const G4ThreeVector& p,const G4ThreeVector& v,
if (v.x() > 0) // X planes
{
pdist = fDx - p.x() ;
pdist = fDx - p.x() ;
if (pdist > kCarTolerance*0.5)
{
snxt = pdist/v.x() ;
side = kPX ;
}
else
{
if (calcNorm) *n = G4ThreeVector(1,0,0) ;
return snxt = 0 ;
}
if (pdist > kCarTolerance*0.5)
{
snxt = pdist/v.x() ;
side = kPX ;
}
else
{
if (calcNorm) *n = G4ThreeVector(1,0,0) ;
return snxt = 0 ;
}
}
else if (v.x() < 0)
{
pdist = fDx + p.x() ;
pdist = fDx + p.x() ;
if (pdist > kCarTolerance*0.5)
{
snxt = -pdist/v.x() ;
side = kMX ;
}
else
{
if (calcNorm) *n = G4ThreeVector(-1,0,0) ;
return snxt = 0 ;
}
if (pdist > kCarTolerance*0.5)
{
snxt = -pdist/v.x() ;
side = kMX ;
}
else
{
if (calcNorm) *n = G4ThreeVector(-1,0,0) ;
return snxt = 0 ;
}
}
else snxt = kInfinity ;
if ( v.y() > 0 ) // Y planes
{
pdist=fDy-p.y();
pdist=fDy-p.y();
if (pdist>kCarTolerance*0.5)
{
stmp=pdist/v.y();
if (pdist>kCarTolerance*0.5)
{
stmp=pdist/v.y();
if (stmp<snxt)
{
snxt=stmp;
side=kPY;
}
}
else
{
if (calcNorm) *n = G4ThreeVector(0,1,0) ;
return snxt = 0 ;
}
if (stmp<snxt)
{
snxt=stmp;
side=kPY;
}
}
else
{
if (calcNorm) *n = G4ThreeVector(0,1,0) ;
return snxt = 0 ;
}
}
else if ( v.y() < 0 )
{
pdist = fDy + p.y() ;
pdist = fDy + p.y() ;
if (pdist > kCarTolerance*0.5)
{
stmp=-pdist/v.y();
if (pdist > kCarTolerance*0.5)
{
stmp=-pdist/v.y();
if (stmp<snxt)
{
snxt=stmp;
side=kMY;
}
}
else
{
if (calcNorm) *n = G4ThreeVector(0,-1,0) ;
return snxt = 0 ;
}
if (stmp<snxt)
{
snxt=stmp;
side=kMY;
}
}
else
{
if (calcNorm) *n = G4ThreeVector(0,-1,0) ;
return snxt = 0 ;
}
}
if (v.z()>0) // Z planes
{
pdist=fDz-p.z();
pdist=fDz-p.z();
if (pdist > kCarTolerance*0.5)
{
stmp=pdist/v.z();
if (pdist > kCarTolerance*0.5)
{
stmp=pdist/v.z();
if (stmp < snxt)
{
snxt=stmp;
side=kPZ;
}
}
else
{
if (calcNorm) *n = G4ThreeVector(0,0,1) ;
return snxt = 0 ;
}
if (stmp < snxt)
{
snxt=stmp;
side=kPZ;
}
}
else
{
if (calcNorm) *n = G4ThreeVector(0,0,1) ;
return snxt = 0 ;
}
}
else if (v.z()<0)
{
pdist = fDz + p.z() ;
pdist = fDz + p.z() ;
if (pdist > kCarTolerance*0.5)
{
stmp=-pdist/v.z();
if (pdist > kCarTolerance*0.5)
{
stmp=-pdist/v.z();
if (stmp < snxt)
{
snxt=stmp;
side=kMZ;
}
}
else
{
if (calcNorm) *n = G4ThreeVector(0,0,-1) ;
return snxt = 0 ;
}
if (stmp < snxt)
{
snxt=stmp;
side=kMZ;
}
}
else
{
if (calcNorm) *n = G4ThreeVector(0,0,-1) ;
return snxt = 0 ;
}
}
if (calcNorm)
{
{
switch (side)
{
case kPX:
*n=G4ThreeVector(1,0,0);
break;
*n=G4ThreeVector(1,0,0);
break;
case kMX:
*n=G4ThreeVector(-1,0,0);
break;
*n=G4ThreeVector(-1,0,0);
break;
case kPY:
*n=G4ThreeVector(0,1,0);
break;
*n=G4ThreeVector(0,1,0);
break;
case kMY:
*n=G4ThreeVector(0,-1,0);
break;
*n=G4ThreeVector(0,-1,0);
break;
case kPZ:
*n=G4ThreeVector(0,0,1);
break;
*n=G4ThreeVector(0,0,1);
break;
case kMZ:
*n=G4ThreeVector(0,0,-1);
break;
*n=G4ThreeVector(0,0,-1);
break;
default:
G4cout.precision(16);
G4cout << G4endl;
G4cout << "Box parameters:" << G4endl << G4endl;
G4cout << "fDx = " << fDx/mm << " mm" << G4endl;
G4cout << "fDy = " << fDy/mm << " mm" << G4endl;
G4cout << "fDz = " << fDz/mm << " mm" << G4endl;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl;
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
@@ -696,8 +724,8 @@ G4double G4Box::DistanceToOut( const G4ThreeVector& p,const G4ThreeVector& v,
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "snxt = " << snxt/mm << " mm" << G4endl << G4endl;
G4Exception("Invalid enum in G4Box::DistanceToOut(p,v,...)");
break;
G4Exception("G4Box::DistanceToOut() - Invalid enum");
break;
}
}
return snxt;
@@ -717,16 +745,13 @@ G4double G4Box::DistanceToOut(const G4ThreeVector& p) const
{
G4cout.precision(16) ;
G4cout << G4endl ;
G4cout << "Box parameters:" << G4endl << G4endl ;
G4cout << "fDx = " << fDx/mm << " mm" << G4endl ;
G4cout << "fDy = " << fDy/mm << " mm" << G4endl ;
G4cout << "fDz = " << fDz/mm << " mm" << G4endl << G4endl ;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl ;
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout << "G4Box::DistanceToOut(p) - point p is outside ?!" << G4endl ;
// G4Exception("Invalid call in G4Box::DistanceToOut(p), point p is outside") ;
G4cerr << "G4Box::DistanceToOut(p) - point p is outside ?!" << G4endl ;
}
#endif
@@ -735,19 +760,19 @@ G4double G4Box::DistanceToOut(const G4ThreeVector& p) const
safy1 = fDy - p.y() ;
safy2 = fDy + p.y() ;
safz1 = fDz - p.z() ;
safz2 = fDz + p.z() ;
// shortest Dist to any boundary now MIN(safx1,safx2,safy1..)
safz2 = fDz + p.z() ;
// shortest Dist to any boundary now MIN(safx1,safx2,safy1..)
if (safx2 < safx1) safe = safx2 ;
else safe = safx1 ;
if (safy1 < safe) safe = safy1 ;
if (safy2 < safe) safe = safy2 ;
if (safz1 < safe) safe = safz1 ;
if (safz2 < safe) safe = safz2 ;
if (safy2 < safe) safe = safy2 ;
if (safz1 < safe) safe = safz1 ;
if (safz2 < safe) safe = safz2 ;
if (safe < 0) safe = 0 ;
return safe ;
if (safe < 0) safe = 0 ;
return safe ;
}
////////////////////////////////////////////////////////////////////////
@@ -787,11 +812,40 @@ G4Box::CreateRotatedVertices(const G4AffineTransform& pTransform) const
}
else
{
G4Exception("G4Box::CreateRotatedVertices - Out of memory !");
DumpInfo();
G4Exception("G4Box::CreateRotatedVertices() - Out of memory !");
}
return vertices;
}
//////////////////////////////////////////////////////////////////////////
//
// GetEntityType
G4GeometryType G4Box::GetEntityType() const
{
return G4String("G4Box");
}
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
G4std::ostream& G4Box::StreamInfo(G4std::ostream& os) const
{
os << "-----------------------------------------------------------\n"
<< " *** Dump for solid - " << GetName() << " ***\n"
<< " ===================================================\n"
<< " Solid type: G4Box\n"
<< " Parameters: \n"
<< " half length X: " << fDx/mm << " mm \n"
<< " half length Y: " << fDy/mm << " mm \n"
<< " half length Z: " << fDz/mm << " mm \n"
<< "-----------------------------------------------------------\n";
return os;
}
//////////////////////////////////////////////////////////////////////////
//
// Methods for visualisation