Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4DisplacedSolid.cc 97300 2016-06-01 09:27:19Z gcosmo $
// $Id: G4DisplacedSolid.cc 101046 2016-11-04 10:44:26Z gcosmo $
//
// Implementation for G4DisplacedSolid class for boolean
// operations between other solids
@@ -261,9 +261,52 @@ void G4DisplacedSolid::SetObjectTranslation(const G4ThreeVector& vector)
fRebuildPolyhedron = true;
}
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Get bounding box
void G4DisplacedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
if (!fDirectTransform->IsRotated())
{
// Special case of pure translation
//
fPtrSolid->Extent(pMin,pMax);
G4ThreeVector offset = fDirectTransform->NetTranslation();
pMin += offset;
pMax += offset;
}
else
{
// General case, use CalculateExtent() to find bounding box
//
G4VoxelLimits unLimit;
G4double xmin,xmax,ymin,ymax,zmin,zmax;
fPtrSolid->CalculateExtent(kXAxis,unLimit,*fDirectTransform,xmin,xmax);
fPtrSolid->CalculateExtent(kYAxis,unLimit,*fDirectTransform,ymin,ymax);
fPtrSolid->CalculateExtent(kZAxis,unLimit,*fDirectTransform,zmin,zmax);
pMin.set(xmin,ymin,zmin);
pMax.set(xmax,ymax,zmax);
}
// Check correctness of the bounding box
//
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
{
std::ostringstream message;
message << "Bad bounding box (min >= max) for solid: "
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4DisplacedSolid::Extent()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
//////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
G4bool
G4DisplacedSolid::CalculateExtent( const EAxis pAxis,
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4IntersectionSolid.cc 95390 2016-02-08 14:46:28Z gcosmo $
// $Id: G4IntersectionSolid.cc 101046 2016-11-04 10:44:26Z gcosmo $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -134,9 +134,43 @@ G4IntersectionSolid::operator = (const G4IntersectionSolid& rhs)
return *this;
}
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Get bounding box
void
G4IntersectionSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
G4ThreeVector minA,maxA, minB,maxB;
fPtrSolidA->Extent(minA,maxA);
fPtrSolidB->Extent(minB,maxB);
pMin.set(std::max(minA.x(),minB.x()),
std::max(minA.y(),minB.y()),
std::max(minA.z(),minB.z()));
pMax.set(std::min(maxA.x(),maxB.x()),
std::min(maxA.y(),maxB.y()),
std::min(maxA.z(),maxB.z()));
// Check correctness of the bounding box
//
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
{
std::ostringstream message;
message << "Bad bounding box (min >= max) for solid: "
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4IntersectionSolid::Extent()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
//////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
G4bool
G4IntersectionSolid::CalculateExtent(const EAxis pAxis,
@@ -159,7 +193,10 @@ G4IntersectionSolid::CalculateExtent(const EAxis pAxis,
pMax = std::min( maxA, maxB );
out = (pMax > pMin); // true;
}
else out = false;
else
{
out = false;
}
return out; // It exists in this slice only if both exist in it.
}
@@ -123,9 +123,37 @@ G4VSolid* G4ScaledSolid::GetUnscaledSolid() const
return fPtrSolid;
}
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// CalculateExtent
// Get bounding box
void G4ScaledSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
G4ThreeVector bmin,bmax;
G4ThreeVector scale = fScale->GetScale();
fPtrSolid->Extent(bmin,bmax);
pMin.set(bmin.x()*scale.x(),bmin.y()*scale.y(),bmin.z()*scale.z());
pMax.set(bmax.x()*scale.x(),bmax.y()*scale.y(),bmax.z()*scale.z());
// Check correctness of the bounding box
//
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
{
std::ostringstream message;
message << "Bad bounding box (min >= max) for solid: "
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4ScaledSolid::Extent()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
//////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
//
G4bool
G4ScaledSolid::CalculateExtent( const EAxis pAxis,
@@ -134,16 +162,9 @@ G4ScaledSolid::CalculateExtent( const EAxis pAxis,
G4double& pMin,
G4double& pMax ) const
{
G4VoxelLimits unLimit;
G4AffineTransform unTransform;
// Find bounding box of unscaled solid
G4double x1,x2,y1,y2,z1,z2;
fPtrSolid->CalculateExtent(kXAxis,unLimit,unTransform,x1,x2);
fPtrSolid->CalculateExtent(kYAxis,unLimit,unTransform,y1,y2);
fPtrSolid->CalculateExtent(kZAxis,unLimit,unTransform,z1,z2);
G4BoundingEnvelope bbox(G4Point3D(x1,y1,z1),
G4Point3D(x2,y2,z2),kCarTolerance);
G4ThreeVector bmin,bmax;
fPtrSolid->Extent(bmin,bmax);
// Set combined transformation
G4Transform3D transform3D =
@@ -151,6 +172,7 @@ G4ScaledSolid::CalculateExtent( const EAxis pAxis,
pTransform.NetTranslation())*GetScaleTransform();
// Find extent
G4BoundingEnvelope bbox(bmin,bmax);
return bbox.CalculateExtent(pAxis,pVoxelLimit,transform3D,pMin,pMax);
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4SubtractionSolid.cc 95390 2016-02-08 14:46:28Z gcosmo $
// $Id: G4SubtractionSolid.cc 101046 2016-11-04 10:44:26Z gcosmo $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -134,9 +134,36 @@ G4SubtractionSolid::operator = (const G4SubtractionSolid& rhs)
return *this;
}
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// CalculateExtent
// Get bounding box
void
G4SubtractionSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
// Since it is unclear how the shape of the first solid will be changed
// after subtraction, just return its original bounding box.
//
fPtrSolidA->Extent(pMin,pMax);
// Check correctness of the bounding box
//
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
{
std::ostringstream message;
message << "Bad bounding box (min >= max) for solid: "
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4SubtractionSolid::Extent()", "GeomMgt0001",
JustWarning, message);
DumpInfo();
}
}
//////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
G4bool
G4SubtractionSolid::CalculateExtent( const EAxis pAxis,
@@ -146,7 +173,7 @@ G4SubtractionSolid::CalculateExtent( const EAxis pAxis,
G4double& pMax ) const
{
// Since we cannot be sure how much the second solid subtracts
// from the first, we must use the first solid's extent!
// from the first, we must use the first solid's extent!
return fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit,
pTransform, pMin, pMax );
@@ -259,7 +286,7 @@ G4double
G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const
{
G4double dist = 0.0,disTmp = 0.0 ;
G4double dist = 0.0, dist2 = 0.0, disTmp = 0.0;
#ifdef G4BOOLDEBUG
if( Inside(p) == kInside )
@@ -297,8 +324,10 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
if( Inside(p+dist*v) == kOutside )
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
dist += disTmp ;
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
dist2 = dist+disTmp;
if (dist == dist2) { return dist; } // no progress
dist = dist2 ;
count1++;
if( count1 > 1000 ) // Infinite loop detected
{
@@ -352,7 +381,9 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
{
return kInfinity ;
}
dist += disTmp ;
dist2 = dist+disTmp;
if (dist == dist2) { return dist; } // no progress
dist = dist2 ;
count2++;
if( count2 > 1000 ) // Infinite loop detected
{
@@ -34,6 +34,8 @@
#if defined(G4GEOM_USE_USOLIDS)
#include "G4VoxelLimits.hh"
#include "G4BoundingEnvelope.hh"
#include "G4Polyhedron.hh"
#include "G4DisplacedSolid.hh"
#include "G4RotationMatrix.hh"
@@ -143,6 +145,50 @@ void G4UMultiUnion::Voxelize()
GetShape()->Voxelize();
}
//////////////////////////////////////////////////////////////////////////
//
// Get bounding box
void G4UMultiUnion::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
UVector3 vmin, vmax;
GetShape()->Extent(vmin,vmax);
pMin.set(vmin.x(),vmin.y(),vmin.z());
pMax.set(vmax.x(),vmax.y(),vmax.z());
// Check correctness of the bounding box
//
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
{
std::ostringstream message;
message << "Bad bounding box (min >= max) for solid: "
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UMultiUnion::Extent()", "GeomMgt0001", JustWarning, message);
DumpInfo();
}
}
//////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
G4bool
G4UMultiUnion::CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
{
G4ThreeVector bmin, bmax;
// Get bounding box
Extent(bmin,bmax);
// Find extent
G4BoundingEnvelope bbox(bmin,bmax);
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
}
//////////////////////////////////////////////////////////////////////////
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UnionSolid.cc 95390 2016-02-08 14:46:28Z gcosmo $
// $Id: G4UnionSolid.cc 101046 2016-11-04 10:44:26Z gcosmo $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -132,9 +132,41 @@ G4UnionSolid& G4UnionSolid::operator = (const G4UnionSolid& rhs)
return *this;
}
///////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Get bounding box
void G4UnionSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
{
G4ThreeVector minA,maxA, minB,maxB;
fPtrSolidA->Extent(minA,maxA);
fPtrSolidB->Extent(minB,maxB);
pMin.set(std::min(minA.x(),minB.x()),
std::min(minA.y(),minB.y()),
std::min(minA.z(),minB.z()));
pMax.set(std::max(maxA.x(),maxB.x()),
std::max(maxA.y(),maxB.y()),
std::max(maxA.z(),maxB.z()));
// Check correctness of the bounding box
//
if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
{
std::ostringstream message;
message << "Bad bounding box (min >= max) for solid: "
<< GetName() << " !"
<< "\npMin = " << pMin
<< "\npMax = " << pMax;
G4Exception("G4UnionSolid::Extent()", "GeomMgt0001", JustWarning, message);
DumpInfo();
}
}
//////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
G4bool
G4UnionSolid::CalculateExtent( const EAxis pAxis,
@@ -149,15 +181,18 @@ G4UnionSolid::CalculateExtent( const EAxis pAxis,
touchesA = fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit,
pTransform, minA, maxA);
touchesB= fPtrSolidB->CalculateExtent( pAxis, pVoxelLimit,
pTransform, minB, maxB);
touchesB = fPtrSolidB->CalculateExtent( pAxis, pVoxelLimit,
pTransform, minB, maxB);
if( touchesA || touchesB )
{
pMin = std::min( minA, minB );
pMax = std::max( maxA, maxB );
out = true ;
}
else out = false ;
else
{
out = false ;
}
return out ; // It exists in this slice if either one does.
}