Import Geant4 10.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2016-06-30 14:12:05 +02:00
parent a654a7ab1f
commit 4ec577e5c4
2021 changed files with 100995 additions and 78277 deletions
@@ -24,19 +24,25 @@
// ********************************************************************
//
//
// $Id: G4BooleanSolid.cc 92010 2015-08-13 10:07:52Z gcosmo $
// $Id: G4BooleanSolid.cc 97300 2016-06-01 09:27:19Z gcosmo $
//
// Implementation for the abstract base class for solids created by boolean
// operations between other solids
//
// History:
//
// 10.09.98 V.Grichine, created
// 2016.03.16 E.Tcherniaev - added GetListOfPrimitives(),
// reimplemented GetPointOnSurface()
//
// 1998.09.10 V.Grichine - created
//
// --------------------------------------------------------------------
#include "G4BooleanSolid.hh"
#include "G4VSolid.hh"
#include "G4DisplacedSolid.hh"
#include "G4ReflectedSolid.hh"
#include "G4ScaledSolid.hh"
#include "G4Polyhedron.hh"
#include "HepPolyhedronProcessor.h"
#include "Randomize.hh"
@@ -55,9 +61,10 @@ namespace
G4BooleanSolid::G4BooleanSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ) :
G4VSolid(pName), fAreaRatio(0.), fStatistics(1000000), fCubVolEpsilon(0.001),
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(false)
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
createdDisplacedSolid(false)
{
fPtrSolidA = pSolidA ;
fPtrSolidB = pSolidB ;
@@ -72,9 +79,10 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
G4VSolid* pSolidB ,
G4RotationMatrix* rotMatrix,
const G4ThreeVector& transVector ) :
G4VSolid(pName), fAreaRatio(0.), fStatistics(1000000), fCubVolEpsilon(0.001),
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(true)
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
createdDisplacedSolid(true)
{
fPtrSolidA = pSolidA ;
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,rotMatrix,transVector) ;
@@ -88,9 +96,10 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
G4VSolid* pSolidA ,
G4VSolid* pSolidB ,
const G4Transform3D& transform ) :
G4VSolid(pName), fAreaRatio(0.), fStatistics(1000000), fCubVolEpsilon(0.001),
G4VSolid(pName), fStatistics(1000000), fCubVolEpsilon(0.001),
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(true)
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
createdDisplacedSolid(true)
{
fPtrSolidA = pSolidA ;
fPtrSolidB = new G4DisplacedSolid("placedB",pSolidB,transform) ;
@@ -102,10 +111,11 @@ G4BooleanSolid::G4BooleanSolid( const G4String& pName,
// for usage restricted to object persistency.
G4BooleanSolid::G4BooleanSolid( __void__& a )
: G4VSolid(a), fPtrSolidA(0), fPtrSolidB(0), fAreaRatio(0.),
: G4VSolid(a), fPtrSolidA(0), fPtrSolidB(0),
fStatistics(1000000), fCubVolEpsilon(0.001),
fAreaAccuracy(-1.), fCubicVolume(0.), fSurfaceArea(0.),
fRebuildPolyhedron(false), fpPolyhedron(0), createdDisplacedSolid(false)
fRebuildPolyhedron(false), fpPolyhedron(0), fPrimitivesSurfaceArea(0.),
createdDisplacedSolid(false)
{
}
@@ -128,12 +138,12 @@ G4BooleanSolid::~G4BooleanSolid()
G4BooleanSolid::G4BooleanSolid(const G4BooleanSolid& rhs)
: G4VSolid (rhs), fPtrSolidA(rhs.fPtrSolidA), fPtrSolidB(rhs.fPtrSolidB),
fAreaRatio(rhs.fAreaRatio),
fStatistics(rhs.fStatistics), fCubVolEpsilon(rhs.fCubVolEpsilon),
fAreaAccuracy(rhs.fAreaAccuracy), fCubicVolume(rhs.fCubicVolume),
fSurfaceArea(rhs.fSurfaceArea), fRebuildPolyhedron(false), fpPolyhedron(0),
createdDisplacedSolid(rhs.createdDisplacedSolid)
{
fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
}
///////////////////////////////////////////////////////////////
@@ -153,21 +163,21 @@ G4BooleanSolid& G4BooleanSolid::operator = (const G4BooleanSolid& rhs)
// Copy data
//
fPtrSolidA= rhs.fPtrSolidA; fPtrSolidB= rhs.fPtrSolidB;
fAreaRatio= rhs.fAreaRatio;
fStatistics= rhs.fStatistics; fCubVolEpsilon= rhs.fCubVolEpsilon;
fAreaAccuracy= rhs.fAreaAccuracy; fCubicVolume= rhs.fCubicVolume;
fSurfaceArea= rhs.fSurfaceArea; fpPolyhedron= 0;
fSurfaceArea= rhs.fSurfaceArea;
createdDisplacedSolid= rhs.createdDisplacedSolid;
fRebuildPolyhedron = false;
delete fpPolyhedron; fpPolyhedron = 0;
fPrimitives.resize(0); fPrimitivesSurfaceArea = 0.;
return *this;
}
///////////////////////////////////////////////////////////////
//
// If Solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If the solid is not a "Boolean", return 0
const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
@@ -189,8 +199,8 @@ const G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no) const
///////////////////////////////////////////////////////////////
//
// If Solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If solid is made up from a Boolean operation of two solids,
// return the corresponding solid (for no=0 and 1)
// If the solid is not a "Boolean", return 0
G4VSolid* G4BooleanSolid::GetConstituentSolid(G4int no)
@@ -240,23 +250,114 @@ std::ostream& G4BooleanSolid::StreamInfo(std::ostream& os) const
//////////////////////////////////////////////////////////////////////////
//
// Returns a point (G4ThreeVector) randomly and uniformly selected
// on the solid surface
// Creates list of constituent primitives of and their placements
void G4BooleanSolid::GetListOfPrimitives(
std::vector<std::pair<G4VSolid *,G4Transform3D>>& primitives,
const G4Transform3D& curPlacement) const
{
G4Transform3D transform;
G4VSolid* solid;
G4String type;
// Repeat two times, first time for fPtrSolidA and then for fPtrSolidB
//
for (G4int i=0; i<2; i++)
{
transform = curPlacement;
solid = (i == 0) ? fPtrSolidA : fPtrSolidB;
type = solid->GetEntityType();
// While current solid is a trasformed solid just modify transform
//
while (type == "G4DisplacedSolid" ||
type == "G4ReflectedSolid" ||
type == "G4ScaledSolid")
{
if (type == "G4DisplacedSolid")
{
transform = transform * G4Transform3D(
((G4DisplacedSolid*)solid)->GetObjectRotation(),
((G4DisplacedSolid*)solid)->GetObjectTranslation());
solid = ((G4DisplacedSolid*)solid)->GetConstituentMovedSolid();
}
else if (type == "G4ReflectedSolid")
{
transform= transform*((G4ReflectedSolid*)solid)->GetDirectTransform3D();
solid = ((G4ReflectedSolid*)solid)->GetConstituentMovedSolid();
}
else if (type == "G4ScaledSolid")
{
transform = transform * ((G4ScaledSolid*)solid)->GetScaleTransform();
solid = ((G4ScaledSolid*)solid)->GetUnscaledSolid();
}
type = solid->GetEntityType();
}
// If current solid is a Boolean solid then continue recursion,
// otherwise add it to the list of primitives
//
if (type == "G4UnionSolid" ||
type == "G4SubtractionSolid" ||
type == "G4IntersectionSolid" ||
type == "G4BooleanSolid")
{
((G4BooleanSolid *)solid)->GetListOfPrimitives(primitives,transform);
}
else
{
primitives.push_back(std::pair<G4VSolid*,G4Transform3D>(solid,transform));
}
}
}
//////////////////////////////////////////////////////////////////////////
//
// Returns a point (G4ThreeVector) randomly and uniformly selected
// on the surface of the solid
G4ThreeVector G4BooleanSolid::GetPointOnSurface() const
{
G4double rand;
G4ThreeVector p;
G4int nprims = fPrimitives.size();
std::pair<G4VSolid *, G4Transform3D> prim;
do // Loop checking, 13.08.2015, G.Cosmo
// Get list of primitives and find the total area of their surfaces
//
if (nprims == 0)
{
rand = G4UniformRand();
if (rand < GetAreaRatio()) { p = fPtrSolidA->GetPointOnSurface(); }
else { p = fPtrSolidB->GetPointOnSurface(); }
} while (Inside(p) != kSurface);
GetListOfPrimitives(fPrimitives, G4Transform3D());
nprims = fPrimitives.size();
fPrimitivesSurfaceArea = 0.;
for (G4int i=0; i<nprims; i++)
{
fPrimitivesSurfaceArea += fPrimitives[i].first->GetSurfaceArea();
}
}
// Select random primitive, get random point on its surface and
// check that the point belongs to the surface of the solid
//
G4ThreeVector p;
for (G4int k=0; k<1000000; k++) // try 1000000 times
{
G4double rand = fPrimitivesSurfaceArea * G4UniformRand();
G4double area = 0.;
for (G4int i=0; i<nprims; i++)
{
prim = fPrimitives[i];
area += prim.first->GetSurfaceArea();
if (rand < area) break;
}
p = prim.first->GetPointOnSurface();
p = prim.second * G4Point3D(p);
if (Inside(p) == kSurface) return p;
}
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!";
G4Exception("G4BooleanSolid::GetPointOnSurface()",
"GeomSolids1001", JustWarning, message);
return p;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4DisplacedSolid.cc 84211 2014-10-10 14:47:30Z gcosmo $
// $Id: G4DisplacedSolid.cc 97300 2016-06-01 09:27:19Z gcosmo $
//
// Implementation for G4DisplacedSolid class for boolean
// operations between other solids
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4IntersectionSolid.cc 92010 2015-08-13 10:07:52Z gcosmo $
// $Id: G4IntersectionSolid.cc 95390 2016-02-08 14:46:28Z gcosmo $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -158,10 +158,6 @@ G4IntersectionSolid::CalculateExtent(const EAxis pAxis,
pMin = std::max( minA, minB );
pMax = std::min( maxA, maxB );
out = (pMax > pMin); // true;
#ifdef G4BOOLDEBUG
// G4cout.precision(16);
// G4cout<<"pMin = "<<pMin<<"; pMax = "<<pMax<<G4endl;
#endif
}
else out = false;
@@ -0,0 +1,403 @@
//
// ********************************************************************
// * 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 for G4ScaledSolid class
//
// History:
//
// 27.10.15 G.Cosmo: created, based on implementation also provided in Root
//
// --------------------------------------------------------------------
#include "G4ScaledSolid.hh"
#include "G4BoundingEnvelope.hh"
#include "G4VPVParameterisation.hh"
#include "G4ScaleTransform.hh"
#include "G4VGraphicsScene.hh"
#include "G4Polyhedron.hh"
///////////////////////////////////////////////////////////////////
//
// Constructor
//
G4ScaledSolid::G4ScaledSolid( const G4String& pName,
G4VSolid* pSolid ,
const G4Scale3D& pScale )
: G4VSolid(pName), fPtrSolid(pSolid),
fRebuildPolyhedron(false), fpPolyhedron(0)
{
fScale = new G4ScaleTransform(pScale);
}
///////////////////////////////////////////////////////////////////
//
// Fake default constructor - sets only member data and allocates memory
// for usage restricted to object persistency.
//
G4ScaledSolid::G4ScaledSolid( __void__& a )
: G4VSolid(a), fPtrSolid(0), fScale(0),
fRebuildPolyhedron(false), fpPolyhedron(0)
{
}
///////////////////////////////////////////////////////////////////
//
// Destructor
//
G4ScaledSolid::~G4ScaledSolid()
{
delete fpPolyhedron; fpPolyhedron= 0;
delete fScale; fScale= 0;
}
///////////////////////////////////////////////////////////////
//
// Copy constructor
//
G4ScaledSolid::G4ScaledSolid(const G4ScaledSolid& rhs)
: G4VSolid (rhs), fPtrSolid(rhs.fPtrSolid),
fRebuildPolyhedron(false), fpPolyhedron(0)
{
fScale = new G4ScaleTransform(*(rhs.fScale));
}
///////////////////////////////////////////////////////////////
//
// Assignment operator
//
G4ScaledSolid& G4ScaledSolid::operator = (const G4ScaledSolid& rhs)
{
// Check assignment to self
//
if (this == &rhs) { return *this; }
// Copy base class data
//
G4VSolid::operator=(rhs);
// Copy data
//
fPtrSolid = rhs.fPtrSolid;
delete fScale;
fScale = new G4ScaleTransform(*(rhs.fScale));
fRebuildPolyhedron = false;
delete fpPolyhedron; fpPolyhedron= 0;
return *this;
}
//////////////////////////////////////////////////////////////////////////
//
// Return original solid not scaled
//
G4VSolid* G4ScaledSolid::GetUnscaledSolid() const
{
return fPtrSolid;
}
///////////////////////////////////////////////////////////////
//
// CalculateExtent
//
G4bool
G4ScaledSolid::CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const
{
G4VoxelLimits unLimit;
G4AffineTransform unTransform;
// Find bounding box of unscaled solid
G4double x1,x2,y1,y2,z1,z2;
fPtrSolid->CalculateExtent(kXAxis,unLimit,unTransform,x1,x2);
fPtrSolid->CalculateExtent(kYAxis,unLimit,unTransform,y1,y2);
fPtrSolid->CalculateExtent(kZAxis,unLimit,unTransform,z1,z2);
G4BoundingEnvelope bbox(G4Point3D(x1,y1,z1),
G4Point3D(x2,y2,z2),kCarTolerance);
// Set combined transformation
G4Transform3D transform3D =
G4Transform3D(pTransform.NetRotation().inverse(),
pTransform.NetTranslation())*GetScaleTransform();
// Find extent
return bbox.CalculateExtent(pAxis,pVoxelLimit,transform3D,pMin,pMax);
}
/////////////////////////////////////////////////////
//
// Inside
//
EInside G4ScaledSolid::Inside(const G4ThreeVector& p) const
{
return fPtrSolid->Inside(fScale->Transform(p));
}
//////////////////////////////////////////////////////////////
//
// SurfaceNormal
//
G4ThreeVector
G4ScaledSolid::SurfaceNormal( const G4ThreeVector& p ) const
{
// Transform point to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Compute normal in unscaled frame
G4ThreeVector newNormal = fPtrSolid->SurfaceNormal(newPoint);
G4ThreeVector normal;
// Convert normal to scaled frame
fScale->InverseTransformNormal(newNormal, normal);
return normal/normal.mag();
}
/////////////////////////////////////////////////////////////
//
// The same algorithm as in DistanceToIn(p)
//
G4double
G4ScaledSolid::DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const
{
// Transform point and direction to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Direction is un-normalized after scale transformation
G4ThreeVector newDirection;
fScale->Transform(v, newDirection);
newDirection = newDirection/newDirection.mag();
// Compute distance in unscaled system
G4double dist = fPtrSolid->DistanceToIn(newPoint,newDirection);
// Return converted distance to global
return fScale->InverseTransformDistance(dist, newDirection);
}
////////////////////////////////////////////////////////
//
// Approximate nearest distance from the point p to the solid from outside
//
G4double
G4ScaledSolid::DistanceToIn( const G4ThreeVector& p ) const
{
// Transform point to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Compute unscaled safety, then scale it.
G4double dist = fPtrSolid->DistanceToIn(newPoint);
return fScale->InverseTransformDistance(dist);
}
//////////////////////////////////////////////////////////
//
// The same algorithm as DistanceToOut(p)
//
G4double
G4ScaledSolid::DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
{
// Transform point and direction to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Direction is un-normalized after scale transformation
G4ThreeVector newDirection;
fScale->Transform(v, newDirection);
newDirection = newDirection/newDirection.mag();
// Compute distance in unscaled system
G4ThreeVector solNorm;
G4double dist = fPtrSolid->DistanceToOut(newPoint,newDirection,
calcNorm,validNorm,&solNorm);
if(calcNorm)
{
G4ThreeVector normal;
fScale->TransformNormal(solNorm, normal);
*n = normal/normal.mag();
}
// Return distance converted to global
return fScale->InverseTransformDistance(dist, newDirection);
}
//////////////////////////////////////////////////////////////
//
// Approximate nearest distance from the point p to the solid from inside
//
G4double
G4ScaledSolid::DistanceToOut( const G4ThreeVector& p ) const
{
// Transform point to unscaled shape frame
G4ThreeVector newPoint;
fScale->Transform(p, newPoint);
// Compute unscaled safety, then scale it.
G4double dist = fPtrSolid->DistanceToOut(newPoint);
return fScale->InverseTransformDistance(dist);
}
//////////////////////////////////////////////////////////////
//
// ComputeDimensions
//
void
G4ScaledSolid::ComputeDimensions( G4VPVParameterisation*,
const G4int,
const G4VPhysicalVolume* )
{
DumpInfo();
G4Exception("G4ScaledSolid::ComputeDimensions()",
"GeomSolids0001", FatalException,
"Method not applicable in this context!");
}
//////////////////////////////////////////////////////////////////////////
//
// Returns a point (G4ThreeVector) randomly and uniformly selected
// on the solid surface
//
G4ThreeVector G4ScaledSolid::GetPointOnSurface() const
{
return fScale->InverseTransform(fPtrSolid->GetPointOnSurface());
}
//////////////////////////////////////////////////////////////////////////
//
// Return object type name
//
G4GeometryType G4ScaledSolid::GetEntityType() const
{
return G4String("G4ScaledSolid");
}
//////////////////////////////////////////////////////////////////////////
//
// Make a clone of the object
//
G4VSolid* G4ScaledSolid::Clone() const
{
return new G4ScaledSolid(*this);
}
//////////////////////////////////////////////////////////////////////////
//
// Returning the scaling transformation
//
G4Scale3D G4ScaledSolid::GetScaleTransform() const
{
return G4Scale3D(fScale->GetScale().x(),
fScale->GetScale().y(),
fScale->GetScale().z());
}
//////////////////////////////////////////////////////////////////////////
//
// Setting the scaling transformation
//
void G4ScaledSolid::SetScaleTransform(const G4Scale3D& scale)
{
if (fScale) { delete fScale; }
fScale = new G4ScaleTransform(scale);
fRebuildPolyhedron = true;
}
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
//
std::ostream& G4ScaledSolid::StreamInfo(std::ostream& os) const
{
os << "-----------------------------------------------------------\n"
<< " *** Dump for Scaled solid - " << GetName() << " ***\n"
<< " ===================================================\n"
<< " Solid type: " << GetEntityType() << "\n"
<< " Parameters of constituent solid: \n"
<< "===========================================================\n";
fPtrSolid->StreamInfo(os);
os << "===========================================================\n"
<< " Scaling: \n"
<< " Scale transformation : \n"
<< " " << fScale->GetScale().x() << ", "
<< fScale->GetScale().y() << ", "
<< fScale->GetScale().z() << "\n"
<< "===========================================================\n";
return os;
}
//////////////////////////////////////////////////////////////////////////
//
// DescribeYourselfTo
//
void
G4ScaledSolid::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
{
scene.AddSolid (*this);
}
//////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron
//
G4Polyhedron*
G4ScaledSolid::CreatePolyhedron () const
{
G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
polyhedron->Transform(GetScaleTransform());
return polyhedron;
}
//////////////////////////////////////////////////////////////////////////
//
// GetPolyhedron
//
G4Polyhedron* G4ScaledSolid::GetPolyhedron () const
{
if (!fpPolyhedron ||
fRebuildPolyhedron ||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
fpPolyhedron->GetNumberOfRotationSteps())
{
fpPolyhedron = CreatePolyhedron();
fRebuildPolyhedron = false;
}
return fpPolyhedron;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4SubtractionSolid.cc 92010 2015-08-13 10:07:52Z gcosmo $
// $Id: G4SubtractionSolid.cc 95390 2016-02-08 14:46:28Z gcosmo $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -169,12 +169,13 @@ EInside G4SubtractionSolid::Inside( const G4ThreeVector& p ) const
}
else
{
static const G4double rtol
= 1000.0*G4GeometryTolerance::GetInstance()->GetRadialTolerance();
if(( positionA == kInside && positionB == kSurface) ||
( positionB == kOutside && positionA == kSurface) ||
( positionA == kSurface && positionB == kSurface &&
( fPtrSolidA->SurfaceNormal(p) -
fPtrSolidB->SurfaceNormal(p) ).mag2() >
1000.0*G4GeometryTolerance::GetInstance()->GetRadialTolerance() ) )
fPtrSolidB->SurfaceNormal(p) ).mag2() > rtol ) )
{
return kSurface;
}
@@ -92,6 +92,58 @@ G4UMultiUnion& G4UMultiUnion::operator=(const G4UMultiUnion &source)
}
//////////////////////////////////////////////////////////////////////////
//
// Accessors & modifiers
//
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);
}
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);
}
G4VSolid* G4UMultiUnion::GetSolid(G4int index) const
{
VUSolid* solid = GetShape()->GetSolid(index);
return new G4USolid(solid->GetName(), solid);
}
G4int G4UMultiUnion::GetNumberOfSolids()const
{
return GetShape()->GetNumberOfSolids();
}
void G4UMultiUnion::Voxelize()
{
GetShape()->Voxelize();
}
//////////////////////////////////////////////////////////////////////////
//
// CreatePolyhedron
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UnionSolid.cc 92010 2015-08-13 10:07:52Z gcosmo $
// $Id: G4UnionSolid.cc 95390 2016-02-08 14:46:28Z gcosmo $
//
// Implementation of methods for the class G4IntersectionSolid
//
@@ -173,13 +173,14 @@ EInside G4UnionSolid::Inside( const G4ThreeVector& p ) const
EInside positionA = fPtrSolidA->Inside(p);
if (positionA == kInside) { return kInside; }
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() <
1000*G4GeometryTolerance::GetInstance()->GetRadialTolerance() ) )
fPtrSolidB->SurfaceNormal(p) ).mag2() < rtol ) )
{
return kInside;
}