Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// Implementation for the abstract base class for solids created by boolean
|
||||
// operations between other solids
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 10.09.98 V.Grichine, creation according J. Apostolakis's recommendations
|
||||
|
||||
#include "G4BooleanSolid.hh"
|
||||
#include "G4DisplacedSolid.hh"
|
||||
|
||||
#include "G4RotationMatrix.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ) :
|
||||
G4VSolid(pName),
|
||||
createdDisplacedSolid(false)
|
||||
{
|
||||
fPtrSolidA = pSolidA ;
|
||||
fPtrSolidB = pSolidB ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ) :
|
||||
G4VSolid(pName),
|
||||
createdDisplacedSolid(true)
|
||||
{
|
||||
fPtrSolidA = pSolidA ;
|
||||
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,rotMatrix,transVector) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
const G4Transform3D& transform ) :
|
||||
G4VSolid(pName),
|
||||
createdDisplacedSolid(true)
|
||||
{
|
||||
fPtrSolidA = pSolidA ;
|
||||
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,transform) ;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor deletes second pointer created by 'new'
|
||||
|
||||
G4BooleanSolid::~G4BooleanSolid()
|
||||
{
|
||||
if(createdDisplacedSolid) delete fPtrSolidB ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
// Implementation for G4DisplacedSolid class for boolean
|
||||
// operations between other solids
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 28.10.98 V.Grichine, creation according J. Apostolakis's recommendations
|
||||
|
||||
#include "G4DisplacedSolid.hh"
|
||||
|
||||
|
||||
#include "G4VoxelLimits.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
#include "G4VisExtent.hh"
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constractor for transformation like rotation of frame then translation
|
||||
// in new frame. It is similar to 1st constractor in G4PVPlacement
|
||||
|
||||
G4DisplacedSolid::
|
||||
G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector )
|
||||
: G4VSolid(pName)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fPtrTransform = new G4AffineTransform(rotMatrix,transVector) ;
|
||||
fPtrTransform->Invert() ;
|
||||
fDirectTransform = new G4AffineTransform(rotMatrix,transVector) ;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4Transform3D& transform ) :
|
||||
G4VSolid(pName)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fPtrTransform = new G4AffineTransform(transform.getRotation().inverse(),
|
||||
transform.getTranslation()) ;
|
||||
fPtrTransform->Invert() ;
|
||||
fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(),
|
||||
transform.getTranslation()) ;
|
||||
}
|
||||
|
||||
G4DisplacedSolid::~G4DisplacedSolid()
|
||||
{
|
||||
if(fPtrTransform)
|
||||
{
|
||||
delete fPtrTransform ;
|
||||
delete fDirectTransform;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4bool
|
||||
G4DisplacedSolid::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const
|
||||
{
|
||||
return fPtrSolid->CalculateExtent(pAxis,pVoxelLimit,pTransform,
|
||||
pMin,pMax) ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
EInside G4DisplacedSolid::Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
|
||||
return fPtrSolid->Inside(newPoint) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4ThreeVector
|
||||
G4DisplacedSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
|
||||
G4ThreeVector normal = fPtrSolid->SurfaceNormal(newPoint) ;
|
||||
return fDirectTransform->TransformAxis(normal) ;
|
||||
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as in DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const
|
||||
{
|
||||
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
|
||||
G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ;
|
||||
return fPtrSolid->DistanceToIn(newPoint,newDirection) ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// Approximate nearest distance from the point p to the intersection of
|
||||
// two solids
|
||||
|
||||
G4double
|
||||
G4DisplacedSolid::DistanceToIn( const G4ThreeVector& p) const
|
||||
{
|
||||
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
|
||||
return fPtrSolid->DistanceToIn(newPoint) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as DistanceToOut(p)
|
||||
|
||||
G4double
|
||||
G4DisplacedSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm,
|
||||
G4bool *validNorm,
|
||||
G4ThreeVector *n ) const
|
||||
{
|
||||
G4ThreeVector solNorm ;
|
||||
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
|
||||
G4ThreeVector newDirection = fPtrTransform->TransformAxis(v) ;
|
||||
G4double dist = fPtrSolid->DistanceToOut(newPoint,newDirection,
|
||||
calcNorm,validNorm,&solNorm) ;
|
||||
if(calcNorm)
|
||||
{
|
||||
*n = fDirectTransform->TransformAxis(solNorm) ;
|
||||
}
|
||||
return dist ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Inverted algorithm of DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4DisplacedSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4ThreeVector newPoint = fPtrTransform->TransformPoint(p) ;
|
||||
return fPtrSolid->DistanceToOut(newPoint) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4DisplacedSolid::ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep )
|
||||
{
|
||||
// fPtrSolid->ComputeDimensions(p,n,pRep);
|
||||
|
||||
G4Exception("ERROR: ComputeDimensions has no meaning for a G4DisplacedSolid. It cannot be called.");
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4DisplacedSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
fPtrSolid->DescribeYourselfTo(scene) ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4VisExtent
|
||||
G4DisplacedSolid::GetExtent () const
|
||||
{
|
||||
return fPtrSolid->GetExtent() ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4Polyhedron*
|
||||
G4DisplacedSolid::CreatePolyhedron () const
|
||||
{
|
||||
return fPtrSolid->CreatePolyhedron() ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4NURBS*
|
||||
G4DisplacedSolid::CreateNURBS () const
|
||||
{
|
||||
return fPtrSolid->CreateNURBS() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,415 @@
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 12.09.98 V.Grichine
|
||||
|
||||
#include "G4IntersectionSolid.hh"
|
||||
// #include "G4DisplacedSolid.hh"
|
||||
|
||||
#include "G4RotationMatrix.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
#include "G4VoxelLimits.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
#include "G4VisExtent.hh"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Transfer all data members to G4BooleanSolid which is responsible
|
||||
// for them. pName will be in turn sent to G4VSolid
|
||||
//
|
||||
|
||||
G4IntersectionSolid:: G4IntersectionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ):
|
||||
G4BooleanSolid(pName,pSolidA,pSolidB)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
G4IntersectionSolid::
|
||||
G4IntersectionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ):
|
||||
G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4IntersectionSolid::
|
||||
G4IntersectionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
const G4Transform3D& transform ):
|
||||
G4BooleanSolid(pName,pSolidA,pSolidB,transform)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
G4IntersectionSolid::~G4IntersectionSolid()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4bool
|
||||
G4IntersectionSolid::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const
|
||||
{
|
||||
G4bool retA, retB;
|
||||
G4double minA, minB, maxA, maxB;
|
||||
|
||||
retA= fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit, pTransform, minA, maxA);
|
||||
retB= fPtrSolidB->CalculateExtent( pAxis, pVoxelLimit, pTransform, minB, maxB);
|
||||
|
||||
pMin = max( minA, minB );
|
||||
pMax = min( maxA, maxB );
|
||||
|
||||
return retA && retB ; // It exists in this slice only if both exist in it.
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// Touching ? Empty intersection ?
|
||||
|
||||
EInside G4IntersectionSolid::Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p) ;
|
||||
EInside positionB = fPtrSolidB->Inside(p) ;
|
||||
|
||||
if(positionA == kInside && positionB == kInside)
|
||||
{
|
||||
return kInside ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((positionA == kInside && positionB == kSurface) ||
|
||||
(positionB == kInside && positionA == kSurface) ||
|
||||
(positionA == kSurface && positionB == kSurface) )
|
||||
{
|
||||
return kSurface ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kOutside ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4ThreeVector
|
||||
G4IntersectionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4ThreeVector normal;
|
||||
G4bool insideA, insideB;
|
||||
|
||||
insideA= fPtrSolidA->Inside(p);
|
||||
insideB= fPtrSolidB->Inside(p);
|
||||
|
||||
// if( Inside(p) == kOutside )
|
||||
if( (insideA == kOutside) || (insideB == kOutside) )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), point p is outside") ;
|
||||
}
|
||||
|
||||
// OLD: if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
|
||||
|
||||
// On the surface of both is difficult ... treat it like on A now!
|
||||
//
|
||||
// if( (insideA == kSurface) && (insideB == kSurface) )
|
||||
// normal= fPtrSolidA->SurfaceNormal(p) ;
|
||||
// else
|
||||
if( insideA == kSurface )
|
||||
{
|
||||
normal= fPtrSolidA->SurfaceNormal(p) ;
|
||||
}
|
||||
else if( insideB == kSurface )
|
||||
{
|
||||
normal= fPtrSolidB->SurfaceNormal(p) ;
|
||||
}
|
||||
// We are on neither surface, so we should generate an exception
|
||||
else
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), point p is not on the surface of the volume.") ;
|
||||
|
||||
// Or else
|
||||
if(fPtrSolidA->DistanceToOut(p) <= fPtrSolidB->DistanceToOut(p) )
|
||||
normal= fPtrSolidA->SurfaceNormal(p) ;
|
||||
else
|
||||
normal= fPtrSolidB->SurfaceNormal(p) ;
|
||||
}
|
||||
|
||||
return normal;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as in DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const
|
||||
{
|
||||
G4double dist = 0.0, disTmp ;
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p,v), point p is inside") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fPtrSolidA->Inside(p) != kOutside )
|
||||
{
|
||||
while( Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
|
||||
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
if(Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( fPtrSolidB->Inside(p) != kOutside )
|
||||
{
|
||||
while( Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
|
||||
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
if(Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToIn(p+dist*v,v) ;
|
||||
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
if(Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
|
||||
if( disTmp != kInfinity )
|
||||
{
|
||||
dist += disTmp ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dist ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// Approximate nearest distance from the point p to the intersection of
|
||||
// two solids
|
||||
|
||||
G4double
|
||||
G4IntersectionSolid::DistanceToIn( const G4ThreeVector& p) const
|
||||
{
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p), point p is inside") ;
|
||||
}
|
||||
EInside sideA = fPtrSolidA->Inside(p) ;
|
||||
EInside sideB = fPtrSolidB->Inside(p) ;
|
||||
G4double dist ;
|
||||
|
||||
if( sideA != kInside && sideB != kOutside )
|
||||
{
|
||||
dist = fPtrSolidA->DistanceToIn(p) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( sideB != kInside && sideA != kOutside )
|
||||
{
|
||||
dist = fPtrSolidB->DistanceToIn(p) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
dist = min(fPtrSolidA->DistanceToIn(p),
|
||||
fPtrSolidB->DistanceToIn(p) ) ;
|
||||
}
|
||||
}
|
||||
return dist ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as DistanceToOut(p)
|
||||
|
||||
G4double
|
||||
G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm,
|
||||
G4bool *validNorm,
|
||||
G4ThreeVector *n ) const
|
||||
{
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
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) ) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Inverted algorithm of DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4IntersectionSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
{
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p), point p is outside") ;
|
||||
}
|
||||
|
||||
|
||||
return min(fPtrSolidA->DistanceToOut(p),
|
||||
fPtrSolidB->DistanceToOut(p) ) ;
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4IntersectionSolid::ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep )
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4IntersectionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4VisExtent
|
||||
G4IntersectionSolid::GetExtent () const
|
||||
{
|
||||
return G4VisExtent(-1.0,1.0,-1.0,1.0,-1.0,1.0) ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4Polyhedron*
|
||||
G4IntersectionSolid::CreatePolyhedron () const
|
||||
{
|
||||
return new G4PolyhedronBox (1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4NURBS*
|
||||
G4IntersectionSolid::CreateNURBS () const
|
||||
{
|
||||
return new G4NURBSbox (1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,359 @@
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 14.10.98 V.Grichine
|
||||
// 19.10.98 V.Grichine new algorithm of DistanceToIn(p,v) according to
|
||||
// J.Apostolakis recommendations
|
||||
//
|
||||
|
||||
#include "G4SubtractionSolid.hh"
|
||||
// #include "G4DisplacedSolid.hh"
|
||||
|
||||
#include "G4RotationMatrix.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
#include "G4VoxelLimits.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
#include "G4VisExtent.hh"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Transfer all data members to G4BooleanSolid which is responsible
|
||||
// for them. pName will be in turn sent to G4VSolid
|
||||
|
||||
G4SubtractionSolid:: G4SubtractionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ):
|
||||
G4BooleanSolid(pName,pSolidA,pSolidB)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4SubtractionSolid::
|
||||
G4SubtractionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ):
|
||||
G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4SubtractionSolid::
|
||||
G4SubtractionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
const G4Transform3D& transform ):
|
||||
G4BooleanSolid(pName,pSolidA,pSolidB,transform)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
G4SubtractionSolid::~G4SubtractionSolid()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4bool
|
||||
G4SubtractionSolid::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, 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!
|
||||
|
||||
return fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit,
|
||||
pTransform, pMin, pMax);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// Touching ? Empty subtraction ?
|
||||
|
||||
EInside G4SubtractionSolid::Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p) ;
|
||||
EInside positionB = fPtrSolidB->Inside(p) ;
|
||||
|
||||
if(positionA == kInside && positionB == kOutside)
|
||||
{
|
||||
return kInside ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((positionA == kInside && positionB == kSurface) ||
|
||||
(positionB == kOutside && positionA == kSurface) ||
|
||||
(positionA == kSurface && positionB == kSurface) )
|
||||
{
|
||||
return kSurface ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kOutside ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4ThreeVector
|
||||
G4SubtractionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4ThreeVector normal;
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4SubtractionSolid::SurfaceNormal(p), point p is outside") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( fPtrSolidA->Inside(p) == kSurface &&
|
||||
fPtrSolidB->Inside(p) != kInside )
|
||||
{
|
||||
normal= fPtrSolidA->SurfaceNormal(p) ;
|
||||
}
|
||||
else if( fPtrSolidA->Inside(p) == kInside &&
|
||||
fPtrSolidB->Inside(p) != kOutside )
|
||||
{
|
||||
normal= -fPtrSolidB->SurfaceNormal(p) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception("Invalid call in G4SubtractionSolid::SurfaceNormal(p), point p is inside rather than on surface") ;
|
||||
}
|
||||
}
|
||||
return normal;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as in DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const
|
||||
{
|
||||
G4double dist,dist2 ;
|
||||
|
||||
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
|
||||
( fPtrSolidB->Inside(p) != kOutside) ) // start: out of B
|
||||
{
|
||||
dist = fPtrSolidB->DistanceToOut(p,v) ; // ,calcNorm,validNorm,n) ;
|
||||
|
||||
while( Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
dist2 = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
|
||||
|
||||
if(dist2 == kInfinity)
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
dist += dist2 ;
|
||||
|
||||
if( Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
dist += fPtrSolidB->DistanceToOut(p+dist*v,v) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // p outside A, start in A
|
||||
{
|
||||
dist = fPtrSolidA->DistanceToIn(p,v) ;
|
||||
|
||||
if( dist == kInfinity ) // past A, hence past A\B
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
else
|
||||
{
|
||||
while( Inside(p+dist*v) == kOutside ) // pushing loop
|
||||
{
|
||||
dist += fPtrSolidB->DistanceToOut(p+dist*v,v) ;
|
||||
|
||||
if( Inside(p+dist*v) == kOutside )
|
||||
{
|
||||
dist2 = fPtrSolidA->DistanceToIn(p+dist*v,v) ;
|
||||
|
||||
if(dist2 == kInfinity) // past A, hence past A\B
|
||||
{
|
||||
return kInfinity ;
|
||||
}
|
||||
dist += dist2 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dist ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// Approximate nearest distance from the point p to the intersection of
|
||||
// two solids. It is usually underestimated from the point of view of
|
||||
// isotropic safety
|
||||
|
||||
G4double
|
||||
G4SubtractionSolid::DistanceToIn( const G4ThreeVector& p) const
|
||||
{
|
||||
G4double dist;
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4SubtractionSolid::DistanceToIn(p), point p is inside") ;
|
||||
}
|
||||
|
||||
if( ( fPtrSolidA->Inside(p) != kOutside) && // case 1
|
||||
( fPtrSolidB->Inside(p) != kOutside) )
|
||||
{
|
||||
dist= fPtrSolidB->DistanceToOut(p) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
dist= fPtrSolidA->DistanceToIn(p) ;
|
||||
}
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as DistanceToOut(p)
|
||||
|
||||
G4double
|
||||
G4SubtractionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm,
|
||||
G4bool *validNorm,
|
||||
G4ThreeVector *n ) const
|
||||
{
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p,v), point p is outside") ;
|
||||
}
|
||||
|
||||
G4double distout;
|
||||
G4double distA = fPtrSolidA->DistanceToOut(p,v,calcNorm,validNorm,n) ;
|
||||
G4double distB = fPtrSolidB->DistanceToIn(p,v) ;
|
||||
if(distB < distA)
|
||||
{
|
||||
if(calcNorm)
|
||||
{
|
||||
*n = -(fPtrSolidB->SurfaceNormal(p+distB*v)) ;
|
||||
*validNorm = false ;
|
||||
}
|
||||
distout= distB ;
|
||||
}
|
||||
else
|
||||
{
|
||||
distout= distA ;
|
||||
*validNorm = true ;
|
||||
}
|
||||
return distout;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Inverted algorithm of DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4SubtractionSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4double dist;
|
||||
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p), point p is outside") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
dist= min(fPtrSolidA->DistanceToOut(p),
|
||||
fPtrSolidB->DistanceToIn(p) ) ;
|
||||
}
|
||||
return dist;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4SubtractionSolid::ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep )
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4SubtractionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4VisExtent
|
||||
G4SubtractionSolid::GetExtent () const
|
||||
{
|
||||
return G4VisExtent(-1.0,1.0,-1.0,1.0,-1.0,1.0) ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4Polyhedron*
|
||||
G4SubtractionSolid::CreatePolyhedron () const
|
||||
{
|
||||
return new G4PolyhedronBox (1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4NURBS*
|
||||
G4SubtractionSolid::CreateNURBS () const
|
||||
{
|
||||
return new G4NURBSbox (1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,356 @@
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 12.09.98 V.Grichine
|
||||
|
||||
#include "G4UnionSolid.hh"
|
||||
// #include "G4PlacedSolid.hh"
|
||||
|
||||
#include "G4RotationMatrix.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
#include "G4VoxelLimits.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
#include "G4VisExtent.hh"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Transfer all data members to G4BooleanSolid which is responsible
|
||||
// for them. pName will be in turn sent to G4VSolid
|
||||
|
||||
G4UnionSolid:: G4UnionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ):
|
||||
G4BooleanSolid(pName,pSolidA,pSolidB)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4UnionSolid:: G4UnionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ):
|
||||
G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
|
||||
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4UnionSolid:: G4UnionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
const G4Transform3D& transform ):
|
||||
G4BooleanSolid(pName,pSolidA,pSolidB,transform)
|
||||
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4UnionSolid::~G4UnionSolid()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4bool
|
||||
G4UnionSolid::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const
|
||||
{
|
||||
G4bool touchesA, touchesB;
|
||||
G4double minA, minB, maxA, maxB;
|
||||
|
||||
touchesA= fPtrSolidA->CalculateExtent( pAxis, pVoxelLimit, pTransform, minA, maxA);
|
||||
touchesB= fPtrSolidB->CalculateExtent( pAxis, pVoxelLimit, pTransform, minB, maxB);
|
||||
|
||||
pMin = min( minA, minB );
|
||||
pMax = max( maxA, maxB );
|
||||
|
||||
return touchesA || touchesB ; // It exists in this slice if either one does.
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
EInside G4UnionSolid::Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p) ;
|
||||
EInside positionB = fPtrSolidB->Inside(p) ;
|
||||
|
||||
if( positionA == kInside || positionB == kInside )
|
||||
{
|
||||
return kInside ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((positionA != kInside && positionB == kSurface) ||
|
||||
(positionB != kInside && positionA == kSurface) ||
|
||||
(positionA == kSurface && positionB == kSurface) )
|
||||
{
|
||||
return kSurface ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return kOutside ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4ThreeVector
|
||||
G4UnionSolid::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4ThreeVector normal;
|
||||
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), point p is outside") ;
|
||||
}
|
||||
|
||||
if(fPtrSolidA->Inside(p) == kSurface && fPtrSolidB->Inside(p) != kInside)
|
||||
{
|
||||
normal= fPtrSolidA->SurfaceNormal(p) ;
|
||||
}
|
||||
else if(fPtrSolidB->Inside(p) == kSurface &&
|
||||
fPtrSolidA->Inside(p) != kInside)
|
||||
{
|
||||
normal= fPtrSolidB->SurfaceNormal(p) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::SurfaceNormal(p), point p is inside") ;
|
||||
}
|
||||
|
||||
return normal;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as in DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4UnionSolid::DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const
|
||||
{
|
||||
G4double dist ;
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToIn(p,v), point p is inside") ;
|
||||
}
|
||||
return min(fPtrSolidA->DistanceToIn(p,v),
|
||||
fPtrSolidB->DistanceToIn(p,v) ) ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// Approximate nearest distance from the point p to the union of
|
||||
// two solids
|
||||
|
||||
G4double
|
||||
G4UnionSolid::DistanceToIn( const G4ThreeVector& p) const
|
||||
{
|
||||
if( Inside(p) == kInside )
|
||||
{
|
||||
G4Exception("Invalid call in G4UnionSolid::DistanceToIn(p), point p is inside") ;
|
||||
}
|
||||
G4double distA = fPtrSolidA->DistanceToIn(p) ;
|
||||
G4double distB = fPtrSolidB->DistanceToIn(p) ;
|
||||
|
||||
return min(distA,distB) ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// The same algorithm as DistanceToOut(p)
|
||||
|
||||
G4double
|
||||
G4UnionSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm,
|
||||
G4bool *validNorm,
|
||||
G4ThreeVector *n ) const
|
||||
{
|
||||
G4double disTmp = 0.0, dist = 0.0 ;
|
||||
G4ThreeVector normTmp;
|
||||
G4ThreeVector* nTmp= &normTmp;
|
||||
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p,v), point p is outside") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p) ;
|
||||
EInside positionB = fPtrSolidB->Inside(p) ;
|
||||
|
||||
if( positionA != kOutside )
|
||||
{
|
||||
|
||||
while( Inside(p+dist*v) == kInside )
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v,calcNorm,
|
||||
validNorm,nTmp) ;
|
||||
dist += disTmp ;
|
||||
if( Inside(p+dist*v) == kInside )
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v,calcNorm,
|
||||
validNorm,nTmp) ;
|
||||
dist += disTmp ;
|
||||
}
|
||||
else
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
*n = *nTmp ;
|
||||
}
|
||||
else
|
||||
{
|
||||
while( Inside(p+dist*v) == kInside )
|
||||
{
|
||||
disTmp = fPtrSolidB->DistanceToOut(p+dist*v,v,calcNorm,
|
||||
validNorm,nTmp) ;
|
||||
dist += disTmp ;
|
||||
if( Inside(p+dist*v) == kInside )
|
||||
{
|
||||
disTmp = fPtrSolidA->DistanceToOut(p+dist*v,v,calcNorm,
|
||||
validNorm,nTmp) ;
|
||||
dist += disTmp ;
|
||||
}
|
||||
else
|
||||
{
|
||||
break ;
|
||||
}
|
||||
}
|
||||
*n = *nTmp ;
|
||||
}
|
||||
}
|
||||
*validNorm = false ;
|
||||
return dist ;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Inverted algorithm of DistanceToIn(p)
|
||||
|
||||
G4double
|
||||
G4UnionSolid::DistanceToOut( const G4ThreeVector& p ) const
|
||||
{
|
||||
G4double distout;
|
||||
if( Inside(p) == kOutside )
|
||||
{
|
||||
G4Exception("Invalid call in G4IntersectionSolid::DistanceToOut(p), point p is outside") ;
|
||||
}
|
||||
else
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p) ;
|
||||
EInside positionB = fPtrSolidB->Inside(p) ;
|
||||
|
||||
// Is this equivalent ??
|
||||
// if( ! ( (positionA == kOutside)) &&
|
||||
// (positionB == kOutside)) )
|
||||
if((positionA == kInside && positionB == kInside ) ||
|
||||
(positionA == kInside && positionB == kSurface ) ||
|
||||
(positionA == kSurface && positionB == kInside ) )
|
||||
{
|
||||
distout= max(fPtrSolidA->DistanceToOut(p),
|
||||
fPtrSolidB->DistanceToOut(p) ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(positionA == kOutside)
|
||||
{
|
||||
distout= fPtrSolidB->DistanceToOut(p) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
distout= fPtrSolidA->DistanceToOut(p) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return distout;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4UnionSolid::ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep )
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
void
|
||||
G4UnionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4VisExtent
|
||||
G4UnionSolid::GetExtent () const
|
||||
{
|
||||
return G4VisExtent(-1.0,1.0,-1.0,1.0,-1.0,1.0) ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4Polyhedron*
|
||||
G4UnionSolid::CreatePolyhedron () const
|
||||
{
|
||||
return new G4PolyhedronBox (1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
|
||||
G4NURBS*
|
||||
G4UnionSolid::CreateNURBS () const
|
||||
{
|
||||
return new G4NURBSbox (1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user