Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
@@ -28,27 +28,26 @@
//
// Class description:
//
// The G4TriangularFacet class is used for the contruction of
// G4TessellatedSolid.
// It is defined by three fVertices, which shall be supplied in anti-clockwise
// order looking from the outsider of the solid where it belongs.
// Its constructor:
// The G4TriangularFacet class is used for the contruction of G4TessellatedSolid.
// It is defined by three fVertices, which shall be supplied in anti-clockwise
// order looking from the outsider of the solid where it belongs.
// Its constructor:
//
// G4TriangularFacet (const G4ThreeVector Pt0, const G4ThreeVector vt1,
// const G4ThreeVector vt2, G4FacetVertexType);
// G4TriangularFacet (const G4ThreeVector Pt0, const G4ThreeVector vt1,
// const G4ThreeVector vt2, G4FacetVertexType);
//
// takes 4 parameters to define the three fVertices:
// 1) G4FacetvertexType = "ABSOLUTE": in this case Pt0, vt1 and vt2 are
// the 3 fVertices in anti-clockwise order looking from the outsider.
// 2) G4FacetvertexType = "RELATIVE": in this case the first vertex is Pt0,
// the second vertex is Pt0+vt1 and the third vertex is Pt0+vt2, all
// in anti-clockwise order when looking from the outsider.
// takes 4 parameters to define the three fVertices:
// 1) G4FacetvertexType = "ABSOLUTE": in this case Pt0, vt1 and vt2 are
// the 3 fVertices in anti-clockwise order looking from the outsider.
// 2) G4FacetvertexType = "RELATIVE": in this case the first vertex is Pt0,
// the second vertex is Pt0+vt1 and the third vertex is Pt0+vt2, all
// in anti-clockwise order when looking from the outsider.
// 31 October 2004, P R Truscott, QinetiQ Ltd, UK - Created.
// 12 October 2012, M Gayer, CERN, - Reviewed optimized implementation.
// Author: P.R.Truscott (QinetiQ Ltd, UK), 31.10.2004 - Created
// M.Gayer (CERN), 12.10.2012 - Reviewed optimised implementation
// --------------------------------------------------------------------
#ifndef G4TRIANGULARFACET_HH
#define G4TRIANGULARFACET_HH 1
#define G4TRIANGULARFACET_HH
#include "G4VFacet.hh"
#include "G4Types.hh"
@@ -57,57 +56,170 @@
#include <vector>
#include <array>
/**
* @brief G4TriangularFacet defines a facet with 3 vertices, used for the
* contruction of G4TessellatedSolid. Vertices shall be supplied in
* anti-clockwise order looking from the outsider of the solid where it belongs.
*/
class G4TriangularFacet : public G4VFacet
{
public:
/**
* Default Constructor.
*/
G4TriangularFacet ();
~G4TriangularFacet () override;
G4TriangularFacet (const G4ThreeVector& vt0, const G4ThreeVector& vt1,
const G4ThreeVector& vt2, G4FacetVertexType);
/**
* Constructs a facet with 3 vertices, given its parameters.
* @param[in] Pt0 The anchor point, first vertex.
* @param[in] vt1 Second vertex.
* @param[in] vt2 Third vertex.
* @param[in] vType The positioning type for the vertices, either:
* "ABSOLUTE" - vertices set in anti-clockwise order
* when looking from the outsider.
* "RELATIVE" - first vertex is Pt0, second is Pt0+vt1,
* and the third vertex is Pt0+vt2,
* still in anti-clockwise order.
*/
G4TriangularFacet (const G4ThreeVector& Pt0, const G4ThreeVector& vt1,
const G4ThreeVector& vt2, G4FacetVertexType vType);
/**
* Destructor.
*/
~G4TriangularFacet () override;
/**
* Copy and move constructors.
*/
G4TriangularFacet (const G4TriangularFacet& right);
G4TriangularFacet ( G4TriangularFacet&& right) noexcept ;
/**
* Assignment and move assignment operators.
*/
G4TriangularFacet& operator=(const G4TriangularFacet& right);
G4TriangularFacet& operator=( G4TriangularFacet&& right) noexcept ;
/**
* Returns a pointer to a newly allocated duplicate copy of the facet.
*/
G4VFacet* GetClone () override;
/**
* Generates and returns an identical facet, but with the normal vector
* pointing at 180 degrees.
*/
G4TriangularFacet* GetFlippedFacet ();
/**
* Determines the vector between p and the closest point on the facet to p.
*/
G4ThreeVector Distance (const G4ThreeVector& p);
/**
* Determines the closest distance between point p and the facet.
*/
G4double Distance (const G4ThreeVector& p, G4double minDist) override;
/**
* Determines the distance to point 'p'. kInfinity is returned if either:
* (1) outgoing is TRUE and the dot product of the normal vector to the
* facet and the displacement vector from p to the triangle is negative.
* (2) outgoing is FALSE and the dot product of the normal vector to the
* facet and the displacement vector from p to the triangle is positive.
*/
G4double Distance (const G4ThreeVector& p, G4double minDist,
const G4bool outgoing) override;
G4double Extent (const G4ThreeVector axis) override;
/**
* Calculates the furthest the triangle extends in fA particular
* direction defined by the vector axis.
*/
G4double Extent (const G4ThreeVector axis) override;
/**
* Finds the next intersection when going from 'p' in the direction of 'v'.
* If 'outgoing' is true, only consider the face if we are going out
* through the face; otherwise, if false, only consider the face if we are
* going in through the face.
* @returns true if there is an intersection, false otherwise.
*/
G4bool Intersect (const G4ThreeVector& p, const G4ThreeVector& v,
const G4bool outgoing, G4double& distance,
G4double& distFromSurface,
G4ThreeVector& normal) override;
/**
* Auxiliary method for returning the surface area.
*/
G4double GetArea () const override;
/**
* Auxiliary method to get a uniform random point on the facet.
*/
G4ThreeVector GetPointOnFace () const override;
/**
* Returns/sets the normal vector to the facet.
*/
G4ThreeVector GetSurfaceNormal () const override;
void SetSurfaceNormal (const G4ThreeVector& normal);
/**
* Returns the type ID, "G4TriangularFacet" of the facet.
*/
G4GeometryType GetEntityType () const override;
/**
* Returns true if the facet is defined.
*/
inline G4bool IsDefined () const override;
inline G4int GetNumberOfVertices () const override;
inline G4ThreeVector GetVertex (G4int i) const override;
inline void SetVertex (G4int i, const G4ThreeVector& val) override;
inline G4ThreeVector GetCircumcentre () const override;
/**
* Returns the number of vertices, i.e. 3.
*/
inline G4int GetNumberOfVertices () const override;
/**
* Returns the vertex based on the index 'i'.
*/
inline G4ThreeVector GetVertex (G4int i) const override;
/**
* Methods to set the vertices.
*/
inline void SetVertex (G4int i, const G4ThreeVector& val) override;
inline void SetVertices(std::vector<G4ThreeVector>* v) override;
/**
* Returns the radius to the anchor point and centered on the circumcentre.
*/
inline G4double GetRadius () const override;
/**
* Returns the circumcentre point of the facet.
*/
inline G4ThreeVector GetCircumcentre () const override;
/**
* Returns the allocated memory (sizeof) by the facet.
*/
inline G4int AllocatedMemory() override;
/**
* Accessor/setter for the vertex index.
*/
inline G4int GetVertexIndex (G4int i) const override;
inline void SetVertexIndex (G4int i, G4int j) override;
inline void SetVertices(std::vector<G4ThreeVector>* v) override;
private:
/**
* Utilities for copying/moving data.
*/
void CopyFrom(const G4TriangularFacet& rhs);
void MoveFrom(G4TriangularFacet& rhs);
@@ -126,66 +238,9 @@ class G4TriangularFacet : public G4VFacet
};
// --------------------------------------------------------------------
// Inlined Methods
// Inline Methods
// --------------------------------------------------------------------
inline G4bool G4TriangularFacet::IsDefined () const
{
return fIsDefined;
}
inline G4int G4TriangularFacet::GetNumberOfVertices () const
{
return 3;
}
inline G4ThreeVector G4TriangularFacet::GetVertex (G4int i) const
{
G4int indice = fIndices[i];
return indice < 0 ? (*fVertices)[i] : (*fVertices)[indice];
}
inline void G4TriangularFacet::SetVertex (G4int i, const G4ThreeVector& val)
{
(*fVertices)[i] = val;
}
inline G4ThreeVector G4TriangularFacet::GetCircumcentre () const
{
return fCircumcentre;
}
inline G4double G4TriangularFacet::GetRadius () const
{
return fRadius;
}
inline G4int G4TriangularFacet::AllocatedMemory()
{
G4int size = sizeof(*this);
size += GetNumberOfVertices() * sizeof(G4ThreeVector);
return size;
}
inline G4int G4TriangularFacet::GetVertexIndex (G4int i) const
{
if (i < 3) return fIndices[i];
else return 999999999;
}
inline void G4TriangularFacet::SetVertexIndex (G4int i, G4int j)
{
fIndices[i] = j;
}
inline void G4TriangularFacet::SetVertices(std::vector<G4ThreeVector>* v)
{
if (fIndices[0] < 0 && (fVertices != nullptr))
{
delete fVertices;
fVertices = nullptr;
}
fVertices = v;
}
#include "G4TriangularFacet.icc"
#endif