Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
+14 -1
View File
@@ -6,7 +6,20 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-02-01 Gabriele Cosmo (geom-specific-V11-01-07)
## 2024-05-29 Evgueni Tcherniaev (geom-specific-V11-02-04)
- Added new methods GetNumOfConstituents() and IsFaceted().
## 2024-05-27 Evgueni Tcherniaev (geom-specific-V11-02-03)
- Completely revised G4GeneriTrap, it addresses the problem report #2547
## 2024-05-26 Evgueni Tcherniaev (geom-specific-V11-02-02)
- New testG4GenericTrap.cc
## 2024-04-02 Gabriele Cosmo (geom-specific-V11-02-01)
- Applied trivial clang-tidy fixes to classes, i.e. use of 'override' and
'default' keywords.
## 2024-02-01 Gabriele Cosmo (geom-specific-V11-02-00)
- Use std::size_t for array sizes in G4PolyhedraSide and G4PolyPhiFace.
## 2023-07-10 Evgueni Tcherniaev (geom-specific-V11-01-06)
@@ -131,6 +131,7 @@ class G4ExtrudedSolid : public G4TessellatedSolid
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
G4GeometryType GetEntityType () const override;
G4bool IsFaceted () const override;
G4VSolid* Clone() const override;
std::ostream& StreamInfo(std::ostream& os) const override;
@@ -54,6 +54,8 @@
// Authors:
// Tatiana Nikitina, CERN; Ivana Hrivnacova, IPN Orsay
// Adapted from Root Arb8 implementation, author Andrei Gheata, CERN
//
// 27.05.2024 - Evgueni Tcherniaev, complete revision, speed up
// -------------------------------------------------------------------
#ifndef G4GENERICTRAP_HH
#define G4GENERICTRAP_HH
@@ -74,21 +76,28 @@
#include "globals.hh"
#include "G4TwoVector.hh"
#include "G4VSolid.hh"
#include "G4TessellatedSolid.hh"
class G4GenericTrap : public G4VSolid
{
public:
G4GenericTrap( const G4String& name, G4double halfZ,
const std::vector<G4TwoVector>& vertices );
// Constructor
// Constructor
G4GenericTrap(const G4String& name, G4double halfZ,
const std::vector<G4TwoVector>& vertices);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4GenericTrap(__void__&);
// Copy constructor and assignment operator
G4GenericTrap(const G4GenericTrap& rhs);
G4GenericTrap& operator=(const G4GenericTrap& rhs);
// Destructor
~G4GenericTrap() override;
// Destructor
// Accessors
inline G4double GetZHalfLength() const;
inline G4int GetNofVertices() const;
inline G4TwoVector GetVertex(G4int index) const;
@@ -99,7 +108,6 @@ class G4GenericTrap : public G4VSolid
inline void SetVisSubdivisions(G4int subdiv);
// Solid methods
EInside Inside(const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
G4double DistanceToIn(const G4ThreeVector& p,
@@ -119,6 +127,8 @@ class G4GenericTrap : public G4VSolid
G4GeometryType GetEntityType() const override;
G4bool IsFaceted () const override;
G4VSolid* Clone() const override;
std::ostream& StreamInfo(std::ostream& os) const override;
@@ -129,93 +139,76 @@ class G4GenericTrap : public G4VSolid
G4double GetSurfaceArea() override;
// Visualisation functions
G4Polyhedron* GetPolyhedron () const override;
void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent() const override;
G4VisExtent GetExtent() const override;
G4Polyhedron* CreatePolyhedron() const override;
G4GenericTrap(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4GenericTrap(const G4GenericTrap& rhs);
G4GenericTrap& operator=(const G4GenericTrap& rhs);
// Copy constructor and assignment operator.
G4Polyhedron* GetPolyhedron () const override;
private:
// Internal methods
inline void SetTwistAngle(G4int index, G4double twist);
G4bool ComputeIsTwisted() ;
G4bool CheckOrder(const std::vector<G4TwoVector>& vertices) const;
G4bool IsSegCrossing(const G4TwoVector& a, const G4TwoVector& b,
const G4TwoVector& c, const G4TwoVector& d) const;
G4bool IsSegCrossingZ(const G4TwoVector& a, const G4TwoVector& b,
const G4TwoVector& c, const G4TwoVector& d) const;
void ReorderVertices(std::vector<G4ThreeVector>& vertices) const;
void ComputeBBox();
inline G4ThreeVector GetMinimumBBox() const;
inline G4ThreeVector GetMaximumBBox() const;
G4VFacet* MakeDownFacet(const std::vector<G4ThreeVector>& fromVertices,
G4int ind1, G4int ind2, G4int ind3) const;
G4VFacet* MakeUpFacet(const std::vector<G4ThreeVector>& fromVertices,
G4int ind1, G4int ind2, G4int ind3) const;
G4VFacet* MakeSideFacet(const G4ThreeVector& downVertex0,
const G4ThreeVector& downVertex1,
const G4ThreeVector& upVertex1,
const G4ThreeVector& upVertex0) const;
G4TessellatedSolid* CreateTessellatedSolid() const;
EInside InsidePolygone(const G4ThreeVector& p,
const std::vector<G4TwoVector>& poly) const;
G4double DistToPlane(const G4ThreeVector& p,
const G4ThreeVector& v, const G4int ipl) const ;
G4double DistToTriangle(const G4ThreeVector& p,
const G4ThreeVector& v, const G4int ipl) const;
G4ThreeVector NormalToPlane(const G4ThreeVector& p,
const G4int ipl) const;
G4double SafetyToFace(const G4ThreeVector& p, const G4int iseg) const;
void CheckParameters(G4double halfZ, const std::vector<G4TwoVector>& vertices);
void ComputeLateralSurfaces();
void ComputeBoundingBox();
void ComputeScratchLength();
G4double GetLateralFaceArea(G4int iface) const;
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
protected:
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr;
void WarningSignA(const G4String& method, const G4String& icase, G4double A,
const G4ThreeVector& p, const G4ThreeVector& v) const;
void WarningSignB(const G4String& method, const G4String& icase, G4double f, G4double B,
const G4ThreeVector& p, const G4ThreeVector& v) const;
void WarningDistanceToIn(G4int k, const G4ThreeVector& p, const G4ThreeVector& v,
G4double tmin, G4double tmax,
const G4double ttin[2], const G4double ttout[2]) const;
void WarningDistanceToOut(const G4ThreeVector& p,
const G4ThreeVector& v,
G4double tout) const;
private:
// static data members
struct G4GenericTrapPlane // Ax + By + Cz + D = 0
{
G4double A = 0.;
G4double B = 0.;
G4double C = 0.;
G4double D = 0.;
};
struct G4GenericTrapSurface // Axz + Byz + Czz + Dx + Ey + Fz + G = 0
{
G4double A = 0.;
G4double B = 0.;
G4double C = 0.;
G4double D = 0.;
G4double E = 0.;
G4double F = 0.;
G4double G = 0.;
};
static const G4int fgkNofVertices;
static const G4double fgkTolerance;
G4double halfCarTolerance;
// data members
G4double fDz;
std::vector<G4TwoVector> fVertices;
// Data members
G4double halfTolerance = 0.;
G4double fScratch = 0.;
G4double fDz = 0.;
std::vector<G4TwoVector> fVertices = {0.,0.,0.,0.,0.,0.,0.,0.};
G4TwoVector fDelta[4];
G4bool fIsTwisted = false;
G4double fTwist[4];
G4TessellatedSolid* fTessellatedSolid = nullptr;
G4ThreeVector fMinBBoxVector;
G4ThreeVector fMaxBBoxVector;
G4double fTwist[5] = {0.};
G4ThreeVector fMinBBox{0.};
G4ThreeVector fMaxBBox{0.};
G4int fVisSubdivisions = 0;
G4GenericTrapPlane fPlane[8];
G4GenericTrapSurface fSurf[4];
mutable G4double fArea[4] = {0.};
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr;
enum ESide {kUndef,kXY0,kXY1,kXY2,kXY3,kMZ,kPZ};
// Codes for faces (kXY[num]=num of lateral face,kMZ= minus z face etc)
G4double fSurfaceArea = 0.0;
G4double fCubicVolume = 0.0;
// Surface and Volume
// Surface and Volume
G4double fSurfaceArea = 0.;
G4double fCubicVolume = 0.;
};
#include "G4GenericTrap.icc"
#endif
#endif // defined(G4GEOM_USE_UGENERICTRAP)
#endif
#endif // G4GENERICTRAP_HH
@@ -26,7 +26,7 @@
// Implementation of inline methods of G4GenericTrap
// --------------------------------------------------------------------
inline
inline
G4double G4GenericTrap::GetZHalfLength() const
{
return fDz;
@@ -34,44 +34,48 @@ G4double G4GenericTrap::GetZHalfLength() const
// --------------------------------------------------------------------
inline
inline
G4int G4GenericTrap::GetNofVertices() const
{
return G4int(fVertices.size());
}
}
// --------------------------------------------------------------------
inline
G4TwoVector G4GenericTrap::GetVertex(G4int index) const
{
if ( index<0 || index >= G4int(fVertices.size()) )
if (index < 0 || index > 7)
{
G4Exception ("G4GenericTrap::GetVertex()", "GeomSolids0003",
FatalException, "Index outside range.");
return {};
std::ostringstream message;
message << "Index = "<< index << " is out of range [0, 7]"
<< " for Solid: " << GetName() << " !";
G4Exception("G4GenericTrap::GetVertex()", "GeomSolids0003",
FatalException, message);
}
return fVertices[index];
}
}
// --------------------------------------------------------------------
inline
inline
const std::vector<G4TwoVector>& G4GenericTrap::GetVertices() const
{
return fVertices;
}
}
// --------------------------------------------------------------------
inline
inline
G4double G4GenericTrap::GetTwistAngle(G4int index) const
{
if ( (index<0) || (index >= G4int(fVertices.size())) )
if (index < 0 || index > 3)
{
G4Exception ("G4GenericTrap::GetTwistAngle()", "GeomSolids0003",
FatalException, "Index outside range.");
return 0.;
std::ostringstream message;
message << "Index = "<< index << " is out of range [0, 3]"
<< " for Solid: " << GetName() << " !";
G4Exception("G4GenericTrap::GetTwistAngle()", "GeomSolids0003",
FatalException, message);
}
return fTwist[index];
}
@@ -86,22 +90,6 @@ G4bool G4GenericTrap::IsTwisted() const
// --------------------------------------------------------------------
inline
void G4GenericTrap::SetTwistAngle(G4int index, G4double twist)
{
if ( (index<0) || (index >= G4int(fVertices.size())) )
{
G4Exception ("G4GenericTrap::SetTwistAngle()", "GeomSolids0003",
FatalException, "Index outside range.");
}
else
{
fTwist[index]=twist;
}
}
// --------------------------------------------------------------------
inline
G4int G4GenericTrap::GetVisSubdivisions()const
{
@@ -115,22 +103,3 @@ void G4GenericTrap::SetVisSubdivisions(G4int subdiv)
{
fVisSubdivisions=subdiv;
}
// --------------------------------------------------------------------
inline
G4ThreeVector G4GenericTrap::GetMinimumBBox() const
{
return fMinBBoxVector;
}
// --------------------------------------------------------------------
inline
G4ThreeVector G4GenericTrap::GetMaximumBBox() const
{
return fMaxBBoxVector;
}
// --------------------------------------------------------------------
@@ -111,6 +111,8 @@ class G4Polyhedra : public G4VCSGfaceted
G4GeometryType GetEntityType() const override;
G4bool IsFaceted () const override;
G4VSolid* Clone() const override;
G4double GetCubicVolume() override;
@@ -45,7 +45,7 @@
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4REDUCIBLEPOLYGON_HH
#define G4REDUCIBLEPOLYGON_HH
#define G4REDUCIBLEPOLYGON_HH 1
#include "G4Types.hh"
@@ -123,7 +123,7 @@ class G4ReduciblePolygon
friend struct ABVertex; // protected nested structures
struct ABVertex
{
ABVertex() {}
ABVertex() = default;
G4double a{0.}, b{0.};
ABVertex *next{nullptr};
};
@@ -167,6 +167,7 @@ class G4TessellatedSolid : public G4VSolid
G4bool aAccurate = false) const;
G4GeometryType GetEntityType () const override;
G4bool IsFaceted () const override;
std::ostream& StreamInfo(std::ostream& os) const override;
G4VSolid* Clone() const override;
@@ -113,6 +113,8 @@ class G4Tet : public G4VSolid
G4GeometryType GetEntityType() const override;
G4bool IsFaceted () const override;
G4VSolid* Clone() const override;
std::ostream& StreamInfo(std::ostream& os) const override;
@@ -86,6 +86,8 @@ class G4UExtrudedSolid : public G4UAdapter<vecgeom::UnplacedExtruded>
inline G4GeometryType GetEntityType() const override;
inline G4bool IsFaceted() const override;
G4UExtrudedSolid(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
@@ -113,6 +115,11 @@ inline G4GeometryType G4UExtrudedSolid::GetEntityType() const
return "G4ExtrudedSolid";
}
inline G4bool G4UExtrudedSolid::IsFaceted() const
{
return true;
}
#endif // G4GEOM_USE_USOLIDS
#endif
@@ -68,6 +68,8 @@ class G4UGenericTrap : public G4UAdapter<vecgeom::UnplacedGenTrap>
inline G4GeometryType GetEntityType() const override;
inline G4bool IsFaceted() const override;
G4UGenericTrap(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
@@ -102,6 +104,11 @@ inline G4GeometryType G4UGenericTrap::GetEntityType() const
return "G4GenericTrap";
}
inline G4bool G4UGenericTrap::IsFaceted() const
{
return true;
}
#endif // G4GEOM_USE_USOLIDS
#endif
@@ -98,6 +98,8 @@ class G4UPolyhedra : public G4UAdapter<vecgeom::UnplacedPolyhedron>
inline G4GeometryType GetEntityType() const override;
inline G4bool IsFaceted() const override;
G4UPolyhedra(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
@@ -140,6 +142,11 @@ inline G4GeometryType G4UPolyhedra::GetEntityType() const
return "G4Polyhedra";
}
inline G4bool G4UPolyhedra::IsFaceted() const
{
return true;
}
#endif // G4GEOM_USE_USOLIDS
#endif
@@ -61,6 +61,8 @@ class G4UTessellatedSolid : public G4UAdapter<vecgeom::UnplacedTessellated>
inline G4GeometryType GetEntityType() const override;
inline G4bool IsFaceted() const override;
void SetSolidClosed(const G4bool t);
G4bool GetSolidClosed() const;
@@ -108,6 +110,11 @@ inline G4GeometryType G4UTessellatedSolid::GetEntityType() const
return "G4TessellatedSolid";
}
inline G4bool G4UTessellatedSolid::IsFaceted() const
{
return true;
}
#endif // G4GEOM_USE_USOLIDS
#endif
@@ -67,6 +67,8 @@ class G4UTet : public G4UAdapter<vecgeom::UnplacedTet>
inline G4GeometryType GetEntityType() const override;
inline G4bool IsFaceted() const override;
G4UTet(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
@@ -120,6 +122,11 @@ inline G4GeometryType G4UTet::GetEntityType() const
return "G4Tet";
}
inline G4bool G4UTet::IsFaceted() const
{
return true;
}
#endif // G4GEOM_USE_USOLIDS
#endif
@@ -33,7 +33,7 @@
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4VCSGFACETED_HH
#define G4VCSGFACETED_HH
#define G4VCSGFACETED_HH 1
#include "G4VSolid.hh"
@@ -45,7 +45,7 @@ class G4VCSGfaceted : public G4VSolid
public:
G4VCSGfaceted( const G4String& name );
virtual ~G4VCSGfaceted();
~G4VCSGfaceted() override;
G4VCSGfaceted( const G4VCSGfaceted& source );
G4VCSGfaceted& operator=( const G4VCSGfaceted& source );
@@ -64,7 +64,7 @@ class G4VTwistSurface
G4double axis0max = kInfinity,
G4double axis1max = kInfinity);
virtual ~G4VTwistSurface();
virtual ~G4VTwistSurface() = default;
virtual G4int AmIOnLeftSide(const G4ThreeVector& me,
const G4ThreeVector& vec,
@@ -274,8 +274,8 @@ class G4VTwistSurface
{
public:
Boundary();
virtual ~Boundary();
Boundary() = default;
virtual ~Boundary() = default;
void SetFields(const G4int& areacode,
const G4ThreeVector& d,
@@ -30,10 +30,10 @@
// G4VTwistedFaceted is an abstract base class for twisted boxoids:
// G4TwistedTrd, G4TwistedTrap and G4TwistedBox
// Author: 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
// Author: 27-Oct-2004 - O.Link (CERN)
// --------------------------------------------------------------------
#ifndef G4VTWISTEDFACETED_HH
#define G4VTWISTEDFACETED_HH
#define G4VTWISTEDFACETED_HH 1
#include "G4VSolid.hh"
#include "G4TwoVector.hh"
@@ -63,7 +63,7 @@ class G4VTwistedFaceted: public G4VSolid
G4double pAlph // tilt angle at +pDz
);
virtual ~G4VTwistedFaceted();
~G4VTwistedFaceted() override;
void ComputeDimensions( G4VPVParameterisation*,
const G4int,
@@ -837,6 +837,13 @@ G4GeometryType G4ExtrudedSolid::GetEntityType () const
//_____________________________________________________________________________
G4bool G4ExtrudedSolid::IsFaceted () const
{
return true;
}
//_____________________________________________________________________________
G4VSolid* G4ExtrudedSolid::Clone() const
{
return new G4ExtrudedSolid(*this);
File diff suppressed because it is too large Load Diff
@@ -742,6 +742,13 @@ G4GeometryType G4Polyhedra::GetEntityType() const
return {"G4Polyhedra"};
}
// IsFaceted
//
G4bool G4Polyhedra::IsFaceted() const
{
return true;
}
// Make a clone of the object
//
G4VSolid* G4Polyhedra::Clone() const
@@ -681,7 +681,7 @@ G4int G4TessellatedSolid::CheckStructure() const
nedge += facet.GetNumberOfVertices();
volume += facet.GetArea()*(facet.GetVertex(0).dot(facet.GetSurfaceNormal()));
}
G4int ivolume = static_cast<G4int>(volume <= 0.);
auto ivolume = static_cast<G4int>(volume <= 0.);
// Create sorted vector of edges
//
@@ -695,7 +695,7 @@ G4int G4TessellatedSolid::CheckStructure() const
{
int64_t i1 = facet.GetVertexIndex((k == 0) ? nnode - 1 : k - 1);
int64_t i2 = facet.GetVertexIndex(k);
int64_t inverse = static_cast<int64_t>(i2 > i1);
auto inverse = static_cast<int64_t>(i2 > i1);
if (inverse != 0) std::swap(i1, i2);
iedge[kk++] = i1*1000000000 + i2*2 + inverse;
}
@@ -1748,6 +1748,15 @@ G4GeometryType G4TessellatedSolid::GetEntityType () const
return fGeometryType;
}
///////////////////////////////////////////////////////////////////////////////
//
// IsFaceted
//
G4bool G4TessellatedSolid::IsFaceted () const
{
return true;
}
///////////////////////////////////////////////////////////////////////////////
//
std::ostream &G4TessellatedSolid::StreamInfo(std::ostream &os) const
@@ -587,6 +587,15 @@ G4GeometryType G4Tet::GetEntityType() const
return {"G4Tet"};
}
////////////////////////////////////////////////////////////////////////
//
// IsFaceted
//
G4bool G4Tet::IsFaceted() const
{
return true;
}
////////////////////////////////////////////////////////////////////////
//
// Make a clone of the object
@@ -134,11 +134,6 @@ G4VTwistSurface::G4VTwistSurface( __void__& )
fNeighbours[0] = fNeighbours[1] = fNeighbours[2] = fNeighbours[3] = nullptr;
}
//=====================================================================
//* destructor --------------------------------------------------------
G4VTwistSurface::~G4VTwistSurface() = default;
//=====================================================================
//* AmIOnLeftSide -----------------------------------------------------
@@ -1267,18 +1262,6 @@ G4VTwistSurface::CurrentStatus::DebugPrint() const
// G4VTwistSurface::Boundary class
//=====================================================================
//=====================================================================
//* Boundary::Boundary ------------------------------------------------
G4VTwistSurface::Boundary::Boundary()
{
}
//=====================================================================
//* Boundary::~Boundary -----------------------------------------------
G4VTwistSurface::Boundary::~Boundary() = default;
//=====================================================================
//* Boundary::SetFields -----------------------------------------------