Import Geant4 10.1.0 source tree
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4BooleanSolid.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
// $Id: G4BooleanSolid.cc 83572 2014-09-01 15:23:27Z gcosmo $
|
||||
//
|
||||
// Implementation for the abstract base class for solids created by boolean
|
||||
// operations between other solids
|
||||
@@ -41,6 +41,13 @@
|
||||
#include "HepPolyhedronProcessor.h"
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
namespace
|
||||
{
|
||||
G4Mutex polyhedronMutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constructor
|
||||
@@ -50,7 +57,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidB ) :
|
||||
G4VSolid(pName), fAreaRatio(0.), fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
|
||||
fpPolyhedron(0), createdDisplacedSolid(false)
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(false)
|
||||
{
|
||||
fPtrSolidA = pSolidA ;
|
||||
fPtrSolidB = pSolidB ;
|
||||
@@ -67,7 +74,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
const G4ThreeVector& transVector ) :
|
||||
G4VSolid(pName), fAreaRatio(0.), fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
|
||||
fpPolyhedron(0), createdDisplacedSolid(true)
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(true)
|
||||
{
|
||||
fPtrSolidA = pSolidA ;
|
||||
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,rotMatrix,transVector) ;
|
||||
@@ -83,7 +90,7 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
|
||||
const G4Transform3D& transform ) :
|
||||
G4VSolid(pName), fAreaRatio(0.), fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
|
||||
fpPolyhedron(0), createdDisplacedSolid(true)
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(true)
|
||||
{
|
||||
fPtrSolidA = pSolidA ;
|
||||
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,transform) ;
|
||||
@@ -98,7 +105,7 @@ G4BooleanSolid::G4BooleanSolid( __void__& a )
|
||||
: G4VSolid(a), fPtrSolidA(0), fPtrSolidB(0), fAreaRatio(0.),
|
||||
fStatistics(1000000), fCubVolEpsilon(0.001),
|
||||
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
|
||||
fpPolyhedron(0), createdDisplacedSolid(false)
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -112,7 +119,7 @@ G4BooleanSolid::~G4BooleanSolid()
|
||||
{
|
||||
((G4DisplacedSolid*)fPtrSolidB)->CleanTransformations();
|
||||
}
|
||||
delete fpPolyhedron;
|
||||
delete fpPolyhedron; fpPolyhedron = 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -124,7 +131,7 @@ G4BooleanSolid::G4BooleanSolid(const G4BooleanSolid& rhs)
|
||||
fAreaRatio(rhs.fAreaRatio),
|
||||
fStatistics(rhs.fStatistics), fCubVolEpsilon(rhs.fCubVolEpsilon),
|
||||
fAreaAccuracy(rhs.fAreaAccuracy), fCubicVolume(rhs.fCubicVolume),
|
||||
fSurfaceArea(rhs.fSurfaceArea), fpPolyhedron(0),
|
||||
fSurfaceArea(rhs.fSurfaceArea), fRebuildPolyhedron(false), fpPolyhedron(0),
|
||||
createdDisplacedSolid(rhs.createdDisplacedSolid)
|
||||
{
|
||||
}
|
||||
@@ -151,6 +158,8 @@ G4BooleanSolid& G4BooleanSolid::operator = (const G4BooleanSolid& rhs)
|
||||
fAreaAccuracy= rhs.fAreaAccuracy; fCubicVolume= rhs.fCubicVolume;
|
||||
fSurfaceArea= rhs.fSurfaceArea; fpPolyhedron= 0;
|
||||
createdDisplacedSolid= rhs.createdDisplacedSolid;
|
||||
fRebuildPolyhedron = false;
|
||||
delete fpPolyhedron; fpPolyhedron = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -258,11 +267,15 @@ G4ThreeVector G4BooleanSolid::GetPointOnSurface() const
|
||||
G4Polyhedron* G4BooleanSolid::GetPolyhedron () const
|
||||
{
|
||||
if (!fpPolyhedron ||
|
||||
fRebuildPolyhedron ||
|
||||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps())
|
||||
{
|
||||
G4AutoLock l(&polyhedronMutex);
|
||||
delete fpPolyhedron;
|
||||
fpPolyhedron = CreatePolyhedron();
|
||||
fRebuildPolyhedron = false;
|
||||
l.unlock();
|
||||
}
|
||||
return fpPolyhedron;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4DisplacedSolid.cc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
// $Id: G4DisplacedSolid.cc 84211 2014-10-10 14:47:30Z gcosmo $
|
||||
//
|
||||
// Implementation for G4DisplacedSolid class for boolean
|
||||
// operations between other solids
|
||||
@@ -55,7 +55,7 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector )
|
||||
: G4VSolid(pName), fpPolyhedron(0)
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fPtrTransform = new G4AffineTransform(rotMatrix,transVector) ;
|
||||
@@ -70,7 +70,7 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4Transform3D& transform )
|
||||
: G4VSolid(pName), fpPolyhedron(0)
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fDirectTransform = new G4AffineTransform(transform.getRotation().inverse(),
|
||||
@@ -89,7 +89,7 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4AffineTransform directTransform )
|
||||
: G4VSolid(pName), fpPolyhedron(0)
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
{
|
||||
fPtrSolid = pSolid ;
|
||||
fDirectTransform = new G4AffineTransform( directTransform );
|
||||
@@ -103,7 +103,7 @@ G4DisplacedSolid::G4DisplacedSolid( const G4String& pName,
|
||||
|
||||
G4DisplacedSolid::G4DisplacedSolid( __void__& a )
|
||||
: G4VSolid(a), fPtrSolid(0), fPtrTransform(0),
|
||||
fDirectTransform(0), fpPolyhedron(0)
|
||||
fDirectTransform(0), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ G4DisplacedSolid::G4DisplacedSolid( __void__& a )
|
||||
G4DisplacedSolid::~G4DisplacedSolid()
|
||||
{
|
||||
CleanTransformations();
|
||||
delete fpPolyhedron;
|
||||
delete fpPolyhedron; fpPolyhedron = 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -122,7 +122,8 @@ G4DisplacedSolid::~G4DisplacedSolid()
|
||||
// Copy constructor
|
||||
|
||||
G4DisplacedSolid::G4DisplacedSolid(const G4DisplacedSolid& rhs)
|
||||
: G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid), fpPolyhedron(0)
|
||||
: G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
{
|
||||
fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
|
||||
fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
|
||||
@@ -148,6 +149,7 @@ G4DisplacedSolid& G4DisplacedSolid::operator = (const G4DisplacedSolid& rhs)
|
||||
delete fPtrTransform; delete fDirectTransform;
|
||||
fPtrTransform = new G4AffineTransform(*(rhs.fPtrTransform));
|
||||
fDirectTransform = new G4AffineTransform(*(rhs.fDirectTransform));
|
||||
fRebuildPolyhedron = false;
|
||||
delete fpPolyhedron; fpPolyhedron= 0;
|
||||
|
||||
return *this;
|
||||
@@ -188,7 +190,7 @@ G4AffineTransform G4DisplacedSolid::GetTransform() const
|
||||
void G4DisplacedSolid::SetTransform(G4AffineTransform& transform)
|
||||
{
|
||||
fPtrTransform = &transform ;
|
||||
fpPolyhedron = 0;
|
||||
fRebuildPolyhedron = true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -202,7 +204,7 @@ G4AffineTransform G4DisplacedSolid::GetDirectTransform() const
|
||||
void G4DisplacedSolid::SetDirectTransform(G4AffineTransform& transform)
|
||||
{
|
||||
fDirectTransform = &transform ;
|
||||
fpPolyhedron = 0;
|
||||
fRebuildPolyhedron = true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -216,7 +218,7 @@ G4RotationMatrix G4DisplacedSolid::GetFrameRotation() const
|
||||
void G4DisplacedSolid::SetFrameRotation(const G4RotationMatrix& matrix)
|
||||
{
|
||||
fDirectTransform->SetNetRotation(matrix);
|
||||
fpPolyhedron = 0;
|
||||
fRebuildPolyhedron = true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -229,7 +231,7 @@ G4ThreeVector G4DisplacedSolid::GetFrameTranslation() const
|
||||
void G4DisplacedSolid::SetFrameTranslation(const G4ThreeVector& vector)
|
||||
{
|
||||
fPtrTransform->SetNetTranslation(vector);
|
||||
fpPolyhedron = 0;
|
||||
fRebuildPolyhedron = true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -243,7 +245,7 @@ G4RotationMatrix G4DisplacedSolid::GetObjectRotation() const
|
||||
void G4DisplacedSolid::SetObjectRotation(const G4RotationMatrix& matrix)
|
||||
{
|
||||
fPtrTransform->SetNetRotation(matrix);
|
||||
fpPolyhedron = 0;
|
||||
fRebuildPolyhedron = true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
@@ -256,7 +258,7 @@ G4ThreeVector G4DisplacedSolid::GetObjectTranslation() const
|
||||
void G4DisplacedSolid::SetObjectTranslation(const G4ThreeVector& vector)
|
||||
{
|
||||
fDirectTransform->SetNetTranslation(vector);
|
||||
fpPolyhedron = 0;
|
||||
fRebuildPolyhedron = true;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -457,11 +459,12 @@ G4DisplacedSolid::CreatePolyhedron () const
|
||||
G4Polyhedron* G4DisplacedSolid::GetPolyhedron () const
|
||||
{
|
||||
if (!fpPolyhedron ||
|
||||
fRebuildPolyhedron ||
|
||||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps())
|
||||
{
|
||||
delete fpPolyhedron;
|
||||
fpPolyhedron = CreatePolyhedron();
|
||||
fRebuildPolyhedron = false;
|
||||
}
|
||||
return fpPolyhedron;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id:$
|
||||
//
|
||||
//
|
||||
// Implementation of G4UMultiUnion wrapper class
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UMultiUnion.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4DisplacedSolid.hh"
|
||||
#include "G4RotationMatrix.hh"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constructor (generic parameters)
|
||||
//
|
||||
G4UMultiUnion::G4UMultiUnion(const G4String& name)
|
||||
: G4USolid(name, new UMultiUnion(name))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4UMultiUnion::G4UMultiUnion(__void__& a)
|
||||
: G4USolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
G4UMultiUnion::~G4UMultiUnion()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copy constructor
|
||||
//
|
||||
G4UMultiUnion::G4UMultiUnion(const G4UMultiUnion &source)
|
||||
: G4USolid(source)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Assignment operator
|
||||
//
|
||||
G4UMultiUnion& G4UMultiUnion::operator=(const G4UMultiUnion &source)
|
||||
{
|
||||
if (this == &source) return *this;
|
||||
|
||||
G4USolid::operator=( source );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CreatePolyhedron
|
||||
//
|
||||
G4Polyhedron* G4UMultiUnion::CreatePolyhedron() const
|
||||
{
|
||||
|
||||
HepPolyhedronProcessor processor;
|
||||
HepPolyhedronProcessor::Operation operation = HepPolyhedronProcessor::UNION;
|
||||
|
||||
G4VSolid* solidA = GetSolid(0);
|
||||
const G4Transform3D* transform0=GetTransformation(0);
|
||||
G4RotationMatrix rot0=(*transform0).getRotation();
|
||||
const G4ThreeVector transl0 = (*transform0).getTranslation();
|
||||
G4DisplacedSolid dispSolidA("placedA",solidA,&rot0,transl0);
|
||||
delete transform0;
|
||||
|
||||
G4Polyhedron* top = new G4Polyhedron(*dispSolidA.GetPolyhedron());
|
||||
|
||||
for(G4int i=1; i<GetNumberOfSolids(); ++i)
|
||||
{
|
||||
G4VSolid* solidB = GetSolid(i);
|
||||
const G4Transform3D* transform=GetTransformation(i);
|
||||
G4RotationMatrix rot=(*transform).getRotation();
|
||||
const G4ThreeVector transl = (*transform).getTranslation();
|
||||
G4DisplacedSolid dispSolidB("placedB",solidB,&rot,transl);
|
||||
G4Polyhedron* operand = dispSolidB.GetPolyhedron();
|
||||
processor.push_back (operation, *operand);
|
||||
delete transform;
|
||||
}
|
||||
|
||||
if (processor.execute(*top)) { return top; }
|
||||
else { return 0; }
|
||||
}
|
||||
Reference in New Issue
Block a user