Import Geant4 9.4.0 source tree
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4BooleanSolid.cc,v 1.21 2006/10/19 15:34:49 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4BooleanSolid.cc,v 1.24 2010/09/22 14:57:59 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
// Implementation for the abstract base class for solids created by boolean
|
||||
// operations between other solids
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "G4BooleanSolid.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "HepPolyhedronProcessor.h"
|
||||
#include "Randomize.hh"
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
@@ -115,6 +116,44 @@ G4BooleanSolid::~G4BooleanSolid()
|
||||
delete fpPolyhedron;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copy constructor
|
||||
|
||||
G4BooleanSolid::G4BooleanSolid(const G4BooleanSolid& rhs)
|
||||
: G4VSolid (rhs), fPtrSolidA(rhs.fPtrSolidA), fPtrSolidB(rhs.fPtrSolidB),
|
||||
fStatistics(rhs.fStatistics), fCubVolEpsilon(rhs.fCubVolEpsilon),
|
||||
fAreaAccuracy(rhs.fAreaAccuracy), fCubicVolume(rhs.fCubicVolume),
|
||||
fSurfaceArea(rhs.fSurfaceArea), fpPolyhedron(0),
|
||||
createdDisplacedSolid(rhs.createdDisplacedSolid)
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Assignment operator
|
||||
|
||||
G4BooleanSolid& G4BooleanSolid::operator = (const G4BooleanSolid& rhs)
|
||||
{
|
||||
// Check assignment to self
|
||||
//
|
||||
if (this == &rhs) { return *this; }
|
||||
|
||||
// Copy base class data
|
||||
//
|
||||
G4VSolid::operator=(rhs);
|
||||
|
||||
// Copy data
|
||||
//
|
||||
fPtrSolidA= rhs.fPtrSolidA; fPtrSolidB= rhs.fPtrSolidB;
|
||||
fStatistics= rhs.fStatistics; fCubVolEpsilon= rhs.fCubVolEpsilon;
|
||||
fAreaAccuracy= rhs.fAreaAccuracy; fCubicVolume= rhs.fCubicVolume;
|
||||
fSurfaceArea= rhs.fSurfaceArea; fpPolyhedron= 0;
|
||||
createdDisplacedSolid= rhs.createdDisplacedSolid;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// If Solid is made up from a Boolean operation of two solids,
|
||||
@@ -230,3 +269,48 @@ G4Polyhedron* G4BooleanSolid::GetPolyhedron () const
|
||||
}
|
||||
return fpPolyhedron;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Stacks polyhedra for processing. Returns top polyhedron.
|
||||
|
||||
G4Polyhedron*
|
||||
G4BooleanSolid::StackPolyhedron(HepPolyhedronProcessor& processor,
|
||||
const G4VSolid* solid) const
|
||||
{
|
||||
HepPolyhedronProcessor::Operation operation;
|
||||
const G4String& type = solid->GetEntityType();
|
||||
if (type == "G4UnionSolid")
|
||||
{ operation = HepPolyhedronProcessor::UNION; }
|
||||
else if (type == "G4IntersectionSolid")
|
||||
{ operation = HepPolyhedronProcessor::INTERSECTION; }
|
||||
else if (type == "G4SubtractionSolid")
|
||||
{ operation = HepPolyhedronProcessor::SUBTRACTION; }
|
||||
else
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Solid - " << solid->GetName()
|
||||
<< " - Unrecognised composite solid"
|
||||
<< "\n Returning NULL !";
|
||||
G4Exception("StackPolyhedron()", "InvalidSetup",
|
||||
JustWarning, oss.str().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4Polyhedron* top = 0;
|
||||
const G4VSolid* solidA = solid->GetConstituentSolid(0);
|
||||
const G4VSolid* solidB = solid->GetConstituentSolid(1);
|
||||
|
||||
if (solidA->GetConstituentSolid(0))
|
||||
{
|
||||
top = StackPolyhedron(processor, solidA);
|
||||
}
|
||||
else
|
||||
{
|
||||
top = solidA->GetPolyhedron();
|
||||
}
|
||||
G4Polyhedron* operand = solidB->GetPolyhedron();
|
||||
processor.push_back (operation, *operand);
|
||||
|
||||
return top;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4DisplacedSolid.cc,v 1.27 2006/06/29 18:43:41 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4DisplacedSolid.cc,v 1.29 2010/10/20 07:31:39 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
// Implementation for G4DisplacedSolid class for boolean
|
||||
// operations between other solids
|
||||
@@ -120,11 +120,42 @@ G4DisplacedSolid::~G4DisplacedSolid()
|
||||
delete fpPolyhedron;
|
||||
}
|
||||
|
||||
G4GeometryType G4DisplacedSolid::GetEntityType() const
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copy constructor
|
||||
|
||||
G4DisplacedSolid::G4DisplacedSolid(const G4DisplacedSolid& rhs)
|
||||
: G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid), fpPolyhedron(0)
|
||||
{
|
||||
return G4String("G4DisplacedSolid");
|
||||
fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
|
||||
fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Assignment operator
|
||||
|
||||
G4DisplacedSolid& G4DisplacedSolid::operator = (const G4DisplacedSolid& rhs)
|
||||
{
|
||||
// Check assignment to self
|
||||
//
|
||||
if (this == &rhs) { return *this; }
|
||||
|
||||
// Copy base class data
|
||||
//
|
||||
G4VSolid::operator=(rhs);
|
||||
|
||||
// Copy data
|
||||
//
|
||||
fPtrSolid = rhs.fPtrSolid;
|
||||
delete fPtrTransform; delete fDirectTransform;
|
||||
fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
|
||||
fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
|
||||
delete fpPolyhedron; fpPolyhedron= 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void G4DisplacedSolid::CleanTransformations()
|
||||
{
|
||||
if(fPtrTransform)
|
||||
@@ -355,6 +386,24 @@ G4ThreeVector G4DisplacedSolid::GetPointOnSurface() const
|
||||
return fDirectTransform->TransformPoint(p);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return object type name
|
||||
|
||||
G4GeometryType G4DisplacedSolid::GetEntityType() const
|
||||
{
|
||||
return G4String("G4DisplacedSolid");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Make a clone of the object
|
||||
//
|
||||
G4VSolid* G4DisplacedSolid::Clone() const
|
||||
{
|
||||
return new G4DisplacedSolid(*this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Stream object contents to an output stream
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4IntersectionSolid.cc,v 1.30 2006/11/08 09:37:41 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4IntersectionSolid.cc,v 1.34 2010/10/20 07:31:39 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
@@ -49,6 +49,7 @@
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "HepPolyhedronProcessor.h"
|
||||
#include "G4NURBS.hh"
|
||||
// #include "G4NURBSbox.hh"
|
||||
|
||||
@@ -107,6 +108,33 @@ G4IntersectionSolid::~G4IntersectionSolid()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copy constructor
|
||||
|
||||
G4IntersectionSolid::G4IntersectionSolid(const G4IntersectionSolid& rhs)
|
||||
: G4BooleanSolid (rhs)
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Assignment operator
|
||||
|
||||
G4IntersectionSolid&
|
||||
G4IntersectionSolid::operator = (const G4IntersectionSolid& rhs)
|
||||
{
|
||||
// Check assignment to self
|
||||
//
|
||||
if (this == &rhs) { return *this; }
|
||||
|
||||
// Copy base class data
|
||||
//
|
||||
G4BooleanSolid::operator=(rhs);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
@@ -484,6 +512,15 @@ G4GeometryType G4IntersectionSolid::GetEntityType() const
|
||||
return G4String("G4IntersectionSolid");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Make a clone of the object
|
||||
|
||||
G4VSolid* G4IntersectionSolid::Clone() const
|
||||
{
|
||||
return new G4IntersectionSolid(*this);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
@@ -501,23 +538,13 @@ G4IntersectionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
G4Polyhedron*
|
||||
G4IntersectionSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* pA = fPtrSolidA->GetPolyhedron();
|
||||
G4Polyhedron* pB = fPtrSolidB->GetPolyhedron();
|
||||
if (pA && pB)
|
||||
{
|
||||
G4Polyhedron* resultant = new G4Polyhedron (pA->intersect(*pB));
|
||||
return resultant;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Solid - " << GetName()
|
||||
<< " - one of the Boolean components has no" << G4endl
|
||||
<< " corresponding polyhedron. Returning NULL !";
|
||||
G4Exception("G4IntersectionSolid::CreatePolyhedron()", "InvalidSetup",
|
||||
JustWarning, oss.str().c_str());
|
||||
return 0;
|
||||
}
|
||||
HepPolyhedronProcessor processor;
|
||||
// Stack components and components of components recursively
|
||||
// See G4BooleanSolid::StackPolyhedron
|
||||
G4Polyhedron* top = StackPolyhedron(processor, this);
|
||||
G4Polyhedron* result = new G4Polyhedron(*top);
|
||||
if (processor.execute(*result)) { return result; }
|
||||
else { return 0; }
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4SubtractionSolid.cc,v 1.31 2007/10/23 14:42:31 grichine Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4SubtractionSolid.cc,v 1.35 2010/10/20 07:31:39 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "HepPolyhedronProcessor.h"
|
||||
#include "G4NURBS.hh"
|
||||
// #include "G4NURBSbox.hh"
|
||||
|
||||
@@ -107,6 +108,33 @@ G4SubtractionSolid::~G4SubtractionSolid()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copy constructor
|
||||
|
||||
G4SubtractionSolid::G4SubtractionSolid(const G4SubtractionSolid& rhs)
|
||||
: G4BooleanSolid (rhs)
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Assignment operator
|
||||
|
||||
G4SubtractionSolid&
|
||||
G4SubtractionSolid::operator = (const G4SubtractionSolid& rhs)
|
||||
{
|
||||
// Check assignment to self
|
||||
//
|
||||
if (this == &rhs) { return *this; }
|
||||
|
||||
// Copy base class data
|
||||
//
|
||||
G4BooleanSolid::operator=(rhs);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CalculateExtent
|
||||
@@ -434,6 +462,15 @@ G4GeometryType G4SubtractionSolid::GetEntityType() const
|
||||
return G4String("G4SubtractionSolid");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Make a clone of the object
|
||||
|
||||
G4VSolid* G4SubtractionSolid::Clone() const
|
||||
{
|
||||
return new G4SubtractionSolid(*this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
@@ -462,23 +499,13 @@ G4SubtractionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
G4Polyhedron*
|
||||
G4SubtractionSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* pA = fPtrSolidA->GetPolyhedron();
|
||||
G4Polyhedron* pB = fPtrSolidB->GetPolyhedron();
|
||||
if (pA && pB)
|
||||
{
|
||||
G4Polyhedron* resultant = new G4Polyhedron (pA->subtract(*pB));
|
||||
return resultant;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "Solid - " << GetName()
|
||||
<< " - one of the Boolean components has no" << G4endl
|
||||
<< " corresponding polyhedron. Returning NULL !";
|
||||
G4Exception("G4SubtractionSolid::CreatePolyhedron()", "InvalidSetup",
|
||||
JustWarning, oss.str().c_str());
|
||||
return 0;
|
||||
}
|
||||
HepPolyhedronProcessor processor;
|
||||
// Stack components and components of components recursively
|
||||
// See G4BooleanSolid::StackPolyhedron
|
||||
G4Polyhedron* top = StackPolyhedron(processor, this);
|
||||
G4Polyhedron* result = new G4Polyhedron(*top);
|
||||
if (processor.execute(*result)) { return result; }
|
||||
else { return 0; }
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4UnionSolid.cc,v 1.35 2007/10/23 14:42:31 grichine Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4UnionSolid.cc,v 1.40 2010/10/20 07:31:39 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-04 $
|
||||
//
|
||||
// Implementation of methods for the class G4IntersectionSolid
|
||||
//
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "HepPolyhedronProcessor.h"
|
||||
#include "G4NURBS.hh"
|
||||
// #include "G4NURBSbox.hh"
|
||||
|
||||
@@ -107,6 +108,32 @@ G4UnionSolid::~G4UnionSolid()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copy constructor
|
||||
|
||||
G4UnionSolid::G4UnionSolid(const G4UnionSolid& rhs)
|
||||
: G4BooleanSolid (rhs)
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Assignment operator
|
||||
|
||||
G4UnionSolid& G4UnionSolid::operator = (const G4UnionSolid& rhs)
|
||||
{
|
||||
// Check assignment to self
|
||||
//
|
||||
if (this == &rhs) { return *this; }
|
||||
|
||||
// Copy base class data
|
||||
//
|
||||
G4BooleanSolid::operator=(rhs);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
@@ -146,11 +173,11 @@ G4UnionSolid::CalculateExtent( const EAxis pAxis,
|
||||
EInside G4UnionSolid::Inside( const G4ThreeVector& p ) const
|
||||
{
|
||||
EInside positionA = fPtrSolidA->Inside(p);
|
||||
if (positionA == kInside) return kInside;
|
||||
if (positionA == kInside) { return kInside; }
|
||||
|
||||
EInside positionB = fPtrSolidB->Inside(p);
|
||||
|
||||
if( positionA == kInside || positionB == kInside ||
|
||||
if( positionB == kInside ||
|
||||
( positionA == kSurface && positionB == kSurface &&
|
||||
( fPtrSolidA->SurfaceNormal(p) +
|
||||
fPtrSolidB->SurfaceNormal(p) ).mag2() <
|
||||
@@ -160,10 +187,10 @@ EInside G4UnionSolid::Inside( const G4ThreeVector& p ) const
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( positionA != kInside && positionB == kSurface ) ||
|
||||
( positionB != kInside && positionA == kSurface ) ||
|
||||
( positionA == kSurface && positionB == kSurface ) ) return kSurface;
|
||||
else return kOutside;
|
||||
if( ( positionB == kSurface ) || ( positionA == kSurface ) )
|
||||
{ return kSurface; }
|
||||
else
|
||||
{ return kOutside; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,6 +452,15 @@ G4GeometryType G4UnionSolid::GetEntityType() const
|
||||
return G4String("G4UnionSolid");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Make a clone of the object
|
||||
|
||||
G4VSolid* G4UnionSolid::Clone() const
|
||||
{
|
||||
return new G4UnionSolid(*this);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
@@ -453,19 +489,13 @@ G4UnionSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
G4Polyhedron*
|
||||
G4UnionSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* pA = fPtrSolidA->GetPolyhedron();
|
||||
G4Polyhedron* pB = fPtrSolidB->GetPolyhedron();
|
||||
if (pA && pB) {
|
||||
G4Polyhedron* resultant = new G4Polyhedron (pA->add(*pB));
|
||||
return resultant;
|
||||
} else {
|
||||
std::ostringstream oss;
|
||||
oss << GetName() <<
|
||||
": one of the Boolean components has no corresponding polyhedron.";
|
||||
G4Exception("G4UnionSolid::CreatePolyhedron",
|
||||
"", JustWarning, oss.str().c_str());
|
||||
return 0;
|
||||
}
|
||||
HepPolyhedronProcessor processor;
|
||||
// Stack components and components of components recursively
|
||||
// See G4BooleanSolid::StackPolyhedron
|
||||
G4Polyhedron* top = StackPolyhedron(processor, this);
|
||||
G4Polyhedron* result = new G4Polyhedron(*top);
|
||||
if (processor.execute(*result)) { return result; }
|
||||
else { return 0; }
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user