Import Geant4 10.4.2 source tree
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4BooleanSolid.cc 97300 2016-06-01 09:27:19Z gcosmo $
|
||||
// $Id: G4BooleanSolid.cc 110069 2018-05-15 09:32:07Z gcosmo $
|
||||
//
|
||||
// Implementation for the abstract base class for solids created by boolean
|
||||
// operations between other solids
|
||||
@@ -62,7 +62,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ) :
|
||||
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
|
||||
fAreaAccuracy(-1.), fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
|
||||
createdDisplacedSolid(false)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ) :
|
||||
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
|
||||
fAreaAccuracy(-1.), fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
|
||||
createdDisplacedSolid(true)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidB ,
|
||||
const G4Transform3D& transform ) :
|
||||
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
|
||||
fAreaAccuracy(-1.), fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
|
||||
createdDisplacedSolid(true)
|
||||
{
|
||||
@@ -113,7 +113,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4BooleanSolid::G4BooleanSolid( __void__& a )
|
||||
: G4VSolid(a), fPtrSolidA(0), fPtrSolidB(0),
|
||||
fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
|
||||
fAreaAccuracy(-1.), fCubicVolume(-1.), fSurfaceArea(-1.),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
|
||||
createdDisplacedSolid(false)
|
||||
{
|
||||
@@ -354,8 +354,8 @@ G4ThreeVector G4BooleanSolid::GetPointOnSurface() const
|
||||
}
|
||||
std::ostringstream message;
|
||||
message << "Solid - " << GetName() << "\n"
|
||||
<< "All attempts to generate a point on the surface have failed.\n"
|
||||
<< "Returning point from the last unsuccessful attempt!";
|
||||
<< "All attempts to generate a point on the surface have failed!\n"
|
||||
<< "The solid created may be an invalid Boolean construct!";
|
||||
G4Exception("G4BooleanSolid::GetPointOnSurface()",
|
||||
"GeomSolids1001", JustWarning, message);
|
||||
return p;
|
||||
@@ -420,7 +420,18 @@ G4BooleanSolid::StackPolyhedron(HepPolyhedronProcessor& processor,
|
||||
top = solidA->GetPolyhedron();
|
||||
}
|
||||
G4Polyhedron* operand = solidB->GetPolyhedron();
|
||||
processor.push_back (operation, *operand);
|
||||
if (operand)
|
||||
{
|
||||
processor.push_back (operation, *operand);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Solid - " << solid->GetName()
|
||||
<< " - No G4Polyhedron for Boolean component";
|
||||
G4Exception("G4BooleanSolid::StackPolyhedron()",
|
||||
"GeomSolids2001", JustWarning, message);
|
||||
}
|
||||
|
||||
return top;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4DisplacedSolid.cc 104316 2017-05-24 13:04:23Z gcosmo $
|
||||
// $Id: G4DisplacedSolid.cc 110069 2018-05-15 09:32:07Z gcosmo $
|
||||
//
|
||||
// Implementation for G4DisplacedSolid class for boolean
|
||||
// operations between other solids
|
||||
@@ -34,6 +34,7 @@
|
||||
// 28.10.98 V.Grichine: created
|
||||
// 14.11.99 V.Grichine: modifications in CalculateExtent(...) method
|
||||
// 22.11.00 V.Grichine: new set methods for matrix/vectors
|
||||
// 28.02.18 E.Tcherniaev: improved contruction from G4DisplacedSolid
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -57,10 +58,19 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
const G4ThreeVector& transVector )
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fPtrTransform = new G4AffineTransform(rotMatrix,transVector) ;
|
||||
fPtrTransform->Invert() ;
|
||||
fDirectTransform = new G4AffineTransform(rotMatrix,transVector) ;
|
||||
if (pSolid->GetEntityType() == "G4DisplacedSolid")
|
||||
{
|
||||
fPtrSolid = ((G4DisplacedSolid*)pSolid)->GetConstituentMovedSolid();
|
||||
G4AffineTransform t1 = ((G4DisplacedSolid*)pSolid)->GetDirectTransform();
|
||||
G4AffineTransform t2 = G4AffineTransform(rotMatrix,transVector);
|
||||
fDirectTransform = new G4AffineTransform(t1*t2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fPtrSolid = pSolid;
|
||||
fDirectTransform = new G4AffineTransform(rotMatrix,transVector);
|
||||
}
|
||||
fPtrTransform = new G4AffineTransform(fDirectTransform->Inverse());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -72,13 +82,21 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
const G4Transform3D& transform )
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(),
|
||||
transform.getTranslation()) ;
|
||||
|
||||
fPtrTransform = new G4AffineTransform(transform.getRotation().inverse(),
|
||||
transform.getTranslation()) ;
|
||||
fPtrTransform->Invert() ;
|
||||
if (pSolid->GetEntityType() == "G4DisplacedSolid")
|
||||
{
|
||||
fPtrSolid = ((G4DisplacedSolid*)pSolid)->GetConstituentMovedSolid();
|
||||
G4AffineTransform t1 = ((G4DisplacedSolid*)pSolid)->GetDirectTransform();
|
||||
G4AffineTransform t2 = G4AffineTransform(transform.getRotation().inverse(),
|
||||
transform.getTranslation());
|
||||
fDirectTransform = new G4AffineTransform(t1*t2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fPtrSolid = pSolid;
|
||||
fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(),
|
||||
transform.getTranslation()) ;
|
||||
}
|
||||
fPtrTransform = new G4AffineTransform(fDirectTransform->Inverse());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
@@ -91,9 +109,19 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
const G4AffineTransform directTransform )
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fDirectTransform = new G4AffineTransform( directTransform );
|
||||
fPtrTransform = new G4AffineTransform( directTransform.Inverse() ) ;
|
||||
if (pSolid->GetEntityType() == "G4DisplacedSolid")
|
||||
{
|
||||
fPtrSolid = ((G4DisplacedSolid*)pSolid)->GetConstituentMovedSolid();
|
||||
G4AffineTransform t1 = ((G4DisplacedSolid*)pSolid)->GetDirectTransform();
|
||||
G4AffineTransform t2 = G4AffineTransform(directTransform);
|
||||
fDirectTransform = new G4AffineTransform(t1*t2);
|
||||
}
|
||||
else
|
||||
{
|
||||
fPtrSolid = pSolid;
|
||||
fDirectTransform = new G4AffineTransform(directTransform);
|
||||
}
|
||||
fPtrTransform = new G4AffineTransform(fDirectTransform->Inverse());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
@@ -491,8 +519,18 @@ G4Polyhedron*
|
||||
G4DisplacedSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
|
||||
polyhedron
|
||||
if (polyhedron)
|
||||
{
|
||||
polyhedron
|
||||
->Transform(G4Transform3D(GetObjectRotation(),GetObjectTranslation()));
|
||||
}
|
||||
else
|
||||
{
|
||||
DumpInfo();
|
||||
G4Exception("G4DisplacedSolid::CreatePolyhedron()",
|
||||
"GeomSolids2002", JustWarning,
|
||||
"No G4Polyhedron for displaced solid");
|
||||
}
|
||||
return polyhedron;
|
||||
}
|
||||
|
||||
|
||||
@@ -404,7 +404,17 @@ G4Polyhedron*
|
||||
G4ScaledSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
|
||||
polyhedron->Transform(GetScaleTransform());
|
||||
if (polyhedron)
|
||||
{
|
||||
polyhedron->Transform(GetScaleTransform());
|
||||
}
|
||||
else
|
||||
{
|
||||
DumpInfo();
|
||||
G4Exception("G4ScaledSolid::CreatePolyhedron()",
|
||||
"GeomSolids2003", JustWarning,
|
||||
"No G4Polyhedron for scaled solid");
|
||||
}
|
||||
return polyhedron;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UnionSolid.cc 104316 2017-05-24 13:04:23Z gcosmo $
|
||||
// $Id: G4UnionSolid.cc 110069 2018-05-15 09:32:07Z gcosmo $
|
||||
//
|
||||
// Implementation of methods for the class G4UnionSolid
|
||||
//
|
||||
@@ -35,6 +35,7 @@
|
||||
// 27.07.99 V.Grichine: modifications in DistToOut(p,v,...), while -> do-while
|
||||
// 16.03.01 V.Grichine: modifications in CalculateExtent()
|
||||
// 17.03.17 E.Tcherniaev: revision of SurfaceNormal()
|
||||
// 23.04.18 E.Tcherniaev: added extended BBox, yearly return in Inside()
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -61,6 +62,11 @@ G4UnionSolid:: G4UnionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidB )
|
||||
: G4BooleanSolid(pName,pSolidA,pSolidB)
|
||||
{
|
||||
G4ThreeVector pdelta(0.5*kCarTolerance,0.5*kCarTolerance,0.5*kCarTolerance);
|
||||
G4ThreeVector pmin, pmax;
|
||||
BoundingLimits(pmin, pmax);
|
||||
fPMin = pmin - pdelta;
|
||||
fPMax = pmax + pdelta;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@@ -75,6 +81,11 @@ G4UnionSolid::G4UnionSolid( const G4String& pName,
|
||||
: G4BooleanSolid(pName,pSolidA,pSolidB,rotMatrix,transVector)
|
||||
|
||||
{
|
||||
G4ThreeVector pdelta(0.5*kCarTolerance,0.5*kCarTolerance,0.5*kCarTolerance);
|
||||
G4ThreeVector pmin, pmax;
|
||||
BoundingLimits(pmin, pmax);
|
||||
fPMin = pmin - pdelta;
|
||||
fPMax = pmax + pdelta;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@@ -87,6 +98,11 @@ G4UnionSolid::G4UnionSolid( const G4String& pName,
|
||||
const G4Transform3D& transform )
|
||||
: G4BooleanSolid(pName,pSolidA,pSolidB,transform)
|
||||
{
|
||||
G4ThreeVector pdelta(0.5*kCarTolerance,0.5*kCarTolerance,0.5*kCarTolerance);
|
||||
G4ThreeVector pmin, pmax;
|
||||
BoundingLimits(pmin, pmax);
|
||||
fPMin = pmin - pdelta;
|
||||
fPMax = pmax + pdelta;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
@@ -114,6 +130,8 @@ G4UnionSolid::~G4UnionSolid()
|
||||
G4UnionSolid::G4UnionSolid(const G4UnionSolid& rhs)
|
||||
: G4BooleanSolid (rhs)
|
||||
{
|
||||
fPMin = rhs.fPMin;
|
||||
fPMax = rhs.fPMax;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -130,6 +148,8 @@ G4UnionSolid& G4UnionSolid::operator = (const G4UnionSolid& rhs)
|
||||
//
|
||||
G4BooleanSolid::operator=(rhs);
|
||||
|
||||
fPMin = rhs.fPMin;
|
||||
fPMax = rhs.fPMax;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -208,27 +228,23 @@ G4UnionSolid::CalculateExtent( const EAxis pAxis,
|
||||
|
||||
EInside G4UnionSolid::Inside( const G4ThreeVector& p ) const
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p);
|
||||
if (positionA == kInside) { return kInside; }
|
||||
if (std::max(p.z()-fPMax.z(),fPMin.z()-p.z()) > 0) return kOutside;
|
||||
|
||||
EInside positionA = fPtrSolidA->Inside(p);
|
||||
if (positionA == kInside) { return positionA; } // inside A
|
||||
EInside positionB = fPtrSolidB->Inside(p);
|
||||
if (positionA == kOutside) { return positionB; }
|
||||
|
||||
if (positionB == kInside) { return positionB; } // inside B
|
||||
if (positionB == kOutside) { return positionA; } // surface A
|
||||
|
||||
// Both points are on surface
|
||||
//
|
||||
static const G4double rtol
|
||||
= 1000*G4GeometryTolerance::GetInstance()->GetRadialTolerance();
|
||||
EInside positionB = fPtrSolidB->Inside(p);
|
||||
|
||||
if( positionB == kInside ||
|
||||
( positionA == kSurface && positionB == kSurface &&
|
||||
( fPtrSolidA->SurfaceNormal(p) +
|
||||
fPtrSolidB->SurfaceNormal(p) ).mag2() < rtol ) )
|
||||
{
|
||||
return kInside;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( positionB == kSurface ) || ( positionA == kSurface ) )
|
||||
{ return kSurface; }
|
||||
else
|
||||
{ return kOutside; }
|
||||
}
|
||||
return ((fPtrSolidA->SurfaceNormal(p) +
|
||||
fPtrSolidB->SurfaceNormal(p)).mag2() < rtol) ? kInside : kSurface;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user