Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
+56 -5
View File
@@ -9,20 +9,71 @@
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
It DOES NOT substitute the log-message one should put in every
commit in the repository !
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
May 29, G. Cosmo (geommng-V10-05-07)
November 15, 2019 Gabriele Cosmo (geommng-V10-05-15)
- Fixed cases of implicit type conversions from size_t to G4int.
November 11, 2019 J.Apostolakis (geommng-V10-05-14)
- G4LogicalVolume: Added method 'ChangeDaughtersType' to change the
volume type for CharacterisedDaughters. It enables the user to turn
over responsibility for navigation in that volume to an external navigator.
( This is for use when one or more daughter volumes are created as an
existing physical volume types (typically G4PVPlacement). )
It can also be used enable to create a (logical) volume which containts a
mixture of existing G4-toolkit physical volume types, and user-created
'external' physical volume (with type code 'kExternal').
G4 types must be created first, and then ChangeDaughtersType must be called
to change the mother's attribute to 'kExternal'.
Note: only one type of sub-navigator will be called to find a track's
intersection (or the location of a point) in all daughters of one mother
volume. The sub-navigator chosen will correspond to the volume type assigned.
October 29, 2019 J.Apostolakis (geommng-V10-05-13)
- Use stored volume type for G4LogicalVolume::CharacterisedDaughters,
after fix to correctly store type of G4PVParameterised volume.
Requires geomvol-V10-05-07.
October 23, 2019 J.Apostolakis, G.Cosmo (geommng-V10-05-12)
- Revised G4LogicalVolume to cope with 'external' type of physical volumes.
Note: these revisions are independent and backward compatible.
- Co-works with geomnav-V10-05-11 (external navigation).
October 23, 2019 J.Apostolakis (geommng-V10-05-11)
- Changed G4VPhysicalVolume::VolumeType() to be virtual.
Preparing for addition of External Navigation, which adds an 'external'
physical volume type (for use with an External sub-Navigator).
Note: This is used by G4Navigator's CharacteriseDaughters() method.
The old method derived this value from response of IsReplicated()
virtual method and, in the case of replica/division/parameterised volumes,
information from a call to the 2nd virtual method ReplicationData.
- G4VPhysicalVolume copy constructor and assignment operator are now 'deleted'.
- Requires and co-works with geomvol-V10-05-05, geomdiv-V10-05-02.
September 14, 2019 E.Tcherniaev (geommng-V10-05-10)
- Use G4QuickRand() in G4VSolid::EstimateCubicVolume() and
G4VSolid::EstimateSurfaceArea()
August 22, 2019 G.Cosmo (geommng-V10-05-09)
- Use pre-increment wherever possible.
July 11, 2019 G.Cosmo (geommng-V10-05-08)
- Implemented c++11 revision: nullptr, auto, inline data initialisation,
const iterators, alias using statements.
- Code cleanup and formatting.
May 29, 2019 G.Cosmo (geommng-V10-05-07)
- Fixed minor Coverity defects.
May 20, G. Cosmo (geommng-V10-05-06)
May 20, 2019 G.Cosmo (geommng-V10-05-06)
- Defined move constructor and move assignment operator for G4AffineTransform.
May 14, B. Morgan (geommng-V10-05-05)
May 14, 2019 B.Morgan (geommng-V10-05-05)
- Use header-based #define/undef symbols to configure VecGeom replacements
- G4GeomConfig.hh: Generated header configuring #defines using CMake settings
- G4GeomTypes.hh: "Interface" header to support old GNUmake system. All Geant4
@@ -23,9 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4AffineTransform
//
// Class description:
@@ -49,9 +46,8 @@
// G4double rzx,rzy,rzz;
// G4double tx,ty,tz; Net translation
// History:
// Paul R C Kent 6 Aug 1996 - initial version
//
// 06.08.1996 Paul R C Kent:
// - initial version
// 19.09.1996 E.Tcherniaev:
// - direct access to the protected members of the G4RotationMatrix class
// replaced by access via public access functions
@@ -72,126 +68,124 @@
class G4AffineTransform
{
public:
public:
inline G4AffineTransform();
inline G4AffineTransform();
public: // with description
public: // with description
inline G4AffineTransform(const G4ThreeVector& tlate);
// Translation only: under t'form translate point at origin by tlate
inline G4AffineTransform(const G4ThreeVector& tlate);
// Translation only: under t'form translate point at origin by tlate
inline G4AffineTransform(const G4RotationMatrix& rot);
// Rotation only: under t'form rotate by rot
inline G4AffineTransform(const G4RotationMatrix& rot);
// Rotation only: under t'form rotate by rot
inline G4AffineTransform(const G4RotationMatrix& rot,
const G4ThreeVector& tlate);
// Under t'form: rotate by rot then translate by tlate
inline G4AffineTransform(const G4RotationMatrix& rot,
const G4ThreeVector& tlate);
// Under t'form: rotate by rot then translate by tlate
inline G4AffineTransform(const G4RotationMatrix* rot,
const G4ThreeVector& tlate);
// Optionally rotate by *rot then translate by tlate - rot may be null
inline G4AffineTransform(const G4RotationMatrix* rot,
const G4ThreeVector& tlate);
// Optionally rotate by *rot then translate by tlate - rot may be null
inline G4AffineTransform(const G4AffineTransform& rhs);
inline G4AffineTransform(G4AffineTransform&& rhs) = default;
// Copy and move constructors
inline G4AffineTransform(const G4AffineTransform& rhs);
inline G4AffineTransform(G4AffineTransform&& rhs) = default;
// Copy and move constructors
inline G4AffineTransform& operator=(const G4AffineTransform& rhs);
inline G4AffineTransform& operator=(G4AffineTransform&& rhs) = default;
// Assignment & Move operators
inline G4AffineTransform& operator=(const G4AffineTransform& rhs);
inline G4AffineTransform& operator=(G4AffineTransform&& rhs) = default;
// Assignment & Move operators
inline ~G4AffineTransform();
// Destructor
inline ~G4AffineTransform();
// Destructor
inline G4AffineTransform operator * (const G4AffineTransform& tf) const;
// Compound Transforms:
// tf2=tf2*tf1 equivalent to tf2*=tf1
// Returns compound transformation of self*tf
inline G4AffineTransform operator * (const G4AffineTransform& tf) const;
// Compound Transforms:
// tf2=tf2*tf1 equivalent to tf2*=tf1
// Returns compound transformation of self*tf
inline G4AffineTransform& operator *= (const G4AffineTransform& tf);
// (Modifying) Multiplies self by tf; Returns self reference
// ie. A=AB for a*=b
inline G4AffineTransform& operator *= (const G4AffineTransform& tf);
// (Modifying) Multiplies self by tf; Returns self reference
// ie. A=AB for a*=b
inline G4AffineTransform& Product(const G4AffineTransform& tf1,
const G4AffineTransform& tf2);
// 'Products' for avoiding (potential) temporaries:
// c.Product(a,b) equivalent to c=a*b
// c.InverseProduct(a*b,b ) equivalent to c=a
// (Modifying) Sets self=tf1*tf2; Returns self reference
inline G4AffineTransform& InverseProduct(const G4AffineTransform& tf1,
const G4AffineTransform& tf2);
// (Modifying) Sets self=tf1*(tf2^-1); Returns self reference
inline G4AffineTransform& Product(const G4AffineTransform& tf1,
const G4AffineTransform& tf2);
// 'Products' for avoiding (potential) temporaries:
// c.Product(a,b) equivalent to c=a*b
// c.InverseProduct(a*b,b ) equivalent to c=a
// (Modifying) Sets self=tf1*tf2; Returns self reference
inline G4ThreeVector TransformPoint(const G4ThreeVector& vec) const;
// Transform the specified point: returns vec*rot+tlate
inline G4AffineTransform& InverseProduct(const G4AffineTransform& tf1,
const G4AffineTransform& tf2);
// (Modifying) Sets self=tf1*(tf2^-1); Returns self reference
inline G4ThreeVector InverseTransformPoint(const G4ThreeVector& vec) const;
// Transform the specified point using inverse transformation
inline G4ThreeVector TransformPoint(const G4ThreeVector& vec) const;
// Transform the specified point: returns vec*rot+tlate
inline G4ThreeVector TransformAxis(const G4ThreeVector& axis) const;
// Transform the specified axis: returns vec*rot
inline G4ThreeVector InverseTransformPoint(const G4ThreeVector& vec) const;
// Transform the specified point using inverse transformation
inline G4ThreeVector InverseTransformAxis(const G4ThreeVector& axis) const;
// Transform the specified axis using inverse transfromation
inline G4ThreeVector TransformAxis(const G4ThreeVector& axis) const;
// Transform the specified axis: returns vec*rot
inline void ApplyPointTransform(G4ThreeVector& vec) const;
// Transform the specified point (in place): sets vec=vec*rot+tlate
inline G4ThreeVector InverseTransformAxis(const G4ThreeVector& axis) const;
// Transform the specified axis using inverse transfromation
inline void ApplyAxisTransform(G4ThreeVector& axis) const;
// Transform the specified axis (in place): sets axis=axis*rot;
inline void ApplyPointTransform(G4ThreeVector& vec) const;
// Transform the specified point (in place): sets vec=vec*rot+tlate
inline G4AffineTransform Inverse() const;
// Return inverse of current transform
inline void ApplyAxisTransform(G4ThreeVector& axis) const;
// Transform the specified axis (in place): sets axis=axis*rot;
inline G4AffineTransform& Invert();
// (Modifying) Sets self=inverse of self; Returns self reference
inline G4AffineTransform Inverse() const;
// Return inverse of current transform
inline G4AffineTransform& operator +=(const G4ThreeVector& tlate);
inline G4AffineTransform& operator -=(const G4ThreeVector& tlate);
// (Modifying) Adjust net translation by given vector;
// Returns self reference
inline G4AffineTransform& Invert();
// (Modifying) Sets self=inverse of self; Returns self reference
inline G4bool operator == (const G4AffineTransform& tf) const;
inline G4bool operator != (const G4AffineTransform& tf) const;
inline G4AffineTransform& operator +=(const G4ThreeVector& tlate);
inline G4AffineTransform& operator -=(const G4ThreeVector& tlate);
// (Modifying) Adjust net translation by given vector;
// Returns self reference
inline G4double operator [] (const G4int n) const;
inline G4bool operator == (const G4AffineTransform& tf) const;
inline G4bool operator != (const G4AffineTransform& tf) const;
inline G4bool IsRotated() const;
// True if transform includes rotation
inline G4double operator [] (const G4int n) const;
inline G4bool IsTranslated() const;
// True if transform includes translation
inline G4bool IsRotated() const;
// True if transform includes rotation
inline G4RotationMatrix NetRotation() const;
inline G4bool IsTranslated() const;
// True if transform includes translation
inline G4RotationMatrix InverseNetRotation() const;
inline G4RotationMatrix NetRotation() const;
inline G4ThreeVector NetTranslation() const;
inline G4RotationMatrix InverseNetRotation() const;
inline G4ThreeVector InverseNetTranslation() const;
inline G4ThreeVector NetTranslation() const;
inline void SetNetRotation(const G4RotationMatrix& rot);
inline G4ThreeVector InverseNetTranslation() const;
inline void SetNetTranslation(const G4ThreeVector& tlate);
inline void SetNetRotation(const G4RotationMatrix& rot);
inline operator G4Transform3D () const;
// Conversion operator (cast) to G4Transform3D
inline void SetNetTranslation(const G4ThreeVector& tlate);
private:
inline operator G4Transform3D () const;
// Conversion operator (cast) to G4Transform3D
private:
inline G4AffineTransform(
inline G4AffineTransform(
const G4double prxx, const G4double prxy, const G4double prxz,
const G4double pryx, const G4double pryy, const G4double pryz,
const G4double przx, const G4double przy, const G4double przz,
const G4double ptx, const G4double pty, const G4double ptz);
G4double rxx,rxy,rxz;
G4double ryx,ryy,ryz;
G4double rzx,rzy,rzz;
G4double tx,ty,tz;
G4double rxx,rxy,rxz;
G4double ryx,ryy,ryz;
G4double rzx,rzy,rzz;
G4double tx,ty,tz;
};
std::ostream& operator << (std::ostream& os, const G4AffineTransform& transf);
@@ -23,9 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4AffineTransformation Inline implementation
//
// --------------------------------------------------------------------
@@ -63,7 +60,7 @@ inline G4AffineTransform::G4AffineTransform( const G4RotationMatrix* rot,
const G4ThreeVector& tlate )
: tx(tlate.x()),ty(tlate.y()),tz(tlate.z())
{
if (rot)
if (rot != nullptr)
{
rxx=rot->xx();rxy=rot->xy();rxz=rot->xz();
ryx=rot->yx();ryy=rot->yy();ryz=rot->yz();
@@ -23,8 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4BlockingList
//
// Class description:
@@ -39,9 +37,7 @@
// increased, so that the ValVector must only be zeroed when the
// numerical range of the tag is used.
// History:
//
// 24.7.96 P.Kent Separated from G4Navigator
// 24.7.96, P.Kent - Separated from G4Navigator
// --------------------------------------------------------------------
#ifndef G4BLOCKINGLIST_HH
#define G4BLOCKINGLIST_HH
@@ -58,8 +54,8 @@ class G4BlockingList
{
public: // with description
G4BlockingList(G4int maxDefault=kBlockingListMaxDefault,
G4int stride=kBlockingListStride);
G4BlockingList(G4int maxDefault = kBlockingListMaxDefault,
G4int stride = kBlockingListStride);
// Create empty blocking List of default size and `stride' resize count.
~G4BlockingList();
@@ -77,7 +73,7 @@ class G4BlockingList
// Enlarges blocking List if current size < nv, in units of stride.
// Clears the new part of the List.
G4int Length() const;
size_t Length() const;
// Returns the current length of the List. Note a length of 16
// means volumes of indices between 0 & 15 inclusive may be blocked.
@@ -91,13 +87,12 @@ class G4BlockingList
private:
G4int fBlockTagNo, fStride;
G4int fBlockTagNo = 1, fStride;
// Current blocked volume tag number.
std::vector<G4int> fBlockingList;
// Blocked volumes: Elements with indices
// corresponding to blocked volume set to fBlockTagNo.
};
#include "G4BlockingList.icc"
@@ -30,7 +30,7 @@
//
// --------------------------------------------------------------------
inline G4int G4BlockingList::Length() const
inline size_t G4BlockingList::Length() const
{
return fBlockingList.size();
}
@@ -59,12 +59,12 @@ inline void G4BlockingList::Reset()
inline void G4BlockingList::Enlarge(const G4int nv)
{
G4int len=fBlockingList.size();
if ( len<nv )
size_t len=fBlockingList.size();
if ( G4int(len)<nv )
{
G4int newlen = (nv/fStride+1)*fStride;
size_t newlen = (nv/fStride+1)*fStride;
fBlockingList.resize(newlen);
for (G4int i=len; i<newlen; i++)
for (auto i=len; i<newlen; ++i)
{
fBlockingList[i] = 0;
}
@@ -23,9 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4BoundingEnvelope
//
// Class description:
@@ -40,10 +37,7 @@
// Calculation of extent uses G4Transform3D, thus takes into account
// scaling and reflection, if any.
// History:
//
// 2016.05.25 E.Tcherniaev - initial version
//
// 2016.05.25, E.Tcherniaev - initial version
// --------------------------------------------------------------------
#ifndef G4BOUNDINGENVELOPE_HH
#define G4BOUNDINGENVELOPE_HH
@@ -57,9 +51,9 @@
#include "G4Point3D.hh"
#include "G4Plane3D.hh"
typedef std::vector<G4ThreeVector> G4ThreeVectorList;
typedef std::vector<G4Point3D> G4Polygon3D;
typedef std::pair<G4Point3D,G4Point3D> G4Segment3D;
using G4ThreeVectorList = std::vector<G4ThreeVector>;
using G4Polygon3D = std::vector<G4Point3D>;
using G4Segment3D = std::pair<G4Point3D,G4Point3D>;
class G4BoundingEnvelope
{
@@ -145,7 +139,7 @@ class G4BoundingEnvelope
G4ThreeVector fMin, fMax;
// original bounding box
const std::vector<const G4ThreeVectorList*>* fPolygons;
const std::vector<const G4ThreeVectorList*>* fPolygons = nullptr;
// ref to original sequence of polygonal bases
};
@@ -23,21 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
// --------------------------------------------------------------------
// G4ErrorCylSurfaceTarget
//
// Class Description:
//
// G4ErrorTarget class: limits step when track reaches a cylindrical surface.
// Limits step when track reaches a cylindrical surface.
// History:
// - Created. P. Arce, September 2004
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorCylSurfaceTarget_hh
#define G4ErrorCylSurfaceTarget_hh
@@ -23,21 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
// --------------------------------------------------------------------
// G4ErrorPlaneSurfaceTarget
//
// Class Description:
//
// G4ErrorTarget class: limits step when track reaches a plane surface.
// Limits step when track reaches a plane surface.
// History:
// - Created. P. Arce, September 2004
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorPlaneSurfaceTarget_hh
#define G4ErrorPlaneSurfaceTarget_hh
@@ -50,17 +43,17 @@ class G4ErrorPlaneSurfaceTarget : public G4ErrorSurfaceTarget, G4Plane3D
{
public: // with description
G4ErrorPlaneSurfaceTarget(G4double a=0, G4double b=0,
G4double c=0, G4double d=0);
G4ErrorPlaneSurfaceTarget(G4double a=0., G4double b=0.,
G4double c=0., G4double d=0.);
// Constructs plane by parameters: ax+by+cz+d = 0
G4ErrorPlaneSurfaceTarget(const G4Normal3D &n,
const G4Point3D &p);
G4ErrorPlaneSurfaceTarget(const G4Normal3D& n,
const G4Point3D& p);
// Constructs plane by point and normal
G4ErrorPlaneSurfaceTarget(const G4Point3D &p1,
const G4Point3D &p2,
const G4Point3D &p3);
G4ErrorPlaneSurfaceTarget(const G4Point3D& p1,
const G4Point3D& p2,
const G4Point3D& p3);
// Constructs plane by three points
~G4ErrorPlaneSurfaceTarget();
@@ -23,19 +23,13 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
// --------------------------------------------------------------------
// G4ErrorSurfaceTarget
//
// Class Description:
//
// Base class for G4ErrorTarget classes that are surfaces.
// History:
// - Created. P. Arce, September 2004
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorSurfaceTarget_hh
@@ -23,21 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
// ------------------------------------------------------------
// G4ErrorTanPlaneTarget
//
// Class Description:
//
// Base class for G4ErrorTarget classes for which a tangent plane is defined.
// History:
// - Created. P. Arce, September 2004
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorTanPlaneTarget_hh
#define G4ErrorTanPlaneTarget_hh
@@ -23,21 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
// --------------------------------------------------------------------
// G4ErrorTarget
//
// Class Description:
//
// Base class for all error propagation targets.
// History:
// - Created. P. Arce, September 2004
// Created: P.Arce, September 2004
// --------------------------------------------------------------------
#ifndef G4ErrorTarget_hh
#define G4ErrorTarget_hh
@@ -22,11 +22,8 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4LogicalVolume
// G4GeomSplitter
//
// Class description:
//
@@ -34,8 +31,7 @@
// classes: G4LogicalVolume, G4Region, G4VPhysicalVolume, G4PolyconeSide
// G4PolyhedraSide, G4PVReplica.
// Author:
// 01.25.09 X.Dong: Initial version from automatic MT conversion.
// Author: X.Dong - Initial version from automatic MT conversion, 01.25.09.
// ------------------------------------------------------------------------
#ifndef G4GEOMSPLITTER_HH
#define G4GEOMSPLITTER_HH
@@ -50,7 +46,7 @@ class G4GeomSplitter
public:
G4GeomSplitter()
: totalobj(0), totalspace(0), sharedOffset(0)
: totalobj(0), totalspace(0), sharedOffset(nullptr)
{
G4MUTEXINIT(mutex);
}
@@ -66,11 +62,11 @@ class G4GeomSplitter
// whenever a new split class instance is created.
{
G4AutoLock l(&mutex);
totalobj++;
++totalobj;
if (totalobj > totalspace)
{
offset = Reallocate(totalspace+512);
if (offset == 0)
if (offset == nullptr)
{
G4Exception("G4GeomSPlitter::CreateSubInstance()",
"OutOfMemory", FatalException, "Cannot malloc space!");
@@ -91,9 +87,9 @@ class G4GeomSplitter
// from the master thread.
{
G4AutoLock l(&mutex);
if (offset) { return; }
if (offset != nullptr) { return; }
offset = Reallocate(totalspace);
if (offset == 0)
if (offset == nullptr)
{
G4Exception("G4GeomSplitter::SlaveCopySubInstanceArray()",
"OutOfMemory", FatalException, "Cannot malloc space!");
@@ -108,10 +104,10 @@ class G4GeomSplitter
// the subclass.
{
G4AutoLock l(&mutex);
if (offset) { return; }
if (offset != nullptr) { return; }
offset = Reallocate(totalspace);
if (offset == 0)
if (offset == nullptr)
{
G4Exception("G4GeomSplitter::SlaveInitializeSubInstance()",
"OutOfMemory", FatalException, "Cannot malloc space!");
@@ -129,7 +125,7 @@ class G4GeomSplitter
// To cope with user's changes in Geometry - e.g. change of material
// in a volume
{
if (!offset)
if (offset == nullptr)
{
SlaveInitializeSubInstance();
G4Exception("G4GeomSPlitter::SlaveReCopySubInstance()",
@@ -142,9 +138,9 @@ class G4GeomSplitter
void FreeSlave()
// Invoked by all threads to free the subinstance array.
{
if (!offset) { return; }
if (offset == nullptr) { return; }
std::free( offset );
offset = 0;
offset = nullptr;
}
// Extension - to allow sharing of workspaces
@@ -154,7 +150,7 @@ class G4GeomSplitter
void UseWorkArea( T* newOffset )
// Use recycled work area - which was created previously
{
if( offset && offset!=newOffset )
if( (offset!=nullptr) && (offset!=newOffset) )
{
G4Exception("G4GeomSplitter::UseWorkspace()",
"TwoWorkspaces", FatalException,
@@ -168,7 +164,7 @@ class G4GeomSplitter
// The object which calls this method is responsible for it.
{
T* offsetRet = offset;
offset = 0;
offset = nullptr;
return offsetRet;
}
@@ -184,6 +180,6 @@ class G4GeomSplitter
G4Mutex mutex;
};
template <typename T> G4ThreadLocal T* G4GeomSplitter<T>::offset = 0;
template <typename T> G4ThreadLocal T* G4GeomSplitter<T>::offset = nullptr;
#endif
@@ -23,22 +23,15 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// --------------------------------------------------------------------
// class G4GeomTools
// G4GeomTools
//
// Class description:
//
// A collection of utilities which can be helpfull for a wide range
// of geometry-related tasks
// History:
//
// 10.10.2016 E.Tcherniaev: Initial version.
// 10.10.2016, E.Tcherniaev: Initial version.
// --------------------------------------------------------------------
#ifndef G4GEOMTOOLS_HH
#define G4GEOMTOOLS_HH
@@ -46,8 +39,8 @@
#include "G4TwoVector.hh"
#include "G4ThreeVector.hh"
typedef std::vector<G4TwoVector> G4TwoVectorList;
typedef std::vector<G4ThreeVector> G4ThreeVectorList;
using G4TwoVectorList = std::vector<G4TwoVector>;
using G4ThreeVectorList = std::vector<G4ThreeVector>;
class G4GeomTools
{
@@ -64,7 +57,7 @@ class G4GeomTools
static G4double TriangleArea(const G4TwoVector& A,
const G4TwoVector& B,
const G4TwoVector& C);
// Calcuate area of 2D triangle, return value is positive if
// Calculate area of 2D triangle, return value is positive if
// vertices of the triangle are given in anticlockwise order,
// otherwise it is negative
@@ -72,12 +65,12 @@ class G4GeomTools
const G4TwoVector& B,
const G4TwoVector& C,
const G4TwoVector& D);
// Calcuate area of 2D quadrilateral, return value is positive if
// Calculate area of 2D quadrilateral, return value is positive if
// vertices of the quadrilateral are given in anticlockwise order,
// otherwise it is negative
static G4double PolygonArea(const G4TwoVectorList& polygon);
// Calcuate area of 2D polygon, return value is positive if
// Calculate area of 2D polygon, return value is positive if
// vertices of the polygon are defined in anticlockwise order,
// otherwise it is negative
@@ -113,7 +106,7 @@ class G4GeomTools
static void RemoveRedundantVertices(G4TwoVectorList& polygon,
std::vector<G4int>& iout,
G4double tolerance = 0);
G4double tolerance = 0.0);
// Remove collinear and coincident points from 2D polygon.
// Indices of removed points are available in iout.
@@ -25,7 +25,7 @@
//
// GEANT4 geomtetry/solid types
//
// --------------------------------------------------------------------
#ifndef G4GEOMTYPES_HH
#define G4GEOMTYPES_HH
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4GeometryManager
// G4GeometryManager
//
// Class description:
//
@@ -39,8 +37,7 @@
// - fgInstance
// Ptr to the unique instance of class
// Author:
// 26.07.95 P.Kent Initial version, including optimisation Build
// 26.07.95, P.Kent - Initial version, including optimisation build
// --------------------------------------------------------------------
#ifndef G4GEOMETRYMANAGER_HH
#define G4GEOMETRYMANAGER_HH
@@ -55,13 +52,13 @@ class G4GeometryManager
{
public: // with description
G4bool CloseGeometry(G4bool pOptimise=true, G4bool verbose=false,
G4VPhysicalVolume* vol=0);
G4bool CloseGeometry(G4bool pOptimise = true, G4bool verbose = false,
G4VPhysicalVolume* vol = nullptr);
// Close (`lock') the geometry: perform sanity and `completion' checks
// and optionally [default=yes] build optimisation information.
// Applies to just a specific subtree if a physical volume is specified.
void OpenGeometry(G4VPhysicalVolume* vol=0);
void OpenGeometry(G4VPhysicalVolume* vol = nullptr);
// Open (`unlock') the geometry and remove optimisation information if
// present. Applies to just a specific subtree if a physical volume is
// specified.
@@ -92,11 +89,11 @@ class G4GeometryManager
private:
void BuildOptimisations(G4bool allOpt, G4bool verbose=false);
void BuildOptimisations(G4bool allOpt, G4bool verbose = false);
void BuildOptimisations(G4bool allOpt, G4VPhysicalVolume* vol);
void DeleteOptimisations();
void DeleteOptimisations(G4VPhysicalVolume* vol);
static void ReportVoxelStats( std::vector<G4SmartVoxelStat> & stats,
static void ReportVoxelStats( std::vector<G4SmartVoxelStat>& stats,
G4double totalCpuTime );
static G4ThreadLocal G4GeometryManager* fgInstance;
static G4ThreadLocal G4bool fIsClosed;
@@ -23,23 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class GIdentityTrajectoryFilter
// G4IdentityTrajectoryFilter
//
// Class description:
//
// Implements a trajectory point filter which accepts all points submitted to it.
// Implements a trajectory point filter which accepts all points submitted
// to it.
//
// IMPORTANT: The base class heap allocates vectors of auxiliary
// points, which it does not delete. The vectors must find their way
// to a subclass of G4VTrajectoryPoint, which must take responsibility
// for deleting them.
// History
//
// - First version: Nov 19, 2002 Jacek Generowicz
// First version: Nov 19, 2002 - Jacek Generowicz
// ------------------------------------------------------------------------
#ifndef G4IdentityTrajectoryFilter_hh
#define G4IdentityTrajectoryFilter_hh
@@ -50,17 +46,18 @@
class G4IdentityTrajectoryFilter : public G4VCurvedTrajectoryFilter
{
public: // with description
public: // with description
G4IdentityTrajectoryFilter();
virtual ~G4IdentityTrajectoryFilter();
G4IdentityTrajectoryFilter();
virtual ~G4IdentityTrajectoryFilter();
// Probably do not want these objects to be copied,
// so make the copy constructor private
G4IdentityTrajectoryFilter(const G4IdentityTrajectoryFilter&) = delete;
G4IdentityTrajectoryFilter& operator=(const G4IdentityTrajectoryFilter&) = delete;
// Do not want these objects to be copied or assigned
void TakeIntermediatePoint( G4ThreeVector newPoint );
// Submit intermediate points for the filter
// to consider keeping or rejecting
void TakeIntermediatePoint( G4ThreeVector newPoint );
// Submit intermediate points for the filter
// to consider keeping or rejecting
};
#endif /* End of ifndef G4IdentityTrajectoryFilter_hh */
#endif /* G4IdentityTrajectoryFilter_hh */
@@ -23,11 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ---------------------------------------------------------------------------
//
// class G4LogicalCrystalVolume
// G4LogicalCrystalVolume
//
// Class description:
//
@@ -35,12 +31,8 @@
// The object can be created only with an extended material
// with a crystal extension. The class handles the orientation
// of the crystal axes wrt the solid to which the crystal is attached.
//
// History:
//
// 21-04-16, created by E.Bagli
//
// ---------------------------------------------------------------------------
#ifndef G4LOGICALCRYSTALVOLUME_HH
#define G4LOGICALCRYSTALVOLUME_HH 1
@@ -58,21 +50,21 @@ class G4LogicalCrystalVolume : public G4LogicalVolume
G4LogicalCrystalVolume(G4VSolid* pSolid,
G4ExtendedMaterial* pMaterial,
const G4String& name,
G4FieldManager* pFieldMgr=0,
G4VSensitiveDetector* pSDetector=0,
G4UserLimits* pULimits=0,
G4bool optimise=true,
G4int h=0,
G4int k=0,
G4int l=0,
G4double rot=0.);
G4FieldManager* pFieldMgr = nullptr,
G4VSensitiveDetector* pSDetector = nullptr,
G4UserLimits* pULimits = nullptr,
G4bool optimise = true,
G4int h = 0,
G4int k = 0,
G4int l = 0,
G4double rot = 0.0);
~G4LogicalCrystalVolume();
G4bool IsExtended() const { return true; }
// Return true if it is not a base-class object.
void SetMillerOrientation(G4int h, G4int k, G4int l, G4double rot=0.);
void SetMillerOrientation(G4int h, G4int k, G4int l, G4double rot = 0.0);
// Set physical lattice orientation, relative to G4VSolid coordinates
// Miller orientation aligns lattice normal (hkl) with geometry +Z
@@ -94,10 +86,10 @@ class G4LogicalCrystalVolume : public G4LogicalVolume
G4RotationMatrix fOrient; // Rotate geometry into lattice frame
G4RotationMatrix fInverse;
G4int hMiller, kMiller, lMiller; // Save Miller indices for dumps
G4double fRot;
G4int hMiller = 1, kMiller = 1, lMiller = 0; // Save Miller indices for dump
G4double fRot = 0.0;
G4int verboseLevel;
G4int verboseLevel = 0;
static std::vector<G4LogicalVolume*> fLCVvec;
};
@@ -23,11 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
////////////////////////////////////////////////////////////////////////
// Class G4LogicalSurface
////////////////////////////////////////////////////////////////////////
// G4LogicalSurface
//
// Class description:
//
@@ -55,44 +51,37 @@
// Created: 1997, June, 4th to 17th
// Author: John Apostolakis, (with help of Peter Gumplinger)
// mail: japost@mail.cern.ch
//
// ------------------------------------------------------------------------
#ifndef G4LogicalSurface_h
#define G4LogicalSurface_h 1
/////////////
// Includes
/////////////
#include "G4Types.hh"
#include "G4String.hh"
class G4SurfaceProperty;
class G4TransitionRadiationSurface;
/////////////////////
// Class Definition
/////////////////////
class G4LogicalSurface
{
public: // with description
inline G4SurfaceProperty* GetSurfaceProperty() const;
inline G4SurfaceProperty* GetSurfaceProperty() const;
inline void SetSurfaceProperty(G4SurfaceProperty* ptrSurfaceProperty);
inline const G4String& GetName() const;
inline void SetName(const G4String& name);
inline G4TransitionRadiationSurface* GetTransitionRadiationSurface() const;
inline void SetTransitionRadiationSurface(G4TransitionRadiationSurface* tRadSurf);
inline void SetTransitionRadiationSurface(G4TransitionRadiationSurface* trs);
public: // without description
virtual ~G4LogicalSurface();
G4LogicalSurface(const G4LogicalSurface&) = delete;
G4LogicalSurface& operator=(const G4LogicalSurface&) = delete;
inline G4bool operator==(const G4LogicalSurface &right) const;
inline G4bool operator!=(const G4LogicalSurface &right) const;
@@ -103,23 +92,14 @@ class G4LogicalSurface
G4LogicalSurface(const G4String& name, G4SurfaceProperty* prop);
// Is the name more meaningful for the properties or the logical surface ?
private: // Copying restricted
G4LogicalSurface(const G4LogicalSurface &right);
inline G4LogicalSurface& operator=(const G4LogicalSurface& right);
private:
G4String theName; // Surface name
G4SurfaceProperty* theSurfaceProperty;
G4TransitionRadiationSurface* theTransRadSurface;
G4SurfaceProperty* theSurfaceProperty = nullptr;
G4TransitionRadiationSurface* theTransRadSurface = nullptr;
};
////////////////////
// Inline methods
////////////////////
#include "G4LogicalSurface.icc"
#endif /* G4LogicalSurface_h */
@@ -23,17 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
////////////////////////////////////////////////////////////////////////
// Surface Class Inline Methods
////////////////////////////////////////////////////////////////////////
//
// File: G4LogicalSurface.icc
// Description: A Surface class
// Created: 1997-06-26
// Author: John Apostolakis
//
// G4LogicalSurface class inline methods
// Created: John Apostolakis, 26-06-1997
// ------------------------------------------------------------------------
inline G4SurfaceProperty*
@@ -70,24 +62,9 @@ inline void
G4LogicalSurface::SetTransitionRadiationSurface(G4TransitionRadiationSurface*
transRadSurf )
{
theTransRadSurface= transRadSurf;
theTransRadSurface = transRadSurf;
}
//////////////
// Operators
//////////////
inline G4LogicalSurface &
G4LogicalSurface::operator=(const G4LogicalSurface &right)
{
if (&right == this) { return *this; }
theName = right.theName;
theSurfaceProperty = right.theSurfaceProperty;
theTransRadSurface = right.theTransRadSurface;
return *this;
}
inline G4bool
G4LogicalSurface::operator==(const G4LogicalSurface &right) const
{
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4LogicalVolume
// G4LogicalVolume
//
// Class description:
//
@@ -94,21 +91,16 @@
// G4bool fIsEnvelope
// - Flags if the Logical Volume is an envelope for a FastSimulationManager.
// History:
// 19.10.16 M.Asai: Added virtual keyword to the destructor
// 15.01.13 G.Cosmo, A.Dotti: Modified for thread-safety for MT
// 12.11.04 G.Cosmo: Added GetMass() method for computing mass of the tree
// 24.09.02 G.Cosmo: Added flags and accessors for region cuts handling
// 17.05.02 G.Cosmo: Added IsToOptimise() method and related flag
// 18.04.01 G.Cosmo: Migrated to STL vector
// 12.02.99 S.Giani: Added user defined optimisation quality
// 09.11.98 J.Apostolakis: Changed G4MagneticField to G4FieldManager
// 09.11.98 M.Verderi, J.Apostolakis: Added BiasWeight member and accessors
// 10.20.97 P.M.DeFreitas: Added pointer to a FastSimulation
// J.Apostolakis: & flag to indicate if it is an Envelope for it
// 19.11.96 J.Allison: Replaced G4Visible with explicit const G4VisAttributes*
// 19.08.96 P.Kent: Split -> hh/icc/cc files; G4VSensitiveDetector change
// 11.07.95 P.Kent: Initial version.
// 11.07.95 P.Kent: Initial version
// ------------------------------------------------------------------------
#ifndef G4LOGICALVOLUME_HH
#define G4LOGICALVOLUME_HH
@@ -139,31 +131,32 @@ class G4LVData
// G4LogicalVolume that may not be read-only.
public:
G4LVData();
void initialize()
{
fSolid = 0;
fSensitiveDetector = 0;
fFieldManager = 0;
fMaterial = 0;
fSolid = nullptr;
fSensitiveDetector = nullptr;
fFieldManager = nullptr;
fMaterial = nullptr;
fMass = 0.0;
fCutsCouple = 0;
fCutsCouple = nullptr;
}
public:
G4VSolid* fSolid;
G4VSolid* fSolid = nullptr;
// Pointer to solid.
G4VSensitiveDetector* fSensitiveDetector;
G4VSensitiveDetector* fSensitiveDetector = nullptr;
// Pointer to sensitive detector.
G4FieldManager* fFieldManager;
// Pointer (possibly 0) to (magnetic or other) field manager object.
G4Material* fMaterial;
G4FieldManager* fFieldManager = nullptr;
// Pointer (possibly nullptr) to (magnetic or other) field manager object.
G4Material* fMaterial = nullptr;
// Pointer to material at this node.
G4double fMass;
G4double fMass = 0.0;
// Mass of the logical volume tree.
G4MaterialCutsCouple* fCutsCouple;
// Pointer (possibly 0) to associated production cuts.
G4MaterialCutsCouple* fCutsCouple = nullptr;
// Pointer (possibly nullptr) to associated production cuts.
};
// The type G4LVManager is introduced to encapsulate the methods used by
@@ -184,7 +177,7 @@ class G4LVData
// In addition, it invokes a method similiar to the constructor explicitly
// to achieve the partial effect for each instance in the array.
//
typedef G4GeomSplitter<G4LVData> G4LVManager;
typedef G4GeomSplitter<G4LVData> G4LVManager;
class G4LogicalVolume
{
@@ -195,10 +188,10 @@ class G4LogicalVolume
G4LogicalVolume(G4VSolid* pSolid,
G4Material* pMaterial,
const G4String& name,
G4FieldManager* pFieldMgr=0,
G4VSensitiveDetector* pSDetector=0,
G4UserLimits* pULimits=0,
G4bool optimise=true);
G4FieldManager* pFieldMgr = nullptr,
G4VSensitiveDetector* pSDetector = nullptr,
G4UserLimits* pULimits = nullptr,
G4bool optimise = true);
// Constructor. The solid and material pointer must be non null.
// The parameters for field, detector and user limits are optional.
// The volume also enters itself into the logical volume Store.
@@ -211,11 +204,15 @@ class G4LogicalVolume
// This class is NOT meant to act as base class, except for exceptional
// circumstances of extended types used in the kernel.
G4LogicalVolume(const G4LogicalVolume&) = delete;
G4LogicalVolume& operator=(const G4LogicalVolume&) = delete;
// Copy-constructor and assignment operator not allowed.
inline const G4String& GetName() const;
inline void SetName(const G4String& pName);
// Returns and sets the name of the logical volume.
inline G4int GetNoDaughters() const;
inline size_t GetNoDaughters() const;
// Returns the number of daughters (0 to n).
inline G4VPhysicalVolume* GetDaughter(const G4int i) const;
// Returns the ith daughter. Note numbering starts from 0,
@@ -240,20 +237,22 @@ class G4LogicalVolume
// in the tree represented by the current logical volume.
inline EVolume CharacteriseDaughters() const;
// Characterise the daughters of this logical volume.
inline EVolume DeduceDaughtersType() const;
// Used by CharacteriseDaughters().
G4VSolid* GetSolid() const;
void SetSolid(G4VSolid *pSolid);
void SetSolid(G4VSolid* pSolid);
// Gets and sets the current solid.
G4Material* GetMaterial() const;
void SetMaterial(G4Material *pMaterial);
void SetMaterial(G4Material* pMaterial);
// Gets and sets the current material.
void UpdateMaterial(G4Material *pMaterial);
void UpdateMaterial(G4Material* pMaterial);
// Sets material and corresponding MaterialCutsCouple.
// This method is invoked by G4Navigator while it is navigating through
// material parameterization.
G4double GetMass(G4bool forced=false, G4bool propagate=true,
G4Material* parMaterial=0);
G4double GetMass(G4bool forced = false, G4bool propagate = true,
G4Material* parMaterial = nullptr);
// Returns the mass of the logical volume tree computed from the
// estimated geometrical volume of each solid and material associated
// to the logical volume and (by default) to its daughters.
@@ -274,17 +273,17 @@ class G4LogicalVolume
G4FieldManager* GetFieldManager() const;
// Gets current FieldManager.
void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters);
void SetFieldManager(G4FieldManager* pFieldMgr, G4bool forceToAllDaughters);
// Sets FieldManager and propagates it:
// i) only to daughters with G4FieldManager = 0
// i) only to daughters with G4FieldManager = nullptr
// if forceToAllDaughters=false
// ii) to all daughters
// if forceToAllDaughters=true
G4VSensitiveDetector* GetSensitiveDetector() const;
// Gets current SensitiveDetector.
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector);
// Sets SensitiveDetector (can be 0).
void SetSensitiveDetector(G4VSensitiveDetector* pSDetector);
// Sets SensitiveDetector (can be nullptr).
inline G4UserLimits* GetUserLimits() const;
inline void SetUserLimits(G4UserLimits *pULimits);
@@ -328,7 +327,7 @@ class G4LogicalVolume
// Returns true if objects are at same address, else false.
inline const G4VisAttributes* GetVisAttributes () const;
inline void SetVisAttributes (const G4VisAttributes* pVA);
inline void SetVisAttributes (const G4VisAttributes* pVA);
void SetVisAttributes (const G4VisAttributes& VA);
// Gets and sets visualization attributes. A copy of 'VA' on the heap
// will be made in the case the call with a const reference is used.
@@ -369,27 +368,27 @@ class G4LogicalVolume
inline void Lock();
// Set lock identifier for final deletion of entity.
void InitialiseWorker(G4LogicalVolume *ptrMasterObject,
void InitialiseWorker(G4LogicalVolume* ptrMasterObject,
G4VSolid* pSolid, G4VSensitiveDetector* pSDetector);
// This method is similar to the constructor. It is used by each worker
// thread to achieve the partial effect as that of the master thread.
void TerminateWorker(G4LogicalVolume *ptrMasterObject);
void TerminateWorker(G4LogicalVolume* ptrMasterObject);
// This method is similar to the destructor. It is used by each worker
// thread to achieve the partial effect as that of the master thread.
void AssignFieldManager( G4FieldManager *fldMgr);
void AssignFieldManager(G4FieldManager* fldMgr);
// Set the FieldManager - only at this level (do not push down hierarchy)
static G4VSolid* GetSolid(G4LVData &instLVdata) ; // const;
static void SetSolid(G4LVData &instLVdata, G4VSolid *pSolid);
static G4VSolid* GetSolid(G4LVData& instLVdata) ; // const;
static void SetSolid(G4LVData& instLVdata, G4VSolid* pSolid);
// Optimised Methods - passing thread instance of worker data
private:
G4LogicalVolume(const G4LogicalVolume&);
G4LogicalVolume& operator=(const G4LogicalVolume&);
// Private copy-constructor and assignment operator.
G4bool ChangeDaughtersType(EVolume atype);
// Change the type of the daughters volume to be of type atype.
// Meant for the user who wants to use the external navigator for
// the contents of a volume.
// Returns: success (true) or failure (false).
private:
@@ -399,26 +398,27 @@ class G4LogicalVolume
// Vector of daughters. Given initial size of 0.
G4String fName;
// Name of logical volume.
// Pointer (possibly 0) to `Hit' object.
EVolume fDaughtersVolumeType;
// Are contents of volume placements, replica, parameterised or external?
G4UserLimits* fUserLimits;
// Pointer (possibly 0) to user Step limit object for this node.
G4SmartVoxelHeader* fVoxel;
// Pointer (possibly 0) to optimisation info objects.
G4bool fOptimise;
G4UserLimits* fUserLimits = nullptr;
// Pointer (possibly nullptr) to user Step limit object for this node.
G4SmartVoxelHeader* fVoxel = nullptr;
// Pointer (possibly nullptr) to optimisation info objects.
G4bool fOptimise = true;
// Flag to identify if optimisation should be applied or not.
G4bool fRootRegion;
G4bool fRootRegion = false;
// Flag to identify if the logical volume is a root region.
G4bool fLock;
G4bool fLock = false;
// Flag to identify if entity is locked for final deletion.
G4double fSmartless;
G4double fSmartless = 2.0;
// Quality for optimisation, average number of voxels to be spent
// per content.
const G4VisAttributes* fVisAttributes;
// Pointer (possibly 0) to visualization attributes.
G4Region* fRegion;
const G4VisAttributes* fVisAttributes = nullptr;
// Pointer (possibly nullptr) to visualization attributes.
G4Region* fRegion = nullptr;
// Pointer to the cuts region (if any)
G4double fBiasWeight;
G4double fBiasWeight = 1.0;
// Weight used in the event biasing technique.
G4int instanceID;
@@ -430,10 +430,10 @@ class G4LogicalVolume
// Each worker thread can access this field from the master thread
// through these pointers.
//
G4VSolid* fSolid;
G4VSensitiveDetector* fSensitiveDetector;
G4FieldManager* fFieldManager;
G4LVData* lvdata; // For use of object persistency
G4VSolid* fSolid = nullptr;
G4VSensitiveDetector* fSensitiveDetector = nullptr;
G4FieldManager* fFieldManager = nullptr;
G4LVData* lvdata = nullptr; // For use of object persistency
};
#include "G4LogicalVolume.icc"
@@ -22,16 +22,13 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4LogicalVolume Inline Implementation file
// class G4LogicalVolume inline implementation
//
// 15.01.13 - G.Cosmo, A.Dotti: Modified for thread-safety for MT
// 10.20.97 - P. MoraDeFreitas : Added SetFastSimulation method
// 05.11.98 - M. Verderi: Add Get/Set methods for fBiasWeight
// 09.11.98 - J. Apostolakis: Changed MagneticField to FieldManager
// 09.11.98 - J.Apostolakis: Changed MagneticField to FieldManager
// 12.02.99 - S.Giani: Added set/get methods for voxelization quality
// 18.04.01 - G.Cosmo: Migrated to STL vector
// 17.05.02 - G.Cosmo: Added IsToOptimise() method
@@ -82,7 +79,7 @@ G4FieldManager* G4LogicalVolume::GetMasterFieldManager() const
// ********************************************************************
//
inline
G4int G4LogicalVolume::GetNoDaughters() const
size_t G4LogicalVolume::GetNoDaughters() const
{
return fDaughters.size();
}
@@ -104,8 +101,8 @@ G4VPhysicalVolume* G4LogicalVolume::GetDaughter(const G4int i) const
inline
G4FastSimulationManager* G4LogicalVolume::GetFastSimulationManager () const
{
G4FastSimulationManager* fFSM = 0;
if(fRegion) fFSM = fRegion->GetFastSimulationManager();
G4FastSimulationManager* fFSM = nullptr;
if(fRegion != nullptr) fFSM = fRegion->GetFastSimulationManager();
return fFSM;
}
@@ -116,8 +113,7 @@ G4FastSimulationManager* G4LogicalVolume::GetFastSimulationManager () const
inline
G4bool G4LogicalVolume::IsDaughter(const G4VPhysicalVolume* p) const
{
G4PhysicalVolumeList::const_iterator i;
for ( i=fDaughters.begin(); i!=fDaughters.end(); ++i )
for (auto i=fDaughters.cbegin(); i!=fDaughters.cend(); ++i)
{
if (**i==*p) return true;
}
@@ -131,18 +127,24 @@ G4bool G4LogicalVolume::IsDaughter(const G4VPhysicalVolume* p) const
inline
EVolume G4LogicalVolume::CharacteriseDaughters() const
{
EVolume type;
G4VPhysicalVolume *pVol;
return fDaughtersVolumeType;
}
if ( GetNoDaughters()==1 )
// ********************************************************************
// DeduceDaughtersType
// ********************************************************************
//
inline
EVolume G4LogicalVolume::DeduceDaughtersType() const
{
EVolume type= kNormal;
G4VPhysicalVolume* pVol;
if ( GetNoDaughters() >= 1 )
{
pVol = GetDaughter(0);
type = pVol->VolumeType();
}
else
{
type = kNormal;
}
return type;
}
@@ -173,9 +175,9 @@ G4VSensitiveDetector* G4LogicalVolume::GetMasterSensitiveDetector() const
inline
G4UserLimits* G4LogicalVolume::GetUserLimits() const
{
if(fUserLimits) return fUserLimits;
if(fRegion) return fRegion->GetUserLimits();
return 0;
if(fUserLimits != nullptr) return fUserLimits;
if(fRegion != nullptr) return fRegion->GetUserLimits();
return nullptr;
}
// ********************************************************************
@@ -276,7 +278,7 @@ inline
G4bool G4LogicalVolume::IsRegion() const
{
G4bool reg = false;
if (fRegion) reg = true;
if (fRegion != nullptr) reg = true;
return reg;
}
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4LogicalVolumeStore
// G4LogicalVolumeStore
//
// Class description:
//
@@ -46,9 +44,8 @@
// static G4LogicalVolumeStore* fgInstance
// - Ptr to the single G4LogicalVolumeStore.
// History:
// 18.04.01 G.Cosmo Migrated to STL vector
// 10.07.95 P.Kent Initial version
// 18.04.01 - G.Cosmo, Migrated to STL vector
// 10.07.95 - P.Kent, Initial version
// --------------------------------------------------------------------
#ifndef G4LOGICALVOLUMESTORE_HH
#define G4LOGICALVOLUMESTORE_HH
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4PhysicalVolume
// G4PhysicalVolumeStore
//
// Class description:
//
@@ -46,9 +44,8 @@
// static G4PhysicalVolumeStore*
// - Ptr to the single G4PhysicalVolumeStore.
// History:
// 18.04.01 G.Cosmo Migrated to STL vector
// 25.07.95 P.Kent Initial version
// 18.04.01, G.Cosmo - Migrated to STL vector
// 25.07.95, P.Kent - Initial version
// --------------------------------------------------------------------
#ifndef G4PHYSICALVOLUMESTORE_HH
#define G4PHYSICALVOLUMESTORE_HH
@@ -75,7 +72,7 @@ class G4PhysicalVolumeStore : public std::vector<G4VPhysicalVolume*>
// are automatically notified and have their daughters de-registered.
G4VPhysicalVolume* GetVolume(const G4String& name,
G4bool verbose=true) const;
G4bool verbose = true) const;
// Return the pointer of the first volume in the collection having
// that name.
@@ -23,19 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4ReflectedSolid
// G4ReflectedSolid
//
// Class description:
//
// A Reflected solid is a solid that has been shifted from its original
// frame of reference to a new one.
// History:
//
// 23.07.01 V.Grichine: created
// 23.07.01, V.Grichine - created
// --------------------------------------------------------------------
#ifndef G4ReflectedSolid_HH
#define G4ReflectedSolid_HH
@@ -78,9 +73,9 @@ class G4ReflectedSolid : public G4VSolid
G4double DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0 ) const;
const G4bool calcNorm = false,
G4bool* validNorm = nullptr,
G4ThreeVector* n = nullptr ) const;
G4double DistanceToOut( const G4ThreeVector& p ) const;
@@ -99,7 +94,7 @@ class G4ReflectedSolid : public G4VSolid
virtual const G4ReflectedSolid* GetReflectedSolidPtr() const;
virtual G4ReflectedSolid* GetReflectedSolidPtr();
// If the Solid is a "G4ReflectedSolid",
// return a self pointer else return 0.
// return a self pointer else return nullptr.
G4VSolid* GetConstituentMovedSolid() const;
@@ -123,11 +118,12 @@ class G4ReflectedSolid : public G4VSolid
protected:
G4VSolid* fPtrSolid;
G4Transform3D* fDirectTransform3D;
G4VSolid* fPtrSolid = nullptr;
G4Transform3D* fDirectTransform3D = nullptr;
mutable G4bool fRebuildPolyhedron;
mutable G4Polyhedron* fpPolyhedron; // Caches reflected G4Polyhedron.
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr;
// Caches reflected G4Polyhedron.
};
#endif
+18 -21
View File
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4Region
// G4Region
//
// Class description:
//
@@ -33,8 +31,7 @@
// setup, sharing properties associated to materials or production
// cuts which may affect or bias specific physics processes.
// History:
// 18.09.02 G.Cosmo Initial version
// 18.09.02, G.Cosmo - Initial version
// --------------------------------------------------------------------
#ifndef G4REGION_HH
#define G4REGION_HH
@@ -67,8 +64,8 @@ class G4RegionData
void initialize()
{
fFastSimulationManager = 0;
fRegionalSteppingAction = 0;
fFastSimulationManager = nullptr;
fRegionalSteppingAction = nullptr;
}
G4FastSimulationManager* fFastSimulationManager;
@@ -107,6 +104,10 @@ class G4Region
G4Region(const G4String& name);
virtual ~G4Region();
G4Region(const G4Region&) = delete;
G4Region& operator=(const G4Region&) = delete;
// Copy constructor and assignment operator not allowed.
inline G4bool operator==(const G4Region& rg) const;
// Equality defined by address only.
@@ -232,8 +233,8 @@ class G4Region
static void Clean();
// Clear memory allocated by sub-instance manager.
inline void UsedInMassGeometry(G4bool val=true);
inline void UsedInParallelGeometry(G4bool val=true);
inline void UsedInMassGeometry(G4bool val = true);
inline void UsedInParallelGeometry(G4bool val = true);
inline G4bool IsInMassGeometry() const;
inline G4bool IsInParallelGeometry() const;
// Utility methods to identify if region is part of the main mass
@@ -241,10 +242,6 @@ class G4Region
private:
G4Region(const G4Region&);
G4Region& operator=(const G4Region&);
// Private copy constructor and assignment operator.
inline void AddMaterial (G4Material* aMaterial);
// Searchs the specified material in the material table and
// if not present adds it.
@@ -257,17 +254,17 @@ class G4Region
G4MaterialList fMaterials;
G4MaterialCoupleMap fMaterialCoupleMap;
G4bool fRegionMod;
G4ProductionCuts* fCut;
G4bool fRegionMod = true;
G4ProductionCuts* fCut = nullptr;
G4VUserRegionInformation* fUserInfo;
G4UserLimits* fUserLimits;
G4FieldManager* fFieldManager;
G4VUserRegionInformation* fUserInfo = nullptr;
G4UserLimits* fUserLimits = nullptr;
G4FieldManager* fFieldManager = nullptr;
G4VPhysicalVolume* fWorldPhys;
G4VPhysicalVolume* fWorldPhys = nullptr;
G4bool fInMassGeometry;
G4bool fInParallelGeometry;
G4bool fInMassGeometry = false;
G4bool fInParallelGeometry = false;
G4int instanceID;
// This field is used as instance ID.
+10 -14
View File
@@ -22,13 +22,10 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4Region Inline Implementation file
// G4Region inline implementation
//
// 19.09.02 - G.Cosmo: Created
// 19.09.02, G.Cosmo - Created
// --------------------------------------------------------------------
// ********************************************************************
@@ -133,7 +130,7 @@ inline
std::vector<G4Material*>::const_iterator
G4Region::GetMaterialIterator() const
{
G4MaterialList::const_iterator iterator = fMaterials.begin();
G4MaterialList::const_iterator iterator = fMaterials.cbegin();
return iterator;
}
@@ -206,8 +203,8 @@ void G4Region::ClearMap()
{
if(!(fMaterialCoupleMap.empty()))
{
G4MaterialCoupleMap::iterator b = fMaterialCoupleMap.begin();
G4MaterialCoupleMap::iterator e = fMaterialCoupleMap.end();
auto b = fMaterialCoupleMap.cbegin();
auto e = fMaterialCoupleMap.cend();
fMaterialCoupleMap.erase(b,e);
}
}
@@ -230,9 +227,9 @@ void G4Region::RegisterMaterialCouplePair(G4Material* mat,
inline
G4MaterialCutsCouple* G4Region::FindCouple(G4Material* mat)
{
G4MaterialCoupleMap::iterator c = fMaterialCoupleMap.find(mat);
G4MaterialCutsCouple* couple = 0;
if(c!=fMaterialCoupleMap.end()) couple = (*c).second;
auto c = fMaterialCoupleMap.find(mat);
G4MaterialCutsCouple* couple = nullptr;
if(c!=fMaterialCoupleMap.cend()) couple = (*c).second;
return couple;
}
@@ -273,9 +270,8 @@ G4VPhysicalVolume* G4Region::GetWorldPhysical() const
inline
void G4Region::AddMaterial(G4Material* aMaterial)
{
G4MaterialList::iterator pos =
std::find(fMaterials.begin(),fMaterials.end(),aMaterial);
if (pos == fMaterials.end())
auto pos = std::find(fMaterials.cbegin(),fMaterials.cend(),aMaterial);
if (pos == fMaterials.cend())
{
fMaterials.push_back(aMaterial);
fRegionMod = true;
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4RegionStore
// G4RegionStore
//
// Class description:
//
@@ -45,8 +43,7 @@
// static G4RegionStore*
// - Pointer to the single G4RegionStore
// History:
// 18.09.02 G.Cosmo Initial version
// 18.09.02, G.Cosmo - Initial version
// --------------------------------------------------------------------
#ifndef G4REGIONSTORE_HH
#define G4REGIONSTORE_HH
@@ -86,7 +83,7 @@ class G4RegionStore : public std::vector<G4Region*>
// Forces recomputation of material lists in all regions
// in the store.
G4Region* GetRegion(const G4String& name, G4bool verbose=true) const;
G4Region* GetRegion(const G4String& name, G4bool verbose = true) const;
// Returns a region through its name specification.
G4Region* FindOrCreateRegion(const G4String& name);
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4ScaleTransform
// G4ScaleTransform
//
// Class description:
//
@@ -47,10 +44,8 @@
// G4double flFactor; // factor for conversion to local frame
// G4double fgFactor; // factor for conversion to global frame
// History:
// E.Tcherniaev 11 Mar 2016 - added transformations for normal
// G.Cosmo 18 Feb 2016 - initial version
//
// E.Tcherniaev, 11 Mar 2016 - added transformations for normal
// G.Cosmo, 18 Feb 2016 - initial version
// --------------------------------------------------------------------
#ifndef G4SCALETRANSFORM_HH
#define G4SCALETRANSFORM_HH
@@ -136,7 +131,8 @@ class G4ScaleTransform
G4ThreeVector fScale; // scale transformation
G4ThreeVector fIScale; // inverse scale (avoid divisions)
G4double flFactor, fgFactor; // conversion factors to local/global frames
G4double flFactor = 1.0, fgFactor = 1.0;
// conversion factors to local/global frames
}; // End class G4ScaleTransform
@@ -23,34 +23,31 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4ScaleTransform Inline implementation.
// G4ScaleTransform inline implementation.
// Based on implementation provided in Root
//
// G.Cosmo, 18 Feb 2016 - initial version
// --------------------------------------------------------------------
inline G4ScaleTransform::G4ScaleTransform()
: fScale(1.,1.,1.), fIScale(1.,1.,1.), flFactor(1.), fgFactor(1.)
: fScale(1.,1.,1.), fIScale(1.,1.,1.)
{
}
inline G4ScaleTransform::G4ScaleTransform(G4double sx, G4double sy, G4double sz)
: fScale(sx,sy,sz), fIScale(), flFactor(1.), fgFactor(1.)
: fScale(sx,sy,sz), fIScale()
{
Init();
}
inline G4ScaleTransform::G4ScaleTransform(const G4ThreeVector& scale)
: fScale(scale), fIScale(), flFactor(1.), fgFactor(1.)
: fScale(scale), fIScale()
{
Init();
}
inline G4ScaleTransform::G4ScaleTransform(const G4Scale3D& scale)
: fScale(scale.xx(), scale.yy(), scale.zz()), fIScale(),
flFactor(1.), fgFactor(1.)
: fScale(scale.xx(), scale.yy(), scale.zz()), fIScale()
{
Init();
}
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4SmartVoxelHeader
// G4SmartVoxelHeader
//
// Class description:
//
@@ -48,9 +46,8 @@
// - Minimum and maximum equivalent slice nos.
// [Applies to the level of the header, not its nodes]
// History:
// 18.04.01 G.Cosmo Migrated to STL vector
// 13.07.95 P.Kent Initial version
// 18.04.01, G.Cosmo - Migrated to STL vector
// 13.07.95, P.Kent - Initial version
// --------------------------------------------------------------------
#ifndef G4SMARTVOXELHEADER_HH
#define G4SMARTVOXELHEADER_HH
@@ -68,17 +65,17 @@ class G4LogicalVolume;
class G4VoxelLimits;
class G4VPhysicalVolume;
// Typedefs
typedef std::vector<G4SmartVoxelProxy*> G4ProxyVector;
typedef std::vector<G4SmartVoxelNode*> G4NodeVector;
typedef std::vector<G4int> G4VolumeNosVector;
typedef std::vector<G4double> G4VolumeExtentVector;
// Aliases
using G4ProxyVector = std::vector<G4SmartVoxelProxy*>;
using G4NodeVector = std::vector<G4SmartVoxelNode*>;
using G4VolumeNosVector = std::vector<G4int>;
using G4VolumeExtentVector = std::vector<G4double>;
class G4SmartVoxelHeader
{
public: // with description
G4SmartVoxelHeader(G4LogicalVolume* pVolume, G4int pSlice=0);
G4SmartVoxelHeader(G4LogicalVolume* pVolume, G4int pSlice = 0);
// Constructor for topmost header, to begin voxel construction at a
// given logical volume. pSlice is used to set max and min equivalent
// slice nos for the header - they apply to the level of the header,
@@ -103,7 +100,7 @@ class G4SmartVoxelHeader
G4double GetMinExtent() const;
// Return the minimum coordinate limit along the current axis.
G4int GetNoSlices() const;
size_t GetNoSlices() const;
// Return the no of slices along the current axis.
G4SmartVoxelProxy* GetSlice(G4int n) const;
@@ -123,7 +120,7 @@ class G4SmartVoxelHeader
G4SmartVoxelHeader(G4LogicalVolume* pVolume,
const G4VoxelLimits& pLimits,
const G4VolumeNosVector* pCandidates,
G4int pSlice=0);
G4int pSlice = 0);
// Build and refine voxels between specified limits, considering only
// the physical volumes numbered `pCandidates'. pSlice is used to set max
// and min equivalent slice nos for the header - they apply to the level
@@ -23,9 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4SmartVoxelHeader Inline implementation
//
// --------------------------------------------------------------------
@@ -39,7 +36,7 @@ G4int G4SmartVoxelHeader::GetMaxEquivalentSliceNo() const
inline
void G4SmartVoxelHeader::SetMaxEquivalentSliceNo(G4int pMax)
{
fmaxEquivalent=pMax;
fmaxEquivalent = pMax;
}
inline
@@ -51,7 +48,7 @@ G4int G4SmartVoxelHeader::GetMinEquivalentSliceNo() const
inline
void G4SmartVoxelHeader::SetMinEquivalentSliceNo(G4int pMin)
{
fminEquivalent=pMin;
fminEquivalent = pMin;
}
inline
@@ -79,7 +76,7 @@ G4double G4SmartVoxelHeader::GetMinExtent() const
}
inline
G4int G4SmartVoxelHeader::GetNoSlices() const
size_t G4SmartVoxelHeader::GetNoSlices() const
{
return fslices.size();
}
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4SmartVoxelNode
// G4SmartVoxelNode
//
// Class description:
//
@@ -43,9 +41,8 @@
// std::vector<G4int> fcontents
// - Vector of no.s of volumes inside the node.
// History:
// 18.04.01 G.Cosmo Migrated to STL vector
// 12.07.95 P.Kent Initial version
// 18.04.01, G.Cosmo - Migrated to STL vector
// 12.07.95, P.Kent - Initial version
// --------------------------------------------------------------------
#ifndef G4SMARTVOXELNODE_HH
#define G4SMARTVOXELNODE_HH
@@ -53,14 +50,14 @@
#include "G4Types.hh"
#include <vector>
typedef std::vector<G4int> G4SliceVector;
using G4SliceVector = std::vector<G4int>;
class G4SmartVoxelNode
{
public: // with description
G4SmartVoxelNode(G4int pSlice=0) : fminEquivalent(pSlice),
fmaxEquivalent(pSlice) {}
G4SmartVoxelNode(G4int pSlice = 0) : fminEquivalent(pSlice),
fmaxEquivalent(pSlice) {}
// Constructor. Create an empty node with slice number pSlice.
// This number is not stored, but used to provide defaults for the
// minimum and maximum equivalent node numbers.
@@ -75,10 +72,10 @@ class G4SmartVoxelNode
inline void Insert(G4int pVolumeNo);
// Add the specified volume number to the contents.
inline G4int GetNoContained() const;
inline size_t GetNoContained() const;
// Return the number of volumes inside the node.
inline G4int GetCapacity() const;
inline size_t GetCapacity() const;
// Return the maximum capacity of the buffer.
inline void Reserve(G4int noSlices);
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4SmartVoxelNode Inline implementation
// G4SmartVoxelNode inline implementation
//
// --------------------------------------------------------------------
@@ -43,13 +40,13 @@ void G4SmartVoxelNode::Insert(G4int pVolumeNo)
}
inline
G4int G4SmartVoxelNode::GetNoContained() const
size_t G4SmartVoxelNode::GetNoContained() const
{
return fcontents.size();
}
inline
G4int G4SmartVoxelNode::GetCapacity() const
size_t G4SmartVoxelNode::GetCapacity() const
{
return fcontents.capacity();
}
@@ -75,7 +72,7 @@ G4int G4SmartVoxelNode::GetMaxEquivalentSliceNo() const
inline
void G4SmartVoxelNode::SetMaxEquivalentSliceNo(G4int pMax)
{
fmaxEquivalent=pMax;
fmaxEquivalent = pMax;
}
inline
@@ -87,5 +84,5 @@ G4int G4SmartVoxelNode::GetMinEquivalentSliceNo() const
inline
void G4SmartVoxelNode::SetMinEquivalentSliceNo(G4int pMin)
{
fminEquivalent=pMin;
fminEquivalent = pMin;
}
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4SmartVoxelProxy
// G4SmartVoxelProxy
//
// Class description:
//
@@ -36,10 +34,7 @@
// Note that the proxy does NOT gain deletion responsibility for proxied
// objects.
// History:
// 12.07.95 P.Kent Initial version
// 03.08.95 P.Kent Updated to become non abstract class, removing
// HeaderProxy and NodeProxy derived classes
// 12.07.95, P.Kent - Initial version
// --------------------------------------------------------------------
#ifndef G4SMARTVOXELPROXY_HH
#define G4SMARTVOXELPROXY_HH
@@ -56,11 +51,11 @@ class G4SmartVoxelProxy
public: // with description
G4SmartVoxelProxy(G4SmartVoxelHeader *pHeader)
: fHeader(pHeader), fNode(0) {}
: fHeader(pHeader) {}
// Proxy for the specified header.
G4SmartVoxelProxy(G4SmartVoxelNode *pNode)
: fHeader(0), fNode(pNode) {}
: fNode(pNode) {}
// Proxy for the specified node.
~G4SmartVoxelProxy();
@@ -84,8 +79,8 @@ class G4SmartVoxelProxy
private:
G4SmartVoxelHeader* fHeader;
G4SmartVoxelNode* fNode;
G4SmartVoxelHeader* fHeader = nullptr;
G4SmartVoxelNode* fNode = nullptr;
};
#include "G4SmartVoxelProxy.icc"
@@ -23,36 +23,33 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4SmartVoxelProxy Inline implementation
// G4SmartVoxelProxy inline implementation
//
// --------------------------------------------------------------------
inline
G4bool G4SmartVoxelProxy::IsHeader() const
{
return (fHeader) ? true:false;
return (fHeader) ? true : false;
}
inline
G4bool G4SmartVoxelProxy::IsNode() const
{
return (fNode) ? true:false;
return (fNode) ? true : false;
}
inline
G4SmartVoxelNode* G4SmartVoxelProxy::GetNode() const
{
assert(fNode != 0);
assert(fNode != nullptr);
return fNode;
}
inline
G4SmartVoxelHeader* G4SmartVoxelProxy::GetHeader() const
{
assert(fHeader != 0);
assert(fHeader != nullptr);
return fHeader;
}
@@ -23,10 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4SmartVoxelStat
//
// Class description:
@@ -36,7 +32,6 @@
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4SmartVoxelStat_hh
#define G4SmartVoxelStat_hh
@@ -49,16 +44,16 @@ class G4SmartVoxelStat
{
public: // with description
G4SmartVoxelStat( const G4LogicalVolume *theVolume,
const G4SmartVoxelHeader *theVoxel,
G4SmartVoxelStat( const G4LogicalVolume* theVolume,
const G4SmartVoxelHeader* theVoxel,
G4double theSysTime,
G4double theUserTime );
// Construct information on one volume's voxels
const G4LogicalVolume *GetVolume() const;
const G4LogicalVolume* GetVolume() const;
// Return a pointer to the logical volume
const G4SmartVoxelHeader *GetVoxel() const;
const G4SmartVoxelHeader* GetVoxel() const;
// Return a pointer to the voxel header
G4double GetSysTime() const;
@@ -85,18 +80,17 @@ class G4SmartVoxelStat
protected:
void CountHeadsAndNodes( const G4SmartVoxelHeader *head );
void CountHeadsAndNodes( const G4SmartVoxelHeader* head );
const G4LogicalVolume *volume;
const G4SmartVoxelHeader *voxel;
const G4LogicalVolume* volume;
const G4SmartVoxelHeader* voxel;
G4double sysTime;
G4double userTime;
G4long heads;
G4long nodes;
G4long pointers;
G4long heads = 1;
G4long nodes = 0;
G4long pointers = 0;
};
#endif
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4SolidStore
// G4SolidStore
//
// Class description:
//
@@ -47,8 +45,8 @@
// - Ptr to the single G4SolidStore
// History:
// 18.04.01 G.Cosmo Migrated to STL vector
// 10.07.95 P.Kent Initial version
// 18.04.01, G.Cosmo - Migrated to STL vector
// 10.07.95, P.Kent - Initial version
// --------------------------------------------------------------------
#ifndef G4VSOLIDSTORE_HH
#define G4VSOLIDSTORE_HH
@@ -73,7 +71,7 @@ class G4SolidStore : public std::vector<G4VSolid*>
static void Clean();
// Delete all solids from the store.
G4VSolid* GetSolid(const G4String& name, G4bool verbose=true) const;
G4VSolid* GetSolid(const G4String& name, G4bool verbose = true) const;
// Return the pointer of the first solid in the collection having
// that name.
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// Class G4TouchableHandle
// G4TouchableHandle
//
// Class description:
//
@@ -36,16 +34,14 @@
// instantiated using 'new').
// For more details see G4ReferenceCountedHandle.
// Author: Radovan Chytracek, CERN (Radovan.Chytracek@cern.ch)
// Version: 1.0
// Date: February 2001
// Author: Radovan Chytracek, CERN - February 2001
// ----------------------------------------------------------------------
#ifndef _G4TOUCHABLEHANDLE_H_
#define _G4TOUCHABLEHANDLE_H_ 1
#ifndef G4TOUCHABLEHANDLE_HH
#define G4TOUCHABLEHANDLE_HH 1
#include "G4VTouchable.hh"
#include "G4ReferenceCountedHandle.hh"
typedef G4ReferenceCountedHandle<G4VTouchable> G4TouchableHandle;
using G4TouchableHandle = G4ReferenceCountedHandle<G4VTouchable>;
#endif // _G4TOUCHABLEHANDLE_H_
#endif // G4TOUCHABLEHANDLE_HH
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4UAdapter
// G4UAdapter
//
// Class description:
//
@@ -70,7 +67,7 @@ class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
{
public:
typedef vecgeom::Vector3D<G4double> U3Vector;
using U3Vector = vecgeom::Vector3D<G4double>;
using UnplacedVolume_t::operator delete;
using UnplacedVolume_t::operator new;
@@ -78,13 +75,12 @@ class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
// and we need to make these functions public again
G4UAdapter(const G4String& name)
: G4VSolid(name), fRebuildPolyhedron(false), fPolyhedron(0)
: G4VSolid(name)
{ kHalfTolerance = 0.5*kCarTolerance; }
template <typename... T>
G4UAdapter(const G4String& name, const T &... params)
: G4VSolid(name), UnplacedVolume_t(params...),
fRebuildPolyhedron(false), fPolyhedron(0)
: G4VSolid(name), UnplacedVolume_t(params...)
{ kHalfTolerance = 0.5*kCarTolerance; }
virtual ~G4UAdapter();
@@ -207,31 +203,31 @@ class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
public: // VecGeom overridden methods
vecgeom::Precision
DistanceToOut(U3Vector const &position, U3Vector const &direction,
DistanceToOut(U3Vector const& position, U3Vector const& direction,
vecgeom::Precision stepMax = kInfinity) const override
{
return UnplacedVolume_t::DistanceToOut(position, direction, stepMax);
}
vecgeom::EnumInside
Inside(U3Vector const &aPoint) const override
Inside(U3Vector const& aPoint) const override
{
return UnplacedVolume_t::Inside(aPoint);
}
vecgeom::Precision
DistanceToIn(U3Vector const &position, U3Vector const &direction,
DistanceToIn(U3Vector const& position, U3Vector const& direction,
const vecgeom::Precision step_max = kInfinity) const override
{
return UnplacedVolume_t::DistanceToIn(position, direction, step_max);
}
G4bool Normal(U3Vector const &aPoint, U3Vector &aNormal) const override
G4bool Normal(U3Vector const& aPoint, U3Vector& aNormal) const override
{
return UnplacedVolume_t::Normal(aPoint, aNormal);
}
void Extent(U3Vector &aMin, U3Vector &aMax) const override
void Extent(U3Vector& aMin, U3Vector& aMax) const override
{
return UnplacedVolume_t::Extent(aMin, aMax);
}
@@ -243,8 +239,8 @@ class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
protected: // data
mutable G4bool fRebuildPolyhedron;
mutable G4Polyhedron* fPolyhedron;
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fPolyhedron = nullptr;
G4double kHalfTolerance; // Cached geometrical tolerance
@@ -257,7 +253,6 @@ class G4UAdapter : public G4VSolid, protected UnplacedVolume_t
template <class UnplacedVolume_t>
G4UAdapter<UnplacedVolume_t>::G4UAdapter(__void__& a)
: G4VSolid(a), UnplacedVolume_t(*this),
fRebuildPolyhedron(false), fPolyhedron(0),
kHalfTolerance(0.5*kCarTolerance)
{
}
@@ -265,7 +260,7 @@ G4UAdapter<UnplacedVolume_t>::G4UAdapter(__void__& a)
template <class UnplacedVolume_t>
G4UAdapter<UnplacedVolume_t>::~G4UAdapter()
{
delete fPolyhedron; fPolyhedron = 0;
delete fPolyhedron; fPolyhedron = nullptr;
}
template <class UnplacedVolume_t>
@@ -278,8 +273,7 @@ operator==(const G4UAdapter& rhs) const
template <class UnplacedVolume_t>
G4UAdapter<UnplacedVolume_t>::
G4UAdapter(const G4UAdapter& rhs)
: G4VSolid(rhs), UnplacedVolume_t(rhs),
fRebuildPolyhedron(false), fPolyhedron(0)
: G4VSolid(rhs), UnplacedVolume_t(rhs)
{
kHalfTolerance = 0.5*kCarTolerance;
}
@@ -303,7 +297,7 @@ operator=(const G4UAdapter& rhs)
// Copy data
//
fRebuildPolyhedron = false;
delete fPolyhedron; fPolyhedron = 0;
delete fPolyhedron; fPolyhedron = nullptr;
kHalfTolerance = 0.5*kCarTolerance;
return *this;
@@ -421,7 +415,7 @@ G4double G4UAdapter<UnplacedVolume_t>::GetSurfaceArea()
template <class UnplacedVolume_t>
G4ThreeVector G4UAdapter<UnplacedVolume_t>::GetPointOnSurface() const
{
U3Vector p = UnplacedVolume_t::SamplePointOnSurface();;
U3Vector p = UnplacedVolume_t::SamplePointOnSurface();
return G4ThreeVector(p.x(), p.y(), p.z());
}
@@ -476,7 +470,7 @@ G4VSolid* G4UAdapter<UnplacedVolume_t>::Clone() const
<< GetEntityType() << "!" << G4endl
<< "Returning NULL pointer!";
G4Exception("G4UAdapter::Clone()", "GeomSolids1001", JustWarning, message);
return 0;
return nullptr;
}
template <class UnplacedVolume_t>
@@ -518,7 +512,7 @@ G4Polyhedron* G4UAdapter<UnplacedVolume_t>::CreatePolyhedron() const
<< GetEntityType() << "... Sorry!" << G4endl;
G4Exception("G4UAdapter::CreatePolyhedron()", "GeomSolids0003",
FatalException, message);
return 0;
return nullptr;
}
template <class UnplacedVolume_t>
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4VCurevedTrajectoryFilter
// G4VCurvedTrajectoryFilter
//
// Class description:
//
@@ -42,9 +39,7 @@
// subclass of G4VTrajectoryPoint, which must take responsibility for
// deleting them.
// History
//
// - First version: Oct 30, 2002 Jacek Generowicz
// First version: Oct 30, 2002 - Jacek Generowicz
// ------------------------------------------------------------------------
#ifndef G4VCurvedTrajectoryFilter_hh
#define G4VCurvedTrajectoryFilter_hh
@@ -63,7 +58,7 @@ public: // with description
// Probably do not want these objects to be copied,
// so make the copy constructor private
void CreateNewTrajectorySegment( );
void CreateNewTrajectorySegment();
// Each segment stores the auxiliary points of a single step.
virtual void TakeIntermediatePoint( G4ThreeVector newPoint ) = 0;
@@ -75,7 +70,7 @@ public: // with description
protected:
std::vector<G4ThreeVector>* fpFilteredPoints;
std::vector<G4ThreeVector>* fpFilteredPoints = nullptr;
};
#endif /* End of ifndef G4VCurvedTrajectoryFilter_hh */
#endif /* G4VCurvedTrajectoryFilter_hh */
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4VNestedParameterisation
// G4VNestedParameterisation
//
// Class description:
//
@@ -44,8 +42,7 @@
// - the mother volume, in which these copies are placed, must always be
// of the same dimensions
// History:
// 24.02.05 - J.Apostolakis - First created version.
// 24.02.05, J.Apostolakis - First created version.
// --------------------------------------------------------------------
#ifndef G4VNESTEDPARAMETERISATION_HH
#define G4VNESTEDPARAMETERISATION_HH
@@ -87,10 +84,10 @@ class G4VNestedParameterisation: public G4VPVParameterisation,
// -----------------------------------
virtual G4Material* ComputeMaterial(G4VPhysicalVolume* currentVol,
const G4int repNo,
const G4VTouchable* parentTouch=0) = 0;
const G4int repNo,
const G4VTouchable* parentTouch = nullptr) = 0;
// Required method, as it is the reason for this class.
// Must cope with parentTouch=0 for navigator's SetupHierarchy.
// Must cope with parentTouch=nullptr for navigator's SetupHierarchy.
virtual G4int GetNumberOfMaterials() const=0;
virtual G4Material* GetMaterial(G4int idx) const=0;
@@ -104,7 +101,7 @@ class G4VNestedParameterisation: public G4VPVParameterisation,
// Methods optional in derived classes
// -----------------------------------
virtual G4VSolid* ComputeSolid(const G4int no, G4VPhysicalVolume *thisVol);
virtual G4VSolid* ComputeSolid(const G4int no, G4VPhysicalVolume* thisVol);
// Additional standard parameterisation methods,
// which can be optionally defined, in case solid is used.
@@ -162,8 +159,8 @@ class G4VNestedParameterisation: public G4VPVParameterisation,
G4Material* ComputeMaterial(const G4int repNo,
G4VPhysicalVolume *currentVol,
const G4VTouchable *parentTouch=0);
G4VPhysicalVolume* currentVol,
const G4VTouchable* parentTouch = nullptr);
// Method implemented in this class in terms of the above
// ComputeMaterial() method.
@@ -23,17 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4VPVDivisionFactory
// G4VPVDivisionFactory
//
// Class description:
//
// Abstract factory that defines interfaces for creating
// volumes divisions.
// Author: Ivana Hrivnacova, 4.5.2004 (Ivana.Hrivnacova@cern.ch)
// Author: Ivana Hrivnacova, 4.5.2004
// ------------------------------------------------------------------------
#ifndef G4VPVDIVISION_FACTORY_HH
#define G4VPVDIVISION_FACTORY_HH
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4VPVParamterisation
// G4VPVParamterisation
//
// Class description:
//
@@ -33,11 +31,10 @@
// (indirectly) the dimensions of parameterised volumes, given a
// replication number.
// History:
// 25.07.96 P.Kent Initial stub version
// 20.09.96 V.Grichine Modifications for G4Trap/Cons/Sphere
// 31.10.96 V.Grichine Modifications for G4Torus/Para
// 17.02.98 J.Apostolakis Allowing the parameterisation of Solid type
// 25.07.96, P.Kent - Initial stub version
// 20.09.96, V.Grichine - Modifications for G4Trap/Cons/Sphere
// 31.10.96, V.Grichine - Modifications for G4Torus/Para
// 17.02.98, J.Apostolakis - Allowing the parameterisation of solid type
// --------------------------------------------------------------------
#ifndef G4VPVPARAMETERISATION_HH
#define G4VPVPARAMETERISATION_HH
@@ -83,8 +80,8 @@ class G4VPVParameterisation
virtual G4VSolid* ComputeSolid(const G4int, G4VPhysicalVolume *);
virtual G4Material* ComputeMaterial(const G4int repNo,
G4VPhysicalVolume *currentVol,
const G4VTouchable *parentTouch=0);
G4VPhysicalVolume* currentVol,
const G4VTouchable* parentTouch = nullptr);
// Refined method, enabling nested parameterisations
virtual G4bool IsNested() const;
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4VPhysicalVolume
// G4VPhysicalVolume
//
// Class description:
//
@@ -35,12 +32,10 @@
// system. Either a single positioned volume or many positioned volume can
// be represented by a particular G4VPhysicalVolume.
// History:
// 15.01.13 G.Cosmo, A.Dotti: Modified for thread-safety for MT
// 09.11.99 J.Apostolakis: Added GetObjectRotationValue() method & comments
// 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
// 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
// --------------------------------------------------------------------
#ifndef G4VPHYSICALVOLUME_HH
#define G4VPHYSICALVOLUME_HH
@@ -60,20 +55,20 @@ class G4VPVParameterisation;
class G4PVData
{
// Encapsulates the fields associated to G4VPhysicalVolume
// that are not read-only - they will change during simulation
// and must have a per-thread state.
// that are not read-only - they will change during simulation
// and must have a per-thread state.
public:
G4PVData() : frot(0) {}
G4PVData() {}
void initialize()
{
frot = 0;
frot = nullptr;
tx = 0.; ty = 0.; tz = 0.;
}
G4RotationMatrix *frot;
G4RotationMatrix* frot = nullptr;
G4double tx = 0., ty = 0., tz = 0.;
};
@@ -84,11 +79,11 @@ class G4VPhysicalVolume
{
public: // with description
G4VPhysicalVolume(G4RotationMatrix *pRot,
const G4ThreeVector &tlate,
const G4String &pName,
G4LogicalVolume *pLogical,
G4VPhysicalVolume *pMother);
G4VPhysicalVolume(G4RotationMatrix* pRot,
const G4ThreeVector& tlate,
const G4String& pName,
G4LogicalVolume* pLogical,
G4VPhysicalVolume* pMother);
// Initialise volume, positioned in a frame which is rotated by *pRot,
// relative to the coordinate system of the mother volume pMother.
// The center of the object is then placed at tlate in the new
@@ -105,6 +100,10 @@ class G4VPhysicalVolume
virtual ~G4VPhysicalVolume();
// Destructor, will be subclassed. Removes volume from volume Store.
G4VPhysicalVolume(const G4VPhysicalVolume&) = delete;
G4VPhysicalVolume& operator=(const G4VPhysicalVolume&) = delete;
// No copy constructor and assignment operator.
inline G4bool operator == (const G4VPhysicalVolume& p) const;
// Equality defined by equal addresses only.
@@ -115,12 +114,12 @@ class G4VPhysicalVolume
// frame or the object/volume that is being placed.
// (They are the inverse of each other).
G4RotationMatrix* GetObjectRotation() const; // Obsolete
G4RotationMatrix* GetObjectRotation() const; // Obsolete
G4RotationMatrix GetObjectRotationValue() const; // Replacement
G4ThreeVector GetObjectTranslation() const;
// Return the rotation/translation of the Object relative to the mother.
const G4RotationMatrix* GetFrameRotation() const;
G4ThreeVector GetFrameTranslation() const;
G4ThreeVector GetFrameTranslation() const;
// Return the rotation/translation of the Frame used to position
// this volume in its mother volume (opposite of object rot/trans).
@@ -133,7 +132,7 @@ class G4VPhysicalVolume
// Set functions
void SetTranslation(const G4ThreeVector &v);
void SetTranslation(const G4ThreeVector& v);
G4RotationMatrix* GetRotation();
void SetRotation(G4RotationMatrix*);
// NOT INTENDED FOR GENERAL USE.
@@ -142,12 +141,12 @@ class G4VPhysicalVolume
inline G4LogicalVolume* GetLogicalVolume() const;
// Return the associated logical volume.
inline void SetLogicalVolume(G4LogicalVolume *pLogical);
inline void SetLogicalVolume(G4LogicalVolume* pLogical);
// Set the logical volume. Must not be called when geometry closed.
inline G4LogicalVolume* GetMotherLogical() const;
// Return the current mother logical volume pointer.
inline void SetMotherLogical(G4LogicalVolume *pMother);
inline void SetMotherLogical(G4LogicalVolume* pMother);
// Set the mother logical volume. Must not be called when geometry closed.
inline const G4String& GetName() const;
@@ -155,15 +154,14 @@ class G4VPhysicalVolume
inline void SetName(const G4String& pName);
// Set the volume's name.
inline EVolume VolumeType() const;
// Characterise the `type' of volume - normal/replicated/parameterised.
virtual G4int GetMultiplicity() const;
// Returns number of object entities (1 for normal placements,
// n for replicas or parameterised).
// Functions required of subclasses
virtual EVolume VolumeType() const = 0;
// Characterise the type of volume - normal/replicated/parameterised.
virtual G4bool IsMany() const = 0;
// Return true if the volume is MANY (not implemented yet).
virtual G4int GetCopyNo() const = 0;
@@ -185,9 +183,9 @@ class G4VPhysicalVolume
G4double& offset,
G4bool& consuming) const = 0;
// Return replication information. No-op for no replicated volumes.
virtual G4bool IsRegularStructure() const = 0;
virtual G4bool IsRegularStructure() const = 0;
// Returns true if the underlying volume structure is regular.
virtual G4int GetRegularStructureId() const = 0;
virtual G4int GetRegularStructureId() const = 0;
// Returns non-zero code in case the underlying volume structure
// is regular, voxel-like. Value is id for structure type.
// If non-zero the volume is a candidate for specialised
@@ -216,14 +214,18 @@ class G4VPhysicalVolume
static void Clean();
// Clear memory allocated by sub-instance manager.
inline EVolume DeduceVolumeType() const;
// Old VolumeType() method, replaced by virtual method,
// kept for checking
protected:
void InitialiseWorker(G4VPhysicalVolume *pMasterObject,
G4RotationMatrix *pRot, const G4ThreeVector &tlate);
void InitialiseWorker(G4VPhysicalVolume* pMasterObject,
G4RotationMatrix* pRot, const G4ThreeVector& tlate);
// This method is similar to the constructor. It is used by each worker
// thread to achieve the partial effect as that of the master thread.
void TerminateWorker(G4VPhysicalVolume *pMasterObject);
void TerminateWorker(G4VPhysicalVolume* pMasterObject);
// This method is similar to the destructor. It is used by each worker
// thread to achieve the partial effect as that of the master thread.
@@ -237,19 +239,13 @@ class G4VPhysicalVolume
private:
G4VPhysicalVolume(const G4VPhysicalVolume&);
G4VPhysicalVolume& operator=(const G4VPhysicalVolume&);
// Private copy constructor and assignment operator.
G4LogicalVolume* flogical = nullptr; // The logical volume representing the
// physical and tracking attributes of
// the volume
G4String fname; // The name of the volume
G4LogicalVolume* flmother = nullptr; // The current mother logical volume
private:
G4LogicalVolume* flogical; // The logical volume representing the
// physical and tracking attributes of
// the volume
G4String fname; // The name of the volume
G4LogicalVolume* flmother; // The current mother logical volume
G4PVData* pvdata; // Shadow pointer for use of object persistency
G4PVData* pvdata = nullptr; // Shadow pointer for use of object persistency
};
// NOTE:
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4VPhysicalVolume Inline Implementation
// class G4VPhysicalVolume inline implementation
//
// --------------------------------------------------------------------
@@ -49,9 +46,9 @@ G4LogicalVolume* G4VPhysicalVolume::GetLogicalVolume() const
}
inline
void G4VPhysicalVolume::SetLogicalVolume(G4LogicalVolume *pLogical)
void G4VPhysicalVolume::SetLogicalVolume(G4LogicalVolume* pLogical)
{
flogical=pLogical;
flogical = pLogical;
}
inline
@@ -61,9 +58,9 @@ G4LogicalVolume* G4VPhysicalVolume::GetMotherLogical() const
}
inline
void G4VPhysicalVolume::SetMotherLogical(G4LogicalVolume *pMother)
void G4VPhysicalVolume::SetMotherLogical(G4LogicalVolume* pMother)
{
flmother=pMother;
flmother = pMother;
}
inline
@@ -75,11 +72,11 @@ const G4String& G4VPhysicalVolume::GetName() const
inline
void G4VPhysicalVolume::SetName(const G4String& pName)
{
fname=pName;
fname = pName;
}
inline
EVolume G4VPhysicalVolume::VolumeType() const
EVolume G4VPhysicalVolume::DeduceVolumeType() const
{
EVolume type;
EAxis axis;
+6 -10
View File
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4VSolid
// G4VSolid
//
// Class description:
//
@@ -52,10 +49,9 @@
// G4String fshapeName
// - Name for this solid.
// History:
// 12.04.00 J.Allison Implemented GetExtent() in terms of CalculateExtent()
// 17.06.98 J.Apostolakis Added pure virtual function GetEntityType()
// 26.07.96 P.Kent Added ComputeDimensions for replication mechanism
// 26.07.96 P.Kent Added ComputeDimensions() for replication mechanism
// 27.03.96 J.Allison Methods for visualisation
// 30.06.95 P.Kent Initial version, no scoping or visualisation functions
// --------------------------------------------------------------------
@@ -80,8 +76,8 @@ class G4DisplacedSolid;
#include "G4ThreeVector.hh"
#include <vector>
typedef std::vector<G4ThreeVector> G4ThreeVectorList;
typedef G4String G4GeometryType;
using G4ThreeVectorList = std::vector<G4ThreeVector>;
using G4GeometryType = G4String;
class G4VSolid
{
@@ -142,8 +138,8 @@ class G4VSolid
virtual G4double DistanceToOut(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm=false,
G4bool *validNorm=0,
G4ThreeVector *n=0) const = 0;
G4bool* validNorm = nullptr,
G4ThreeVector* n = nullptr) const = 0;
// Return the distance along the normalised vector v to the shape,
// from a point at an offset p inside or on the surface of the shape.
// Intersections with surfaces, when the point is < Tolerance/2 from a
@@ -22,11 +22,8 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4VSolid Inline implementation
// G4VSolid inline implementation
//
// --------------------------------------------------------------------
@@ -45,17 +42,17 @@ void G4VSolid::DumpInfo () const
inline
G4String G4VSolid::GetName() const
{
return fshapeName;
return fshapeName;
}
inline
void G4VSolid::SetName(const G4String& name)
{
fshapeName=name;
fshapeName = name;
}
inline
G4double G4VSolid::GetTolerance() const
{
return kCarTolerance;
return kCarTolerance;
}
@@ -23,9 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4VStoreNotifier
// G4VStoreNotifier
//
// Class description:
//
@@ -34,14 +32,13 @@
// volume, solid and region stores.
// See G4VNotifier for the details.
// Author:
// 01.09.04 G.Cosmo Initial version
// 01.09.04, G.Cosmo - Initial version
// --------------------------------------------------------------------
#ifndef G4VSTORENOTIFIER_HH
#define G4VSTORENOTIFIER_HH
#include "G4VNotifier.hh"
typedef G4VNotifier G4VStoreNotifier;
using G4VStoreNotifier = G4VNotifier;
#endif
@@ -22,11 +22,8 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4VTouchable
// G4VTouchable
//
// Class description:
//
@@ -88,7 +85,6 @@
// 8) UpdateYourself takes a physical volume pointer and can additionally
// take a NavigationHistory.
// History:
// Created: Paul Kent, August 1996
// --------------------------------------------------------------------
#ifndef G4VTOUCHABLE_HH
@@ -126,7 +122,7 @@ class G4VTouchable
// Methods for touchables with history.
virtual void UpdateYourself(G4VPhysicalVolume* pPhysVol,
const G4NavigationHistory* history=0);
const G4NavigationHistory* history = nullptr);
// Update method.
public: // without description
@@ -22,11 +22,8 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class G4VTouchable Inline implementation
// class G4VTouchable inline implementation
//
// --------------------------------------------------------------------
@@ -23,11 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// --------------------------------------------------------------------
//
// G4VUserRegionInformation
//
// Class Description:
@@ -40,11 +35,10 @@
// The concrete class object is deleted by Geant4 kernel when
// associated G4Region object is deleted.
// History:
// 21/10/2003 - M.Asai, Created.
// --------------------------------------------------------------------
#ifndef G4VUserRegionInformation_H
#define G4VUserRegionInformation_H 1
#ifndef G4VUserRegionInformation_HH
#define G4VUserRegionInformation_HH 1
class G4VUserRegionInformation
{
@@ -23,17 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4VVolumeMaterialScanner
// G4VVolumeMaterialScanner
//
// Class description:
//
// Interface for repeated volumes or parameterisations that are able to
// tabulate their materials.
// tabulate their materials.
// History:
// 18.11.05 J.Apostolakis Initial version
// 18.11.05, J.Apostolakis - Initial version
// --------------------------------------------------------------------
#ifndef G4VVOLUMEMATERIALSCANNER_HH
#define G4VVOLUMEMATERIALSCANNER_HH
@@ -45,6 +42,7 @@ class G4Material;
class G4VVolumeMaterialScanner
{
public:
G4VVolumeMaterialScanner() {;}
virtual ~G4VVolumeMaterialScanner() {;}
@@ -23,30 +23,21 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// class G4VoxelLimits
// G4VoxelLimits
//
// Class description:
//
// Represents limitation/restrictions of space, where restrictions
// are only made perpendicular to the cartesian axes.
//
//
// Member data:
//
// G4double fxAxisMin,fxAxisMax
// G4double fyAxisMin,fyAxisMax
// G4double fzAxisMin,fzAxisMax
// - The min and max values along each axis. +-kInfinity if not restricted.
//
//
// Notes:
//
// Beware no break statements after returns in switch(pAxis)s.
// - The min and max values along each axis. +-kInfinity if not restricted.
// History:
// 13.07.95 P.Kent Initial version.
// 13.07.95, P.Kent - Initial version.
// --------------------------------------------------------------------
#ifndef G4VOXELLIMITS_HH
#define G4VOXELLIMITS_HH
@@ -68,7 +59,7 @@ class G4VoxelLimits
~G4VoxelLimits();
// Destructor. No actions.
void AddLimit(const EAxis pAxis, const G4double pMin,const G4double pMax);
void AddLimit(const EAxis pAxis, const G4double pMin, const G4double pMax);
// Restrict the volume to between specified min and max along the
// given axis. Cartesian axes only, pMin<=pMax.
@@ -103,7 +94,7 @@ class G4VoxelLimits
G4bool IsLimited(const EAxis pAxis) const;
// Return true if the specified axis is restricted/limited.
G4bool ClipToLimits(G4ThreeVector& pStart,G4ThreeVector& pEnd) const;
G4bool ClipToLimits(G4ThreeVector& pStart, G4ThreeVector& pEnd) const;
// Clip the line segment pStart->pEnd to the volume described by the
// current limits. Return true if the line remains after clipping,
// else false, and leave the vectors in an undefined state.
@@ -124,9 +115,9 @@ class G4VoxelLimits
private:
G4double fxAxisMin,fxAxisMax;
G4double fyAxisMin,fyAxisMax;
G4double fzAxisMin,fzAxisMax;
G4double fxAxisMin = -kInfinity, fxAxisMax = kInfinity;
G4double fyAxisMin = -kInfinity, fyAxisMax = kInfinity;
G4double fzAxisMin = -kInfinity, fzAxisMax = kInfinity;
};
#include "G4VoxelLimits.icc"
@@ -22,11 +22,8 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// G4VoxelLimits Inline implementation
// G4VoxelLimits inline implementation
//
// --------------------------------------------------------------------
@@ -23,12 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// Defines for Windows DLLs import/export
//
// --------------------------------------------------------------------
#ifndef GEOMWDEFS_HH
#define GEOMWDEFS_HH
+10 -10
View File
@@ -23,13 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// Tube/Cone Meshing constants for extent calculations
// History:
// 13.08.95 P.Kent Created separate file
// 13.08.95, P.Kent - Created separate file
// --------------------------------------------------------------------
#ifndef MESHDEFS_HH
#define MESHDEFS_HH
@@ -38,11 +34,15 @@
#include "G4Types.hh"
const G4double kMeshAngleDefault=(CLHEP::pi/4); // Angle for mesh `wedges' in rads
// Works best when simple fraction of pi/2
const G4double kMeshAngleDefault = (CLHEP::pi/4);
// Angle for mesh `wedges' in rads
// Works best when simple fraction of pi/2
const G4int kMinMeshSections=3; // Min wedges+1 to make
const G4int kMaxMeshSections=37; // max wedges+1 to make
// =>10 degrees/wedge for complete tube
const G4int kMinMeshSections = 3;
// Min wedges+1 to make
const G4int kMaxMeshSections = 37;
// max wedges+1 to make
// =>10 degrees/wedge for complete tube
#endif
+15 -17
View File
@@ -23,30 +23,28 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
//
// Voxel Optimisation Constants
// History:
// 12.02.99 S.Giani made numerical values consistent with Geant3.21
// 13.08.95 P.Kent Created separate file
// 12.02.99, S.Giani - Made numerical values consistent with Geant3.21
// 13.08.95, P.Kent - Created separate file
// --------------------------------------------------------------------
#ifndef VOXELDEFS_HH
#define VOXELDEFS_HH
#include "G4Types.hh"
// Hard limit on no. voxel nodes per given header
const G4int kMaxVoxelNodes=1000; // PK chose 2000, Geant 3.21 used 1000
const G4int kMaxVoxelNodes = 1000; // PK chose 2000, Geant 3.21 used 1000
// Hard limit on no. voxel nodes per given header
const G4int kMinVoxelVolumesLevel1 = 2;
// Only begin to make voxels if >= this no of daughters
const G4int kMinVoxelVolumesLevel2 = 3;
// Only make second level of refinement if >= this no of
// volumes in 1st level node
const G4int kMinVoxelVolumesLevel3 = 4;
// Only make third level of refinement if >= this no of
// volumes in 2nd level node
const G4int kMinVoxelVolumesLevel1=2; // Only begin to make voxels if >=
// this no of daughters
const G4int kMinVoxelVolumesLevel2=3; // Only make second level of refinement
// if >= this no of volumes in
// 1st level node
const G4int kMinVoxelVolumesLevel3=4; // Only make third level of refinement
// if >= this no of volumes in
// 2nd level node
#endif
@@ -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;
}
+9 -13
View File
@@ -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)
{
}
+117 -65
View File
@@ -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;
+34 -44
View File
@@ -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)
{
+22 -27
View File
@@ -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());
}
}
+15 -21
View File
@@ -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;
}
+24 -63
View File
@@ -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