Import Geant4 10.4.0.beta source tree
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
// $Id: $
|
||||
//
|
||||
//
|
||||
// class G4GeomTools Implementation
|
||||
// class G4GeomTools implementation
|
||||
//
|
||||
// Author: evgueni.tcherniaev@cern.ch
|
||||
//
|
||||
@@ -81,11 +81,12 @@ G4double G4GeomTools::QuadArea(const G4TwoVector& A,
|
||||
|
||||
G4double G4GeomTools::PolygonArea(const G4TwoVectorList& p)
|
||||
{
|
||||
G4double area = 0.0;
|
||||
G4int n = p.size();
|
||||
for(G4int i=0,k=n-1; i<n; k=i,++i)
|
||||
if (n < 3) return 0; // degerate polygon
|
||||
G4double area = p[n-1].x()*p[0].y() - p[0].x()*p[n-1].y();
|
||||
for(G4int i=1; i<n; ++i)
|
||||
{
|
||||
area += p[k].x()*p[i].y() - p[i].x()*p[k].y();
|
||||
area += p[i-1].x()*p[i].y() - p[i].x()*p[i-1].y();
|
||||
}
|
||||
return area*0.5;
|
||||
}
|
||||
@@ -192,7 +193,7 @@ G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
// Triangulation of a simple polygon by "ear clipping"
|
||||
|
||||
G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
std::vector<G4int>& result)
|
||||
std::vector<G4int>& result)
|
||||
{
|
||||
result.resize(0);
|
||||
|
||||
@@ -283,9 +284,6 @@ G4bool G4GeomTools::CheckSnip(const G4TwoVectorList& contour,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Remove collinear and coincident points from 2D polygon
|
||||
@@ -346,7 +344,7 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
G4double area = std::abs(e1.x()*e2.y()-e1.y()*e2.x())*0.5;
|
||||
if (area/std::sqrt(lmax) <= std::abs(tolerance))
|
||||
{
|
||||
polygon[icur].setX(removeIt); nout++;
|
||||
polygon[icur].setX(removeIt); nout++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,7 +371,7 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find bounding box of a disk sector
|
||||
// Find bounding rectangle of a disk sector
|
||||
|
||||
G4bool G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
G4double startPhi, G4double delPhi,
|
||||
@@ -405,7 +403,7 @@ G4bool G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find bounding box of a disk sector, fast version.
|
||||
// Find bounding rectangle of a disk sector, fast version.
|
||||
// No check of parameters !!!
|
||||
|
||||
void G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
@@ -513,13 +511,117 @@ void G4GeomTools::DiskExtent(G4double rmin, G4double rmax,
|
||||
return;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Compute the circumference (perimeter) of an ellipse
|
||||
|
||||
G4double G4GeomTools::EllipsePerimeter(G4double pA, G4double pB)
|
||||
{
|
||||
G4double x = std::abs(pA);
|
||||
G4double y = std::abs(pB);
|
||||
G4double a = std::max(x,y);
|
||||
G4double b = std::min(x,y);
|
||||
G4double e = std::sqrt((1. - b/a)*(1. + b/a));
|
||||
return 4. * a * comp_ellint_2(e);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Compute the lateral surface area of an elliptic cone
|
||||
|
||||
G4double G4GeomTools::EllipticConeLateralArea(G4double pA,
|
||||
G4double pB,
|
||||
G4double pH)
|
||||
{
|
||||
G4double x = std::abs(pA);
|
||||
G4double y = std::abs(pB);
|
||||
G4double h = std::abs(pH);
|
||||
G4double a = std::max(x,y);
|
||||
G4double b = std::min(x,y);
|
||||
G4double e = std::sqrt((1. - b/a)*(1. + b/a)) / std::hypot(1.,b/h);
|
||||
return 2. * a * std::hypot(b,h) * comp_ellint_2(e);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Compute Elliptical Integral of the Second Kind
|
||||
//
|
||||
// The algorithm is based upon Carlson B.C., "Computation of real
|
||||
// or complex elliptic integrals", Numerical Algorithms,
|
||||
// Volume 10, Issue 1, 1995 (see equations 2.36 - 2.39)
|
||||
//
|
||||
// The code was adopted from C code at:
|
||||
// http://paulbourke.net/geometry/ellipsecirc/
|
||||
|
||||
G4double G4GeomTools::comp_ellint_2(G4double e)
|
||||
{
|
||||
const G4double eps = 1. / 134217728.; // 1 / 2^27
|
||||
|
||||
G4double a = 1.;
|
||||
G4double b = std::sqrt((1. - e)*(1. + e));
|
||||
if (b == 1.) return CLHEP::halfpi;
|
||||
if (b == 0.) return 1.;
|
||||
|
||||
G4double x = 1.;
|
||||
G4double y = b;
|
||||
G4double S = 0.;
|
||||
G4double M = 1.;
|
||||
while (x - y > eps*y) {
|
||||
G4double tmp = (x + y) * 0.5;
|
||||
y = std::sqrt(x*y);
|
||||
x = tmp;
|
||||
M += M;
|
||||
S += M * (x - y)*(x - y);
|
||||
}
|
||||
return 0.5 * CLHEP::halfpi * ((a + b)*(a + b) - S) / (x + y);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calcuate area of a triangle in 3D
|
||||
|
||||
G4ThreeVector G4GeomTools::TriangleAreaNormal(const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C)
|
||||
{
|
||||
return ((B-A).cross(C-A))*0.5;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calcuate area of a quadrilateral in 3D
|
||||
|
||||
G4ThreeVector G4GeomTools::QuadAreaNormal(const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C,
|
||||
const G4ThreeVector& D)
|
||||
{
|
||||
return ((C-A).cross(D-B))*0.5;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calculate area of a polygon in 3D
|
||||
|
||||
G4ThreeVector G4GeomTools::PolygonAreaNormal(const G4ThreeVectorList& p)
|
||||
{
|
||||
G4int n = p.size();
|
||||
if (n < 3) return G4ThreeVector(0,0,0); // degerate polygon
|
||||
G4ThreeVector normal = p[n-1].cross(p[0]);
|
||||
for(G4int i=1; i<n; ++i)
|
||||
{
|
||||
normal += p[i-1].cross(p[i]);
|
||||
}
|
||||
return normal*0.5;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calculate distance between point P and line segment AB in 3D
|
||||
|
||||
G4double G4GeomTools::DistancePointSegment(G4ThreeVector P,
|
||||
G4ThreeVector A,
|
||||
G4ThreeVector B)
|
||||
G4double G4GeomTools::DistancePointSegment(const G4ThreeVector& P,
|
||||
const G4ThreeVector& A,
|
||||
const G4ThreeVector& B)
|
||||
{
|
||||
G4ThreeVector AP = P - A;
|
||||
G4ThreeVector AB = B - A;
|
||||
@@ -533,6 +635,137 @@ G4double G4GeomTools::DistancePointSegment(G4ThreeVector P,
|
||||
return ((u/len2)*AB - AP).mag(); // distance to line
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find closest point on line segment in 3D
|
||||
|
||||
G4ThreeVector
|
||||
G4GeomTools::ClosestPointOnSegment(const G4ThreeVector& P,
|
||||
const G4ThreeVector& A,
|
||||
const G4ThreeVector& B)
|
||||
{
|
||||
G4ThreeVector AP = P - A;
|
||||
G4ThreeVector AB = B - A;
|
||||
|
||||
G4double u = AP.dot(AB);
|
||||
if (u <= 0) return A; // closest point is A
|
||||
|
||||
G4double len2 = AB.mag2();
|
||||
if (u >= len2) return B; // closest point is B
|
||||
|
||||
G4double t = u/len2;
|
||||
return A + t*AB; // closest point on segment
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Find closest point on triangle in 3D.
|
||||
//
|
||||
// The implementation is based on the algorithm published in
|
||||
// "Geometric Tools for Computer Graphics", Philip J Scheider and
|
||||
// David H Eberly, Elsevier Science (USA), 2003.
|
||||
//
|
||||
// The algorithm is also available at:
|
||||
// http://www.geometrictools.com/Documentation/DistancePoint3Triangle3.pdf
|
||||
|
||||
G4ThreeVector
|
||||
G4GeomTools::ClosestPointOnTriangle(const G4ThreeVector& P,
|
||||
const G4ThreeVector& A,
|
||||
const G4ThreeVector& B,
|
||||
const G4ThreeVector& C)
|
||||
{
|
||||
G4ThreeVector diff = A - P;
|
||||
G4ThreeVector edge0 = B - A;
|
||||
G4ThreeVector edge1 = C - A;
|
||||
|
||||
G4double a = edge0.mag2();
|
||||
G4double b = edge0.dot(edge1);
|
||||
G4double c = edge1.mag2();
|
||||
G4double d = diff.dot(edge0);
|
||||
G4double e = diff.dot(edge1);
|
||||
|
||||
G4double det = a*c - b*b;
|
||||
G4double t0 = b*e - c*d;
|
||||
G4double t1 = b*d - a*e;
|
||||
|
||||
/*
|
||||
^ t1
|
||||
\ 2 |
|
||||
\ |
|
||||
\ | regions
|
||||
\|
|
||||
C
|
||||
|\
|
||||
3 | \ 1
|
||||
| \
|
||||
| 0 \
|
||||
| \
|
||||
---- A --- B ----> t0
|
||||
| \
|
||||
4 | 5 \ 6
|
||||
| \
|
||||
*/
|
||||
|
||||
G4int region = -1;
|
||||
if (t0+t1 <= det)
|
||||
region = (t0 < 0) ? ((t1 < 0) ? 4 : 3) : ((t1 < 0) ? 5 : 0);
|
||||
else
|
||||
region = (t0 < 0) ? 2 : ((t1 < 0) ? 6 : 1);
|
||||
|
||||
switch (region)
|
||||
{
|
||||
case 0: // interior of triangle
|
||||
{
|
||||
G4double invDet = 1./det;
|
||||
return A + (t0*invDet)*edge0 + (t1*invDet)*edge1;
|
||||
}
|
||||
case 1: // edge BC
|
||||
{
|
||||
G4double numer = c + e - b - d;
|
||||
if (numer <= 0) return C;
|
||||
G4double denom = a - 2*b + c;
|
||||
return (numer >= denom) ? B : C + (numer/denom)*(edge0-edge1);
|
||||
}
|
||||
case 2: // edge AC or BC
|
||||
{
|
||||
G4double tmp0 = b + d;
|
||||
G4double tmp1 = c + e;
|
||||
if (tmp1 > tmp0)
|
||||
{
|
||||
G4double numer = tmp1 - tmp0;
|
||||
G4double denom = a - 2*b + c;
|
||||
return (numer >= denom) ? B : C + (numer/denom)*(edge0-edge1);
|
||||
}
|
||||
// same: (e >= 0) ? A : ((-e >= c) ? C : A + (-e/c)*edge1)
|
||||
return (tmp1 <= 0) ? C : (( e >= 0) ? A : A + (-e/c)*edge1);
|
||||
}
|
||||
case 3: // edge AC
|
||||
return (e >= 0) ? A : ((-e >= c) ? C : A + (-e/c)*edge1);
|
||||
|
||||
case 4: // edge AB or AC
|
||||
if (d < 0) return (-d >= a) ? B : A + (-d/a)*edge0;
|
||||
return (e >= 0) ? A : ((-e >= c) ? C : A + (-e/c)*edge1);
|
||||
|
||||
case 5: // edge AB
|
||||
return (d >= 0) ? A : ((-d >= a) ? B : A + (-d/a)*edge0);
|
||||
|
||||
case 6: // edge AB or BC
|
||||
{
|
||||
G4double tmp0 = b + e;
|
||||
G4double tmp1 = a + d;
|
||||
if (tmp1 > tmp0)
|
||||
{
|
||||
G4double numer = tmp1 - tmp0;
|
||||
G4double denom = a - 2*b + c;
|
||||
return (numer >= denom) ? C : B + (numer/denom)*(edge1-edge0);
|
||||
}
|
||||
// same: (d >= 0) ? A : ((-d >= a) ? B : A + (-d/a)*edge0)
|
||||
return (tmp1 <= 0) ? B : (( d >= 0) ? A : A + (-d/a)*edge0);
|
||||
}
|
||||
default: // impossible case
|
||||
return G4ThreeVector(kInfinity,kInfinity,kInfinity);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4GeometryManager.cc 67975 2013-03-13 10:19:44Z gcosmo $
|
||||
// $Id: G4GeometryManager.cc 103235 2017-03-22 15:53:48Z gcosmo $
|
||||
//
|
||||
// class G4GeometryManager
|
||||
//
|
||||
@@ -57,20 +57,30 @@
|
||||
#include "G4VSolid.hh"
|
||||
|
||||
// ***************************************************************************
|
||||
// Static class variable: ptr to single instance of class
|
||||
// Static class data
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4ThreadLocal G4GeometryManager* G4GeometryManager::fgInstance = 0;
|
||||
G4ThreadLocal G4bool G4GeometryManager::fIsClosed = false;
|
||||
|
||||
// ***************************************************************************
|
||||
// Constructor. Set the geometry to be open
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4GeometryManager::G4GeometryManager()
|
||||
: fIsClosed(false)
|
||||
{
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Destructor
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4GeometryManager::~G4GeometryManager()
|
||||
{
|
||||
fgInstance = 0;
|
||||
fIsClosed = false;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Closes geometry - performs sanity checks and optionally builds optimisation
|
||||
// for placed volumes (always built for replicas & parameterised).
|
||||
@@ -81,7 +91,7 @@ G4GeometryManager::G4GeometryManager()
|
||||
G4bool G4GeometryManager::CloseGeometry(G4bool pOptimise, G4bool verbose,
|
||||
G4VPhysicalVolume* pVolume)
|
||||
{
|
||||
if (!fIsClosed)
|
||||
if (!fIsClosed)
|
||||
{
|
||||
if (pVolume)
|
||||
{
|
||||
@@ -138,7 +148,16 @@ G4GeometryManager* G4GeometryManager::GetInstance()
|
||||
{
|
||||
fgInstance = new G4GeometryManager;
|
||||
}
|
||||
return fgInstance;
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// Returns the instance of the singleton.
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4GeometryManager* G4GeometryManager::GetInstanceIfExist()
|
||||
{
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalVolume.cc 100906 2016-11-03 09:59:32Z gcosmo $
|
||||
// $Id: G4LogicalVolume.cc 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4LogicalVolume Implementation
|
||||
@@ -190,6 +190,15 @@ InitialiseWorker( G4LogicalVolume* /*pMasterObject*/,
|
||||
#endif
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// Clean
|
||||
// ********************************************************************
|
||||
//
|
||||
void G4LogicalVolume::Clean()
|
||||
{
|
||||
subInstanceManager.FreeSlave();
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// TerminateWorker
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4LogicalVolumeStore.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4LogicalVolumeStore.cc 103235 2017-03-22 15:53:48Z gcosmo $
|
||||
//
|
||||
// G4LogicalVolumeStore
|
||||
//
|
||||
@@ -63,7 +63,8 @@ G4LogicalVolumeStore::G4LogicalVolumeStore()
|
||||
//
|
||||
G4LogicalVolumeStore::~G4LogicalVolumeStore()
|
||||
{
|
||||
Clean();
|
||||
Clean(); // Delete all volumes in the store
|
||||
G4LogicalVolume::Clean(); // Delete allocated sub-instance data
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -74,7 +75,7 @@ void G4LogicalVolumeStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the logical volume store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4PhysicalVolumeStore.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4PhysicalVolumeStore.cc 103235 2017-03-22 15:53:48Z gcosmo $
|
||||
//
|
||||
// G4PhysicalVolumeStore
|
||||
//
|
||||
@@ -64,7 +64,8 @@ G4PhysicalVolumeStore::G4PhysicalVolumeStore()
|
||||
//
|
||||
G4PhysicalVolumeStore::~G4PhysicalVolumeStore()
|
||||
{
|
||||
Clean();
|
||||
Clean(); // Delete all volumes in the store
|
||||
G4VPhysicalVolume::Clean(); // Delete allocated sub-instance data
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -75,7 +76,7 @@ void G4PhysicalVolumeStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the physical volume store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
@@ -90,13 +91,12 @@ void G4PhysicalVolumeStore::Clean()
|
||||
|
||||
size_t i=0;
|
||||
G4PhysicalVolumeStore* store = GetInstance();
|
||||
std::vector<G4VPhysicalVolume*>::iterator pos;
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
G4cout << "Deleting Physical Volumes ... ";
|
||||
#endif
|
||||
|
||||
for(pos=store->begin(); pos!=store->end(); pos++)
|
||||
for(iterator pos=store->begin(); pos!=store->end(); pos++)
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
if (*pos) { delete *pos; }
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ReflectedSolid.cc 100906 2016-11-03 09:59:32Z gcosmo $
|
||||
// $Id: G4ReflectedSolid.cc 104317 2017-05-24 13:08:38Z gcosmo $
|
||||
//
|
||||
//
|
||||
// Implementation for G4ReflectedSolid class
|
||||
@@ -152,9 +152,10 @@ void G4ReflectedSolid::SetDirectTransform3D(G4Transform3D& transform)
|
||||
//
|
||||
// Get bounding box
|
||||
|
||||
void G4ReflectedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
|
||||
void G4ReflectedSolid::BoundingLimits(G4ThreeVector& pMin,
|
||||
G4ThreeVector& pMax) const
|
||||
{
|
||||
fPtrSolid->Extent(pMin,pMax);
|
||||
fPtrSolid->BoundingLimits(pMin,pMax);
|
||||
G4double xmin = pMin.x(), ymin = pMin.y(), zmin = pMin.z();
|
||||
G4double xmax = pMax.x(), ymax = pMax.y(), zmax = pMax.z();
|
||||
G4double xx = fDirectTransform3D->xx();
|
||||
@@ -203,7 +204,7 @@ void G4ReflectedSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
|
||||
<< GetName() << " !"
|
||||
<< "\npMin = " << pMin
|
||||
<< "\npMax = " << pMax;
|
||||
G4Exception("G4ReflectedSolid::Extent()", "GeomMgt0001",
|
||||
G4Exception("G4ReflectedSolid::BoundingLimits()", "GeomMgt0001",
|
||||
JustWarning, message);
|
||||
DumpInfo();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Region.cc 100428 2016-10-21 12:59:37Z gcosmo $
|
||||
// $Id: G4Region.cc 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4Region Implementation
|
||||
@@ -341,6 +341,15 @@ void G4Region::RemoveRootLogicalVolume(G4LogicalVolume* lv, G4bool scan)
|
||||
fRegionMod = true;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// Clean
|
||||
// ********************************************************************
|
||||
//
|
||||
void G4Region::Clean()
|
||||
{
|
||||
subInstanceManager.FreeSlave();
|
||||
}
|
||||
|
||||
// *******************************************************************
|
||||
// ClearMaterialList:
|
||||
// - Clears the material list.
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4RegionStore.cc 66872 2013-01-15 01:25:57Z japost $
|
||||
// $Id: G4RegionStore.cc 103235 2017-03-22 15:53:48Z gcosmo $
|
||||
//
|
||||
// G4RegionStore
|
||||
//
|
||||
@@ -67,7 +67,8 @@ G4RegionStore::G4RegionStore()
|
||||
//
|
||||
G4RegionStore::~G4RegionStore()
|
||||
{
|
||||
Clean();
|
||||
Clean(); // Delete all regions in the store
|
||||
G4Region::Clean(); // Delete allocated sub-instance data
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -78,7 +79,7 @@ void G4RegionStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the region store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4SolidStore.cc 67975 2013-03-13 10:19:44Z gcosmo $
|
||||
// $Id: G4SolidStore.cc 103345 2017-03-28 14:20:20Z gcosmo $
|
||||
//
|
||||
// G4SolidStore
|
||||
//
|
||||
@@ -63,13 +63,7 @@ G4SolidStore::G4SolidStore()
|
||||
//
|
||||
G4SolidStore::~G4SolidStore()
|
||||
{
|
||||
// In multi-threaded mode, since parameterised solids are replicated
|
||||
// by threads, the master thread can not free them when thread private
|
||||
// malloc library is used. May let the master thread to replicate.
|
||||
|
||||
#ifndef G4MULTITHREADED
|
||||
Clean();
|
||||
#endif
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -80,7 +74,7 @@ void G4SolidStore::Clean()
|
||||
{
|
||||
// Do nothing if geometry is closed
|
||||
//
|
||||
if (G4GeometryManager::GetInstance()->IsGeometryClosed())
|
||||
if (G4GeometryManager::IsGeometryClosed())
|
||||
{
|
||||
G4cout << "WARNING - Attempt to delete the solid store"
|
||||
<< " while geometry closed !" << G4endl;
|
||||
|
||||
@@ -72,152 +72,6 @@ G4bool G4USolid::operator==(const G4USolid& s) const
|
||||
return (this == &s) ? true : false;
|
||||
}
|
||||
|
||||
EInside G4USolid::Inside(const G4ThreeVector& p) const
|
||||
{
|
||||
UVector3 pt;
|
||||
VUSolid::EnumInside in_temp;
|
||||
EInside in = kOutside;
|
||||
pt.x() = p.x();
|
||||
pt.y() = p.y();
|
||||
pt.z() = p.z(); // better assign at construction
|
||||
|
||||
in_temp = fShape->Inside(pt);
|
||||
|
||||
if (in_temp == VUSolid::EnumInside::eSurface) return kSurface;
|
||||
if (in_temp == VUSolid::EnumInside::eInside) return kInside;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
G4ThreeVector G4USolid::SurfaceNormal(const G4ThreeVector& pt) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z();
|
||||
UVector3 n;
|
||||
fShape->Normal(p, n);
|
||||
return G4ThreeVector(n.x(), n.y(), n.z());
|
||||
}
|
||||
|
||||
G4double G4USolid::DistanceToIn(const G4ThreeVector& pt,
|
||||
const G4ThreeVector& d) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z(); // better assign at construction
|
||||
UVector3 v;
|
||||
v.x() = d.x();
|
||||
v.y() = d.y();
|
||||
v.z() = d.z(); // better assign at construction
|
||||
G4double dist = fShape->DistanceToIn(p, v);
|
||||
if (dist > kInfinity) return kInfinity;
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return dist;
|
||||
}
|
||||
|
||||
G4double G4USolid::DistanceToIn(const G4ThreeVector& pt) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z(); // better assign at construction
|
||||
G4double dist = fShape->SafetyFromOutside(p); // true?
|
||||
if (dist > kInfinity) return kInfinity;
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return dist;
|
||||
}
|
||||
|
||||
G4double G4USolid::DistanceToOut(const G4ThreeVector& pt,
|
||||
const G4ThreeVector& d,
|
||||
const G4bool calcNorm,
|
||||
G4bool* validNorm,
|
||||
G4ThreeVector* norm) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z(); // better assign at construction
|
||||
UVector3 v;
|
||||
v.x() = d.x();
|
||||
v.y() = d.y();
|
||||
v.z() = d.z(); // better assign at construction
|
||||
UVector3 n;
|
||||
G4bool valid;
|
||||
G4double dist = fShape->DistanceToOut(p, v, n, valid); // should use local variable
|
||||
if(calcNorm)
|
||||
{
|
||||
if(valid){ *validNorm = true; }
|
||||
else { *validNorm = false; }
|
||||
if(*validNorm) // *norm = n, but only after calcNorm check
|
||||
{
|
||||
norm->setX(n.x());
|
||||
norm->setY(n.y());
|
||||
norm->setZ(n.z());
|
||||
}
|
||||
}
|
||||
if (dist > kInfinity) return kInfinity;
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return dist;
|
||||
}
|
||||
|
||||
G4double G4USolid::DistanceToOut(const G4ThreeVector& pt) const
|
||||
{
|
||||
UVector3 p;
|
||||
p.x() = pt.x();
|
||||
p.y() = pt.y();
|
||||
p.z() = pt.z(); // better assign at construction
|
||||
G4double dist = fShape->SafetyFromInside(p); // true?
|
||||
// return (dist > halfTolerance) ? dist : 0.0;
|
||||
return dist;
|
||||
}
|
||||
|
||||
G4double G4USolid::GetCubicVolume()
|
||||
{
|
||||
return fShape->Capacity();
|
||||
}
|
||||
|
||||
G4double G4USolid::GetSurfaceArea()
|
||||
{
|
||||
return fShape->SurfaceArea();
|
||||
}
|
||||
|
||||
G4ThreeVector G4USolid::GetPointOnSurface() const
|
||||
{
|
||||
UVector3 p;
|
||||
p = fShape->GetPointOnSurface();
|
||||
return G4ThreeVector(p.x(), p.y(), p.z());
|
||||
}
|
||||
|
||||
G4bool G4USolid::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const
|
||||
{
|
||||
UVector3 vmin, vmax;
|
||||
fShape->Extent(vmin,vmax);
|
||||
G4ThreeVector bmin(vmin.x(),vmin.y(),vmin.z());
|
||||
G4ThreeVector bmax(vmax.x(),vmax.y(),vmax.z());
|
||||
|
||||
// Check correctness of the bounding box
|
||||
//
|
||||
if (bmin.x() >= bmax.x() || bmin.y() >= bmax.y() || bmin.z() >= bmax.z())
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Bad bounding box (min >= max) for solid: "
|
||||
<< GetName() << " - " << GetEntityType() << " !"
|
||||
<< "\nmin = " << bmin
|
||||
<< "\nmax = " << bmax;
|
||||
G4Exception("G4USolid::CalculateExtent()", "GeomMgt0001",
|
||||
JustWarning, message);
|
||||
StreamInfo(G4cout);
|
||||
}
|
||||
|
||||
G4BoundingEnvelope bbox(bmin,bmax);
|
||||
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
|
||||
}
|
||||
|
||||
void G4USolid::ComputeDimensions(G4VPVParameterisation*,
|
||||
const G4int,
|
||||
const G4VPhysicalVolume*)
|
||||
@@ -284,6 +138,34 @@ G4VSolid* G4USolid::Clone() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
G4bool G4USolid::CalculateExtent(const EAxis pAxis,
|
||||
const G4VoxelLimits& pVoxelLimit,
|
||||
const G4AffineTransform& pTransform,
|
||||
G4double& pMin, G4double& pMax) const
|
||||
{
|
||||
UVector3 vmin, vmax;
|
||||
fShape->Extent(vmin,vmax);
|
||||
G4ThreeVector bmin(vmin.x(),vmin.y(),vmin.z());
|
||||
G4ThreeVector bmax(vmax.x(),vmax.y(),vmax.z());
|
||||
|
||||
// Check correctness of the bounding box
|
||||
//
|
||||
if (bmin.x() >= bmax.x() || bmin.y() >= bmax.y() || bmin.z() >= bmax.z())
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Bad bounding box (min >= max) for solid: "
|
||||
<< GetName() << " - " << GetEntityType() << " !"
|
||||
<< "\nmin = " << bmin
|
||||
<< "\nmax = " << bmax;
|
||||
G4Exception("G4USolid::CalculateExtent()", "GeomMgt0001",
|
||||
JustWarning, message);
|
||||
StreamInfo(G4cout);
|
||||
}
|
||||
|
||||
G4BoundingEnvelope bbox(bmin,bmax);
|
||||
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
|
||||
}
|
||||
|
||||
G4Polyhedron* G4USolid::CreatePolyhedron() const
|
||||
{
|
||||
// Must be implemented in concrete wrappers...
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VPhysicalVolume.cc 100428 2016-10-21 12:59:37Z gcosmo $
|
||||
// $Id: G4VPhysicalVolume.cc 103096 2017-03-15 15:21:33Z gcosmo $
|
||||
//
|
||||
//
|
||||
// class G4VPhysicalVolume Implementation
|
||||
@@ -109,6 +109,13 @@ InitialiseWorker( G4VPhysicalVolume* /*pMasterObject*/,
|
||||
// G4PhysicalVolumeStore::Register(this);
|
||||
}
|
||||
|
||||
// Release memory allocated for offset
|
||||
//
|
||||
void G4VPhysicalVolume::Clean()
|
||||
{
|
||||
subInstanceManager.FreeSlave();
|
||||
}
|
||||
|
||||
// This method is similar to the destructor. It is used by each worker
|
||||
// thread to achieve the partial effect as that of the master thread.
|
||||
// For G4VPhysicalVolume instances, nothing more to do here.
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4VSolid.cc 100906 2016-11-03 09:59:32Z gcosmo $
|
||||
// $Id: G4VSolid.cc 104317 2017-05-24 13:08:38Z gcosmo $
|
||||
//
|
||||
// class G4VSolid
|
||||
//
|
||||
@@ -32,7 +32,6 @@
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 03.11.16 E.Tcherniaev, added Extent()
|
||||
// 06.12.02 V.Grichine, restored original conditions in ClipPolygon()
|
||||
// 10.05.02 V.Grichine, ClipPolygon(): clip only other axis and limited voxels
|
||||
// 15.04.02 V.Grichine, bug fixed in ClipPolygon(): clip only one axis
|
||||
@@ -623,13 +622,14 @@ G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVectorList& pPolygon,
|
||||
//
|
||||
// Throw exception (warning) for solids not implementing the method
|
||||
|
||||
void G4VSolid::Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const
|
||||
void G4VSolid::BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Not implemented for solid: "
|
||||
<< GetEntityType() << " !"
|
||||
<< "\nReturning infinite boundinx box.";
|
||||
G4Exception("G4VSolid::Extent()", "GeomMgt1001", JustWarning, message);
|
||||
G4Exception("G4VSolid::BoundingLimits()", "GeomMgt1001",
|
||||
JustWarning, message);
|
||||
|
||||
pMin.set(-kInfinity,-kInfinity,-kInfinity);
|
||||
pMax.set( kInfinity, kInfinity, kInfinity);
|
||||
|
||||
Reference in New Issue
Block a user