Import Geant4 1.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 15:28:20 +02:00
parent aaa409b6ee
commit ca1c8cb059
2995 changed files with 106830 additions and 299600 deletions
@@ -67,6 +67,37 @@ G4BooleanSolid::~G4BooleanSolid()
if(createdDisplacedSolid) delete fPtrSolidB ;
}
///////////////////////////////////////////////////////////////
//
// If Solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If the solid is not a "Boolean", return 0
const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
{
const G4VSolid* subSolid;
if( no == 0 )
subSolid = fPtrSolidA;
else if( no == 1 )
subSolid = fPtrSolidB;
else
G4Exception("G4BooleanSolid::GetConstituentSolid()const invalid subsolid index");
return subSolid;
}
G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no)
{
G4VSolid* subSolid;
if( no == 0 )
subSolid = fPtrSolidA;
else if( no == 1 )
subSolid = fPtrSolidB;
else
G4Exception("G4BooleanSolid::GetConstituentSolid invalid subsolid index");
return subSolid;
}
@@ -4,6 +4,7 @@
// History:
//
// 28.10.98 V.Grichine, creation according J. Apostolakis's recommendations
// 14.11.99 V.Grichine, modifications in CalculateExtent(...) method
#include "G4DisplacedSolid.hh"
@@ -37,23 +38,40 @@ G4DisplacedSolid( const G4String& pName,
fDirectTransform = new G4AffineTransform(rotMatrix,transVector) ;
}
///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
//
//
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
G4VSolid* pSolid ,
const G4Transform3D& transform ) :
G4VSolid(pName)
{
fPtrSolid = pSolid ;
fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(),
transform.getTranslation()) ;
fPtrTransform = new G4AffineTransform(transform.getRotation().inverse(),
transform.getTranslation()) ;
fPtrTransform->Invert() ;
}
/////////////////////////////////////////////////////////////////////////////////
// Constructor for use with creation of Transient object from Persistent object
//
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
G4VSolid* pSolid ,
const G4Transform3D& transform ) :
const G4AffineTransform directTransform ) :
G4VSolid(pName)
{
fPtrSolid = pSolid ;
fPtrTransform = new G4AffineTransform(transform.getRotation().inverse(),
transform.getTranslation()) ;
fPtrTransform->Invert() ;
fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(),
transform.getTranslation()) ;
fDirectTransform = new G4AffineTransform( directTransform );
fPtrTransform = new G4AffineTransform( directTransform.Inverse() ) ;
}
///////////////////////////////////////////////////////////////////
//
G4DisplacedSolid::~G4DisplacedSolid()
{
if(fPtrTransform)
@@ -63,20 +81,64 @@ G4DisplacedSolid::~G4DisplacedSolid()
}
}
const G4DisplacedSolid* G4DisplacedSolid::GetDisplacedSolidPtr() const
{ return this; }
G4DisplacedSolid* G4DisplacedSolid::GetDisplacedSolidPtr()
{ return this; }
G4VSolid* G4DisplacedSolid::GetConstituentMovedSolid()
{ return fPtrSolid; }
G4AffineTransform G4DisplacedSolid::GetTransform() const
{
G4AffineTransform aTransform= *fPtrTransform;
return aTransform;
}
G4AffineTransform G4DisplacedSolid::GetDirectTransform() const
{
G4AffineTransform aTransform= *fDirectTransform;
return aTransform;
}
G4RotationMatrix G4DisplacedSolid::GetFrameRotation() const
{
G4RotationMatrix InvRotation= fPtrTransform->NetRotation();
InvRotation.invert();
return InvRotation;
}
G4ThreeVector G4DisplacedSolid::GetFrameTranslation() const
{
return fPtrTransform->NetTranslation();
}
///////////////////////////////////////////////////////////////
G4RotationMatrix G4DisplacedSolid::GetObjectRotation() const
{
G4RotationMatrix Rotation= fDirectTransform->NetRotation();
return Rotation;
}
G4ThreeVector G4DisplacedSolid::GetObjectTranslation() const
{
return fDirectTransform->NetTranslation();
}
///////////////////////////////////////////////////////////////
//
//
G4bool
G4DisplacedSolid::CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
G4DisplacedSolid::CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const
{
return fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,pTransform,
G4AffineTransform sumTransform ;
sumTransform.Product(*fDirectTransform,pTransform) ;
return fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,sumTransform,
pMin,pMax) ;
}
@@ -218,3 +280,5 @@ G4DisplacedSolid::CreateNURBS () const
@@ -3,6 +3,7 @@
// History:
//
// 12.09.98 V.Grichine
// 29.07.99 V.Grichine, modifications in DistanceToIn(p,v)
#include "G4IntersectionSolid.hh"
// #include "G4DisplacedSolid.hh"
@@ -177,7 +178,7 @@ G4double
G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const
{
G4double dist = 0.0, disTmp ;
G4double dist = 0.0, disTmp = 0.0 ;
if( Inside(p) == kInside )
{
G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p,v), point p is inside") ;
@@ -186,7 +187,7 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
{
if( fPtrSolidA->Inside(p) != kOutside )
{
while( Inside(p+dist*v) == kOutside )
do
{
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
@@ -215,10 +216,12 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
return kInfinity ;
}
}
while( Inside(p+dist*v) == kOutside ) ;
// while( fPtrSolidB->Inside(p) != kOutside ) ;
}
else if( fPtrSolidB->Inside(p) != kOutside )
{
while( Inside(p+dist*v) == kOutside )
do
{
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
@@ -247,10 +250,11 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
return kInfinity ;
}
}
while( Inside(p+dist*v) == kOutside ) ;
}
else
{
while( Inside(p+dist*v) == kOutside )
do
{
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
@@ -279,6 +283,7 @@ G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
return kInfinity ;
}
}
while( Inside(p+dist*v) == kOutside ) ;
}
}
return dist ;
@@ -334,9 +339,12 @@ G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
{
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p,v), point p is outside") ;
}
return min(fPtrSolidA->DistanceToOut(p,v,calcNorm,validNorm,n),
fPtrSolidB->DistanceToOut(p,v,calcNorm,validNorm,n) ) ;
G4double distA = fPtrSolidA->DistanceToOut(p,v,calcNorm,validNorm,n) ;
G4double distB = fPtrSolidB->DistanceToOut(p,v,calcNorm,validNorm,n) ;
G4double dist = min(distA,distB) ;
return dist ;
// return min(fPtrSolidA->DistanceToOut(p,v,calcNorm,validNorm,n),
// fPtrSolidB->DistanceToOut(p,v,calcNorm,validNorm,n) ) ;
}
//////////////////////////////////////////////////////////////
@@ -2,9 +2,11 @@
//
// History:
//
// 14.10.98 V.Grichine
// 19.10.98 V.Grichine new algorithm of DistanceToIn(p,v) according to
// J.Apostolakis recommendations
// 14.10.98 V.Grichine, implementation of the first version
// 19.10.98 V.Grichine, new algorithm of DistanceToIn(p,v) according to
// J.Apostolakis recommendations (while loops)
// 02.08.99 V.Grichine, bugs fixed in DistanceToOut(p,v,...)
// while -> do-while & surfaceA limitations
//
#include "G4SubtractionSolid.hh"
@@ -157,32 +159,38 @@ G4double
G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const
{
G4double dist,dist2 ;
G4double dist = 0.0,disTmp = 0.0 ;
if( Inside(p) == kInside )
{
G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p,v), point p is inside") ;
}
if( ( fPtrSolidA->Inside(p) != kOutside) && // case1:p in both A&B
if( // ( fPtrSolidA->Inside(p) != kOutside) && // case1:p in both A&B
( fPtrSolidB->Inside(p) != kOutside) ) // start: out of B
{
dist = fPtrSolidB->DistanceToOut(p,v) ; // ,calcNorm,validNorm,n) ;
while( Inside(p+dist*v) == kOutside )
if( fPtrSolidA->Inside(p+dist*v) != kInside )
{
dist2 = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
do
{
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
if(dist2 == kInfinity)
{
return kInfinity ;
}
dist += dist2 ;
if(disTmp == kInfinity)
{
return kInfinity ;
}
dist += disTmp ;
if( Inside(p+dist*v) == kOutside )
{
dist += fPtrSolidB->DistanceToOut(p+dist*v,v) ;
}
if( Inside(p+dist*v) == kOutside )
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
dist += disTmp ;
}
}
while( Inside(p+dist*v) == kOutside ) ;
}
}
else // p outside A, start in A
@@ -195,21 +203,24 @@ G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
}
else
{
while( Inside(p+dist*v) == kOutside ) // pushing loop
while( Inside(p+dist*v) == kOutside ) // pushing loop
// do
{
dist += fPtrSolidB->DistanceToOut(p+dist*v,v) ;
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v) ;
dist += disTmp ;
if( Inside(p+dist*v) == kOutside )
{
dist2 = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
if(dist2 == kInfinity) // past A, hence past A\B
if(disTmp == kInfinity) // past A, hence past A\B
{
return kInfinity ;
}
dist += dist2 ;
dist += disTmp ;
}
}
// while( Inside(p+dist*v) == kOutside ) ;
}
}
@@ -2,7 +2,10 @@
//
// History:
//
// 12.09.98 V.Grichine
// 12.09.98 V.Grichine, implementation
// 28.11.98 V.Grichine, J. Apostolakis, while loops in DistToIn/Out
// 27.07.99 V.Grichine, modifications in Distance ToOut(p,v,...)
// while -> do-while
#include "G4UnionSolid.hh"
// #include "G4PlacedSolid.hh"
@@ -94,7 +97,9 @@ G4UnionSolid::CalculateExtent(const EAxis pAxis,
/////////////////////////////////////////////////////
//
//
// Important comment: When solids A and B touch together along flat
// surface the surface points will be considered as kSurface, while points
// located around will correspond to kInside
EInside G4UnionSolid::Inside(const G4ThreeVector& p) const
{
@@ -197,7 +202,7 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
G4bool *validNorm,
G4ThreeVector *n ) const
{
G4double disTmp = 0.0, dist = 0.0 ;
G4double dist = 0.0, disTmp = 0.0 ;
G4ThreeVector normTmp;
G4ThreeVector* nTmp= &normTmp;
@@ -209,46 +214,45 @@ G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
{
EInside positionA = fPtrSolidA->Inside(p) ;
EInside positionB = fPtrSolidB->Inside(p) ;
if( positionA != kOutside )
{
while( Inside(p+dist*v) == kInside )
do
{
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v,calcNorm,
validNorm,nTmp) ;
dist += disTmp ;
if( Inside(p+dist*v) == kInside )
if(fPtrSolidB->Inside(p+dist*v) != kOutside)
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v,calcNorm,
validNorm,nTmp) ;
dist += disTmp ;
}
else
{
break ;
}
}
// while( Inside(p+dist*v) == kInside ) ;
while( fPtrSolidA->Inside(p+dist*v) != kOutside &&
disTmp > 0.5*kCarTolerance ) ;
*n = *nTmp ;
}
else
else // if( positionB != kOutside )
{
while( Inside(p+dist*v) == kInside )
do
{
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v,calcNorm,
validNorm,nTmp) ;
validNorm,nTmp) ;
dist += disTmp ;
if( Inside(p+dist*v) == kInside )
if(fPtrSolidA->Inside(p+dist*v) != kOutside)
{
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v,calcNorm,
validNorm,nTmp) ;
dist += disTmp ;
}
else
{
break ;
}
}
// while( Inside(p+dist*v) == kInside ) ;
while( fPtrSolidB->Inside(p+dist*v) != kOutside &&
disTmp > 0.5*kCarTolerance ) ;
*n = *nTmp ;
}
}