Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -23,9 +23,6 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4BlockingList Implementation
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
@@ -33,7 +30,7 @@
|
||||
#include "G4BlockingList.hh"
|
||||
|
||||
G4BlockingList::G4BlockingList(G4int maxDefault, G4int stride)
|
||||
: fBlockTagNo(1), fStride(stride), fBlockingList(maxDefault,0)
|
||||
: fStride(stride), fBlockingList(maxDefault,0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,7 +45,7 @@ G4BlockingList::~G4BlockingList()
|
||||
void G4BlockingList::FullyReset()
|
||||
{
|
||||
fBlockTagNo = 1;
|
||||
for ( G4int i=fBlockingList.size()-1; i>=0; i-- )
|
||||
for ( G4long i=G4long(fBlockingList.size()-1); i>=0; --i )
|
||||
{
|
||||
fBlockingList[i] = 0;
|
||||
}
|
||||
|
||||
@@ -23,15 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// Implementation of G4BoundingEnvelope
|
||||
//
|
||||
// Author: evgueni.tcherniaev@cern.ch
|
||||
//
|
||||
// 2016.05.25 E.Tcherniaev - initial version
|
||||
//
|
||||
// 2016.05.25, E.Tcherniaev - initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <cmath>
|
||||
@@ -49,7 +43,7 @@ const G4double kCarTolerance =
|
||||
//
|
||||
G4BoundingEnvelope::G4BoundingEnvelope(const G4ThreeVector& pMin,
|
||||
const G4ThreeVector& pMax)
|
||||
: fMin(pMin), fMax(pMax), fPolygons(0)
|
||||
: fMin(pMin), fMax(pMax)
|
||||
{
|
||||
// Check correctness of bounding box
|
||||
//
|
||||
@@ -72,11 +66,9 @@ G4BoundingEnvelope(const std::vector<const G4ThreeVectorList*>& polygons)
|
||||
//
|
||||
G4double xmin = kInfinity, ymin = kInfinity, zmin = kInfinity;
|
||||
G4double xmax = -kInfinity, ymax = -kInfinity, zmax = -kInfinity;
|
||||
std::vector<const G4ThreeVectorList*>::const_iterator ibase;
|
||||
for (ibase = fPolygons->begin(); ibase != fPolygons->end(); ibase++)
|
||||
for (auto ibase = fPolygons->cbegin(); ibase != fPolygons->cend(); ++ibase)
|
||||
{
|
||||
std::vector<G4ThreeVector>::const_iterator ipoint;
|
||||
for (ipoint = (*ibase)->begin(); ipoint != (*ibase)->end(); ipoint++)
|
||||
for (auto ipoint = (*ibase)->cbegin(); ipoint != (*ibase)->cend(); ++ipoint)
|
||||
{
|
||||
G4double x = ipoint->x();
|
||||
if (x < xmin) xmin = x;
|
||||
@@ -311,7 +303,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
if (zmin-kCarTolerance > zmaxlim) return false;
|
||||
if (zmax+kCarTolerance < zminlim) return false;
|
||||
|
||||
if (fPolygons == 0)
|
||||
if (fPolygons == nullptr)
|
||||
{
|
||||
if (pAxis == kXAxis)
|
||||
{
|
||||
@@ -379,7 +371,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
cx = cy = cz = cd = kInfinity;
|
||||
}
|
||||
G4double emin = kInfinity, emax = -kInfinity;
|
||||
if (fPolygons == 0)
|
||||
if (fPolygons == nullptr)
|
||||
{
|
||||
G4double coor;
|
||||
coor = cx*fMin.x() + cy*fMin.y() + cz*fMin.z() + cd;
|
||||
@@ -409,11 +401,9 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<const G4ThreeVectorList*>::const_iterator ibase;
|
||||
for (ibase = fPolygons->begin(); ibase != fPolygons->end(); ibase++)
|
||||
for (auto ibase=fPolygons->cbegin(); ibase!=fPolygons->cend(); ++ibase)
|
||||
{
|
||||
G4ThreeVectorList::const_iterator ipoint;
|
||||
for (ipoint = (*ibase)->begin(); ipoint != (*ibase)->end(); ipoint++)
|
||||
for (auto ipoint=(*ibase)->cbegin(); ipoint!=(*ibase)->cend(); ++ipoint)
|
||||
{
|
||||
G4double coor = ipoint->x()*cx + ipoint->y()*cy + ipoint->z()*cz + cd;
|
||||
if (coor < emin) emin = coor;
|
||||
@@ -440,7 +430,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
//
|
||||
G4int nbases = (fPolygons == 0) ? 2 : fPolygons->size();
|
||||
std::vector<G4Polygon3D*> bases(nbases);
|
||||
if (fPolygons == 0)
|
||||
if (fPolygons == nullptr)
|
||||
{
|
||||
bases[0] = new G4Polygon3D(4);
|
||||
bases[1] = new G4Polygon3D(4);
|
||||
@@ -463,7 +453,7 @@ G4BoundingEnvelope::CalculateExtent(const EAxis pAxis,
|
||||
//
|
||||
EAxis axis[] = { kXAxis,kYAxis,kZAxis };
|
||||
G4VoxelLimits limits; // default is unlimited
|
||||
for (G4int i=0; i<3; ++i)
|
||||
for (auto i=0; i<3; ++i)
|
||||
{
|
||||
if (pVoxelLimits.IsLimited(axis[i]))
|
||||
{
|
||||
@@ -607,7 +597,7 @@ G4BoundingEnvelope::TransformVertices(const G4Transform3D& pTransform3D,
|
||||
G4ThreeVectorList baseA(4), baseB(4);
|
||||
std::vector<const G4ThreeVectorList*> aabb(2);
|
||||
aabb[0] = &baseA; aabb[1] = &baseB;
|
||||
if (fPolygons == 0)
|
||||
if (fPolygons == nullptr)
|
||||
{
|
||||
baseA[0].set(fMin.x(),fMin.y(),fMin.z());
|
||||
baseA[1].set(fMax.x(),fMin.y(),fMin.z());
|
||||
@@ -626,20 +616,20 @@ G4BoundingEnvelope::TransformVertices(const G4Transform3D& pTransform3D,
|
||||
if (pTransform3D.xx()==1 && pTransform3D.yy()==1 && pTransform3D.zz()==1)
|
||||
{
|
||||
G4ThreeVector offset = pTransform3D.getTranslation();
|
||||
for ( ; ia != iaend; ia++, ib++)
|
||||
for ( ; ia != iaend; ++ia, ++ib)
|
||||
{
|
||||
G4ThreeVectorList::const_iterator ka = (*ia)->begin();
|
||||
G4Polygon3D::iterator kb = (*ib)->begin();
|
||||
for ( ; ka != (*ia)->end(); ka++, kb++) { (*kb) = (*ka) + offset; }
|
||||
for ( ; ka != (*ia)->end(); ++ka, ++kb) { (*kb) = (*ka) + offset; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( ; ia != iaend; ia++, ib++)
|
||||
for ( ; ia != iaend; ++ia, ++ib)
|
||||
{
|
||||
G4ThreeVectorList::const_iterator ka = (*ia)->begin();
|
||||
G4Polygon3D::iterator kb = (*ib)->begin();
|
||||
for ( ; ka != (*ia)->end(); ka++, kb++)
|
||||
for ( ; ka != (*ia)->end(); ++ka, ++kb)
|
||||
{
|
||||
(*kb) = pTransform3D*G4Point3D(*ka);
|
||||
}
|
||||
@@ -658,34 +648,33 @@ G4BoundingEnvelope::GetPrismAABB(const G4Polygon3D& pBaseA,
|
||||
{
|
||||
G4double xmin = kInfinity, ymin = kInfinity, zmin = kInfinity;
|
||||
G4double xmax = -kInfinity, ymax = -kInfinity, zmax = -kInfinity;
|
||||
G4Polygon3D::const_iterator it;
|
||||
|
||||
// First base
|
||||
//
|
||||
for (it = pBaseA.begin(); it != pBaseA.end(); it++)
|
||||
for (auto it1 = pBaseA.cbegin(); it1 != pBaseA.cend(); ++it1)
|
||||
{
|
||||
G4double x = it->x();
|
||||
G4double x = it1->x();
|
||||
if (x < xmin) xmin = x;
|
||||
if (x > xmax) xmax = x;
|
||||
G4double y = it->y();
|
||||
G4double y = it1->y();
|
||||
if (y < ymin) ymin = y;
|
||||
if (y > ymax) ymax = y;
|
||||
G4double z = it->z();
|
||||
G4double z = it1->z();
|
||||
if (z < zmin) zmin = z;
|
||||
if (z > zmax) zmax = z;
|
||||
}
|
||||
|
||||
// Second base
|
||||
//
|
||||
for (it = pBaseB.begin(); it != pBaseB.end(); it++)
|
||||
for (auto it2 = pBaseB.cbegin(); it2 != pBaseB.cend(); ++it2)
|
||||
{
|
||||
G4double x = it->x();
|
||||
G4double x = it2->x();
|
||||
if (x < xmin) xmin = x;
|
||||
if (x > xmax) xmax = x;
|
||||
G4double y = it->y();
|
||||
G4double y = it2->y();
|
||||
if (y < ymin) ymin = y;
|
||||
if (y > ymax) ymax = y;
|
||||
G4double z = it->z();
|
||||
G4double z = it2->z();
|
||||
if (z < zmin) zmin = z;
|
||||
if (z > zmax) zmax = z;
|
||||
}
|
||||
@@ -1054,14 +1043,12 @@ G4BoundingEnvelope::ClipVoxelByPlanes(G4int pBits,
|
||||
|
||||
// Clip the edges by the planes
|
||||
//
|
||||
std::vector<G4Segment3D>::const_iterator iedge;
|
||||
for (iedge = edges.begin(); iedge != edges.end(); iedge++)
|
||||
for (auto iedge = edges.cbegin(); iedge != edges.cend(); ++iedge)
|
||||
{
|
||||
G4bool exist = true;
|
||||
G4Point3D p1 = iedge->first;
|
||||
G4Point3D p2 = iedge->second;
|
||||
std::vector<G4Plane3D>::const_iterator iplane;
|
||||
for (iplane = pPlanes.begin(); iplane != pPlanes.end(); iplane++)
|
||||
for (auto iplane = pPlanes.cbegin(); iplane != pPlanes.cend(); ++iplane)
|
||||
{
|
||||
// Clip current edge
|
||||
G4double d1 = iplane->distance(p1);
|
||||
|
||||
@@ -23,18 +23,16 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// G4ErrorCylSurfaceTarget class implementation
|
||||
//
|
||||
// Created: P.Arce, September 2004
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ErrorCylSurfaceTarget.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
#include "G4ErrorPropagatorData.hh" //for verbosity checking
|
||||
#include "G4ErrorPropagatorData.hh" // for verbosity checking
|
||||
#endif
|
||||
|
||||
#include "geomdefs.hh"
|
||||
@@ -52,7 +50,8 @@ G4ErrorCylSurfaceTarget( const G4double& radius,
|
||||
|
||||
ftransform = G4AffineTransform( rotm.inverse(), -trans );
|
||||
#ifdef G4VERBOSE
|
||||
if(G4ErrorPropagatorData::verbose() >= 2 ) {
|
||||
if(G4ErrorPropagatorData::verbose() >= 2 )
|
||||
{
|
||||
Dump( " $$$ creating G4ErrorCylSurfaceTarget ");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -23,17 +23,15 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ErrorPlaneSurfaceTarget class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// Created: P.Arce, September 2004
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ErrorPlaneSurfaceTarget.hh"
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
#include "G4ErrorPropagatorData.hh" //for verbosity checking
|
||||
#include "G4ErrorPropagatorData.hh" // for verbosity checking
|
||||
#endif
|
||||
|
||||
#include "G4Point3D.hh"
|
||||
@@ -169,6 +167,7 @@ GetTangentPlane( const G4ThreeVector& ) const
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
void G4ErrorPlaneSurfaceTarget::Dump( const G4String& msg ) const
|
||||
{
|
||||
|
||||
@@ -23,11 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ErrorSurfaceTarget class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// Created: P.Arce, September 2004
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ErrorSurfaceTarget.hh"
|
||||
|
||||
@@ -23,11 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ErrorTanPlaneTarget class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// Created: P.Arce, September 2004
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ErrorTanPlaneTarget.hh"
|
||||
|
||||
@@ -23,17 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ErrorTarget class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// Created: P.Arce, September 2004
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ErrorTarget.hh"
|
||||
|
||||
G4ErrorTarget::G4ErrorTarget()
|
||||
: theType(G4ErrorTarget_GeomVolume) {}
|
||||
G4ErrorTarget::G4ErrorTarget() : theType(G4ErrorTarget_GeomVolume) {}
|
||||
|
||||
G4ErrorTarget::~G4ErrorTarget() {}
|
||||
|
||||
@@ -50,5 +47,5 @@ G4double G4ErrorTarget::GetDistanceFromPoint( const G4ThreeVector& ) const
|
||||
|
||||
G4bool G4ErrorTarget::TargetReached(const G4Step*)
|
||||
{
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4GeomTools implementation
|
||||
//
|
||||
// Author: evgueni.tcherniaev@cern.ch
|
||||
//
|
||||
// 10.10.2016 E.Tcherniaev: initial version.
|
||||
// 10.10.2016, E.Tcherniaev: initial version.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GeomTools.hh"
|
||||
@@ -81,7 +76,7 @@ G4double G4GeomTools::QuadArea(const G4TwoVector& A,
|
||||
G4double G4GeomTools::PolygonArea(const G4TwoVectorList& p)
|
||||
{
|
||||
G4int n = p.size();
|
||||
if (n < 3) return 0; // degerate polygon
|
||||
if (n < 3) return 0.0; // degenerate polygon
|
||||
G4double area = p[n-1].x()*p[0].y() - p[0].x()*p[n-1].y();
|
||||
for(G4int i=1; i<n; ++i)
|
||||
{
|
||||
@@ -239,7 +234,7 @@ G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
// ERROR: if we loop, it is probably a non-simple polygon
|
||||
if ((count--) <= 0)
|
||||
{
|
||||
delete[] V;
|
||||
delete [] V;
|
||||
if (area < 0.) std::reverse(result.begin(),result.end());
|
||||
return false;
|
||||
}
|
||||
@@ -263,7 +258,7 @@ G4bool G4GeomTools::TriangulatePolygon(const G4TwoVectorList& polygon,
|
||||
count = 2*nv; // resest error detection counter
|
||||
}
|
||||
}
|
||||
delete[] V;
|
||||
delete [] V;
|
||||
if (area < 0.) std::reverse(result.begin(),result.end());
|
||||
return true;
|
||||
}
|
||||
@@ -313,7 +308,7 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
{
|
||||
iout.resize(0);
|
||||
// set tolerance squared
|
||||
G4double delta = tolerance*tolerance;
|
||||
G4double delta = sqr(tolerance);
|
||||
// set special value to mark vertices for removal
|
||||
G4double removeIt = kInfinity;
|
||||
|
||||
@@ -355,7 +350,7 @@ void G4GeomTools::RemoveRedundantVertices(G4TwoVectorList& polygon,
|
||||
G4double leng3 = (e2-e1).mag2();
|
||||
if (leng1 <= delta || leng2 <= delta || leng3 <= delta)
|
||||
{
|
||||
polygon[icur].setX(removeIt); nout++;
|
||||
polygon[icur].setX(removeIt); ++nout;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -363,7 +358,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -585,7 +580,8 @@ G4double G4GeomTools::comp_ellint_2(G4double e)
|
||||
G4double y = b;
|
||||
G4double S = 0.;
|
||||
G4double M = 1.;
|
||||
while (x - y > eps*y) {
|
||||
while (x - y > eps*y)
|
||||
{
|
||||
G4double tmp = (x + y) * 0.5;
|
||||
y = std::sqrt(x*y);
|
||||
x = tmp;
|
||||
|
||||
@@ -23,14 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Class G4GeometryManager implementation
|
||||
//
|
||||
//
|
||||
// class G4GeometryManager
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
// Author:
|
||||
// 26.07.95 P.Kent Initial version, including optimisation Build
|
||||
// 26.07.95, P.Kent - Initial version, including optimisation build
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <iomanip>
|
||||
@@ -59,7 +54,7 @@
|
||||
// Static class data
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4ThreadLocal G4GeometryManager* G4GeometryManager::fgInstance = 0;
|
||||
G4ThreadLocal G4GeometryManager* G4GeometryManager::fgInstance = nullptr;
|
||||
G4ThreadLocal G4bool G4GeometryManager::fIsClosed = false;
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -76,7 +71,7 @@ G4GeometryManager::G4GeometryManager()
|
||||
//
|
||||
G4GeometryManager::~G4GeometryManager()
|
||||
{
|
||||
fgInstance = 0;
|
||||
fgInstance = nullptr;
|
||||
fIsClosed = false;
|
||||
}
|
||||
|
||||
@@ -92,7 +87,7 @@ G4bool G4GeometryManager::CloseGeometry(G4bool pOptimise, G4bool verbose,
|
||||
{
|
||||
if (!fIsClosed)
|
||||
{
|
||||
if (pVolume)
|
||||
if (pVolume != nullptr)
|
||||
{
|
||||
BuildOptimisations(pOptimise, pVolume);
|
||||
}
|
||||
@@ -100,7 +95,7 @@ G4bool G4GeometryManager::CloseGeometry(G4bool pOptimise, G4bool verbose,
|
||||
{
|
||||
BuildOptimisations(pOptimise, verbose);
|
||||
}
|
||||
fIsClosed=true;
|
||||
fIsClosed = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -115,7 +110,7 @@ void G4GeometryManager::OpenGeometry(G4VPhysicalVolume* pVolume)
|
||||
{
|
||||
if (fIsClosed)
|
||||
{
|
||||
if (pVolume)
|
||||
if (pVolume != nullptr)
|
||||
{
|
||||
DeleteOptimisations(pVolume);
|
||||
}
|
||||
@@ -123,7 +118,7 @@ void G4GeometryManager::OpenGeometry(G4VPhysicalVolume* pVolume)
|
||||
{
|
||||
DeleteOptimisations();
|
||||
}
|
||||
fIsClosed=false;
|
||||
fIsClosed = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +138,7 @@ G4bool G4GeometryManager::IsGeometryClosed()
|
||||
//
|
||||
G4GeometryManager* G4GeometryManager::GetInstance()
|
||||
{
|
||||
if (!fgInstance)
|
||||
if (fgInstance == nullptr)
|
||||
{
|
||||
fgInstance = new G4GeometryManager;
|
||||
}
|
||||
@@ -175,7 +170,7 @@ void G4GeometryManager::BuildOptimisations(G4bool allOpts, G4bool verbose)
|
||||
G4LogicalVolume* volume;
|
||||
G4SmartVoxelHeader* head;
|
||||
|
||||
for (size_t n=0; n<Store->size(); n++)
|
||||
for (size_t n=0; n<Store->size(); ++n)
|
||||
{
|
||||
if (verbose) timer.Start();
|
||||
volume=(*Store)[n];
|
||||
@@ -197,7 +192,7 @@ void G4GeometryManager::BuildOptimisations(G4bool allOpts, G4bool verbose)
|
||||
<< volume->GetName() << G4endl;
|
||||
#endif
|
||||
head = new G4SmartVoxelHeader(volume);
|
||||
if (head)
|
||||
if (head != nullptr)
|
||||
{
|
||||
volume->SetVoxelHeader(head);
|
||||
}
|
||||
@@ -243,24 +238,24 @@ void G4GeometryManager::BuildOptimisations(G4bool allOpts, G4bool verbose)
|
||||
void G4GeometryManager::BuildOptimisations(G4bool allOpts,
|
||||
G4VPhysicalVolume* pVolume)
|
||||
{
|
||||
if (!pVolume) { return; }
|
||||
if (pVolume == nullptr) { return; }
|
||||
|
||||
// Retrieve the mother logical volume, if not NULL,
|
||||
// otherwise apply global optimisation for the world volume
|
||||
//
|
||||
G4LogicalVolume* tVolume = pVolume->GetMotherLogical();
|
||||
if (!tVolume) { return BuildOptimisations(allOpts, false); }
|
||||
if (tVolume == nullptr) { return BuildOptimisations(allOpts, false); }
|
||||
|
||||
G4SmartVoxelHeader* head = tVolume->GetVoxelHeader();
|
||||
delete head;
|
||||
tVolume->SetVoxelHeader(0);
|
||||
tVolume->SetVoxelHeader(nullptr);
|
||||
if ( ( (tVolume->IsToOptimise())
|
||||
&& (tVolume->GetNoDaughters()>=kMinVoxelVolumesLevel1&&allOpts) )
|
||||
|| ( (tVolume->GetNoDaughters()==1)
|
||||
&& (tVolume->GetDaughter(0)->IsReplicated()==true) ) )
|
||||
{
|
||||
head = new G4SmartVoxelHeader(tVolume);
|
||||
if (head)
|
||||
if (head != nullptr)
|
||||
{
|
||||
tVolume->SetVoxelHeader(head);
|
||||
}
|
||||
@@ -300,13 +295,13 @@ void G4GeometryManager::BuildOptimisations(G4bool allOpts,
|
||||
//
|
||||
void G4GeometryManager::DeleteOptimisations()
|
||||
{
|
||||
G4LogicalVolume* tVolume = 0;
|
||||
G4LogicalVolume* tVolume = nullptr;
|
||||
G4LogicalVolumeStore* Store = G4LogicalVolumeStore::GetInstance();
|
||||
for (size_t n=0; n<Store->size(); n++)
|
||||
for (size_t n=0; n<Store->size(); ++n)
|
||||
{
|
||||
tVolume=(*Store)[n];
|
||||
delete tVolume->GetVoxelHeader();
|
||||
tVolume->SetVoxelHeader(0);
|
||||
tVolume->SetVoxelHeader(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,9 +318,9 @@ void G4GeometryManager::DeleteOptimisations(G4VPhysicalVolume* pVolume)
|
||||
// otherwise global deletion to world volume.
|
||||
//
|
||||
G4LogicalVolume* tVolume = pVolume->GetMotherLogical();
|
||||
if (!tVolume) { return DeleteOptimisations(); }
|
||||
if (tVolume == nullptr) { return DeleteOptimisations(); }
|
||||
delete tVolume->GetVoxelHeader();
|
||||
tVolume->SetVoxelHeader(0);
|
||||
tVolume->SetVoxelHeader(nullptr);
|
||||
|
||||
// Scan recursively the associated logical volume tree
|
||||
//
|
||||
@@ -372,7 +367,7 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
|
||||
G4int i, nStat = stats.size();
|
||||
G4long totalMemory = 0;
|
||||
|
||||
for( i=0;i<nStat;++i ) { totalMemory += stats[i].GetMemoryUse(); }
|
||||
for( i=0; i<nStat; ++i ) { totalMemory += stats[i].GetMemoryUse(); }
|
||||
|
||||
G4cout << " Total memory consumed for geometry optimisation: "
|
||||
<< totalMemory/1024 << " kByte" << G4endl;
|
||||
@@ -400,7 +395,7 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
|
||||
// 12345678901.234567890123.234567890123.234567890123k .
|
||||
}
|
||||
|
||||
for(i=0;i<nPrint;++i)
|
||||
for(i=0; i<nPrint; ++i)
|
||||
{
|
||||
G4double total = stats[i].GetTotalTime();
|
||||
G4double system = stats[i].GetSysTime();
|
||||
@@ -443,7 +438,7 @@ G4GeometryManager::ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
|
||||
// 12345678901.2345678901k .23456789.23456789.2345678901.234567890123. .
|
||||
}
|
||||
|
||||
for(i=0;i<nPrint;++i)
|
||||
for(i=0; i<nPrint; ++i)
|
||||
{
|
||||
G4long memory = stats[i].GetMemoryUse();
|
||||
G4double totTime = stats[i].GetTotalTime();
|
||||
|
||||
@@ -23,8 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Class G4IdentityTrajectoryFilter implementation
|
||||
//
|
||||
//
|
||||
// First version: Nov 19, 2002 - Jacek Generowicz
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#include "G4IdentityTrajectoryFilter.hh"
|
||||
|
||||
@@ -23,13 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// Implementation of G4LogicalCrystalVolume
|
||||
//
|
||||
// 21-04-16, created by E.Bagli
|
||||
//
|
||||
// 21-04-16, created by E.Bagli
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4LogicalCrystalVolume.hh"
|
||||
@@ -47,19 +43,18 @@ G4LogicalCrystalVolume(G4VSolid* pSolid, G4ExtendedMaterial* pMaterial,
|
||||
G4VSensitiveDetector* pSDetector,
|
||||
G4UserLimits* pULimits, G4bool optimise,
|
||||
G4int h, G4int k, G4int l, G4double rot)
|
||||
: G4LogicalVolume(pSolid,pMaterial,name,pFieldMgr,pSDetector,pULimits,optimise),
|
||||
hMiller(1), kMiller(0), lMiller(0), fRot(0), verboseLevel(0)
|
||||
: G4LogicalVolume(pSolid,pMaterial,name,pFieldMgr,pSDetector,pULimits,optimise)
|
||||
{
|
||||
SetMillerOrientation(h, k, l, rot);
|
||||
fLCVvec.push_back(this);
|
||||
SetMillerOrientation(h, k, l, rot);
|
||||
fLCVvec.push_back(this);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
G4LogicalCrystalVolume::~G4LogicalCrystalVolume()
|
||||
{
|
||||
fLCVvec.erase( std::remove(fLCVvec.begin(),fLCVvec.end(), this ),
|
||||
fLCVvec.end() );
|
||||
fLCVvec.erase( std::remove(fLCVvec.begin(),fLCVvec.end(), this ),
|
||||
fLCVvec.end() );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -73,7 +68,8 @@ G4bool G4LogicalCrystalVolume::IsLattice(G4LogicalVolume* aLV)
|
||||
|
||||
const G4CrystalExtension* G4LogicalCrystalVolume::GetCrystal() const
|
||||
{
|
||||
return dynamic_cast<G4CrystalExtension*>(dynamic_cast<G4ExtendedMaterial*>(GetMaterial())
|
||||
return dynamic_cast<G4CrystalExtension*>(
|
||||
dynamic_cast<G4ExtendedMaterial*>(GetMaterial() )
|
||||
->RetrieveExtension("crystal"));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,27 +23,16 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4LogicalSurface class implementation
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// G4LogicalSurface Class Implementation
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Created: John Apostolakis & Peter Gumplinger, 26-06-1997
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#include "G4LogicalSurface.hh"
|
||||
|
||||
////////////////////////////
|
||||
// Constructors & Destructor
|
||||
////////////////////////////
|
||||
|
||||
G4LogicalSurface::G4LogicalSurface(const G4String& name,
|
||||
G4SurfaceProperty* surfaceProperty)
|
||||
: theName(name), theSurfaceProperty(surfaceProperty), theTransRadSurface(0)
|
||||
{
|
||||
}
|
||||
|
||||
G4LogicalSurface::G4LogicalSurface(const G4LogicalSurface &r)
|
||||
: theName(r.theName), theSurfaceProperty(r.theSurfaceProperty),
|
||||
theTransRadSurface(r.theTransRadSurface)
|
||||
: theName(name), theSurfaceProperty(surfaceProperty)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -22,19 +22,14 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4LogicalVolume Implementation
|
||||
// class G4LogicalVolume implementation
|
||||
//
|
||||
// History:
|
||||
// 15.01.13 G.Cosmo, A.Dotti: Modified for thread-safety for MT
|
||||
// 01.03.05 G.Santin: Added flag for optional propagation of GetMass()
|
||||
// 17.05.02 G.Cosmo: Added flag for optional optimisation
|
||||
// 12.02.99 S.Giani: Default initialization of voxelization quality
|
||||
// 04.08.97 P.M.DeFreitas: Added methods for parameterised simulation
|
||||
// 19.08.96 P.Kent: Modified for G4VSensitive Detector
|
||||
// 11.07.95 P.Kent: Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -47,10 +42,7 @@
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
G4LVData::G4LVData()
|
||||
: fSolid(0),fSensitiveDetector(0),fFieldManager(0),
|
||||
fMaterial(0),fMass(0.),fCutsCouple(0)
|
||||
{;}
|
||||
G4LVData::G4LVData() {;}
|
||||
|
||||
// This new field helps to use the class G4LVManager
|
||||
//
|
||||
@@ -80,9 +72,8 @@ G4LogicalVolume::G4LogicalVolume( G4VSolid* pSolid,
|
||||
G4VSensitiveDetector* pSDetector,
|
||||
G4UserLimits* pULimits,
|
||||
G4bool optimise )
|
||||
: fDaughters(0,(G4VPhysicalVolume*)0),
|
||||
fVoxel(0), fOptimise(optimise), fRootRegion(false), fLock(false),
|
||||
fSmartless(2.), fVisAttributes(0), fRegion(0), fBiasWeight(1.)
|
||||
: fDaughters(0,(G4VPhysicalVolume*)nullptr), fDaughtersVolumeType(kNormal),
|
||||
fOptimise(optimise)
|
||||
{
|
||||
// Initialize 'Shadow'/master pointers - for use in copying to workers
|
||||
//
|
||||
@@ -94,7 +85,7 @@ G4LogicalVolume::G4LogicalVolume( G4VSolid* pSolid,
|
||||
AssignFieldManager(pFieldMgr);
|
||||
|
||||
G4MT_mass = 0.;
|
||||
G4MT_ccouple = 0;
|
||||
G4MT_ccouple = nullptr;
|
||||
|
||||
SetSolid(pSolid);
|
||||
SetMaterial(pMaterial);
|
||||
@@ -120,19 +111,15 @@ G4LogicalVolume::G4LogicalVolume( G4VSolid* pSolid,
|
||||
// ********************************************************************
|
||||
//
|
||||
G4LogicalVolume::G4LogicalVolume( __void__& )
|
||||
: fDaughters(0,(G4VPhysicalVolume*)0),
|
||||
fName(""), fUserLimits(0),
|
||||
fVoxel(0), fOptimise(true), fRootRegion(false), fLock(false),
|
||||
fSmartless(2.), fVisAttributes(0), fRegion(0), fBiasWeight(1.),
|
||||
fSolid(0), fSensitiveDetector(0), fFieldManager(0), lvdata(0)
|
||||
: fDaughters(0,(G4VPhysicalVolume*)nullptr), fName("")
|
||||
{
|
||||
instanceID = subInstanceManager.CreateSubInstance();
|
||||
|
||||
SetSensitiveDetector(0); // G4MT_sdetector = 0;
|
||||
SetFieldManager(0, false); // G4MT_fmanager = 0;
|
||||
SetSensitiveDetector(nullptr); // G4MT_sdetector = nullptr;
|
||||
SetFieldManager(nullptr, false); // G4MT_fmanager = nullptr;
|
||||
|
||||
G4MT_mass = 0.;
|
||||
G4MT_ccouple = 0;
|
||||
G4MT_ccouple = nullptr;
|
||||
|
||||
// Add to store
|
||||
//
|
||||
@@ -180,7 +167,7 @@ InitialiseWorker( G4LogicalVolume* /*pMasterObject*/,
|
||||
#ifdef CLONE_FIELD_MGR
|
||||
// Create a field FieldManager by cloning
|
||||
//
|
||||
G4FieldManager workerFldMgr= fFieldManager->GetWorkerClone(G4bool* created);
|
||||
G4FieldManager workerFldMgr = fFieldManager->GetWorkerClone(G4bool* created);
|
||||
if( created || (GetFieldManager() != workerFldMgr) )
|
||||
{
|
||||
SetFieldManager(fFieldManager, false); // which propagates FieldMgr
|
||||
@@ -265,12 +252,12 @@ G4LogicalVolume::SetFieldManager(G4FieldManager* pNewFieldMgr,
|
||||
{
|
||||
AssignFieldManager(pNewFieldMgr);
|
||||
|
||||
G4int NoDaughters = GetNoDaughters();
|
||||
auto NoDaughters = GetNoDaughters();
|
||||
while ( (NoDaughters--)>0 )
|
||||
{
|
||||
G4LogicalVolume* DaughterLogVol;
|
||||
DaughterLogVol = GetDaughter(NoDaughters)->GetLogicalVolume();
|
||||
if ( forceAllDaughters || (DaughterLogVol->GetFieldManager() == 0) )
|
||||
if ( forceAllDaughters || (DaughterLogVol->GetFieldManager() == nullptr) )
|
||||
{
|
||||
DaughterLogVol->SetFieldManager(pNewFieldMgr, forceAllDaughters);
|
||||
}
|
||||
@@ -283,18 +270,56 @@ G4LogicalVolume::SetFieldManager(G4FieldManager* pNewFieldMgr,
|
||||
//
|
||||
void G4LogicalVolume::AddDaughter(G4VPhysicalVolume* pNewDaughter)
|
||||
{
|
||||
if( !fDaughters.empty() && fDaughters[0]->IsReplicated() )
|
||||
EVolume daughterType = pNewDaughter->VolumeType();
|
||||
|
||||
// The type of the navigation needed is determined by the first daughter
|
||||
//
|
||||
if( fDaughters.empty() )
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "ERROR - Attempt to place a volume in a mother volume" << G4endl
|
||||
<< " already containing a replicated volume." << G4endl
|
||||
<< " A volume can either contain several placements" << G4endl
|
||||
<< " or a unique replica or parameterised volume !" << G4endl
|
||||
<< " Mother logical volume: " << GetName() << G4endl
|
||||
<< " Placing volume: " << pNewDaughter->GetName() << G4endl;
|
||||
G4Exception("G4LogicalVolume::AddDaughter()", "GeomMgt0002",
|
||||
FatalException, message,
|
||||
"Replica or parameterised volume must be the only daughter !");
|
||||
fDaughtersVolumeType = daughterType;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check consistency of detector description
|
||||
|
||||
// 1. A replica or parameterised volume can have only one daughter
|
||||
//
|
||||
if( fDaughters[0]->IsReplicated() )
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "ERROR - Attempt to place a volume in a mother volume"
|
||||
<< G4endl
|
||||
<< " already containing a replicated volume." << G4endl
|
||||
<< " A volume can either contain several placements" << G4endl
|
||||
<< " or a unique replica or parameterised volume !" << G4endl
|
||||
<< " Mother logical volume: " << GetName() << G4endl
|
||||
<< " Placing volume: " << pNewDaughter->GetName()
|
||||
<< G4endl;
|
||||
G4Exception("G4LogicalVolume::AddDaughter()", "GeomMgt0002",
|
||||
FatalException, message,
|
||||
"Replica or parameterised volume must be the only daughter!");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 2. Ensure that Placement and External physical volumes do not mix
|
||||
//
|
||||
if( daughterType != fDaughtersVolumeType )
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "ERROR - Attempt to place a volume in a mother volume"
|
||||
<< G4endl
|
||||
<< " already containing a different type of volume." << G4endl
|
||||
<< " A volume can either contain" << G4endl
|
||||
<< " - one or more placements, OR" << G4endl
|
||||
<< " - one or more 'external' type physical volumes." << G4endl
|
||||
<< " Mother logical volume: " << GetName() << G4endl
|
||||
<< " Volume being placed: " << pNewDaughter->GetName()
|
||||
<< G4endl;
|
||||
G4Exception("G4LogicalVolume::AddDaughter()", "GeomMgt0002",
|
||||
FatalException, message,
|
||||
"Cannot mix placements and external physical volumes !");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Invalidate previous calculation of mass - if any - for all threads
|
||||
@@ -311,7 +336,7 @@ void G4LogicalVolume::AddDaughter(G4VPhysicalVolume* pNewDaughter)
|
||||
// Avoid propagating the fieldManager pointer if null
|
||||
// and daughter's one is null as well...
|
||||
//
|
||||
if( (G4MT_fmanager !=0 ) && (pDaughterFieldManager == 0) )
|
||||
if( (G4MT_fmanager != nullptr ) && (pDaughterFieldManager == nullptr) )
|
||||
{
|
||||
pDaughterLogical->SetFieldManager(G4MT_fmanager, false);
|
||||
}
|
||||
@@ -328,8 +353,7 @@ void G4LogicalVolume::AddDaughter(G4VPhysicalVolume* pNewDaughter)
|
||||
//
|
||||
void G4LogicalVolume::RemoveDaughter(const G4VPhysicalVolume* p)
|
||||
{
|
||||
G4PhysicalVolumeList::iterator i;
|
||||
for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i )
|
||||
for (auto i=fDaughters.cbegin(); i!=fDaughters.cend(); ++i )
|
||||
{
|
||||
if (**i==*p)
|
||||
{
|
||||
@@ -350,8 +374,8 @@ void G4LogicalVolume::RemoveDaughter(const G4VPhysicalVolume* p)
|
||||
//
|
||||
void G4LogicalVolume::ClearDaughters()
|
||||
{
|
||||
fDaughters.erase(fDaughters.begin(), fDaughters.end());
|
||||
if (fRegion)
|
||||
fDaughters.erase(fDaughters.cbegin(), fDaughters.cend());
|
||||
if (fRegion != nullptr)
|
||||
{
|
||||
fRegion->RegionModified(true);
|
||||
}
|
||||
@@ -392,11 +416,10 @@ void G4LogicalVolume::SetSolid(G4VSolid *pSolid)
|
||||
this->ResetMass();
|
||||
}
|
||||
|
||||
void G4LogicalVolume::SetSolid(G4LVData &instLVdata, G4VSolid *pSolid)
|
||||
void G4LogicalVolume::SetSolid(G4LVData& instLVdata, G4VSolid* pSolid)
|
||||
{
|
||||
instLVdata.fSolid = pSolid;
|
||||
instLVdata.fMass= 0;
|
||||
// A fast way to reset the mass... i.e. G4MT_mass = 0.;
|
||||
instLVdata.fMass = 0.0;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
@@ -412,21 +435,21 @@ G4Material* G4LogicalVolume::GetMaterial() const
|
||||
// SetMaterial
|
||||
// ********************************************************************
|
||||
//
|
||||
void G4LogicalVolume::SetMaterial(G4Material *pMaterial)
|
||||
void G4LogicalVolume::SetMaterial(G4Material* pMaterial)
|
||||
{
|
||||
G4MT_material = pMaterial;
|
||||
G4MT_mass = 0.;
|
||||
G4MT_mass = 0.0;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// UpdateMaterial
|
||||
// ********************************************************************
|
||||
//
|
||||
void G4LogicalVolume::UpdateMaterial(G4Material *pMaterial)
|
||||
void G4LogicalVolume::UpdateMaterial(G4Material* pMaterial)
|
||||
{
|
||||
G4MT_material=pMaterial;
|
||||
if (fRegion) { G4MT_ccouple = fRegion->FindCouple(pMaterial); }
|
||||
G4MT_mass = 0.;
|
||||
if (fRegion != nullptr) { G4MT_ccouple = fRegion->FindCouple(pMaterial); }
|
||||
G4MT_mass = 0.0;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
@@ -479,8 +502,7 @@ G4LogicalVolume::IsAncestor(const G4VPhysicalVolume* aVolume) const
|
||||
G4bool isDaughter = IsDaughter(aVolume);
|
||||
if (!isDaughter)
|
||||
{
|
||||
for (G4PhysicalVolumeList::const_iterator itDau = fDaughters.begin();
|
||||
itDau != fDaughters.end(); itDau++)
|
||||
for (auto itDau = fDaughters.cbegin(); itDau != fDaughters.cend(); ++itDau)
|
||||
{
|
||||
isDaughter = (*itDau)->GetLogicalVolume()->IsAncestor(aVolume);
|
||||
if (isDaughter) break;
|
||||
@@ -499,8 +521,7 @@ G4LogicalVolume::IsAncestor(const G4VPhysicalVolume* aVolume) const
|
||||
G4int G4LogicalVolume::TotalVolumeEntities() const
|
||||
{
|
||||
G4int vols = 1;
|
||||
for (G4PhysicalVolumeList::const_iterator itDau = fDaughters.begin();
|
||||
itDau != fDaughters.end(); itDau++)
|
||||
for (auto itDau = fDaughters.cbegin(); itDau != fDaughters.cend(); ++itDau)
|
||||
{
|
||||
G4VPhysicalVolume* physDaughter = (*itDau);
|
||||
vols += physDaughter->GetMultiplicity()
|
||||
@@ -540,7 +561,7 @@ G4double G4LogicalVolume::GetMass(G4bool forced,
|
||||
// volume without considering its daughters
|
||||
//
|
||||
G4Material* logMaterial = parMaterial ? parMaterial : GetMaterial();
|
||||
if (!logMaterial)
|
||||
if (logMaterial == nullptr)
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "No material associated to the logical volume: "
|
||||
@@ -548,9 +569,9 @@ G4double G4LogicalVolume::GetMass(G4bool forced,
|
||||
<< "Sorry, cannot compute the mass ...";
|
||||
G4Exception("G4LogicalVolume::GetMass()", "GeomMgt0002",
|
||||
FatalException, message);
|
||||
return 0;
|
||||
return 0.0;
|
||||
}
|
||||
if ( !GetSolid() )
|
||||
if ( GetSolid() == nullptr )
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "No solid is associated to the logical volume: "
|
||||
@@ -558,30 +579,29 @@ G4double G4LogicalVolume::GetMass(G4bool forced,
|
||||
<< "Sorry, cannot compute the mass ...";
|
||||
G4Exception("G4LogicalVolume::GetMass()", "GeomMgt0002",
|
||||
FatalException, message);
|
||||
return 0;
|
||||
return 0.0;
|
||||
}
|
||||
G4double globalDensity = logMaterial->GetDensity();
|
||||
G4double motherMass= GetSolid()->GetCubicVolume() * globalDensity;
|
||||
G4double motherMass = GetSolid()->GetCubicVolume() * globalDensity;
|
||||
G4double massSum = motherMass;
|
||||
|
||||
// For each daughter in the tree, subtract the mass occupied
|
||||
// and if required by the propagate flag, add the real daughter's
|
||||
// one computed recursively
|
||||
|
||||
for (G4PhysicalVolumeList::const_iterator itDau = fDaughters.begin();
|
||||
itDau != fDaughters.end(); itDau++)
|
||||
for (auto itDau = fDaughters.cbegin(); itDau != fDaughters.cend(); ++itDau)
|
||||
{
|
||||
G4VPhysicalVolume* physDaughter = (*itDau);
|
||||
G4LogicalVolume* logDaughter = physDaughter->GetLogicalVolume();
|
||||
G4double subMass=0.;
|
||||
G4VSolid* daughterSolid = 0;
|
||||
G4Material* daughterMaterial = 0;
|
||||
G4double subMass = 0.0;
|
||||
G4VSolid* daughterSolid = nullptr;
|
||||
G4Material* daughterMaterial = nullptr;
|
||||
|
||||
// Compute the mass to subtract and to add for each daughter
|
||||
// considering its multiplicity (i.e. replicated or not) and
|
||||
// eventually its parameterisation (by solid and/or by material)
|
||||
//
|
||||
for (G4int i=0; i<physDaughter->GetMultiplicity(); i++)
|
||||
for (auto i=0; i<physDaughter->GetMultiplicity(); ++i)
|
||||
{
|
||||
G4VPVParameterisation* physParam = physDaughter->GetParameterisation();
|
||||
if (physParam)
|
||||
@@ -607,7 +627,7 @@ G4double G4LogicalVolume::GetMass(G4bool forced,
|
||||
}
|
||||
}
|
||||
}
|
||||
G4MT_mass= massSum;
|
||||
G4MT_mass = massSum;
|
||||
return massSum;
|
||||
}
|
||||
|
||||
@@ -615,3 +635,35 @@ void G4LogicalVolume::SetVisAttributes (const G4VisAttributes& VA)
|
||||
{
|
||||
fVisAttributes = new G4VisAttributes(VA);
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// Change the daughters volume type -- checking proposed values
|
||||
//
|
||||
// Undertakes primitive checking, to ensure that only 'legal' changes
|
||||
// are made:
|
||||
// - any type to 'external' ( user responsibility )
|
||||
// - the type proposed is checked against the deduced type
|
||||
// (for potential switch back to 'internal' type.)
|
||||
// Returns success (true) or failure (false)
|
||||
//
|
||||
G4bool G4LogicalVolume::ChangeDaughtersType(EVolume aType)
|
||||
{
|
||||
G4bool works = false;
|
||||
if( aType == kExternal )
|
||||
{
|
||||
// It is the responsibility of External Navigator to handle types selected
|
||||
//
|
||||
fDaughtersVolumeType = aType;
|
||||
works = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
EVolume expectedVType = DeduceDaughtersType();
|
||||
works = (expectedVType == aType);
|
||||
if ( works )
|
||||
{
|
||||
fDaughtersVolumeType = aType;
|
||||
}
|
||||
}
|
||||
return works;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4LogicalVolumeStore implementation for singleton container
|
||||
//
|
||||
//
|
||||
// G4LogicalVolumeStore
|
||||
//
|
||||
// Implementation for singleton container
|
||||
//
|
||||
// History:
|
||||
// 10.07.95 P.Kent Initial version
|
||||
// 10.07.95 - P.Kent, Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4Types.hh"
|
||||
@@ -41,8 +36,8 @@
|
||||
// Static class variables
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4LogicalVolumeStore* G4LogicalVolumeStore::fgInstance = 0;
|
||||
G4ThreadLocal G4VStoreNotifier* G4LogicalVolumeStore::fgNotifier = 0;
|
||||
G4LogicalVolumeStore* G4LogicalVolumeStore::fgInstance = nullptr;
|
||||
G4ThreadLocal G4VStoreNotifier* G4LogicalVolumeStore::fgNotifier = nullptr;
|
||||
G4ThreadLocal G4bool G4LogicalVolumeStore::locked = false;
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -86,18 +81,18 @@ void G4LogicalVolumeStore::Clean()
|
||||
//
|
||||
locked = true;
|
||||
|
||||
size_t i=0;
|
||||
size_t i = 0;
|
||||
G4LogicalVolumeStore* store = GetInstance();
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
G4cout << "Deleting Logical Volumes ... ";
|
||||
#endif
|
||||
|
||||
for(iterator pos=store->begin(); pos!=store->end(); pos++)
|
||||
for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
if (*pos) { (*pos)->Lock(); delete *pos; }
|
||||
i++;
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
if (*pos != nullptr) { (*pos)->Lock(); delete *pos; }
|
||||
++i;
|
||||
}
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
@@ -139,8 +134,8 @@ void G4LogicalVolumeStore::DeRegister(G4LogicalVolume* pVolume)
|
||||
{
|
||||
if (!locked) // Do not de-register if locked !
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
if (**i==*pVolume)
|
||||
{
|
||||
@@ -158,7 +153,7 @@ void G4LogicalVolumeStore::DeRegister(G4LogicalVolume* pVolume)
|
||||
G4LogicalVolume*
|
||||
G4LogicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
if ((*i)->GetName() == name) { return *i; }
|
||||
}
|
||||
@@ -181,7 +176,7 @@ G4LogicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
|
||||
G4LogicalVolumeStore* G4LogicalVolumeStore::GetInstance()
|
||||
{
|
||||
static G4LogicalVolumeStore worldStore;
|
||||
if (!fgInstance)
|
||||
if (fgInstance == nullptr)
|
||||
{
|
||||
fgInstance = &worldStore;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4PhysicalVolumeStore implementation for singleton container
|
||||
//
|
||||
//
|
||||
// G4PhysicalVolumeStore
|
||||
//
|
||||
// Implementation for singleton container
|
||||
//
|
||||
// History:
|
||||
// 25.07.95 P.Kent Initial version
|
||||
// 25.07.95, P.Kent - Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4Types.hh"
|
||||
@@ -42,8 +37,8 @@
|
||||
// Static class variables
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4PhysicalVolumeStore* G4PhysicalVolumeStore::fgInstance = 0;
|
||||
G4ThreadLocal G4VStoreNotifier* G4PhysicalVolumeStore::fgNotifier = 0;
|
||||
G4PhysicalVolumeStore* G4PhysicalVolumeStore::fgInstance = nullptr;
|
||||
G4ThreadLocal G4VStoreNotifier* G4PhysicalVolumeStore::fgNotifier = nullptr;
|
||||
G4ThreadLocal G4bool G4PhysicalVolumeStore::locked = false;
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -95,11 +90,10 @@ void G4PhysicalVolumeStore::Clean()
|
||||
G4cout << "Deleting Physical Volumes ... ";
|
||||
#endif
|
||||
|
||||
for(iterator pos=store->begin(); pos!=store->end(); pos++)
|
||||
for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
if (*pos) { delete *pos; }
|
||||
i++;
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
delete *pos; ++i;
|
||||
}
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
@@ -142,10 +136,10 @@ void G4PhysicalVolumeStore::DeRegister(G4VPhysicalVolume* pVolume)
|
||||
{
|
||||
if (!locked) // Do not de-register if locked !
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
G4LogicalVolume* motherLogical = pVolume->GetMotherLogical();
|
||||
if (motherLogical) { motherLogical->RemoveDaughter(pVolume); }
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
if (motherLogical != nullptr) { motherLogical->RemoveDaughter(pVolume); }
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
if (**i==*pVolume)
|
||||
{
|
||||
@@ -163,7 +157,7 @@ void G4PhysicalVolumeStore::DeRegister(G4VPhysicalVolume* pVolume)
|
||||
G4VPhysicalVolume*
|
||||
G4PhysicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
if ((*i)->GetName() == name) { return *i; }
|
||||
}
|
||||
@@ -176,7 +170,7 @@ G4PhysicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
|
||||
G4Exception("G4PhysicalVolumeStore::GetVolume()",
|
||||
"GeomMgt1001", JustWarning, message);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -186,7 +180,7 @@ G4PhysicalVolumeStore::GetVolume(const G4String& name, G4bool verbose) const
|
||||
G4PhysicalVolumeStore* G4PhysicalVolumeStore::GetInstance()
|
||||
{
|
||||
static G4PhysicalVolumeStore worldStore;
|
||||
if (!fgInstance)
|
||||
if (fgInstance == nullptr)
|
||||
{
|
||||
fgInstance = &worldStore;
|
||||
}
|
||||
|
||||
@@ -23,13 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// Implementation for G4ReflectedSolid class
|
||||
//
|
||||
// Author: Vladimir Grichine, 23.07.01 (Vladimir.Grichine@cern.ch)
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ReflectedSolid.hh"
|
||||
@@ -55,7 +51,7 @@
|
||||
G4ReflectedSolid::G4ReflectedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4Transform3D& transform )
|
||||
: G4VSolid(pName), fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(pName)
|
||||
{
|
||||
fPtrSolid = pSolid;
|
||||
fDirectTransform3D = new G4Transform3D(transform);
|
||||
@@ -66,16 +62,15 @@ G4ReflectedSolid::G4ReflectedSolid( const G4String& pName,
|
||||
|
||||
G4ReflectedSolid::~G4ReflectedSolid()
|
||||
{
|
||||
delete fDirectTransform3D; fDirectTransform3D=0;
|
||||
delete fpPolyhedron; fpPolyhedron = 0;
|
||||
delete fDirectTransform3D; fDirectTransform3D = nullptr;
|
||||
delete fpPolyhedron; fpPolyhedron = nullptr;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
G4ReflectedSolid::G4ReflectedSolid(const G4ReflectedSolid& rhs)
|
||||
: G4VSolid(rhs), fPtrSolid(rhs.fPtrSolid),
|
||||
fRebuildPolyhedron(false), fpPolyhedron(0)
|
||||
: G4VSolid(rhs), fPtrSolid(rhs.fPtrSolid)
|
||||
{
|
||||
fDirectTransform3D = new G4Transform3D(*rhs.fDirectTransform3D);
|
||||
}
|
||||
@@ -95,11 +90,11 @@ G4ReflectedSolid& G4ReflectedSolid::operator=(const G4ReflectedSolid& rhs)
|
||||
|
||||
// Copy data
|
||||
//
|
||||
fPtrSolid= rhs.fPtrSolid;
|
||||
fPtrSolid = rhs.fPtrSolid;
|
||||
delete fDirectTransform3D;
|
||||
fDirectTransform3D= new G4Transform3D(*rhs.fDirectTransform3D);
|
||||
fDirectTransform3D = new G4Transform3D(*rhs.fDirectTransform3D);
|
||||
fRebuildPolyhedron = false;
|
||||
delete fpPolyhedron; fpPolyhedron= 0;
|
||||
delete fpPolyhedron; fpPolyhedron = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -137,7 +132,7 @@ G4Transform3D G4ReflectedSolid::GetTransform3D() const
|
||||
|
||||
G4Transform3D G4ReflectedSolid::GetDirectTransform3D() const
|
||||
{
|
||||
G4Transform3D aTransform= *fDirectTransform3D;
|
||||
G4Transform3D aTransform = *fDirectTransform3D;
|
||||
return aTransform;
|
||||
}
|
||||
|
||||
@@ -310,8 +305,8 @@ G4double
|
||||
G4ReflectedSolid::DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm,
|
||||
G4bool *validNorm,
|
||||
G4ThreeVector *n ) const
|
||||
G4bool* validNorm,
|
||||
G4ThreeVector* n ) const
|
||||
{
|
||||
G4ThreeVector solNorm;
|
||||
|
||||
@@ -360,7 +355,7 @@ G4ReflectedSolid::ComputeDimensions( G4VPVParameterisation*,
|
||||
|
||||
G4ThreeVector G4ReflectedSolid::GetPointOnSurface() const
|
||||
{
|
||||
G4ThreeVector p = fPtrSolid->GetPointOnSurface();
|
||||
G4ThreeVector p = fPtrSolid->GetPointOnSurface();
|
||||
return (*fDirectTransform3D)*G4Point3D(p);
|
||||
}
|
||||
|
||||
@@ -418,7 +413,7 @@ G4Polyhedron*
|
||||
G4ReflectedSolid::CreatePolyhedron () const
|
||||
{
|
||||
G4Polyhedron* polyhedron = fPtrSolid->CreatePolyhedron();
|
||||
if (polyhedron)
|
||||
if (polyhedron != nullptr)
|
||||
{
|
||||
polyhedron->Transform(*fDirectTransform3D);
|
||||
return polyhedron;
|
||||
@@ -431,7 +426,7 @@ G4ReflectedSolid::CreatePolyhedron () const
|
||||
<< "corresponding polyhedron. Returning NULL!";
|
||||
G4Exception("G4ReflectedSolid::CreatePolyhedron()",
|
||||
"GeomMgt1001", JustWarning, message);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,10 +437,9 @@ G4ReflectedSolid::CreatePolyhedron () const
|
||||
G4Polyhedron*
|
||||
G4ReflectedSolid::GetPolyhedron () const
|
||||
{
|
||||
if (!fpPolyhedron ||
|
||||
fRebuildPolyhedron ||
|
||||
fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps())
|
||||
if ((fpPolyhedron == nullptr) || fRebuildPolyhedron ||
|
||||
(fpPolyhedron->GetNumberOfRotationStepsAtTimeOfCreation() !=
|
||||
fpPolyhedron->GetNumberOfRotationSteps()))
|
||||
{
|
||||
fpPolyhedron = CreatePolyhedron();
|
||||
fRebuildPolyhedron = false;
|
||||
|
||||
@@ -22,12 +22,10 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4Region Implementation
|
||||
// G4Region class implementation
|
||||
//
|
||||
// 18.09.02, G.Cosmo - Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4Region.hh"
|
||||
@@ -65,17 +63,15 @@ const G4RegionManager& G4Region::GetSubInstanceManager()
|
||||
// *******************************************************************
|
||||
//
|
||||
G4Region::G4Region(const G4String& pName)
|
||||
: fName(pName), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0),
|
||||
fFieldManager(0), fWorldPhys(0),
|
||||
fInMassGeometry(false), fInParallelGeometry(false)
|
||||
: fName(pName)
|
||||
{
|
||||
|
||||
instanceID = subInstanceManager.CreateSubInstance();
|
||||
G4MT_fsmanager = 0;
|
||||
G4MT_rsaction = 0;
|
||||
G4MT_fsmanager = nullptr;
|
||||
G4MT_rsaction = nullptr;
|
||||
|
||||
G4RegionStore* rStore = G4RegionStore::GetInstance();
|
||||
if (rStore->GetRegion(pName,false))
|
||||
if (rStore->GetRegion(pName, false))
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "The region has NOT been registered !" << G4endl
|
||||
@@ -96,13 +92,11 @@ G4Region::G4Region(const G4String& pName)
|
||||
// ********************************************************************
|
||||
//
|
||||
G4Region::G4Region( __void__& )
|
||||
: fName(""), fRegionMod(true), fCut(0), fUserInfo(0), fUserLimits(0),
|
||||
fFieldManager(0), fWorldPhys(0),
|
||||
fInMassGeometry(false), fInParallelGeometry(false)
|
||||
: fName("")
|
||||
{
|
||||
instanceID = subInstanceManager.CreateSubInstance();
|
||||
G4MT_fsmanager = 0;
|
||||
G4MT_rsaction = 0;
|
||||
G4MT_fsmanager = nullptr;
|
||||
G4MT_rsaction = nullptr;
|
||||
|
||||
// Register to store
|
||||
//
|
||||
@@ -117,7 +111,7 @@ G4Region::G4Region( __void__& )
|
||||
G4Region::~G4Region()
|
||||
{
|
||||
G4RegionStore::GetInstance()->DeRegister(this);
|
||||
if(fUserInfo) delete fUserInfo;
|
||||
if(fUserInfo != nullptr) { delete fUserInfo; }
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
@@ -170,10 +164,10 @@ void G4Region::ScanVolumeTree(G4LogicalVolume* lv, G4bool region)
|
||||
// If logical volume is going to become a region, add
|
||||
// its material to the list if not already present
|
||||
//
|
||||
G4Region* currentRegion = 0;
|
||||
G4Region* currentRegion = nullptr;
|
||||
size_t noDaughters = lv->GetNoDaughters();
|
||||
G4Material* volMat = lv->GetMaterial();
|
||||
if(!volMat && fInMassGeometry)
|
||||
if((volMat == nullptr) && fInMassGeometry)
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Logical volume <" << lv->GetName() << ">" << G4endl
|
||||
@@ -186,11 +180,11 @@ void G4Region::ScanVolumeTree(G4LogicalVolume* lv, G4bool region)
|
||||
if (region)
|
||||
{
|
||||
currentRegion = this;
|
||||
if (volMat)
|
||||
if (volMat != nullptr)
|
||||
{
|
||||
AddMaterial(volMat);
|
||||
G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
|
||||
if (baseMat) { AddMaterial(baseMat); }
|
||||
if (baseMat != nullptr) { AddMaterial(baseMat); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,10 +205,10 @@ void G4Region::ScanVolumeTree(G4LogicalVolume* lv, G4bool region)
|
||||
//
|
||||
G4VPVParameterisation* pParam = daughterPVol->GetParameterisation();
|
||||
|
||||
if (pParam->GetMaterialScanner())
|
||||
if (pParam->GetMaterialScanner() != nullptr)
|
||||
{
|
||||
size_t matNo = pParam->GetMaterialScanner()->GetNumberOfMaterials();
|
||||
for (size_t mat=0; mat<matNo; mat++)
|
||||
for (size_t mat=0; mat<matNo; ++mat)
|
||||
{
|
||||
volMat = pParam->GetMaterialScanner()->GetMaterial(mat);
|
||||
if(!volMat && fInMassGeometry)
|
||||
@@ -228,21 +222,21 @@ void G4Region::ScanVolumeTree(G4LogicalVolume* lv, G4bool region)
|
||||
G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
|
||||
FatalException, message, "Check your parameterisation.");
|
||||
}
|
||||
if (volMat)
|
||||
if (volMat != nullptr)
|
||||
{
|
||||
AddMaterial(volMat);
|
||||
G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
|
||||
if (baseMat) { AddMaterial(baseMat); }
|
||||
if (baseMat != nullptr) { AddMaterial(baseMat); }
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t repNo = daughterPVol->GetMultiplicity();
|
||||
for (size_t rep=0; rep<repNo; rep++)
|
||||
for (size_t rep=0; rep<repNo; ++rep)
|
||||
{
|
||||
volMat = pParam->ComputeMaterial(rep, daughterPVol);
|
||||
if(!volMat && fInMassGeometry)
|
||||
if((volMat == nullptr) && fInMassGeometry)
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "The parameterisation for the physical volume <"
|
||||
@@ -253,11 +247,11 @@ void G4Region::ScanVolumeTree(G4LogicalVolume* lv, G4bool region)
|
||||
G4Exception("G4Region::ScanVolumeTree()", "GeomMgt0002",
|
||||
FatalException, message, "Check your parameterisation.");
|
||||
}
|
||||
if(volMat)
|
||||
if(volMat != nullptr)
|
||||
{
|
||||
AddMaterial(volMat);
|
||||
G4Material* baseMat = const_cast<G4Material*>(volMat->GetBaseMaterial());
|
||||
if (baseMat) { AddMaterial(baseMat); }
|
||||
if (baseMat != nullptr) { AddMaterial(baseMat); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -266,7 +260,7 @@ void G4Region::ScanVolumeTree(G4LogicalVolume* lv, G4bool region)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i=0; i<noDaughters; i++)
|
||||
for (size_t i=0; i<noDaughters; ++i)
|
||||
{
|
||||
G4LogicalVolume* daughterLVol = lv->GetDaughter(i)->GetLogicalVolume();
|
||||
if (!daughterLVol->IsRootRegion())
|
||||
@@ -292,9 +286,8 @@ void G4Region::AddRootLogicalVolume(G4LogicalVolume* lv, G4bool search)
|
||||
//
|
||||
if (search)
|
||||
{
|
||||
G4RootLVList::iterator pos;
|
||||
pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
|
||||
if (pos == fRootVolumes.end())
|
||||
auto pos = std::find(fRootVolumes.cbegin(),fRootVolumes.cend(),lv);
|
||||
if (pos == fRootVolumes.cend())
|
||||
{
|
||||
// Insert the root volume in the list and set it as root region
|
||||
//
|
||||
@@ -326,9 +319,8 @@ void G4Region::RemoveRootLogicalVolume(G4LogicalVolume* lv, G4bool scan)
|
||||
{
|
||||
// Find and remove logical volume from the list
|
||||
//
|
||||
G4RootLVList::iterator pos;
|
||||
pos = std::find(fRootVolumes.begin(),fRootVolumes.end(),lv);
|
||||
if (pos != fRootVolumes.end())
|
||||
auto pos = std::find(fRootVolumes.cbegin(),fRootVolumes.cend(),lv);
|
||||
if (pos != fRootVolumes.cend())
|
||||
{
|
||||
if (fRootVolumes.size() != 1) // Avoid resetting flag for world since
|
||||
{ // volume may be already deleted !
|
||||
@@ -381,8 +373,7 @@ void G4Region::UpdateMaterialList()
|
||||
// Loop over the root logical volumes and rebuild the list
|
||||
// of materials from scratch
|
||||
//
|
||||
G4RootLVList::iterator pLV;
|
||||
for (pLV=fRootVolumes.begin(); pLV!=fRootVolumes.end(); pLV++)
|
||||
for (auto pLV=fRootVolumes.cbegin(); pLV!=fRootVolumes.cend(); ++pLV)
|
||||
{
|
||||
ScanVolumeTree(*pLV, true);
|
||||
}
|
||||
@@ -434,7 +425,7 @@ void G4Region::ClearFastSimulationManager()
|
||||
{
|
||||
G4bool isUnique;
|
||||
G4Region* parent = GetParentRegion(isUnique);
|
||||
if(parent)
|
||||
if(parent != nullptr)
|
||||
{
|
||||
if (isUnique)
|
||||
{
|
||||
@@ -450,12 +441,12 @@ void G4Region::ClearFastSimulationManager()
|
||||
<< "to have fast-simulation assigned.";
|
||||
G4Exception("G4Region::ClearFastSimulationManager()",
|
||||
"GeomMgt1002", JustWarning, message);
|
||||
G4MT_fsmanager = 0;
|
||||
G4MT_fsmanager = nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
G4MT_fsmanager = 0;
|
||||
G4MT_fsmanager = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,20 +458,19 @@ void G4Region::ClearFastSimulationManager()
|
||||
//
|
||||
G4Region* G4Region::GetParentRegion(G4bool& unique) const
|
||||
{
|
||||
G4Region* parent = 0; unique = true;
|
||||
G4Region* parent = nullptr; unique = true;
|
||||
G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
|
||||
G4LogicalVolumeStore::iterator lvItr;
|
||||
|
||||
// Loop over all logical volumes in the store
|
||||
//
|
||||
for(lvItr=lvStore->begin(); lvItr!=lvStore->end(); lvItr++)
|
||||
for(auto lvItr=lvStore->cbegin(); lvItr!=lvStore->cend(); ++lvItr)
|
||||
{
|
||||
G4int nD = (*lvItr)->GetNoDaughters();
|
||||
G4Region* aR = (*lvItr)->GetRegion();
|
||||
|
||||
// Loop over all daughters of each logical volume
|
||||
//
|
||||
for(G4int iD=0; iD<nD; iD++)
|
||||
for(auto iD=0; iD<nD; ++iD)
|
||||
{
|
||||
if((*lvItr)->GetDaughter(iD)->GetLogicalVolume()->GetRegion()==this)
|
||||
{
|
||||
|
||||
@@ -23,14 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4RegionStore implementation for singleton container
|
||||
//
|
||||
//
|
||||
// G4RegionStore
|
||||
//
|
||||
// Implementation for singleton container
|
||||
//
|
||||
// History:
|
||||
// 18.09.02 G.Cosmo Initial version
|
||||
// 18.09.02, G.Cosmo - Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4Region.hh"
|
||||
@@ -45,8 +40,8 @@
|
||||
// Static class variables
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4RegionStore* G4RegionStore::fgInstance = 0;
|
||||
G4ThreadLocal G4VStoreNotifier* G4RegionStore::fgNotifier = 0;
|
||||
G4RegionStore* G4RegionStore::fgInstance = nullptr;
|
||||
G4ThreadLocal G4VStoreNotifier* G4RegionStore::fgNotifier = nullptr;
|
||||
G4ThreadLocal G4bool G4RegionStore::locked = false;
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -97,11 +92,10 @@ void G4RegionStore::Clean()
|
||||
G4cout << "Deleting Regions ... ";
|
||||
#endif
|
||||
|
||||
for(iterator pos=store->begin(); pos!=store->end(); ++pos)
|
||||
for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
if (*pos) { delete *pos; }
|
||||
i++;
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
delete *pos; ++i;
|
||||
}
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
@@ -143,8 +137,8 @@ void G4RegionStore::DeRegister(G4Region* pRegion)
|
||||
{
|
||||
if (!locked) // Do not de-register if locked !
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
if (**i==*pRegion)
|
||||
{
|
||||
@@ -162,7 +156,7 @@ void G4RegionStore::DeRegister(G4Region* pRegion)
|
||||
G4RegionStore* G4RegionStore::GetInstance()
|
||||
{
|
||||
static G4RegionStore worldStore;
|
||||
if (!fgInstance)
|
||||
if (fgInstance == nullptr)
|
||||
{
|
||||
fgInstance = &worldStore;
|
||||
}
|
||||
@@ -176,7 +170,7 @@ G4RegionStore* G4RegionStore::GetInstance()
|
||||
//
|
||||
G4bool G4RegionStore::IsModified() const
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
if ((*i)->IsModified()) { return true; }
|
||||
}
|
||||
@@ -190,7 +184,7 @@ G4bool G4RegionStore::IsModified() const
|
||||
//
|
||||
void G4RegionStore::ResetRegionModified()
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
(*i)->RegionModified(false);
|
||||
}
|
||||
@@ -202,9 +196,10 @@ void G4RegionStore::ResetRegionModified()
|
||||
//
|
||||
void G4RegionStore::UpdateMaterialList(G4VPhysicalVolume* currentWorld)
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
if((*i)->IsInMassGeometry() || (*i)->IsInParallelGeometry() || currentWorld)
|
||||
if((*i)->IsInMassGeometry() || (*i)->IsInParallelGeometry()
|
||||
|| (currentWorld != nullptr))
|
||||
{ (*i)->UpdateMaterialList(); }
|
||||
}
|
||||
}
|
||||
@@ -215,7 +210,7 @@ void G4RegionStore::UpdateMaterialList(G4VPhysicalVolume* currentWorld)
|
||||
//
|
||||
G4Region* G4RegionStore::GetRegion(const G4String& name, G4bool verbose) const
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
if ((*i)->GetName() == name) { return *i; }
|
||||
}
|
||||
@@ -240,7 +235,7 @@ G4Region* G4RegionStore::GetRegion(const G4String& name, G4bool verbose) const
|
||||
G4Region* G4RegionStore::FindOrCreateRegion(const G4String& name)
|
||||
{
|
||||
G4Region* target = GetRegion(name,false);
|
||||
if (!target)
|
||||
if (target == nullptr)
|
||||
{
|
||||
target = new G4Region(name);
|
||||
}
|
||||
@@ -256,22 +251,22 @@ void G4RegionStore::SetWorldVolume()
|
||||
{
|
||||
// Reset all pointers first
|
||||
//
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
{ (*i)->SetWorld(0); }
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{ (*i)->SetWorld(nullptr); }
|
||||
|
||||
// Find world volumes
|
||||
//
|
||||
G4PhysicalVolumeStore* fPhysicalVolumeStore
|
||||
= G4PhysicalVolumeStore::GetInstance();
|
||||
size_t nPhys = fPhysicalVolumeStore->size();
|
||||
for(size_t iPhys=0; iPhys<nPhys; iPhys++)
|
||||
for(size_t iPhys=0; iPhys<nPhys; ++iPhys)
|
||||
{
|
||||
G4VPhysicalVolume* fPhys = (*fPhysicalVolumeStore)[iPhys];
|
||||
if(fPhys->GetMotherLogical()) { continue; } // not a world volume
|
||||
if(fPhys->GetMotherLogical() != nullptr) { continue; } // not a world volume
|
||||
|
||||
// Now 'fPhys' is a world volume, set it to regions that belong to it.
|
||||
//
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{ (*i)->SetWorld(fPhys); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,23 +22,17 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4SmartVoxelHeader
|
||||
//
|
||||
// Implementation
|
||||
// class G4SmartVoxelHeader implementation
|
||||
//
|
||||
// Define G4GEOMETRY_VOXELDEBUG for debugging information on G4cout
|
||||
//
|
||||
// History:
|
||||
// 29.04.02 Use 3D voxelisation for non consuming replication - G.C.
|
||||
// 18.04.01 Migrated to STL vector - G.C.
|
||||
// 12.02.99 Introduction of new quality/smartless: max for (slices/candid) S.G.
|
||||
// 11.02.99 Voxels at lower levels are now built for collapsed slices S.G.
|
||||
// 21.07.95 Full implementation, supporting non divided physical volumes
|
||||
// 14.07.95 Initial version - stubb definitions only
|
||||
// 12.02.99 Introduction of new quality/smartless: max for (slices/cand) - S.G.
|
||||
// 11.02.99 Voxels at lower levels are now built for collapsed slices - S.G.
|
||||
// 21.07.95 Full implementation, supporting non divided physical volumes - P.K.
|
||||
// 14.07.95 Initial version - stubb definitions only - P.K.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SmartVoxelHeader.hh"
|
||||
@@ -68,7 +62,7 @@ G4SmartVoxelHeader::G4SmartVoxelHeader(G4LogicalVolume* pVolume,
|
||||
fmaxEquivalent(pSlice),
|
||||
fparamAxis(kUndefined)
|
||||
{
|
||||
G4int nDaughters = pVolume->GetNoDaughters();
|
||||
size_t nDaughters = pVolume->GetNoDaughters();
|
||||
G4VoxelLimits limits; // Create `unlimited' limits object
|
||||
|
||||
// Determine whether daughter is replicated
|
||||
@@ -108,7 +102,7 @@ G4SmartVoxelHeader::G4SmartVoxelHeader(G4LogicalVolume* pVolume,
|
||||
G4cout << "**** G4SmartVoxelHeader::G4SmartVoxelHeader" << G4endl
|
||||
<< " Limits " << pLimits << G4endl
|
||||
<< " Candidate #s = " ;
|
||||
for (size_t i=0;i<pCandidates->size();i++)
|
||||
for (auto i=0; i<pCandidates->size(); ++i)
|
||||
{
|
||||
G4cout << (*pCandidates)[i] << " ";
|
||||
}
|
||||
@@ -128,39 +122,39 @@ G4SmartVoxelHeader::~G4SmartVoxelHeader()
|
||||
// Manually destroy underlying nodes/headers
|
||||
// Delete collected headers and nodes once only
|
||||
//
|
||||
G4int node, proxy, maxNode=fslices.size();
|
||||
G4SmartVoxelProxy *lastProxy=0;
|
||||
G4SmartVoxelNode *dyingNode, *lastNode=0;
|
||||
G4SmartVoxelHeader *dyingHeader, *lastHeader=0;
|
||||
size_t node, proxy, maxNode=fslices.size();
|
||||
G4SmartVoxelProxy* lastProxy = nullptr;
|
||||
G4SmartVoxelNode *dyingNode, *lastNode=nullptr;
|
||||
G4SmartVoxelHeader *dyingHeader, *lastHeader=nullptr;
|
||||
|
||||
for (node=0; node<maxNode; node++)
|
||||
for (node=0; node<maxNode; ++node)
|
||||
{
|
||||
if (fslices[node]->IsHeader())
|
||||
{
|
||||
dyingHeader = fslices[node]->GetHeader();
|
||||
if (lastHeader!=dyingHeader)
|
||||
if (lastHeader != dyingHeader)
|
||||
{
|
||||
lastHeader = dyingHeader;
|
||||
lastNode = 0;
|
||||
lastNode = nullptr;
|
||||
delete dyingHeader;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dyingNode = fslices[node]->GetNode();
|
||||
if (dyingNode!=lastNode)
|
||||
if (dyingNode != lastNode)
|
||||
{
|
||||
lastNode=dyingNode;
|
||||
lastHeader=0;
|
||||
lastNode = dyingNode;
|
||||
lastHeader = nullptr;
|
||||
delete dyingNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Delete proxies
|
||||
//
|
||||
for (proxy=0; proxy<maxNode; proxy++)
|
||||
for (proxy=0; proxy<maxNode; ++proxy)
|
||||
{
|
||||
if (fslices[proxy]!=lastProxy)
|
||||
if (fslices[proxy] != lastProxy)
|
||||
{
|
||||
lastProxy = fslices[proxy];
|
||||
delete lastProxy;
|
||||
@@ -186,13 +180,13 @@ G4bool G4SmartVoxelHeader::operator == (const G4SmartVoxelHeader& pHead) const
|
||||
&& (GetMinExtent() == pHead.GetMinExtent())
|
||||
&& (GetMaxExtent() == pHead.GetMaxExtent()) )
|
||||
{
|
||||
G4int node, maxNode;
|
||||
size_t node, maxNode;
|
||||
G4SmartVoxelProxy *leftProxy, *rightProxy;
|
||||
G4SmartVoxelHeader *leftHeader, *rightHeader;
|
||||
G4SmartVoxelNode *leftNode, *rightNode;
|
||||
|
||||
maxNode=GetNoSlices();
|
||||
for (node=0; node<maxNode; node++)
|
||||
maxNode = GetNoSlices();
|
||||
for (node=0; node<maxNode; ++node)
|
||||
{
|
||||
leftProxy = GetSlice(node);
|
||||
rightProxy = pHead.GetSlice(node);
|
||||
@@ -206,7 +200,7 @@ G4bool G4SmartVoxelHeader::operator == (const G4SmartVoxelHeader& pHead) const
|
||||
{
|
||||
leftHeader = leftProxy->GetHeader();
|
||||
rightHeader = rightProxy->GetHeader();
|
||||
if (!(*leftHeader==*rightHeader))
|
||||
if (!(*leftHeader == *rightHeader))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -222,7 +216,7 @@ G4bool G4SmartVoxelHeader::operator == (const G4SmartVoxelHeader& pHead) const
|
||||
{
|
||||
leftNode = leftProxy->GetNode();
|
||||
rightNode = rightProxy->GetNode();
|
||||
if (!(*leftNode==*rightNode))
|
||||
if (!(*leftNode == *rightNode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -246,11 +240,11 @@ G4bool G4SmartVoxelHeader::operator == (const G4SmartVoxelHeader& pHead) const
|
||||
void G4SmartVoxelHeader::BuildVoxels(G4LogicalVolume* pVolume)
|
||||
{
|
||||
G4VoxelLimits limits; // Create `unlimited' limits object
|
||||
G4int nDaughters = pVolume->GetNoDaughters();
|
||||
size_t nDaughters = pVolume->GetNoDaughters();
|
||||
|
||||
G4VolumeNosVector targetList;
|
||||
targetList.reserve(nDaughters);
|
||||
for (G4int i=0; i<nDaughters; i++)
|
||||
for (size_t i=0; i<nDaughters; ++i)
|
||||
{
|
||||
targetList.push_back(i);
|
||||
}
|
||||
@@ -265,7 +259,7 @@ void G4SmartVoxelHeader::BuildVoxels(G4LogicalVolume* pVolume)
|
||||
//
|
||||
void G4SmartVoxelHeader::BuildReplicaVoxels(G4LogicalVolume* pVolume)
|
||||
{
|
||||
G4VPhysicalVolume *pDaughter=0;
|
||||
G4VPhysicalVolume* pDaughter = nullptr;
|
||||
|
||||
// Replication data
|
||||
//
|
||||
@@ -281,15 +275,15 @@ void G4SmartVoxelHeader::BuildReplicaVoxels(G4LogicalVolume* pVolume)
|
||||
{
|
||||
// Obtain replication data
|
||||
//
|
||||
pDaughter=pVolume->GetDaughter(0);
|
||||
pDaughter = pVolume->GetDaughter(0);
|
||||
pDaughter->GetReplicationData(axis,nReplicas,width,offset,consuming);
|
||||
fparamAxis = axis;
|
||||
if ( consuming==false )
|
||||
if ( consuming == false )
|
||||
{
|
||||
G4VoxelLimits limits; // Create `unlimited' limits object
|
||||
G4VolumeNosVector targetList;
|
||||
targetList.reserve(nReplicas);
|
||||
for (G4int i=0; i<nReplicas; i++)
|
||||
for (auto i=0; i<nReplicas; ++i)
|
||||
{
|
||||
targetList.push_back(i);
|
||||
}
|
||||
@@ -394,24 +388,24 @@ void G4SmartVoxelHeader::BuildReplicaVoxels(G4LogicalVolume* pVolume)
|
||||
void G4SmartVoxelHeader::BuildConsumedNodes(G4int nReplicas)
|
||||
{
|
||||
G4int nNode, nVol;
|
||||
G4SmartVoxelNode *pNode;
|
||||
G4SmartVoxelProxy *pProxyNode;
|
||||
G4SmartVoxelNode* pNode;
|
||||
G4SmartVoxelProxy* pProxyNode;
|
||||
|
||||
// Create and fill nodes in temporary G4NodeVector (on stack)
|
||||
//
|
||||
G4NodeVector nodeList;
|
||||
nodeList.reserve(nReplicas);
|
||||
for (nNode=0; nNode<nReplicas; nNode++)
|
||||
for (nNode=0; nNode<nReplicas; ++nNode)
|
||||
{
|
||||
pNode=new G4SmartVoxelNode(nNode);
|
||||
if (!pNode)
|
||||
pNode = new G4SmartVoxelNode(nNode);
|
||||
if (pNode == nullptr)
|
||||
{
|
||||
G4Exception("G4SmartVoxelHeader::BuildConsumedNodes()", "GeomMgt0003",
|
||||
FatalException, "Node allocation error.");
|
||||
}
|
||||
nodeList.push_back(pNode);
|
||||
}
|
||||
for (nVol=0; nVol<nReplicas; nVol++)
|
||||
for (nVol=0; nVol<nReplicas; ++nVol)
|
||||
{
|
||||
nodeList[nVol]->Insert(nVol); // Insert replication of number
|
||||
} // identical to voxel number
|
||||
@@ -419,7 +413,7 @@ void G4SmartVoxelHeader::BuildConsumedNodes(G4int nReplicas)
|
||||
// Create & fill proxy List `in place' by modifying instance data fslices
|
||||
//
|
||||
fslices.clear();
|
||||
for (nNode=0; nNode<nReplicas; nNode++)
|
||||
for (nNode=0; nNode<nReplicas; ++nNode)
|
||||
{
|
||||
pProxyNode = new G4SmartVoxelProxy(nodeList[nNode]);
|
||||
if (!pProxyNode)
|
||||
@@ -447,16 +441,16 @@ G4SmartVoxelHeader::BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
|
||||
// 1. Trying all unlimited cartesian axes
|
||||
// 2. Select axis which gives greatest no slices
|
||||
|
||||
G4ProxyVector *pGoodSlices=0, *pTestSlices, *tmpSlices;
|
||||
G4ProxyVector *pGoodSlices=nullptr, *pTestSlices, *tmpSlices;
|
||||
G4double goodSliceScore=kInfinity, testSliceScore;
|
||||
EAxis goodSliceAxis = kXAxis;
|
||||
EAxis testAxis = kXAxis;
|
||||
G4int node, maxNode, iaxis;
|
||||
size_t node, maxNode, iaxis;
|
||||
G4VoxelLimits noLimits;
|
||||
|
||||
// Try all non-limited cartesian axes
|
||||
//
|
||||
for (iaxis=0; iaxis<3; iaxis++)
|
||||
for (iaxis=0; iaxis<3; ++iaxis)
|
||||
{
|
||||
switch(iaxis)
|
||||
{
|
||||
@@ -487,7 +481,7 @@ G4SmartVoxelHeader::BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
|
||||
// Destroy pTestSlices and all its contents
|
||||
//
|
||||
maxNode=pTestSlices->size();
|
||||
for (node=0; node<maxNode; node++)
|
||||
for (node=0; node<maxNode; ++node)
|
||||
{
|
||||
delete (*pTestSlices)[node]->GetNode();
|
||||
}
|
||||
@@ -496,8 +490,7 @@ G4SmartVoxelHeader::BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
|
||||
{
|
||||
tmpProx = pTestSlices->back();
|
||||
pTestSlices->pop_back();
|
||||
for (G4ProxyVector::iterator i=pTestSlices->begin();
|
||||
i!=pTestSlices->end(); )
|
||||
for (auto i=pTestSlices->cbegin(); i!=pTestSlices->cend(); )
|
||||
{
|
||||
if (*i==tmpProx)
|
||||
{
|
||||
@@ -531,18 +524,18 @@ G4SmartVoxelHeader::BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
|
||||
|
||||
// Store chosen axis, slice ptr
|
||||
//
|
||||
fslices=*pGoodSlices; // Set slice information, copy ptrs in collection
|
||||
delete pGoodSlices; // Destroy slices vector, but not contained
|
||||
// proxies or nodes
|
||||
faxis=goodSliceAxis;
|
||||
fslices =* pGoodSlices; // Set slice information, copy ptrs in collection
|
||||
delete pGoodSlices; // Destroy slices vector, but not contained
|
||||
// proxies or nodes
|
||||
faxis = goodSliceAxis;
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
G4cout << G4endl << " Volume = " << pVolume->GetName()
|
||||
<< G4endl << " Selected axis = " << faxis << G4endl;
|
||||
for (size_t islice=0; islice<fslices.size(); islice++)
|
||||
for (auto islice=0; islice<fslices.size(); ++islice)
|
||||
{
|
||||
G4cout << " Node #" << islice << " = {";
|
||||
for (G4int j=0; j<fslices[islice]->GetNode()->GetNoContained(); j++)
|
||||
for (auto j=0; j<fslices[islice]->GetNode()->GetNoContained(); ++j)
|
||||
{
|
||||
G4cout << " " << fslices[islice]->GetNode()->GetVolume(j);
|
||||
}
|
||||
@@ -563,8 +556,8 @@ G4SmartVoxelHeader::BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
|
||||
// Calculate equivalent nos
|
||||
//
|
||||
BuildEquivalentSliceNos();
|
||||
CollectEquivalentNodes(); // Collect common nodes
|
||||
RefineNodes(pVolume,pLimits); // Refine nodes creating headers
|
||||
CollectEquivalentNodes(); // Collect common nodes
|
||||
RefineNodes(pVolume, pLimits); // Refine nodes creating headers
|
||||
|
||||
// No common headers can exist because collapsed by construction
|
||||
}
|
||||
@@ -581,10 +574,10 @@ G4SmartVoxelHeader::BuildVoxelsWithinLimits(G4LogicalVolume* pVolume,
|
||||
//
|
||||
void G4SmartVoxelHeader::BuildEquivalentSliceNos()
|
||||
{
|
||||
G4int sliceNo, minNo, maxNo, equivNo;
|
||||
G4int maxNode = fslices.size();
|
||||
size_t sliceNo, minNo, maxNo, equivNo;
|
||||
size_t maxNode = fslices.size();
|
||||
G4SmartVoxelNode *startNode, *sampleNode;
|
||||
for (sliceNo=0; sliceNo<maxNode; sliceNo++)
|
||||
for (sliceNo=0; sliceNo<maxNode; ++sliceNo)
|
||||
{
|
||||
minNo = sliceNo;
|
||||
|
||||
@@ -594,7 +587,7 @@ void G4SmartVoxelHeader::BuildEquivalentSliceNos()
|
||||
|
||||
// Find max equivalent
|
||||
//
|
||||
for (equivNo=minNo+1; equivNo<maxNode; equivNo++)
|
||||
for (equivNo=minNo+1; equivNo<maxNode; ++equivNo)
|
||||
{
|
||||
sampleNode = fslices[equivNo]->GetNode();
|
||||
if (!((*startNode) == (*sampleNode))) { break; }
|
||||
@@ -604,7 +597,7 @@ void G4SmartVoxelHeader::BuildEquivalentSliceNos()
|
||||
{
|
||||
// Set min and max nos
|
||||
//
|
||||
for (equivNo=minNo; equivNo<=maxNo; equivNo++)
|
||||
for (equivNo=minNo; equivNo<=maxNo; ++equivNo)
|
||||
{
|
||||
sampleNode = fslices[equivNo]->GetNode();
|
||||
sampleNode->SetMinEquivalentSliceNo(minNo);
|
||||
@@ -628,12 +621,12 @@ void G4SmartVoxelHeader::BuildEquivalentSliceNos()
|
||||
//
|
||||
void G4SmartVoxelHeader::CollectEquivalentNodes()
|
||||
{
|
||||
G4int sliceNo, maxNo, equivNo;
|
||||
G4int maxNode=fslices.size();
|
||||
G4SmartVoxelNode *equivNode;
|
||||
G4SmartVoxelProxy *equivProxy;
|
||||
size_t sliceNo, maxNo, equivNo;
|
||||
size_t maxNode=fslices.size();
|
||||
G4SmartVoxelNode* equivNode;
|
||||
G4SmartVoxelProxy* equivProxy;
|
||||
|
||||
for (sliceNo=0; sliceNo<maxNode; sliceNo++)
|
||||
for (sliceNo=0; sliceNo<maxNode; ++sliceNo)
|
||||
{
|
||||
equivProxy=fslices[sliceNo];
|
||||
|
||||
@@ -650,7 +643,7 @@ void G4SmartVoxelHeader::CollectEquivalentNodes()
|
||||
#endif
|
||||
// Do collection between sliceNo and maxNo inclusive
|
||||
//
|
||||
for (equivNo=sliceNo+1; equivNo<=maxNo; equivNo++)
|
||||
for (equivNo=sliceNo+1; equivNo<=maxNo; ++equivNo)
|
||||
{
|
||||
delete fslices[equivNo]->GetNode();
|
||||
delete fslices[equivNo];
|
||||
@@ -675,12 +668,12 @@ void G4SmartVoxelHeader::CollectEquivalentNodes()
|
||||
//
|
||||
void G4SmartVoxelHeader::CollectEquivalentHeaders()
|
||||
{
|
||||
G4int sliceNo, maxNo, equivNo;
|
||||
G4int maxNode = fslices.size();
|
||||
size_t sliceNo, maxNo, equivNo;
|
||||
size_t maxNode = fslices.size();
|
||||
G4SmartVoxelHeader *equivHeader, *sampleHeader;
|
||||
G4SmartVoxelProxy *equivProxy;
|
||||
|
||||
for (sliceNo=0; sliceNo<maxNode; sliceNo++)
|
||||
for (sliceNo=0; sliceNo<maxNode; ++sliceNo)
|
||||
{
|
||||
equivProxy = fslices[sliceNo];
|
||||
if (equivProxy->IsHeader())
|
||||
@@ -697,7 +690,7 @@ void G4SmartVoxelHeader::CollectEquivalentHeaders()
|
||||
G4cout << "**** G4SmartVoxelHeader::CollectEquivalentHeaders" << G4endl
|
||||
<< " Collecting Headers =";
|
||||
#endif
|
||||
for (equivNo=sliceNo+1; equivNo<=maxNo; equivNo++)
|
||||
for (equivNo=sliceNo+1; equivNo<=maxNo; ++equivNo)
|
||||
{
|
||||
sampleHeader = fslices[equivNo]->GetHeader();
|
||||
if ( (*sampleHeader) == (*equivHeader) )
|
||||
@@ -753,13 +746,13 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
{
|
||||
G4double motherMinExtent= kInfinity, motherMaxExtent= -kInfinity,
|
||||
targetMinExtent= kInfinity, targetMaxExtent= -kInfinity;
|
||||
G4VPhysicalVolume *pDaughter=0;
|
||||
G4VPVParameterisation *pParam=0;
|
||||
G4VPhysicalVolume* pDaughter = nullptr;
|
||||
G4VPVParameterisation* pParam = nullptr;
|
||||
G4VSolid *targetSolid;
|
||||
G4AffineTransform targetTransform;
|
||||
G4bool replicated;
|
||||
G4int nCandidates = pCandidates->size();
|
||||
G4int nVol, nNode, targetVolNo;
|
||||
size_t nCandidates = pCandidates->size();
|
||||
size_t nVol, nNode, targetVolNo;
|
||||
G4VoxelLimits noLimits;
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
@@ -783,22 +776,22 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
G4VolumeExtentVector minExtents(nCandidates,0.);
|
||||
G4VolumeExtentVector maxExtents(nCandidates,0.);
|
||||
|
||||
if ( (pVolume->GetNoDaughters()==1)
|
||||
&& (pVolume->GetDaughter(0)->IsReplicated()==true) )
|
||||
if ( (pVolume->GetNoDaughters() == 1)
|
||||
&& (pVolume->GetDaughter(0)->IsReplicated() == true) )
|
||||
{
|
||||
// Replication data not required: only parameterisation object
|
||||
// and volume no. List used
|
||||
//
|
||||
pDaughter = pVolume->GetDaughter(0);
|
||||
pParam = pDaughter->GetParameterisation();
|
||||
if (!pParam)
|
||||
if (pParam == nullptr)
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "PANIC! - Missing parameterisation." << G4endl
|
||||
<< " Replicated volume with no parameterisation object !";
|
||||
G4Exception("G4SmartVoxelHeader::BuildNodes()", "GeomMgt0003",
|
||||
FatalException, message);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Setup daughter's transformations
|
||||
@@ -814,12 +807,12 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
|
||||
// Compute extents
|
||||
//
|
||||
for (nVol=0; nVol<nCandidates; nVol++)
|
||||
for (nVol=0; nVol<nCandidates; ++nVol)
|
||||
{
|
||||
targetVolNo=(*pCandidates)[nVol];
|
||||
targetVolNo = (*pCandidates)[nVol];
|
||||
if (replicated == false)
|
||||
{
|
||||
pDaughter=pVolume->GetDaughter(targetVolNo);
|
||||
pDaughter = pVolume->GetDaughter(targetVolNo);
|
||||
|
||||
// Setup daughter's transformations
|
||||
//
|
||||
@@ -887,7 +880,7 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
if (!pLimits.IsLimited())
|
||||
{
|
||||
G4double width;
|
||||
G4int kStraddlePercent=5;
|
||||
G4int kStraddlePercent = 5;
|
||||
width = maxExtents[nVol]-minExtents[nVol];
|
||||
if ( (((motherMinExtent-minExtents[nVol])*100/width) > kStraddlePercent)
|
||||
||(((maxExtents[nVol]-motherMaxExtent)*100/width) > kStraddlePercent) )
|
||||
@@ -910,7 +903,7 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
//
|
||||
G4double minWidth = kInfinity;
|
||||
G4double currentWidth;
|
||||
for (nVol=0; nVol<nCandidates; nVol++)
|
||||
for (nVol=0; nVol<nCandidates; ++nVol)
|
||||
{
|
||||
// currentWidth should -always- be a positive value. Inaccurate computed extent
|
||||
// from the solid or situations of malformed geometries (overlaps) may lead to
|
||||
@@ -939,7 +932,7 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
? smartlessComputed : smartlessUser;
|
||||
G4double noNodesSmart = smartless*nCandidates;
|
||||
G4int noNodesExactI = G4int(noNodesSmart);
|
||||
G4int noNodes = ((noNodesSmart-noNodesExactI)>=0.5)
|
||||
G4long noNodes = ((noNodesSmart-noNodesExactI)>=0.5)
|
||||
? noNodesExactI+1 : noNodesExactI;
|
||||
if( noNodes == 0 ) { noNodes=1; }
|
||||
|
||||
@@ -963,23 +956,23 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
// Create G4VoxelNodes. Will Add proxies before setting fslices
|
||||
//
|
||||
G4NodeVector* nodeList = new G4NodeVector();
|
||||
if (!nodeList)
|
||||
if (nodeList == nullptr)
|
||||
{
|
||||
G4Exception("G4SmartVoxelHeader::BuildNodes()", "GeomMgt0003",
|
||||
FatalException, "NodeList allocation error.");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
nodeList->reserve(noNodes);
|
||||
|
||||
for (nNode=0; nNode<noNodes; nNode++)
|
||||
for (nNode=0; G4long(nNode)<noNodes; ++nNode)
|
||||
{
|
||||
G4SmartVoxelNode *pNode;
|
||||
pNode = new G4SmartVoxelNode(nNode);
|
||||
if (!pNode)
|
||||
if (pNode == nullptr)
|
||||
{
|
||||
G4Exception("G4SmartVoxelHeader::BuildNodes()", "GeomMgt0003",
|
||||
FatalException, "Node allocation error.");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
nodeList->push_back(pNode);
|
||||
}
|
||||
@@ -988,11 +981,11 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
|
||||
// Fill nodes: Step through extent lists
|
||||
//
|
||||
for (nVol=0; nVol<nCandidates; nVol++)
|
||||
for (nVol=0; nVol<nCandidates; ++nVol)
|
||||
{
|
||||
G4int nodeNo, minContainingNode, maxContainingNode;
|
||||
minContainingNode = G4int((minExtents[nVol]-motherMinExtent)/nodeWidth);
|
||||
maxContainingNode = G4int((maxExtents[nVol]-motherMinExtent)/nodeWidth);
|
||||
G4long nodeNo, minContainingNode, maxContainingNode;
|
||||
minContainingNode = (minExtents[nVol]-motherMinExtent)/nodeWidth;
|
||||
maxContainingNode = (maxExtents[nVol]-motherMinExtent)/nodeWidth;
|
||||
|
||||
// Only add nodes that are inside the limits of the axis
|
||||
//
|
||||
@@ -1010,9 +1003,9 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
//
|
||||
if (minContainingNode<0)
|
||||
{
|
||||
minContainingNode=0;
|
||||
minContainingNode = 0;
|
||||
}
|
||||
for (nodeNo=minContainingNode; nodeNo<=maxContainingNode; nodeNo++)
|
||||
for (nodeNo=minContainingNode; nodeNo<=maxContainingNode; ++nodeNo)
|
||||
{
|
||||
(*nodeList)[nodeNo]->Insert((*pCandidates)[nVol]);
|
||||
}
|
||||
@@ -1025,28 +1018,28 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
// (but we must delete nodeList *itself* - not the contents)
|
||||
//
|
||||
G4ProxyVector* proxyList = new G4ProxyVector();
|
||||
if (!proxyList)
|
||||
if (proxyList == nullptr)
|
||||
{
|
||||
G4Exception("G4SmartVoxelHeader::BuildNodes()", "GeomMgt0003",
|
||||
FatalException, "Proxy list allocation error.");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
proxyList->reserve(noNodes);
|
||||
|
||||
//
|
||||
// Fill proxy List
|
||||
//
|
||||
for (nNode=0; nNode<noNodes; nNode++)
|
||||
for (nNode=0; G4long(nNode)<noNodes; ++nNode)
|
||||
{
|
||||
// Get rid of possible excess capacity in the internal node vector
|
||||
//
|
||||
((*nodeList)[nNode])->Shrink();
|
||||
G4SmartVoxelProxy* pProxyNode = new G4SmartVoxelProxy((*nodeList)[nNode]);
|
||||
if (!pProxyNode)
|
||||
if (pProxyNode == nullptr)
|
||||
{
|
||||
G4Exception("G4SmartVoxelHeader::BuildNodes()", "GeomMgt0003",
|
||||
FatalException, "Proxy node allocation failed.");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
proxyList->push_back(pProxyNode);
|
||||
}
|
||||
@@ -1072,11 +1065,11 @@ G4ProxyVector* G4SmartVoxelHeader::BuildNodes(G4LogicalVolume* pVolume,
|
||||
G4double G4SmartVoxelHeader::CalculateQuality(G4ProxyVector *pSlice)
|
||||
{
|
||||
G4double quality;
|
||||
G4int nNodes = pSlice->size();
|
||||
G4int noContained, maxContained=0, sumContained=0, sumNonEmptyNodes=0;
|
||||
size_t nNodes = pSlice->size();
|
||||
size_t noContained, maxContained=0, sumContained=0, sumNonEmptyNodes=0;
|
||||
G4SmartVoxelNode *node;
|
||||
|
||||
for (G4int i=0; i<nNodes; i++)
|
||||
for (size_t i=0; i<nNodes; ++i)
|
||||
{
|
||||
if ((*pSlice)[i]->IsNode())
|
||||
{
|
||||
@@ -1086,7 +1079,7 @@ G4double G4SmartVoxelHeader::CalculateQuality(G4ProxyVector *pSlice)
|
||||
noContained = node->GetNoContained();
|
||||
if (noContained)
|
||||
{
|
||||
sumNonEmptyNodes++;
|
||||
++sumNonEmptyNodes;
|
||||
sumContained += noContained;
|
||||
//
|
||||
// Calc maxContained for statistics
|
||||
@@ -1138,20 +1131,20 @@ G4double G4SmartVoxelHeader::CalculateQuality(G4ProxyVector *pSlice)
|
||||
void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
|
||||
G4VoxelLimits pLimits)
|
||||
{
|
||||
G4int refinedDepth=0, minVolumes;
|
||||
G4int maxNode = fslices.size();
|
||||
size_t refinedDepth=0, minVolumes;
|
||||
size_t maxNode = fslices.size();
|
||||
|
||||
if (pLimits.IsXLimited())
|
||||
{
|
||||
refinedDepth++;
|
||||
++refinedDepth;
|
||||
}
|
||||
if (pLimits.IsYLimited())
|
||||
{
|
||||
refinedDepth++;
|
||||
++refinedDepth;
|
||||
}
|
||||
if (pLimits.IsZLimited())
|
||||
{
|
||||
refinedDepth++;
|
||||
++refinedDepth;
|
||||
}
|
||||
|
||||
// Calculate minimum number of volumes necessary to refine
|
||||
@@ -1171,7 +1164,7 @@ void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
|
||||
|
||||
if (refinedDepth<2)
|
||||
{
|
||||
G4int targetNo, noContainedDaughters, minNo, maxNo, replaceNo, i;
|
||||
size_t targetNo, noContainedDaughters, minNo, maxNo, replaceNo, i;
|
||||
G4double sliceWidth = (fmaxExtent-fminExtent)/maxNode;
|
||||
G4VoxelLimits newLimits;
|
||||
G4SmartVoxelNode* targetNode;
|
||||
@@ -1181,7 +1174,7 @@ void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
|
||||
G4VolumeNosVector* targetList;
|
||||
G4SmartVoxelProxy* lastProxy;
|
||||
|
||||
for (targetNo=0; targetNo<maxNode; targetNo++)
|
||||
for (targetNo=0; targetNo<maxNode; ++targetNo)
|
||||
{
|
||||
// Assume all slices are nodes (see preconditions)
|
||||
//
|
||||
@@ -1192,7 +1185,7 @@ void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
|
||||
{
|
||||
noContainedDaughters = targetNode->GetNoContained();
|
||||
targetList = new G4VolumeNosVector();
|
||||
if (!targetList)
|
||||
if (targetList == nullptr)
|
||||
{
|
||||
G4Exception("G4SmartVoxelHeader::RefineNodes()",
|
||||
"GeomMgt0003", FatalException,
|
||||
@@ -1200,7 +1193,7 @@ void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
|
||||
return;
|
||||
}
|
||||
targetList->reserve(noContainedDaughters);
|
||||
for (i=0; i<noContainedDaughters; i++)
|
||||
for (i=0; i<noContainedDaughters; ++i)
|
||||
{
|
||||
targetList->push_back(targetNode->GetVolume(i));
|
||||
}
|
||||
@@ -1222,7 +1215,7 @@ void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
|
||||
// Delete node proxies at start of collected sets of nodes/headers
|
||||
//
|
||||
lastProxy=0;
|
||||
for (replaceNo=minNo; replaceNo<=maxNo; replaceNo++)
|
||||
for (replaceNo=minNo; replaceNo<=maxNo; ++replaceNo)
|
||||
{
|
||||
if (lastProxy != fslices[replaceNo])
|
||||
{
|
||||
@@ -1241,7 +1234,7 @@ void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
|
||||
fminExtent+sliceWidth*(maxNo+1));
|
||||
replaceHeader = new G4SmartVoxelHeader(pVolume,newLimits,
|
||||
targetList,replaceNo);
|
||||
if (!replaceHeader)
|
||||
if (replaceHeader == nullptr)
|
||||
{
|
||||
G4Exception("G4SmartVoxelHeader::RefineNodes()", "GeomMgt0003",
|
||||
FatalException, "Refined VoxelHeader allocation error.");
|
||||
@@ -1250,13 +1243,13 @@ void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
|
||||
replaceHeader->SetMinEquivalentSliceNo(minNo);
|
||||
replaceHeader->SetMaxEquivalentSliceNo(maxNo);
|
||||
replaceHeaderProxy = new G4SmartVoxelProxy(replaceHeader);
|
||||
if (!replaceHeaderProxy)
|
||||
if (replaceHeaderProxy == nullptr)
|
||||
{
|
||||
G4Exception("G4SmartVoxelHeader::RefineNodes()", "GeomMgt0003",
|
||||
FatalException, "Refined VoxelProxy allocation error.");
|
||||
return;
|
||||
}
|
||||
for (replaceNo=minNo; replaceNo<=maxNo; replaceNo++)
|
||||
for (replaceNo=minNo; replaceNo<=maxNo; ++replaceNo)
|
||||
{
|
||||
fslices[replaceNo] = replaceHeaderProxy;
|
||||
}
|
||||
@@ -1279,13 +1272,13 @@ void G4SmartVoxelHeader::RefineNodes(G4LogicalVolume* pVolume,
|
||||
//
|
||||
G4bool G4SmartVoxelHeader::AllSlicesEqual() const
|
||||
{
|
||||
G4int noSlices = fslices.size();
|
||||
size_t noSlices = fslices.size();
|
||||
G4SmartVoxelProxy* refProxy;
|
||||
|
||||
if (noSlices>1)
|
||||
{
|
||||
refProxy=fslices[0];
|
||||
for (G4int i=1; i<noSlices; i++)
|
||||
for (size_t i=1; i<noSlices; ++i)
|
||||
{
|
||||
if (refProxy!=fslices[i])
|
||||
{
|
||||
@@ -1303,13 +1296,13 @@ G4bool G4SmartVoxelHeader::AllSlicesEqual() const
|
||||
std::ostream& operator << (std::ostream& os, const G4SmartVoxelHeader& h)
|
||||
{
|
||||
os << "Axis = " << G4int(h.faxis) << G4endl;
|
||||
G4SmartVoxelProxy *collectNode=0, *collectHead=0;
|
||||
G4int collectNodeNo=0;
|
||||
G4int collectHeadNo=0;
|
||||
G4SmartVoxelProxy *collectNode=nullptr, *collectHead=nullptr;
|
||||
G4int collectNodeNo = 0;
|
||||
G4int collectHeadNo = 0;
|
||||
size_t i, j;
|
||||
G4bool haveHeaders=false;
|
||||
G4bool haveHeaders = false;
|
||||
|
||||
for (i=0; i<h.fslices.size(); i++)
|
||||
for (i=0; i<h.fslices.size(); ++i)
|
||||
{
|
||||
os << "Slice #" << i << " = ";
|
||||
if (h.fslices[i]->IsNode())
|
||||
@@ -1317,7 +1310,7 @@ std::ostream& operator << (std::ostream& os, const G4SmartVoxelHeader& h)
|
||||
if (h.fslices[i]!=collectNode)
|
||||
{
|
||||
os << "{";
|
||||
for (G4int k=0; k<h.fslices[i]->GetNode()->GetNoContained(); k++)
|
||||
for (size_t k=0; k<h.fslices[i]->GetNode()->GetNoContained(); ++k)
|
||||
{
|
||||
os << " " << h.fslices[i]->GetNode()->GetVolume(k);
|
||||
}
|
||||
@@ -1349,7 +1342,7 @@ std::ostream& operator << (std::ostream& os, const G4SmartVoxelHeader& h)
|
||||
if (haveHeaders)
|
||||
{
|
||||
collectHead=0;
|
||||
for (j=0; j<h.fslices.size(); j++)
|
||||
for (j=0; j<h.fslices.size(); ++j)
|
||||
{
|
||||
if (h.fslices[j]->IsHeader())
|
||||
{
|
||||
|
||||
@@ -23,12 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Class G4SmartVoxelNode implementation
|
||||
//
|
||||
//
|
||||
// Class G4SmartVoxelNode
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
// 18.04.01, G.Cosmo - Migrated to STL vector
|
||||
// 12.07.95, P.Kent - Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SmartVoxelNode.hh"
|
||||
@@ -46,12 +44,12 @@ G4SmartVoxelNode::~G4SmartVoxelNode()
|
||||
// Node contents were entered in the same order
|
||||
G4bool G4SmartVoxelNode::operator == (const G4SmartVoxelNode& v) const
|
||||
{
|
||||
G4int maxNode=GetNoContained();
|
||||
if (maxNode==v.GetNoContained())
|
||||
size_t maxNode = GetNoContained();
|
||||
if (maxNode == v.GetNoContained())
|
||||
{
|
||||
for (G4int node=0;node<maxNode;node++)
|
||||
for (size_t node=0; node<maxNode; ++node)
|
||||
{
|
||||
if (GetVolume(node)!=v.GetVolume(node))
|
||||
if (GetVolume(node) != v.GetVolume(node))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Class G4SmartVoxelProxy implementation
|
||||
//
|
||||
//
|
||||
// Class G4SmartVoxelProxy
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
// 12.07.95, P.Kent - Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SmartVoxelProxy.hh"
|
||||
|
||||
@@ -23,18 +23,12 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class source file
|
||||
//
|
||||
// class G4SmartVoxelStat
|
||||
// G4SmartVoxelStat class implementation
|
||||
//
|
||||
// Stores information on the performance of the smart voxel algorithm
|
||||
// for an individual logical volume.
|
||||
//
|
||||
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SmartVoxelStat.hh"
|
||||
@@ -45,31 +39,27 @@
|
||||
//
|
||||
// Constructor
|
||||
//
|
||||
G4SmartVoxelStat::G4SmartVoxelStat( const G4LogicalVolume *theVolume,
|
||||
const G4SmartVoxelHeader *theVoxel,
|
||||
G4SmartVoxelStat::G4SmartVoxelStat( const G4LogicalVolume* theVolume,
|
||||
const G4SmartVoxelHeader* theVoxel,
|
||||
G4double theSysTime,
|
||||
G4double theUserTime )
|
||||
: volume(theVolume),
|
||||
voxel(theVoxel),
|
||||
sysTime(theSysTime),
|
||||
userTime(theUserTime),
|
||||
heads(1),
|
||||
nodes(0),
|
||||
pointers(0)
|
||||
userTime(theUserTime)
|
||||
{
|
||||
CountHeadsAndNodes( voxel );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Simple Accessors
|
||||
//
|
||||
const G4LogicalVolume *G4SmartVoxelStat::GetVolume() const
|
||||
const G4LogicalVolume* G4SmartVoxelStat::GetVolume() const
|
||||
{
|
||||
return volume;
|
||||
}
|
||||
|
||||
const G4SmartVoxelHeader *G4SmartVoxelStat::GetVoxel() const
|
||||
const G4SmartVoxelHeader* G4SmartVoxelStat::GetVoxel() const
|
||||
{
|
||||
return voxel;
|
||||
}
|
||||
@@ -104,7 +94,6 @@ G4long G4SmartVoxelStat::GetNumberPointers() const
|
||||
return pointers;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Return approximate memory use
|
||||
//
|
||||
@@ -121,33 +110,34 @@ G4long G4SmartVoxelStat::GetMemoryUse() const
|
||||
return nodes*nodeSize + heads*headSize + pointers*pointerSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// CountHeadsAndNodes
|
||||
//
|
||||
// Recursively count the number of voxel headers and nodes,
|
||||
// updating class member variables heads and nodes on the way.
|
||||
//
|
||||
void G4SmartVoxelStat::CountHeadsAndNodes( const G4SmartVoxelHeader *head )
|
||||
void G4SmartVoxelStat::CountHeadsAndNodes( const G4SmartVoxelHeader* head )
|
||||
{
|
||||
G4int numSlices = head->GetNoSlices();
|
||||
|
||||
pointers += numSlices;
|
||||
|
||||
const G4SmartVoxelProxy *lastProxy = 0;
|
||||
const G4SmartVoxelProxy* lastProxy = nullptr;
|
||||
|
||||
for(G4int i=0;i<numSlices;++i) {
|
||||
for(auto i=0; i<numSlices; ++i)
|
||||
{
|
||||
const G4SmartVoxelProxy *proxy = head->GetSlice(i);
|
||||
if (proxy == lastProxy) continue;
|
||||
|
||||
lastProxy = proxy;
|
||||
|
||||
if (proxy->IsNode()) {
|
||||
nodes++;
|
||||
if (proxy->IsNode())
|
||||
{
|
||||
++nodes;
|
||||
}
|
||||
else {
|
||||
heads++;
|
||||
else
|
||||
{
|
||||
++heads;
|
||||
CountHeadsAndNodes(proxy->GetHeader());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4SolidStore implementation for singleton container
|
||||
//
|
||||
//
|
||||
// G4SolidStore
|
||||
//
|
||||
// Implementation for singleton container
|
||||
//
|
||||
// History:
|
||||
// 10.07.95 P.Kent Initial version
|
||||
// 18.04.01, G.Cosmo - Migrated to STL vector
|
||||
// 10.07.95, P.Kent - Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "globals.hh"
|
||||
@@ -41,8 +37,8 @@
|
||||
// Static class variables
|
||||
// ***************************************************************************
|
||||
//
|
||||
G4SolidStore* G4SolidStore::fgInstance = 0;
|
||||
G4ThreadLocal G4VStoreNotifier* G4SolidStore::fgNotifier = 0;
|
||||
G4SolidStore* G4SolidStore::fgInstance = nullptr;
|
||||
G4ThreadLocal G4VStoreNotifier* G4SolidStore::fgNotifier = nullptr;
|
||||
G4ThreadLocal G4bool G4SolidStore::locked = false;
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -85,18 +81,17 @@ void G4SolidStore::Clean()
|
||||
//
|
||||
locked = true;
|
||||
|
||||
size_t i=0;
|
||||
size_t i = 0;
|
||||
G4SolidStore* store = GetInstance();
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
G4cout << "Deleting Solids ... ";
|
||||
#endif
|
||||
|
||||
for(iterator pos=store->begin(); pos!=store->end(); pos++)
|
||||
for(auto pos=store->cbegin(); pos!=store->cend(); ++pos)
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
if (*pos) { delete *pos; }
|
||||
i++;
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
delete *pos; ++i;
|
||||
}
|
||||
|
||||
#ifdef G4GEOMETRY_VOXELDEBUG
|
||||
@@ -127,7 +122,7 @@ void G4SolidStore::SetNotifier(G4VStoreNotifier* pNotifier)
|
||||
void G4SolidStore::Register(G4VSolid* pSolid)
|
||||
{
|
||||
GetInstance()->push_back(pSolid);
|
||||
if (fgNotifier) { fgNotifier->NotifyRegistration(); }
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyRegistration(); }
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -138,9 +133,8 @@ void G4SolidStore::DeRegister(G4VSolid* pSolid)
|
||||
{
|
||||
if (!locked) // Do not de-register if locked !
|
||||
{
|
||||
if (fgNotifier) { fgNotifier->NotifyDeRegistration(); }
|
||||
for (reverse_iterator i=GetInstance()->rbegin();
|
||||
i!=GetInstance()->rend(); i++)
|
||||
if (fgNotifier != nullptr) { fgNotifier->NotifyDeRegistration(); }
|
||||
for (auto i=GetInstance()->crbegin(); i!=GetInstance()->crend(); ++i)
|
||||
{
|
||||
if (**i==*pSolid)
|
||||
{
|
||||
@@ -157,7 +151,7 @@ void G4SolidStore::DeRegister(G4VSolid* pSolid)
|
||||
//
|
||||
G4VSolid* G4SolidStore::GetSolid(const G4String& name, G4bool verbose) const
|
||||
{
|
||||
for (iterator i=GetInstance()->begin(); i!=GetInstance()->end(); i++)
|
||||
for (auto i=GetInstance()->cbegin(); i!=GetInstance()->cend(); ++i)
|
||||
{
|
||||
if ((*i)->GetName() == name) { return *i; }
|
||||
}
|
||||
@@ -169,7 +163,7 @@ G4VSolid* G4SolidStore::GetSolid(const G4String& name, G4bool verbose) const
|
||||
G4Exception("G4SolidStore::GetSolid()",
|
||||
"GeomMgt1001", JustWarning, message);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
@@ -179,7 +173,7 @@ G4VSolid* G4SolidStore::GetSolid(const G4String& name, G4bool verbose) const
|
||||
G4SolidStore* G4SolidStore::GetInstance()
|
||||
{
|
||||
static G4SolidStore worldStore;
|
||||
if (!fgInstance)
|
||||
if (fgInstance == nullptr)
|
||||
{
|
||||
fgInstance = &worldStore;
|
||||
}
|
||||
|
||||
@@ -23,13 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VCurvedTrajectoryFilter class implementation
|
||||
//
|
||||
// First version: Oct 30, 2002 - Jacek Generowicz
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VCurvedTrajectoryFilter.hh"
|
||||
|
||||
G4VCurvedTrajectoryFilter::G4VCurvedTrajectoryFilter()
|
||||
: fpFilteredPoints(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -49,17 +50,17 @@ G4VCurvedTrajectoryFilter::GimmeThePointsAndForgetThem()
|
||||
// responsibility for deleting the vector lies with the
|
||||
// SmoothTrajctoryPoint, which is the vector's final destination.)
|
||||
// (jacek 08/11/2002)
|
||||
fpFilteredPoints = 0;
|
||||
fpFilteredPoints = nullptr;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
void
|
||||
G4VCurvedTrajectoryFilter::CreateNewTrajectorySegment( )
|
||||
{
|
||||
if (fpFilteredPoints)
|
||||
if (fpFilteredPoints != nullptr)
|
||||
{
|
||||
// GimmePoints has not been called (it would have set the
|
||||
// pointer to NULL), therefore nobody has taken charge of the
|
||||
// pointer to nullptr), therefore nobody has taken charge of the
|
||||
// points and they will never be deleted!
|
||||
G4cout << "!!!!!!!! Filter: auxiliary points are being memory leaked !!!!!"
|
||||
<< G4endl;
|
||||
|
||||
@@ -23,10 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4VNestedParameterisation implementation
|
||||
//
|
||||
// 24.02.05, J.Apostolakis - First created version.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VNestedParameterisation.hh"
|
||||
|
||||
@@ -23,16 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4VPVDivisionFactory Implementation file
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 4.5.2004 (Ivana.Hrivnacova@cern.ch)
|
||||
// Author: Ivana Hrivnacova, 4.5.2004
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#include "G4VPVDivisionFactory.hh"
|
||||
|
||||
G4ThreadLocal G4VPVDivisionFactory* G4VPVDivisionFactory::fgInstance = 0;
|
||||
G4ThreadLocal G4VPVDivisionFactory* G4VPVDivisionFactory::fgInstance = nullptr;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// Default implementations for Parameterisations that do not
|
||||
// parameterise solid and/or material.
|
||||
//
|
||||
// 25.07.96, P.Kent - Initial stub version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VPVParameterisation.hh"
|
||||
@@ -44,14 +44,14 @@ G4VPVParameterisation::~G4VPVParameterisation()
|
||||
|
||||
G4VSolid*
|
||||
G4VPVParameterisation::ComputeSolid(const G4int,
|
||||
G4VPhysicalVolume *pPhysicalVol)
|
||||
G4VPhysicalVolume* pPhysicalVol)
|
||||
{
|
||||
return pPhysicalVol->GetLogicalVolume()->GetSolid();
|
||||
}
|
||||
|
||||
G4Material*
|
||||
G4VPVParameterisation::ComputeMaterial(const G4int,
|
||||
G4VPhysicalVolume *pPhysicalVol,
|
||||
G4VPhysicalVolume* pPhysicalVol,
|
||||
const G4VTouchable *)
|
||||
{
|
||||
return pPhysicalVol->GetLogicalVolume()->GetMaterial();
|
||||
@@ -66,6 +66,6 @@ G4bool G4VPVParameterisation::IsNested() const
|
||||
G4VVolumeMaterialScanner*
|
||||
G4VPVParameterisation::GetMaterialScanner()
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
// These enable material scan for nested parameterisations
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4VPhysicalVolume Implementation
|
||||
//
|
||||
// 15.01.13, G.Cosmo, A.Dotti: Modified for thread-safety for MT
|
||||
// 28.08.96, P.Kent: Replaced transform by rotmat + vector
|
||||
// 25.07.96, P.Kent: Modified interface for new `Replica' capable geometry
|
||||
// 24.07.95, P.Kent: First non-stub version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
@@ -50,13 +51,12 @@ G4PVManager G4VPhysicalVolume::subInstanceManager;
|
||||
|
||||
// Constructor: init parameters and register in Store
|
||||
//
|
||||
G4VPhysicalVolume::G4VPhysicalVolume( G4RotationMatrix *pRot,
|
||||
const G4ThreeVector &tlate,
|
||||
G4VPhysicalVolume::G4VPhysicalVolume( G4RotationMatrix* pRot,
|
||||
const G4ThreeVector& tlate,
|
||||
const G4String& pName,
|
||||
G4LogicalVolume* pLogical,
|
||||
G4VPhysicalVolume* )
|
||||
: flogical(pLogical),
|
||||
fname(pName), flmother(0)
|
||||
: flogical(pLogical), fname(pName)
|
||||
{
|
||||
instanceID = subInstanceManager.CreateSubInstance();
|
||||
|
||||
@@ -77,7 +77,7 @@ G4VPhysicalVolume::G4VPhysicalVolume( G4RotationMatrix *pRot,
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4VPhysicalVolume::G4VPhysicalVolume( __void__& )
|
||||
: flogical(0), fname(""), flmother(0), pvdata(0)
|
||||
: fname("")
|
||||
{
|
||||
// Register to store
|
||||
//
|
||||
@@ -161,7 +161,7 @@ G4RotationMatrix* G4VPhysicalVolume::GetRotation()
|
||||
|
||||
void G4VPhysicalVolume::SetRotation(G4RotationMatrix *pRot)
|
||||
{
|
||||
G4MT_rot=pRot;
|
||||
G4MT_rot = pRot;
|
||||
}
|
||||
|
||||
G4RotationMatrix* G4VPhysicalVolume::GetObjectRotation() const
|
||||
@@ -182,12 +182,12 @@ G4RotationMatrix* G4VPhysicalVolume::GetObjectRotation() const
|
||||
|
||||
G4RotationMatrix G4VPhysicalVolume::GetObjectRotationValue() const
|
||||
{
|
||||
G4RotationMatrix aRotM; // Initialised to identity
|
||||
G4RotationMatrix aRotM; // Initialised to identity
|
||||
|
||||
// Insure against G4MT_rot being a null pointer
|
||||
if(G4MT_rot)
|
||||
{
|
||||
aRotM= G4MT_rot->inverse();
|
||||
aRotM = G4MT_rot->inverse();
|
||||
}
|
||||
return aRotM;
|
||||
}
|
||||
|
||||
@@ -23,28 +23,16 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VSolid implementation for solid base class
|
||||
//
|
||||
//
|
||||
// class G4VSolid
|
||||
//
|
||||
// Implementation for solid base class
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 10.10.18 E.Tcherniaev, more robust EstimateSurfaceArea() based on distance
|
||||
// 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
|
||||
// 13.03.02 V.Grichine, cosmetics of voxel limit functions
|
||||
// 15.11.00 D.Williams, V.Grichine, fix in CalculateClippedPolygonExtent()
|
||||
// 10.07.95 P.Kent, Added == operator, solid Store entry
|
||||
// 30.06.95 P.Kent, Created.
|
||||
// 10.10.18 E.Tcherniaev, more robust EstimateSurfaceArea() based on distance
|
||||
// 30.06.95 P.Kent, Created.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
#include "globals.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4QuickRand.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
|
||||
#include "G4VoxelLimits.hh"
|
||||
@@ -165,16 +153,16 @@ G4ThreeVector G4VSolid::GetPointOnSurface() const
|
||||
// Dummy implementations ...
|
||||
|
||||
const G4VSolid* G4VSolid::GetConstituentSolid(G4int) const
|
||||
{ return 0; }
|
||||
{ return nullptr; }
|
||||
|
||||
G4VSolid* G4VSolid::GetConstituentSolid(G4int)
|
||||
{ return 0; }
|
||||
{ return nullptr; }
|
||||
|
||||
const G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr() const
|
||||
{ return 0; }
|
||||
{ return nullptr; }
|
||||
|
||||
G4DisplacedSolid* G4VSolid::GetDisplacedSolidPtr()
|
||||
{ return 0; }
|
||||
{ return nullptr; }
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -224,14 +212,14 @@ G4double G4VSolid::EstimateCubicVolume(G4int nStat, G4double epsilon) const
|
||||
if(epsilon > 0.01) epsilon = 0.01;
|
||||
halfepsilon = 0.5*epsilon;
|
||||
|
||||
for(G4int i = 0; i < nStat; i++ )
|
||||
for(auto i = 0; i < nStat; ++i )
|
||||
{
|
||||
px = minX-halfepsilon+(maxX-minX+epsilon)*G4UniformRand();
|
||||
py = minY-halfepsilon+(maxY-minY+epsilon)*G4UniformRand();
|
||||
pz = minZ-halfepsilon+(maxZ-minZ+epsilon)*G4UniformRand();
|
||||
px = minX-halfepsilon+(maxX-minX+epsilon)*G4QuickRand();
|
||||
py = minY-halfepsilon+(maxY-minY+epsilon)*G4QuickRand();
|
||||
pz = minZ-halfepsilon+(maxZ-minZ+epsilon)*G4QuickRand();
|
||||
p = G4ThreeVector(px,py,pz);
|
||||
in = Inside(p);
|
||||
if(in != kOutside) iInside++;
|
||||
if(in != kOutside) ++iInside;
|
||||
}
|
||||
volume = (maxX-minX+epsilon)*(maxY-minY+epsilon)
|
||||
* (maxZ-minZ+epsilon)*iInside/nStat;
|
||||
@@ -335,11 +323,11 @@ G4double G4VSolid::EstimateSurfaceArea(G4int nstat, G4double ell) const
|
||||
// Calculate surface area
|
||||
//
|
||||
G4int icount = 0;
|
||||
for(G4int i = 0; i < npoints; ++i)
|
||||
for(auto i = 0; i < npoints; ++i)
|
||||
{
|
||||
G4double px = minX + dX*G4UniformRand();
|
||||
G4double py = minY + dY*G4UniformRand();
|
||||
G4double pz = minZ + dZ*G4UniformRand();
|
||||
G4double px = minX + dX*G4QuickRand();
|
||||
G4double py = minY + dY*G4QuickRand();
|
||||
G4double pz = minZ + dZ*G4QuickRand();
|
||||
G4ThreeVector p = G4ThreeVector(px, py, pz);
|
||||
EInside in = Inside(p);
|
||||
G4double dist = 0;
|
||||
@@ -376,7 +364,7 @@ G4double G4VSolid::EstimateSurfaceArea(G4int nstat, G4double ell) const
|
||||
G4ThreeVector n = SurfaceNormal(p + v*dist);
|
||||
dist *= -(v.dot(n));
|
||||
}
|
||||
if (dist < eps) icount++;
|
||||
if (dist < eps) ++icount;
|
||||
}
|
||||
return dX*dY*dZ*icount/npoints/dd;
|
||||
}
|
||||
@@ -395,7 +383,7 @@ G4VSolid* G4VSolid::Clone() const
|
||||
<< GetEntityType() << "!" << G4endl
|
||||
<< "Returning NULL pointer!";
|
||||
G4Exception("G4VSolid::Clone()", "GeomMgt1001", JustWarning, message);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -424,7 +412,6 @@ void G4VSolid::ClipCrossSection( G4ThreeVectorList* pVertices,
|
||||
polygon.push_back((*pVertices)[pSectionIndex+1]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex+2]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex+3]);
|
||||
// G4cout<<"ClipCrossSection: 0-1-2-3"<<G4endl;
|
||||
CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
|
||||
return;
|
||||
}
|
||||
@@ -454,7 +441,6 @@ void G4VSolid::ClipBetweenSections( G4ThreeVectorList* pVertices,
|
||||
polygon.push_back((*pVertices)[pSectionIndex+4]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex+5]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex+1]);
|
||||
// G4cout<<"ClipBetweenSections: 0-4-5-1"<<G4endl;
|
||||
CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
|
||||
polygon.clear();
|
||||
|
||||
@@ -462,7 +448,6 @@ void G4VSolid::ClipBetweenSections( G4ThreeVectorList* pVertices,
|
||||
polygon.push_back((*pVertices)[pSectionIndex+5]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex+6]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex+2]);
|
||||
// G4cout<<"ClipBetweenSections: 1-5-6-2"<<G4endl;
|
||||
CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
|
||||
polygon.clear();
|
||||
|
||||
@@ -470,7 +455,6 @@ void G4VSolid::ClipBetweenSections( G4ThreeVectorList* pVertices,
|
||||
polygon.push_back((*pVertices)[pSectionIndex+6]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex+7]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex+3]);
|
||||
// G4cout<<"ClipBetweenSections: 2-6-7-3"<<G4endl;
|
||||
CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
|
||||
polygon.clear();
|
||||
|
||||
@@ -478,7 +462,6 @@ void G4VSolid::ClipBetweenSections( G4ThreeVectorList* pVertices,
|
||||
polygon.push_back((*pVertices)[pSectionIndex+7]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex+4]);
|
||||
polygon.push_back((*pVertices)[pSectionIndex]);
|
||||
// G4cout<<"ClipBetweenSections: 3-7-4-0"<<G4endl;
|
||||
CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
|
||||
return;
|
||||
}
|
||||
@@ -499,43 +482,26 @@ G4VSolid::CalculateClippedPolygonExtent(G4ThreeVectorList& pPolygon,
|
||||
{
|
||||
G4int noLeft,i;
|
||||
G4double component;
|
||||
/*
|
||||
G4cout<<G4endl;
|
||||
for(i = 0 ; i < pPolygon.size() ; i++ )
|
||||
{
|
||||
G4cout << i << "\t"
|
||||
<< "p.x = " << pPolygon[i].operator()(pAxis) << "\t"
|
||||
// << "p.y = " << pPolygon[i].y() << "\t"
|
||||
// << "p.z = " << pPolygon[i].z() << "\t"
|
||||
<< G4endl;
|
||||
}
|
||||
G4cout<<G4endl;
|
||||
*/
|
||||
|
||||
ClipPolygon(pPolygon,pVoxelLimit,pAxis);
|
||||
noLeft = pPolygon.size();
|
||||
|
||||
if ( noLeft )
|
||||
{
|
||||
// G4cout<<G4endl;
|
||||
for (i=0;i<noLeft;i++)
|
||||
for (i=0; i<noLeft; ++i)
|
||||
{
|
||||
component = pPolygon[i].operator()(pAxis);
|
||||
// G4cout <<i<<"\t"<<component<<G4endl;
|
||||
|
||||
if (component < pMin)
|
||||
{
|
||||
// G4cout <<i<<"\t"<<"Pmin = "<<component<<G4endl;
|
||||
pMin = component;
|
||||
}
|
||||
if (component > pMax)
|
||||
{
|
||||
// G4cout <<i<<"\t"<<"PMax = "<<component<<G4endl;
|
||||
pMax = component;
|
||||
}
|
||||
}
|
||||
// G4cout<<G4endl;
|
||||
}
|
||||
// G4cout<<"pMin = "<<pMin<<"\t"<<"pMax = "<<pMax<<G4endl;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -570,7 +536,6 @@ void G4VSolid::ClipPolygon( G4ThreeVectorList& pPolygon,
|
||||
{
|
||||
G4VoxelLimits simpleLimit1;
|
||||
simpleLimit1.AddLimit(kXAxis,pVoxelLimit.GetMinXExtent(),kInfinity);
|
||||
// G4cout<<"MinXExtent()"<<G4endl;
|
||||
ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
|
||||
|
||||
pPolygon.clear();
|
||||
@@ -578,7 +543,6 @@ void G4VSolid::ClipPolygon( G4ThreeVectorList& pPolygon,
|
||||
if ( !outputPolygon.size() ) return;
|
||||
|
||||
G4VoxelLimits simpleLimit2;
|
||||
// G4cout<<"MaxXExtent()"<<G4endl;
|
||||
simpleLimit2.AddLimit(kXAxis,-kInfinity,pVoxelLimit.GetMaxXExtent());
|
||||
ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
|
||||
|
||||
@@ -641,10 +605,9 @@ G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVectorList& pPolygon,
|
||||
G4int noVertices=pPolygon.size();
|
||||
G4ThreeVector vEnd,vStart;
|
||||
|
||||
for (i = 0 ; i < noVertices ; i++ )
|
||||
for (i = 0 ; i < noVertices ; ++i )
|
||||
{
|
||||
vStart = pPolygon[i];
|
||||
// G4cout << "i = " << i << G4endl;
|
||||
if ( i == noVertices-1 ) vEnd = pPolygon[0];
|
||||
else vEnd = pPolygon[i+1];
|
||||
|
||||
@@ -660,7 +623,6 @@ G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVectorList& pPolygon,
|
||||
{
|
||||
// vStart inside, vEnd outside -> output crossing point
|
||||
//
|
||||
// G4cout << "vStart inside, vEnd outside" << G4endl;
|
||||
pVoxelLimit.ClipToLimits(vStart,vEnd);
|
||||
outputPolygon.push_back(vEnd);
|
||||
}
|
||||
@@ -671,7 +633,6 @@ G4VSolid::ClipPolygonToSimpleLimits( G4ThreeVectorList& pPolygon,
|
||||
{
|
||||
// vStart outside, vEnd inside -> output inside section
|
||||
//
|
||||
// G4cout << "vStart outside, vEnd inside" << G4endl;
|
||||
pVoxelLimit.ClipToLimits(vStart,vEnd);
|
||||
outputPolygon.push_back(vStart);
|
||||
outputPolygon.push_back(vEnd);
|
||||
@@ -726,10 +687,10 @@ G4VisExtent G4VSolid::GetExtent () const
|
||||
|
||||
G4Polyhedron* G4VSolid::CreatePolyhedron () const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
G4Polyhedron* G4VSolid::GetPolyhedron () const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -22,12 +22,10 @@
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// class G4VTouchable implementation
|
||||
//
|
||||
// Created: Paul Kent, August 1996
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VTouchable.hh"
|
||||
@@ -44,14 +42,14 @@ G4VPhysicalVolume* G4VTouchable::GetVolume(G4int) const
|
||||
{
|
||||
G4Exception("G4VTouchable::GetVolume()", "GeomMgt0001",
|
||||
FatalException, "Undefined call to base class.");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
G4VSolid* G4VTouchable::GetSolid(G4int) const
|
||||
{
|
||||
G4Exception("G4VTouchable::GetSolid()", "GeomMgt0001",
|
||||
FatalException, "Undefined call to base class.");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
G4int G4VTouchable::GetReplicaNumber(G4int) const
|
||||
|
||||
@@ -23,16 +23,9 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Class G4VoxelLimits implementation
|
||||
//
|
||||
//
|
||||
// class G4VoxelLimits
|
||||
//
|
||||
// Implementation
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 14.03.02 V. Grichine, cosmetics
|
||||
// 13.07.95 P.Kent Initial version
|
||||
// 13.07.95, P.Kent - Initial version
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VoxelLimits.hh"
|
||||
@@ -43,11 +36,7 @@
|
||||
//
|
||||
// Empty constructor and destructor
|
||||
//
|
||||
|
||||
G4VoxelLimits::G4VoxelLimits()
|
||||
: fxAxisMin(-kInfinity),fxAxisMax(kInfinity),
|
||||
fyAxisMin(-kInfinity),fyAxisMax(kInfinity),
|
||||
fzAxisMin(-kInfinity),fzAxisMax(kInfinity)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,7 +49,6 @@ G4VoxelLimits::~G4VoxelLimits()
|
||||
// Further restrict limits
|
||||
// No checks for illegal restrictions
|
||||
//
|
||||
|
||||
void G4VoxelLimits::AddLimit( const EAxis pAxis,
|
||||
const G4double pMin,
|
||||
const G4double pMax )
|
||||
@@ -97,7 +85,6 @@ void G4VoxelLimits::AddLimit( const EAxis pAxis,
|
||||
// Use Cohen-Sutherland clipping in 3D
|
||||
// [Fundamentals of Interactive Computer Graphics,Foley & Van Dam]
|
||||
//
|
||||
|
||||
G4bool G4VoxelLimits::ClipToLimits( G4ThreeVector& pStart,
|
||||
G4ThreeVector& pEnd ) const
|
||||
{
|
||||
@@ -136,20 +123,7 @@ G4bool G4VoxelLimits::ClipToLimits( G4ThreeVector& pStart,
|
||||
x2 = pEnd.x() ;
|
||||
y2 = pEnd.y() ;
|
||||
z2 = pEnd.z() ;
|
||||
/*
|
||||
if( std::abs(x1-x2) < kCarTolerance*kCarTolerance)
|
||||
{
|
||||
G4cout<<"x1 = "<<x1<<"\t"<<"x2 = "<<x2<<G4endl;
|
||||
}
|
||||
if( std::abs(y1-y2) < kCarTolerance*kCarTolerance)
|
||||
{
|
||||
G4cout<<"y1 = "<<y1<<"\t"<<"y2 = "<<y2<<G4endl;
|
||||
}
|
||||
if( std::abs(z1-z2) < kCarTolerance*kCarTolerance)
|
||||
{
|
||||
G4cout<<"z1 = "<<z1<<"\t"<<"z2 = "<<z2<<G4endl;
|
||||
}
|
||||
*/
|
||||
|
||||
while ( sCode != eCode ) // Loop checking, 06.08.2015, G.Cosmo
|
||||
{
|
||||
// Copy vectors to work variables x1-z1,x2-z2
|
||||
@@ -234,7 +208,6 @@ G4bool G4VoxelLimits::ClipToLimits( G4ThreeVector& pStart,
|
||||
z2 = fzAxisMax;
|
||||
}
|
||||
}
|
||||
// G4endl; G4cout<<"x1 = "<<x1<<"\t"<<"x2 = "<<x2<<G4endl<<G4endl;
|
||||
pStart = G4ThreeVector(x1,y1,z1);
|
||||
pEnd = G4ThreeVector(x2,y2,z2);
|
||||
sCode = OutCode(pStart);
|
||||
@@ -257,7 +230,6 @@ G4bool G4VoxelLimits::ClipToLimits( G4ThreeVector& pStart,
|
||||
// 4 pVec.z()<fzAxisMin && IsZLimited()
|
||||
// 5 pVec.z()>fzAxisMax && IsZLimited()
|
||||
//
|
||||
|
||||
G4int G4VoxelLimits::OutCode( const G4ThreeVector& pVec ) const
|
||||
{
|
||||
G4int code = 0 ; // The outcode
|
||||
|
||||
Reference in New Issue
Block a user