Import Geant4 10.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 12:08:39 +02:00
parent 286caacf06
commit c9b32a6c0a
5770 changed files with 1050949 additions and 367105 deletions
+1 -2
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile 76263 2013-11-08 11:41:52Z gcosmo $
# $Id: GNUmakefile 85530 2014-10-30 16:17:43Z gcosmo $
# ----------------------------------------------------------------
# GNUmakefile for geometry/CSG library. Gabriele Cosmo, 16/11/96.
# ----------------------------------------------------------------
@@ -18,7 +18,6 @@ CPPFLAGS += -I$(G4BASE)/intercoms/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/geometry/solids/usolids/include \
-I$(G4BASE)/geometry/management/include
ifdef G4BOOLDEBUG
+43 -1
View File
@@ -1,5 +1,5 @@
$Id: History 76607 2013-11-13 08:46:40Z gcosmo $
$Id: History 86201 2014-11-07 15:22:50Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -20,6 +20,48 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
November 7, 2014 G.Cosmo geom-bool-V10-00-09
- Fixed Coverity defects in G4UMultiUnion::CreatePolyhedron() for
memory leaks.
October 3, 2014 G.Cosmo geom-bool-V10-00-08
- Avoid polyhedron deletion (and therefore mutexing) in CreatePolyhedron
for G4DisplacedSolid, as not necessary.
September 25, 2014 T.Nikitina geom-bool-V10-00-07
- Additional correction to G4UMultiUnion::CreatePolyhedron(), to take into
account possible displacement of first component in the structure and have
it visualised correctly.
September 18, 2014 T.Nikitina geom-bool-V10-00-06
- Corrected implementation of CreatePolyhedron() in G4UMultiUnion wrapper.
September 1, 2014 G.Cosmo geom-bool-V10-00-05
- Fixed use of polyhedron pointer, to avoid race condition in MT
when parameterised volumes are visualised.
Jul 18, 2014 G.Cosmo geom-bool-V10-00-04
- G4UMultiUnion: correction in destructor to avoid deletion of polyhedron,
as not owned by the structure.
Corrected initialisation of base class name to adopt string provided as
input parameter instead of hard-coded name.
Adapted implementation of GetTransformation() to API correction in
UMultiUnion. Requires co-working tag "geom-usolids-V10-00-12" with
'usolids' module.
Jul 04, 2014 G.Cosmo geom-bool-V10-00-03
- Avoid leak in G4UMultiUnion::AddNode() for transformations being passed,
now that UMultiUnion is locally caching them.
Jul 01, 2014 G.Cosmo geom-bool-V10-00-02
- Fixed assignment operator signature in G4UMultiUnion wrapper.
Jun 20, 2014 G.Cosmo geom-bool-V10-00-01
- Correction to G4MultiUnion::AddNode() for treatment of transformations.
May 23, 2014 G.Cosmo geom-bool-V10-00-00
- Enabled G4MultiUnion wrapper.
November 13, 2013 G.Cosmo geom-bool-V09-06-05, 04
- Removed G4MultiUnion and related wrapper, as not yet ready for release.
Returning to tag "geom-bool-V09-06-02".
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.hh 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4BooleanSolid.hh 83572 2014-09-01 15:23:27Z gcosmo $
//
//
// class G4BooleanSolid
@@ -132,6 +132,7 @@ class G4BooleanSolid : public G4VSolid
G4double fCubicVolume;
G4double fSurfaceArea;
mutable G4bool fRebuildPolyhedron;
mutable G4Polyhedron* fpPolyhedron;
G4bool createdDisplacedSolid;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4DisplacedSolid.hh 66356 2012-12-18 09:02:32Z gcosmo $
// $Id: G4DisplacedSolid.hh 83572 2014-09-01 15:23:27Z gcosmo $
//
//
// class G4DisplacedSolid
@@ -161,6 +161,7 @@ class G4DisplacedSolid : public G4VSolid
G4VSolid* fPtrSolid ;
G4AffineTransform* fPtrTransform ;
G4AffineTransform* fDirectTransform ;
mutable G4bool fRebuildPolyhedron;
mutable G4Polyhedron* fpPolyhedron;
} ;
@@ -0,0 +1,49 @@
//
// ********************************************************************
// * 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:$
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4MultiUnion
//
// Class description:
//
// Typedef for UMultiUnion from USolids module.
// History:
// 13.11.13 G.Cosmo, CERN/PH
// --------------------------------------------------------------------
#ifndef G4MULTIUNION_HH
#define G4MULTIUNION_HH
#include "G4UMultiUnion.hh"
typedef G4UMultiUnion G4MultiUnion;
#endif
@@ -0,0 +1,139 @@
//
// ********************************************************************
// * 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:$
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4UMultiUnion
//
// Class description:
//
// Wrapper class for G4UMultiUnion to make use of it from USolids module.
// History:
// 30.10.13 G.Cosmo, T.Nikitina, CERN/PH
// --------------------------------------------------------------------
#ifndef G4UMULTIUNION_HH
#define G4UMULTIUNION_HH
#include <CLHEP/Vector/Rotation.h>
#include "G4USolid.hh"
#include "UMultiUnion.hh"
#include "G4Transform3D.hh"
#include "G4RotationMatrix.hh"
#include "HepPolyhedronProcessor.h"
class G4UMultiUnion : public G4USolid
{
public: // with description
G4UMultiUnion(const G4String& name);
~G4UMultiUnion();
inline UMultiUnion* GetShape() const;
inline void AddNode(G4VSolid& solid, G4Transform3D& trans);
// Build the multiple union by adding nodes
inline G4Transform3D* GetTransformation(G4int index) const;
inline G4VSolid* GetSolid(G4int index) const;
inline int GetNumberOfSolids()const;
inline void Voxelize();
public: // without description
G4UMultiUnion(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4UMultiUnion( const G4UMultiUnion& source );
G4UMultiUnion& operator=(const G4UMultiUnion& source);
// Copy constructor and assignment operator.
G4Polyhedron* CreatePolyhedron() const;
// Called by visualization engine
};
// --------------------------------------------------------------------
// Inline methods
// --------------------------------------------------------------------
inline UMultiUnion* G4UMultiUnion::GetShape() const
{
return (UMultiUnion*) fShape;
}
inline void G4UMultiUnion::AddNode(G4VSolid& solid, G4Transform3D& trans)
{
HepGeom::Rotate3D rot;
HepGeom::Translate3D transl ;
HepGeom::Scale3D scale;
trans.getDecomposition(scale,rot,transl);
G4ThreeVector pos = transl.getTranslation();
UTransform3D tr;
tr.fRot[0] = rot.xx(); tr.fRot[1] = rot.xy(); tr.fRot[2] = rot.xz();
tr.fRot[3] = rot.yx(); tr.fRot[4] = rot.yy(); tr.fRot[5] = rot.yz();
tr.fRot[6] = rot.zx(); tr.fRot[7] = rot.zy(); tr.fRot[8] = rot.zz();
tr.fTr = UVector3(pos.x(), pos.y(), pos.z());
GetShape()->AddNode(*(static_cast<G4USolid&>(solid).GetSolid()), tr);
}
inline G4Transform3D* G4UMultiUnion::GetTransformation(G4int index) const
{
UTransform3D tr = GetShape()->GetTransformation(index);
G4RotationMatrix
rot(CLHEP::HepRep3x3(tr.fRot[0], tr.fRot[1], tr.fRot[2],
tr.fRot[3], tr.fRot[4], tr.fRot[5],
tr.fRot[6], tr.fRot[7], tr.fRot[8]));
G4ThreeVector transl(tr.fTr.x, tr.fTr.y, tr.fTr.z);
return new G4Transform3D(rot, transl);
}
inline G4VSolid* G4UMultiUnion::GetSolid(G4int index) const
{
VUSolid* solid = GetShape()->GetSolid(index);
return new G4USolid(solid->GetName(), solid);
}
inline int G4UMultiUnion::GetNumberOfSolids()const
{
return GetShape()->GetNumberOfSolids();
}
inline void G4UMultiUnion::Voxelize()
{
GetShape()->Voxelize();
}
#endif
+7 -3
View File
@@ -1,7 +1,7 @@
#------------------------------------------------------------------------------
# sources.cmake
# Module : G4geomBoolean
# Package: Geant4.src.G4geometry..G4geomBoolean
# Package: Geant4.src.G4geometry.G4geomBoolean
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
@@ -11,17 +11,17 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 76607 2013-11-13 08:46:40Z gcosmo $
# $Id: sources.cmake 85608 2014-10-31 11:23:30Z gcosmo $
#
#------------------------------------------------------------------------------
# List external includes needed.
include_directories(${CLHEP_INCLUDE_DIRS})
include_directories(${USOLIDS_INCLUDE_DIRS})
# List internal includes needed.
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/volumes/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/solids/usolids/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
@@ -38,13 +38,16 @@ GEANT4_DEFINE_MODULE(NAME G4geomBoolean
G4BooleanSolid.icc
G4DisplacedSolid.hh
G4IntersectionSolid.hh
G4MultiUnion.hh
G4SubtractionSolid.hh
G4UMultiUnion.hh
G4UnionSolid.hh
SOURCES
G4BooleanSolid.cc
G4DisplacedSolid.cc
G4IntersectionSolid.cc
G4SubtractionSolid.cc
G4UMultiUnion.cc
G4UnionSolid.cc
GRANULAR_DEPENDENCIES
G4geometrymng
@@ -58,6 +61,7 @@ GEANT4_DEFINE_MODULE(NAME G4geomBoolean
G4graphics_reps
G4intercoms
LINK_LIBRARIES
${USOLIDS_LIBRARIES}
)
# List any source specific properties here
@@ -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; }
}