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
@@ -27,10 +27,9 @@
//
// Class description:
//
// Declaration of a utility class of a polygon that can be
// clipped by a voxel.
// A utility class of a polygon that can be clipped by a voxel.
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998
// --------------------------------------------------------------------
#ifndef G4CLIPPABLEPOLYGON_HH
#define G4CLIPPABLEPOLYGON_HH
@@ -44,71 +43,125 @@
class G4AffineTransform;
class G4VoxelLimits;
/**
* @brief G4ClippablePolygon in a utility class defining a polygon
* that can be clipped by a voxel.
*/
class G4ClippablePolygon
{
using G4ThreeVectorList = std::vector<G4ThreeVector>;
public:
/**
* Default Constructor and Destructor.
*/
G4ClippablePolygon();
virtual ~G4ClippablePolygon();
// Constructor & virtual destructor.
~G4ClippablePolygon() = default;
virtual void AddVertexInOrder( const G4ThreeVector vertex );
virtual void ClearAllVertices();
/**
* Adds a vertex to collection.
*/
void AddVertexInOrder( const G4ThreeVector& vertex );
/**
* Clears the collection of vertices.
*/
void ClearAllVertices();
inline void SetNormal( const G4ThreeVector& newNormal );
/**
* Accessor and setter for normal vector.
*/
inline const G4ThreeVector GetNormal() const;
inline void SetNormal( const G4ThreeVector& newNormal );
virtual G4bool Clip( const G4VoxelLimits& voxelLimit );
/**
* Clips the polygon along the Cartesian axes, as specified in 'voxelLimit'.
* @returns true if the collection of vertices is not empty.
*/
G4bool Clip( const G4VoxelLimits& voxelLimit );
virtual G4bool PartialClip( const G4VoxelLimits& voxelLimit,
const EAxis IgnoreMe );
// Clip, while ignoring the indicated axis.
/**
* Clips the polygon while ignoring the indicated axis.
* @returns true if the collection of vertices is not empty.
*/
G4bool PartialClip( const G4VoxelLimits& voxelLimit,
const EAxis IgnoreMe );
virtual void ClipAlongOneAxis( const G4VoxelLimits& voxelLimit,
const EAxis axis );
// Clip along just one axis, as specified in voxelLimit.
/**
* Clips the polygon along just one axis, as specified in 'voxelLimit'.
*/
void ClipAlongOneAxis( const G4VoxelLimits& voxelLimit,
const EAxis axis );
virtual G4bool GetExtent( const EAxis axis,
G4double& min, G4double& max ) const;
/**
* Computes the polygon extent along the specified 'axis'.
* @param[in] axis The Cartesian axis along which computing the extent.
* @param[out] min The minimum extent value.
* @param[out] max The maximum extent value.
* @returns false if invalid polygon (no vertices).
*/
G4bool GetExtent( const EAxis axis,
G4double& min, G4double& max ) const;
virtual const G4ThreeVector* GetMinPoint( const EAxis axis ) const;
// Returns pointer to minimum point along the specified axis.
// Take care! Do not use pointer after destroying parent polygon.
virtual const G4ThreeVector* GetMaxPoint( const EAxis axis ) const;
// Returns pointer to maximum point along the specified axis.
// Take care! Do not use pointer after destroying parent polygon.
/**
* Returns a pointer to the minimum or maximum point along specified 'axis'.
* Take care! Do not use pointer after destroying parent polygon.
*/
const G4ThreeVector* GetMinPoint( const EAxis axis ) const;
const G4ThreeVector* GetMaxPoint( const EAxis axis ) const;
/**
* Returns the number of vertices in the polygon.
*/
inline std::size_t GetNumVertices() const;
/**
* Returns true if collection of vertices is empty.
*/
inline G4bool Empty() const;
virtual G4bool InFrontOf(const G4ClippablePolygon& other, EAxis axis) const;
// Decide if the polygon is in "front" of another when
// viewed along the specified axis. For our purposes here,
// it is sufficient to use the minimum extent of the
// polygon along the axis to determine this.
/**
* Decides if the polygon is in "front" of another when viewed along the
* specified 'axis'. For our purposes here, it is sufficient to use the
* minimum extent of the polygon along the axis to determine this.
*/
G4bool InFrontOf(const G4ClippablePolygon& other, EAxis axis) const;
virtual G4bool BehindOf(const G4ClippablePolygon& other, EAxis axis) const;
// Decide if this polygon is behind another.
// Remarks in method "InFrontOf" are valid here too.
/**
* Decides if this polygon is behind another.
* Remarks in previous method are valid here too.
*/
G4bool BehindOf(const G4ClippablePolygon& other, EAxis axis) const;
virtual G4bool GetPlanerExtent( const G4ThreeVector& pointOnPlane,
const G4ThreeVector& planeNormal,
G4double& min, G4double& max ) const;
// Get min/max distance in or out of a plane.
/**
* Gets min/max vertices distance in or out of a plane.
* @param[in] pointOnPlane The point on the plane.
* @param[in] planeNormal The normal vector to the plane.
* @param[out] min The minimum distance from the plane.
* @param[out] max The maximum distance from the plane.
* @returns false if invalid polygon (no vertices).
*/
G4bool GetPlanerExtent( const G4ThreeVector& pointOnPlane,
const G4ThreeVector& planeNormal,
G4double& min, G4double& max ) const;
protected:
private:
/**
* Clips 'pPolygon' according to 'pVoxelLimits', which must be only
* limited along one axis, and either the maximum along the axis must be
* +kInfinity, or the minimum -kInfinity.
* @param[in] pPolygon The polygon to clip.
* @param[out] outputPolygon The resulting clipped polygon.
* @param[in] pVoxelLimit The Cartesian limits.
*/
void ClipToSimpleLimits( G4ThreeVectorList& pPolygon,
G4ThreeVectorList& outputPolygon,
const G4VoxelLimits& pVoxelLimit );
// pVoxelLimits must be only limited along one axis, and either
// the maximum along the axis must be +kInfinity, or the minimum
// -kInfinity
const G4VoxelLimits& pVoxelLimit );
protected:
private:
G4ThreeVectorList vertices;
G4ThreeVector normal;
@@ -27,19 +27,18 @@
//
// Class description:
//
// A G4Ellipsoid is an ellipsoidal solid, optionally cut at a given z
//
// Member Data:
// A G4Ellipsoid is an ellipsoidal solid, optionally cut at a given z.
//
// Member Data:
// xSemiAxis semi-axis, X
// ySemiAxis semi-axis, Y
// zSemiAxis semi-axis, Z
// zBottomCut lower cut in Z (solid lies above this plane)
// zTopCut upper cut in Z (solid lies below this plane)
// 10.11.1999 G.Horton-Smith (Caltech, USA) - First implementation
// 10.02.2005 G.Guerrieri (INFN Genova, Italy) - Revision
// 15.12.2019 E.Tcherniaev - Complete revision
// Author: G.Horton-Smith (Caltech, USA), 10.11.1999 - First implementation
// G.Guerrieri (INFN Genova, Italy), 10.02.2005 - Revision
// E.Tcherniaev (CERN), 15.12.2019 - Complete revision
// --------------------------------------------------------------------
#ifndef G4ELLIPSOID_HH
#define G4ELLIPSOID_HH
@@ -60,20 +59,38 @@
#include "G4VSolid.hh"
#include "G4Polyhedron.hh"
/**
* @brief G4Ellipsoid is an ellipsoidal solid, optionally cut at a given Z.
*/
class G4Ellipsoid : public G4VSolid
{
public:
/**
* Constructs an ellipsoid, given its input parameters.
* @param[in] name The solid name.
* @param[in] xSemiAxis Semiaxis in X.
* @param[in] ySemiAxis Semiaxis in Y.
* @param[in] zSemiAxis Semiaxis in Z.
* @param[in] zBottomCut Optional lower cut plane level in Z.
* @param[in] zTopCut Optional upper cut plane level in Z.
*/
G4Ellipsoid(const G4String& name,
G4double xSemiAxis,
G4double ySemiAxis,
G4double zSemiAxis,
G4double zBottomCut = 0.,
G4double zTopCut = 0.);
G4double xSemiAxis,
G4double ySemiAxis,
G4double zSemiAxis,
G4double zBottomCut = 0.,
G4double zTopCut = 0.);
/**
* Destructor.
*/
~G4Ellipsoid() override;
// Accessors
/**
* Accessors.
*/
inline G4double GetDx() const;
inline G4double GetDy() const;
inline G4double GetDz() const;
@@ -81,21 +98,46 @@ class G4Ellipsoid : public G4VSolid
inline G4double GetZBottomCut() const;
inline G4double GetZTopCut() const;
// Modifiers
/**
* Modifiers.
*/
inline void SetSemiAxis (G4double x, G4double y, G4double z);
inline void SetZCuts (G4double newzBottomCut, G4double newzTopCut);
// Standard methods
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside(const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
G4double DistanceToIn(const G4ThreeVector& p,
@@ -108,55 +150,84 @@ class G4Ellipsoid : public G4VSolid
G4ThreeVector* n = nullptr) const override;
G4double DistanceToOut(const G4ThreeVector& p) const override;
/**
* Returns the type ID, "G4Ellipsoid" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
// Visualisation methods
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent() const override;
G4Polyhedron* CreatePolyhedron() const override;
G4Polyhedron* GetPolyhedron () const override;
G4Polyhedron* GetPolyhedron() const override;
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4Ellipsoid(__void__&);
// Copy constructorassignment operator
/**
* Copy constructor and assignment operator.
*/
G4Ellipsoid(const G4Ellipsoid& rhs);
// Assignment
G4Ellipsoid& operator=(const G4Ellipsoid& rhs);
private:
// Check parameters and set cached values
/**
* Checks parameters and sets cached values.
*/
void CheckParameters();
// Return normal to surface closest to p
/**
* Algorithm for SurfaceNormal() following the original specification
* for points not on the surface.
*/
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
// Calculate area of lateral surface
/**
* Calculates the area of lateral surface.
*/
G4double LateralSurfaceArea() const;
private:
// Ellipsoid parameters
/** Ellipsoid parameters. */
G4double fDx; // X semi-axis
G4double fDy; // Y semi-axis
G4double fDz; // Z semi-axis
G4double fZBottomCut; // Bottom cut in Z
G4double fZTopCut; // Top cut in Z
// Precalculated cached values
/** Precalculated cached values. */
G4double halfTolerance; // Surface tolerance
G4double fXmax; // X extent
G4double fYmax; // Y extent
@@ -60,10 +60,9 @@
// ySemiAxis = (Dy-dy)/(2*zTopCut)
// zheight = (Dx+dx)/(2*xSemiAxis)
// Author: Dionysios Anninos, 8.9.2005
// Revisions:
// Lukas Lindroos, Tatiana Nikitina, 20.08.2007
// Evgueni Tcherniaev, 20.07.2017
// Author: Dionysios Anninos (CERN), 08.09.2005 - Created
// Lukas Lindroos, Tatiana Nikitina (CERN), 20.08.2007 - Revised
// Evgueni Tcherniaev (CERN), 20.07.2017 - New revision
// --------------------------------------------------------------------
#ifndef G4ELLIPTICALCONE_HH
#define G4ELLIPTICALCONE_HH
@@ -84,19 +83,38 @@
#include "G4VSolid.hh"
#include "G4Polyhedron.hh"
/**
* @brief G4EllipticalCone is a full cone with elliptical base which
* can be cut in Z. The height in Z corresponds to where the elliptical
* cone hits the Z-axis if it had no Z cut.
*/
class G4EllipticalCone : public G4VSolid
{
public:
/**
* Constructs an elliptical cone, with cut in Z.
* @param[in] name The solid name.
* @param[in] pxSemiAxis Scalar value, defining the scaling along X-axis.
* @param[in] pySemiAxis Scalar value, defining the scaling along Y-axis.
* @param[in] zMax The Z-coordinate at the apex.
* @param[in] pzTopCut Upper cut plane level.
*/
G4EllipticalCone(const G4String& pName,
G4double pxSemiAxis,
G4double pySemiAxis,
G4double zMax,
G4double pzTopCut);
/**
* Destructor.
*/
~G4EllipticalCone() override;
// Access functions
/**
* Accessors.
*/
inline G4double GetSemiAxisMin () const;
inline G4double GetSemiAxisMax () const;
inline G4double GetSemiAxisX () const;
@@ -104,58 +122,97 @@ class G4EllipticalCone : public G4VSolid
inline G4double GetZMax() const;
inline G4double GetZTopCut() const;
// Modifiers
/**
* Modifiers.
*/
void SetSemiAxis (G4double x, G4double y, G4double z);
void SetZCut (G4double newzTopCut);
// Solid standard methods
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside(const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
G4double DistanceToIn(const G4ThreeVector& p,
const G4ThreeVector& v) const override;
G4double DistanceToIn(const G4ThreeVector& p) const override;
G4double DistanceToOut(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm = false,
G4bool* validNorm = nullptr,
G4ThreeVector* n = nullptr) const override;
G4double DistanceToOut(const G4ThreeVector& p) const override;
/**
* Returns the type ID, "G4EllipticalCone" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
// Visualisation functions
G4Polyhedron* GetPolyhedron () const override;
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
G4Polyhedron* GetPolyhedron() const override;
void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent() const override;
G4VisExtent GetExtent() const override;
G4Polyhedron* CreatePolyhedron() const override;
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4EllipticalCone(__void__&);
// Copy constructor and assignment operator
/**
* Copy constructor and assignment operator.
*/
G4EllipticalCone(const G4EllipticalCone& rhs);
G4EllipticalCone& operator=(const G4EllipticalCone& rhs);
@@ -166,8 +223,10 @@ class G4EllipticalCone : public G4VSolid
private:
// Algorithm for SurfaceNormal() following the original
// specification for points not on the surface
/**
* Algorithm for SurfaceNormal() following the original
* specification for points not on the surface.
*/
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
private:
@@ -27,18 +27,17 @@
//
// Class description:
//
// Declaration of a CSG volume representing a tube with elliptical
// cross section (geant3 solid 'ELTU'):
// A tube with elliptical cross section:
//
// G4EllipticalTube( const G4String& name,
// G4double Dx,
// G4double Dy,
// G4double Dz )
//
// The equation of the lateral surface : (x/dx)^2 + (y/dy)^2 = 1
// The equation of the lateral surface is: (x/dx)^2 + (y/dy)^2 = 1
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Revision: Evgueni Tcherniaev (evgueni.tcherniaev@cern.ch), 23.12.2019
// Author: David C. Williams (UCSC), 29.03.2000 - First implementation
// Evgueni Tcherniaev (CERN), 23.12.2019 - Revised
// --------------------------------------------------------------------
#ifndef G4ELLIPTICALTUBE_HH
#define G4ELLIPTICALTUBE_HH
@@ -57,92 +56,150 @@
#include "G4VSolid.hh"
#include "G4Polyhedron.hh"
/**
* @brief G4EllipticalTube is a tube with elliptical cross section.
* The equation of the lateral surface is: (x/dx)^2 + (y/dy)^2 = 1.
*/
class G4EllipticalTube : public G4VSolid
{
public:
/**
* Constructs an elliptical tube, given its parameters.
* @param[in] name The solid name.
* @param[in] Dx Half length of axis along X.
* @param[in] Dy Half length of axis along Y.
* @param[in] Dz Half length in Z.
*/
G4EllipticalTube( const G4String& name,
G4double Dx,
G4double Dy,
G4double Dz );
/**
* Destructor.
*/
~G4EllipticalTube() override;
// Standard methods
//
/**
* Accessors.
*/
inline G4double GetDx() const;
inline G4double GetDy() const;
inline G4double GetDz() const;
/**
* Modifiers.
*/
inline void SetDx( G4double Dx );
inline void SetDy( G4double Dy );
inline void SetDz( G4double Dz );
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside( const G4ThreeVector& p ) const override;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
G4double DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const override;
G4double DistanceToIn( const G4ThreeVector& p ) const override;
G4double DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm = false,
G4bool* validNorm = nullptr,
G4ThreeVector* n = nullptr ) const override;
G4double DistanceToOut( const G4ThreeVector& p ) const override;
/**
* Returns the type ID, "G4EllipticalTube" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
// Visualisation methods
//
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
G4Polyhedron* CreatePolyhedron() const override;
G4Polyhedron* GetPolyhedron () const override;
G4Polyhedron* GetPolyhedron() const override;
void DescribeYourselfTo( G4VGraphicsScene& scene ) const override;
G4VisExtent GetExtent() const override;
// Accessors
//
inline G4double GetDx() const;
inline G4double GetDy() const;
inline G4double GetDz() const;
// Modifiers
//
inline void SetDx( G4double Dx );
inline void SetDy( G4double Dy );
inline void SetDz( G4double Dz );
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4EllipticalTube(__void__&);
// Copy constructor and assignment operator
/**
* Copy constructor and assignment operator.
*/
G4EllipticalTube(const G4EllipticalTube& rhs);
G4EllipticalTube& operator=(const G4EllipticalTube& rhs);
private:
// Check parameters and set pre-calculated values
/**
* Checks parameters and sets pre-calculated values.
*/
void CheckParameters();
// Algorithm for SurfaceNormal() following the original
// specification for points not on the surface
/**
* Algorithm for SurfaceNormal() following the original
* specification for points not on the surface.
*/
G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
// Calculate surface area and cache it
/**
* Calculates the surface area and caches it.
*/
G4double GetCachedSurfaceArea() const;
private:
@@ -156,7 +213,7 @@ class G4EllipticalTube : public G4VSolid
G4double fCubicVolume = 0.0; // volume
G4double fSurfaceArea = 0.0; // surface area
// Cached pre-calculated values
/** Cached pre-calculated values. */
G4double fRsph; // R of bounding sphere
G4double fDDx; // Dx squared
G4double fDDy; // Dy squared
@@ -27,11 +27,11 @@
//
// Class description:
//
// Definition of a utility class for quickly deciding if a point
// is clearly outside a polyhedra or polycone or deciding if
// a trajectory is clearly going to miss those shapes.
// A utility class for quickly deciding if a point is clearly outside a
// polyhedra or polycone or deciding if a trajectory is clearly going to
// miss those shapes.
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - Created
// --------------------------------------------------------------------
#ifndef G4ENCLOSINGCYLINDER_HH
#define G4ENCLOSINGCYLINDER_HH
@@ -42,29 +42,52 @@
class G4ReduciblePolygon;
/**
* @brief G4EnclosingCylinder is a utility class defining an envelope for
* quickly deciding if a point is clearly outside a polyhedra or polycone or
* deciding if a trajectory is clearly going to miss those shapes.
*/
class G4EnclosingCylinder
{
public:
/**
* Constructs the envelope, given its parameters.
* @param[in] rz Pointer to the polygon structure.
* @param[in] phiIsOpen Boolean flag to indicate if it is a section in Phi.
* @param[in] startPhi Starting Phi angle.
* @param[in] totalPhi Total Phi angle of the section.
*/
G4EnclosingCylinder( const G4ReduciblePolygon* rz,
G4bool phiIsOpen,
G4double startPhi, G4double totalPhi );
/**
* Default Destructor.
*/
~G4EnclosingCylinder() = default;
/**
* Decides very rapidly if the point 'p' is outside the cylinder.
* @returns If not certain to be outside, return false.
*/
G4bool MustBeOutside( const G4ThreeVector& p ) const;
// Decide very rapidly if the point is outside the cylinder.
// If one is not certain, return false.
/**
* Decides very rapidly if the trajectory is going to miss the cylinder.
* @returns If not certain to miss, return false.
*/
G4bool ShouldMiss( const G4ThreeVector& p, const G4ThreeVector& v ) const;
// Decide very rapidly if the trajectory is going to miss the cylinder.
// If one is not sure, return false.
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4EnclosingCylinder(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
protected:
private:
G4double radius; // radius of our cylinder
G4double zLo, zHi; // z extent
@@ -45,9 +45,9 @@
// G4TwoVector off1 - offset of the side in -halfZ
// G4double scale1 - scale of the side in -halfZ
// G4TwoVector off2 - offset of the side in +halfZ
// G4double scale2 - scale of the side in -halfZ
// G4double scale2 - scale of the side in +halfZ
// Author: Ivana Hrivnacova, IPN Orsay
// Author: Ivana Hrivnacova (IPN, Orsay), 09.02.2007 - First implementation
// --------------------------------------------------------------------
#ifndef G4EXTRUDEDSOLID_HH
#define G4EXTRUDEDSOLID_HH
@@ -68,11 +68,20 @@
#include "G4TwoVector.hh"
#include "G4TessellatedSolid.hh"
/**
* @brief G4ExtrudedSolid is a is a solid which represents the extrusion
* of an arbitrary polygon with fixed outline in the defined Z sections.
* The z-sides of the solid are the scaled versions of the same polygon.
* The solid is implemented as a specification of a G4TessellatedSolid.
*/
class G4ExtrudedSolid : public G4TessellatedSolid
{
public:
/**
* Structure defining a Z section composing the solid.
*/
struct ZSection
{
ZSection() : fZ(0.), fOffset(0.,0.), fScale(1.) {}
@@ -84,11 +93,30 @@ class G4ExtrudedSolid : public G4TessellatedSolid
G4double fScale;
};
/**
* General constructor for an extruded polygon, through contour and polyline.
* @param[in] pName The solid name.
* @param[in] polygon The 2D polygonal contour, i.e. the vertices of the
* outlined polygon defined in clock-wise order.
* @param[in] zsections The 3D polyline with scale factors, i.e. the
* Z-sections defined by Z position in increasing order.
*/
G4ExtrudedSolid( const G4String& pName,
const std::vector<G4TwoVector>& polygon,
const std::vector<ZSection>& zsections);
// General constructor
/**
* Special constructor for an extruded polygon with 2 Z-sections.
* @param[in] pName The solid name.
* @param[in] polygon The 2D polygonal contour, i.e. the vertices of the
* outlined polygon defined in clock-wise order.
* @param[in] halfZ Half length in Z, i.e. the distance from the origin
* to the sections.
* @param[in] off1 (X, Y) position of the first polygon in -halfZ.
* @param[in] scale1 Scale factor at -halfZ.
* @param[in] off2 (X, Y) position of the second polygon in +halfZ.
* @param[in] scale2 Scale factor at +halfZ.
*/
G4ExtrudedSolid( const G4String& pName,
const std::vector<G4TwoVector>& polygon,
G4double halfZ,
@@ -96,23 +124,26 @@ class G4ExtrudedSolid : public G4TessellatedSolid
G4double scale1 = 1.,
const G4TwoVector& off2 = G4TwoVector(0.,0.),
G4double scale2 = 1. );
// Special constructor for solid with 2 z-sections
~G4ExtrudedSolid() override;
// Destructor
// Accessors
/**
* Default Destructor.
*/
~G4ExtrudedSolid() override = default;
/**
* Accessors.
*/
inline G4int GetNofVertices() const;
inline G4TwoVector GetVertex(G4int index) const;
inline std::vector<G4TwoVector> GetPolygon() const;
inline G4int GetNofZSections() const;
inline ZSection GetZSection(G4int index) const;
inline std::vector<ZSection> GetZSections() const;
// Solid methods
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside(const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
G4double DistanceToIn(const G4ThreeVector& p,
@@ -125,59 +156,163 @@ class G4ExtrudedSolid : public G4TessellatedSolid
G4ThreeVector* n = nullptr) const override;
G4double DistanceToOut(const G4ThreeVector& p) const override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Returns the type ID, "G4ExtrudedSolid" of the solid.
*/
G4GeometryType GetEntityType () const override;
/**
* Returns true as the solid has only planar faces.
*/
G4bool IsFaceted () const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4ExtrudedSolid(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4ExtrudedSolid(const G4ExtrudedSolid& rhs);
/**
* Copy constructor and assignment operator.
*/
G4ExtrudedSolid(const G4ExtrudedSolid& rhs) = default;
G4ExtrudedSolid& operator=(const G4ExtrudedSolid& rhs);
// Copy constructor and assignment operator.
private:
void ComputeProjectionParameters();
void ComputeLateralPlanes();
inline G4bool PointInPolygon(const G4ThreeVector& p) const;
inline G4double DistanceToPolygonSqr(const G4ThreeVector& p) const;
/**
* Algorithm for SurfaceNormal() following the original
* specification for points not on the surface.
*/
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
/**
* Computes parameters for point projections p(z)
* to the polygon scale & offset.
*/
void ComputeProjectionParameters();
/**
* Computes the lateral planes: a*x + b*y + c*z + d = 0.
*/
void ComputeLateralPlanes();
/**
* Returns if point 'p' is within the polygon.
*/
inline G4bool PointInPolygon(const G4ThreeVector& p) const;
/**
* Returns the square distance of point 'p' from the polygon.
*/
inline G4double DistanceToPolygonSqr(const G4ThreeVector& p) const;
/**
* Returns the vertex coordinates, given the indeces for the
* polygons and Z sections.
* @param[in] iz Index for the Z section.
* @param[in] ind Index for the polygon.
* @returns The shifted and scaled coordinates of the vertex.
*/
G4ThreeVector GetVertex(G4int iz, G4int ind) const;
/**
* Returns the projected point of 'p' in the polygon scale.
*/
G4TwoVector ProjectPoint(const G4ThreeVector& point) const;
/**
* Returns true if 'p' is on the line through 'l1', 'l2'.
*/
G4bool IsSameLine(const G4TwoVector& p,
const G4TwoVector& l1,
const G4TwoVector& l2) const;
/**
* Returns true if 'p' is on the line through 'l1', 'l2'
* and lies between 'l1' and 'l2'.
*/
G4bool IsSameLineSegment(const G4TwoVector& p,
const G4TwoVector& l1,
const G4TwoVector& l2) const;
/**
* Returns true if 'p1' and 'p2' are on the same side of the line
* through 'l1', 'l2'.
*/
G4bool IsSameSide(const G4TwoVector& p1,
const G4TwoVector& p2,
const G4TwoVector& l1,
const G4TwoVector& l2) const;
/**
* Returns true if 'p' is inside of triangle abc or on its edges.
*/
G4bool IsPointInside(const G4TwoVector& a,
const G4TwoVector& b,
const G4TwoVector& c,
const G4TwoVector& p) const;
/**
* Returns the angle of the vertex in 'p0'.
*/
G4double GetAngle(const G4TwoVector& p0,
const G4TwoVector& pa,
const G4TwoVector& pb) const;
/**
* Returns a pointer to a triangular facet from the polygon points
* given by indices forming the down side ( the normal goes in -z).
*/
G4VFacet* MakeDownFacet(G4int ind1, G4int ind2, G4int ind3) const;
/**
* Returns a pointer to a triangular facet from the polygon points
* given by indices forming the upper side ( z>0 ).
*/
G4VFacet* MakeUpFacet(G4int ind1, G4int ind2, G4int ind3) const;
/**
* Decomposes polygonal sides in triangular facets.
* @returns false if failing to define a facet.
*/
G4bool AddGeneralPolygonFacets();
/**
* Generates the tessellated structure of the solid creating the
* triangular or quadrangular facets from the vertices.
* @returns false if failing to define a facet.
*/
G4bool MakeFacets();
private:
@@ -77,13 +77,13 @@ inline
G4bool G4ExtrudedSolid::PointInPolygon(const G4ThreeVector& p) const
{
G4bool in = false;
G4int icur = (fPolygon[fNv-1].y() > p.y()), iprev = 0;
G4int icur = static_cast<G4int>(fPolygon[fNv-1].y() > p.y()), iprev = 0;
for (std::size_t i = 0; i < fNv; ++i)
{
iprev = icur;
if ((icur = (fPolygon[i].y() > p.y())) != iprev)
if ((icur = static_cast<G4int>(fPolygon[i].y() > p.y())) != iprev)
{
in ^= (p.y()*fLines[i].k + fLines[i].m < p.x());
in ^= static_cast<int>(p.y()*fLines[i].k + fLines[i].m < p.x());
}
}
return in;
@@ -101,20 +101,20 @@ G4double G4ExtrudedSolid::DistanceToPolygonSqr(const G4ThreeVector& p) const
if (u < 0)
{
G4double tmp = ix*ix + iy*iy;
if (tmp < dd) dd = tmp;
if (tmp < dd) { dd = tmp; }
}
else if (u > fLengths[i])
{
G4double kx = p.x() - fPolygon[k].x();
G4double ky = p.y() - fPolygon[k].y();
G4double tmp = kx*kx + ky*ky;
if (tmp < dd) dd = tmp;
if (tmp < dd) { dd = tmp; }
}
else
{
G4double tmp = fPlanes[i].a*p.x() + fPlanes[i].b*p.y() + fPlanes[i].d;
tmp *= tmp;
if (tmp < dd) dd = tmp;
if (tmp < dd) { dd = tmp; }
}
}
return dd;
@@ -27,19 +27,17 @@
//
// Class description:
//
// Class implementing a GenericPolycone constructed by points with
// (r,z)coordinates, allows Z 'go back'
//
// Implementing a GenericPolycone constructed by points with (r,z)
// coordinates and allowing Z 'go back'.
//
// G4GenericPolycone( const G4String& name,
// G4double phiStart, // initial phi starting angle
// G4double phiTotal, // total phi angle
// G4int numRZ, // number corners in r,z space
// const G4double r[], // r coordinate of these corners
// const G4double z[]) // z coordinate of these corners
//
// G4double phiStart, // initial phi starting angle
// G4double phiTotal, // total phi angle
// G4int numRZ, // number corners in r,z space
// const G4double r[], // r coordinate of these corners
// const G4double z[]) // z coordinate of these corners
// Authors: T.Nikitina, G.Cosmo - CERN
// Authors: T.Nikitina, G.Cosmo (CERN), 29.10.2013 - Created
// --------------------------------------------------------------------
#ifndef G4GENERICPOLYCONE_HH
#define G4GENERICPOLYCONE_HH
@@ -62,47 +60,40 @@ class G4EnclosingCylinder;
class G4ReduciblePolygon;
class G4VCSGface;
/**
* @brief G4GenericPolycone is a Polycone shape where the composing Z planes
* positions, in their order of definition, may not be monotically increasing,
* i.e. may also decrease.
*/
class G4GenericPolycone : public G4VCSGfaceted
{
public:
/**
* Constructs a generic polycone shape, given its parameters.
* @param[in] name The solid name.
* @param[in] phiStart The initial Phi starting angle.
* @param[in] phiTotal The total Phi angle.
* @param[in] numRZ Number of corners in r,Z space.
* @param[in] r Vector of r coordinate of corners.
* @param[in] z Vector of Z coordinate of corners.
*/
G4GenericPolycone( const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
G4int numRZ, // number corners in r,z space
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
G4double phiStart,
G4double phiTotal,
G4int numRZ,
const G4double r[],
const G4double z[] );
/**
* Destructor.
*/
~G4GenericPolycone() override;
EInside Inside( const G4ThreeVector &p ) const override;
G4double DistanceToIn( const G4ThreeVector &p,
const G4ThreeVector &v ) const override;
G4double DistanceToIn( const G4ThreeVector &p ) const override;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
G4ThreeVector GetPointOnSurface() const override;
G4GeometryType GetEntityType() const override;
G4VSolid* Clone() const override;
std::ostream& StreamInfo(std::ostream& os) const override;
G4Polyhedron* CreatePolyhedron() const override;
G4bool Reset();
// Accessors
/**
* Accessors.
*/
inline G4double GetStartPhi() const;
inline G4double GetEndPhi() const;
inline G4double GetSinStartPhi() const;
@@ -113,33 +104,97 @@ class G4GenericPolycone : public G4VCSGfaceted
inline G4int GetNumRZCorner() const;
inline G4PolyconeSideRZ GetCorner(G4int index) const;
G4GenericPolycone(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside( const G4ThreeVector &p ) const override;
G4double DistanceToIn( const G4ThreeVector &p,
const G4ThreeVector &v ) const override;
G4double DistanceToIn( const G4ThreeVector &p ) const override;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
/**
* Returns the type ID, "G4GenericPolycone" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Returns a pointer to a polyhedron for use in visualisation.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Does nothing. Reset of parameters (for use in divisions) is not
* allowed for a generic polycone. Issues a warning and just returns true.
*/
G4bool Reset();
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4GenericPolycone(__void__&);
/**
* Copy constructor and assignment operator.
*/
G4GenericPolycone( const G4GenericPolycone& source );
G4GenericPolycone& operator=( const G4GenericPolycone& source );
// Copy constructor and assignment operator.
protected:
// Generic initializer, called by all constructors
private:
/**
* Generic initializer, called by constructor.
*/
void Create( G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
G4ReduciblePolygon* rz ); // r/z coordinate of these corners
/**
* Utility for copying contents, used in copy constructor and assignment
* operator.
*/
void CopyStuff( const G4GenericPolycone& source );
// Methods for random point generation
/**
* Auxiliary method for sampling random points on surface.
* Sets the vector of surface elements.
*/
void SetSurfaceElements() const;
protected:
// Here are our parameters
private:
/** Original parameters. */
G4double startPhi; // Starting phi value (0 < phiStart < 2pi)
G4double endPhi; // end phi value (0 < endPhi-phiStart < 2pi)
G4bool phiIsOpen = false; // true if there is a phi segment
@@ -39,7 +39,7 @@
// o last four points: vertices[i], i>=4
// are the vertices sitting on the +halfZ plane.
//
// The order of defining the vertices of the solid is the following:
// The order of defining the vertices of the solid is the following:
// - point 0 is connected with points 1,3,4
// - point 1 is connected with points 0,2,5
// - point 2 is connected with points 1,3,6
@@ -48,14 +48,11 @@
// - point 5 is connected with points 1,4,6
// - point 6 is connected with points 2,5,7
// - point 7 is connected with points 3,4,6
// Points can be identical in order to create shapes with less than
// 8 vertices.
// Points can be identical in order to create shapes with less than 8 vertices.
// Adapted from Arb8 implementation in Root/TGeo.
// 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
// Authors: T.Nikitina (CERN) & I.Hrivnacova (IPN, Orsay), 27.05.2010 - Created
// Evgueni Tcherniaev (CERN), 27.05.2024 - Complete revision, speed up
// -------------------------------------------------------------------
#ifndef G4GENERICTRAP_HH
#define G4GENERICTRAP_HH
@@ -77,27 +74,46 @@
#include "G4TwoVector.hh"
#include "G4VSolid.hh"
/**
* @brief G4GenericTrap is a solid which represents an arbitrary trapezoid with
* up to 8 vertices standing on two parallel planes perpendicular to the Z axis.
* Points can be identical in order to create shapes with less than 8 vertices.
*/
class G4GenericTrap : public G4VSolid
{
public:
// Constructor
/**
* Constructs an generic trapezoid, given its vertices.
* @param[in] name The solid name.
* @param[in] halfZ Half length in Z.
* @param[in] vertices The (x,y) coordinates of the vertices.
*/
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.
/**
* 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
/**
* Copy constructor and assignment operator.
*/
G4GenericTrap(const G4GenericTrap& rhs);
G4GenericTrap& operator=(const G4GenericTrap& rhs);
// Destructor
~G4GenericTrap() override;
/**
* Default Destructor.
*/
~G4GenericTrap() override = default;
// Accessors
/**
* Accessors and modifiers.
*/
inline G4double GetZHalfLength() const;
inline G4int GetNofVertices() const;
inline G4TwoVector GetVertex(G4int index) const;
@@ -107,7 +123,10 @@ class G4GenericTrap : public G4VSolid
inline G4int GetVisSubdivisions() const;
inline void SetVisSubdivisions(G4int subdiv);
// Solid methods
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside(const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
G4double DistanceToIn(const G4ThreeVector& p,
@@ -119,41 +138,109 @@ class G4GenericTrap : public G4VSolid
G4bool* validNorm = nullptr,
G4ThreeVector* n = nullptr) const override;
G4double DistanceToOut(const G4ThreeVector& p) const override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Returns the type ID, "G4GenericTrap" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Returns true if the solid has only planar faces; false if twisted.
*/
G4bool IsFaceted () const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override ;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
// Visualisation functions
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent() const override;
G4Polyhedron* CreatePolyhedron() const override;
G4Polyhedron* GetPolyhedron () const override;
G4Polyhedron* GetPolyhedron() const override;
private:
// Internal methods
void CheckParameters(G4double halfZ, const std::vector<G4TwoVector>& vertices);
void ComputeLateralSurfaces();
void ComputeBoundingBox();
void ComputeScratchLength();
G4double GetLateralFaceArea(G4int iface) const;
/**
* Algorithm for SurfaceNormal() following the original
* specification for points not on the surface.
*/
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
/**
* Checks the parameters of the solid and issues exception if leading
* to an invalid construct.
*/
void CheckParameters(G4double halfZ, const std::vector<G4TwoVector>& vertices);
/**
* Computes surface equations and twist angles of lateral faces.
*/
void ComputeLateralSurfaces();
/**
* Sets the bounding box.
*/
void ComputeBoundingBox();
/**
* Sets the max length of a scratch.
*/
void ComputeScratchLength();
/**
* Computes the lateral face area, given the face index.
* Used for random sampling of points on surface.
*/
G4double GetLateralFaceArea(G4int iface) const;
/**
* Logger methods for issuing warnings.
*/
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,
@@ -167,7 +254,7 @@ class G4GenericTrap : public G4VSolid
private:
struct G4GenericTrapPlane // Ax + By + Cz + D = 0
struct G4GenericTrapPlane // Ax + By + Cz + D = 0
{
G4double A = 0.;
G4double B = 0.;
@@ -198,6 +285,7 @@ class G4GenericTrap : public G4VSolid
G4int fVisSubdivisions = 0;
G4GenericTrapPlane fPlane[8];
G4GenericTrapSurface fSurf[4];
G4double f4k[4] = {0.}; // Lipschitz constants * 4
mutable G4double fArea[4] = {0.};
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr;
+132 -59
View File
@@ -27,22 +27,18 @@
//
// Class description:
//
// This class implements a tube with hyperbolic profile.
//
// It describes an hyperbolic volume with curved sides parallel to
// the z-axis. The solid has a specified half-length along the z axis,
// about which it is centered, and a given minimum and maximum radius.
// A minimum radius of 0 signifies a filled Hype (with hyperbolical
// inner surface). To have a filled Hype the user must specify
// inner radius = 0 AND inner stereo angle = 0.
//
// The inner and outer hyperbolical surfaces can have different
// stereo angles. A stereo angle of 0 gives a cylindrical surface.
// This class implements a tube with hyperbolic profile.
// It describes an hyperbolic volume with curved sides parallel to
// the z-axis. The solid has a specified half-length along the z axis,
// about which it is centered, and a given minimum and maximum radius.
// A minimum radius of 0 signifies a filled Hype (with hyperbolical
// inner surface). To have a filled Hype the user must specify
// inner radius = 0 AND inner stereo angle = 0.
// The inner and outer hyperbolical surfaces can have different
// stereo angles. A stereo angle of 0 gives a cylindrical surface.
// Authors:
// Ernesto Lamanna (Ernesto.Lamanna@roma1.infn.it) &
// Francesco Safai Tehrani (Francesco.SafaiTehrani@roma1.infn.it)
// Rome, INFN & University of Rome "La Sapienza", 9 June 1998.
// Authors: Ernesto Lamanna & Francesco Safai Tehrani - Created
// Rome, INFN & University of Rome "La Sapienza", 09.06.1998.
// --------------------------------------------------------------------
#ifndef G4HYPE_HH
#define G4HYPE_HH
@@ -65,46 +61,92 @@
class G4SolidExtentList;
class G4ClippablePolygon;
/**
* @brief G4Hype is a tube with hyperbolic profile; it describes an hyperbolic
* volume with curved sides parallel to the Z axis. The solid has a specified
* half-length along the Z axis, about which it is centered, and a given
* minimum and maximum radii.
*/
class G4Hype : public G4VSolid
{
public:
/**
* Constructs a hyperbolic tube, given its parameters.
* @param[in] pName The solid name.
* @param[in] newInnerRadius Inner radius.
* @param[in] newOuterRadius Outer radius.
* @param[in] newInnerStereo Inner stereo angle in radians.
* @param[in] newOuterStereo Outer stereo angle in radians.
* @param[in] newHalfLenZ Half length in Z.
*/
G4Hype(const G4String& pName,
G4double newInnerRadius,
G4double newOuterRadius,
G4double newInnerStereo,
G4double newOuterStereo,
G4double newHalfLenZ);
G4double newInnerRadius,
G4double newOuterRadius,
G4double newInnerStereo,
G4double newOuterStereo,
G4double newHalfLenZ);
/**
* Destructor.
*/
~G4Hype() override;
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Accessors.
*/
inline G4double GetInnerRadius () const;
inline G4double GetOuterRadius () const;
inline G4double GetZHalfLength () const;
inline G4double GetInnerStereo () const;
inline G4double GetOuterStereo () const;
/**
* Modifiers.
*/
void SetInnerRadius (G4double newIRad);
void SetOuterRadius (G4double newORad);
void SetZHalfLength (G4double newHLZ);
void SetInnerStereo (G4double newISte);
void SetOuterStereo (G4double newOSte);
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside(const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
G4double DistanceToIn(const G4ThreeVector& p,
const G4ThreeVector& v) const override;
G4double DistanceToIn(const G4ThreeVector& p) const override;
@@ -114,51 +156,86 @@ class G4Hype : public G4VSolid
G4ThreeVector* n = nullptr) const override;
G4double DistanceToOut(const G4ThreeVector& p) const override;
/**
* Returns the type ID, "G4Hype" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent () const override;
G4Polyhedron* CreatePolyhedron () const override;
G4Polyhedron* GetPolyhedron () const override;
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent() const override;
G4Polyhedron* CreatePolyhedron() const override;
G4Polyhedron* GetPolyhedron() const override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4Hype(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Copy constructor and assignment operator.
*/
G4Hype(const G4Hype& rhs);
G4Hype& operator=(const G4Hype& rhs);
// Copy constructor and assignment operator.
protected:
private:
/**
* Tells whether we have an inner surface or not.
*/
inline G4bool InnerSurfaceExists() const;
// whether we have an inner surface or not
static G4double ApproxDistOutside( G4double pr, G4double pz,
G4double r0, G4double tanPhi );
static G4double ApproxDistInside( G4double pr, G4double pz,
G4double r0, G4double tan2Phi );
// approximate isotropic distance to hyperbolic surface
/**
* Returns the approximate isotropic distance to the hyperbolic surface.
*/
G4double ApproxDistOutside( G4double pr, G4double pz,
G4double r0, G4double tanPhi ) const;
G4double ApproxDistInside( G4double pr, G4double pz,
G4double r0, G4double tan2Phi ) const;
/**
* Returns the values of the hype radii at a given Z.
*/
inline G4double HypeInnerRadius2(G4double zVal) const;
inline G4double HypeOuterRadius2(G4double zVal) const;
// values of hype radius at a given Z
static G4int IntersectHype( const G4ThreeVector &p, const G4ThreeVector &v,
G4double r2, G4double tan2Phi, G4double s[2] );
// intersection with hyperbolic surface
/**
* Decides if and where a line intersects with a hyperbolic surface
* (of infinite extent).
* @returns The number of intersections. If 0, the trajectory misses.
*/
G4int IntersectHype( const G4ThreeVector& p, const G4ThreeVector& v,
G4double r2, G4double tan2Phi, G4double s[2] ) const;
protected:
private:
G4double innerRadius;
G4double outerRadius;
@@ -166,8 +243,7 @@ class G4Hype : public G4VSolid
G4double innerStereo;
G4double outerStereo;
// precalculated parameters, squared quantities
/** Precalculated parameters, squared quantities. */
G4double tanInnerStereo; // tan of Inner Stereo angle
G4double tanOuterStereo; // tan of Outer Stereo angle
G4double tanInnerStereo2; // squared tan of Inner Stereo angle
@@ -179,12 +255,9 @@ class G4Hype : public G4VSolid
G4double endInnerRadius; // endcap Inner Radius
G4double endOuterRadius; // endcap Outer Radius
// Used by distanceToOut
/** Used by DistanceToOut(). */
enum ESide { outerFace, innerFace, leftCap, rightCap };
private:
G4double fCubicVolume = 0.0;
G4double fSurfaceArea = 0.0;
G4double fInnerSurfaceArea = 0.0;
@@ -27,10 +27,10 @@
//
// Class description:
//
// Utility class which calculates the intersection
// of an arbitrary line with a fixed cone
// Utility class which calculates the intersection
// of an arbitrary line with a fixed cone.
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - Created
// --------------------------------------------------------------------
#ifndef G4INTERSECTINGCONE_HH
#define G4INTERSECTINGCONE_HH
@@ -39,44 +39,75 @@
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
/**
* @brief G4IntersectingCone is a utility class used to calculate the
* intersection of an arbitrary line with a fixed cone.
*/
class G4IntersectingCone
{
public:
/**
* Constructor given r,z values.
* @param[in] r r values.
* @param[in] z Z values.
*/
G4IntersectingCone( const G4double r[2], const G4double z[2] );
virtual ~G4IntersectingCone();
/**
* Default Destructor.
*/
~G4IntersectingCone() = default;
/**
* Calculates the intersection of a line with the conical surface,
* ignoring any Phi division.
*/
G4int LineHitsCone( const G4ThreeVector& p, const G4ThreeVector& v,
G4double* s1, G4double* s2 );
/**
* Checks r or z extent, as appropriate, to see if the point is
* possibly on the cone.
*/
G4bool HitOn( const G4double r, const G4double z );
/**
* Accessors for R and Z bounds of side.
*/
inline G4double RLo() const { return rLo; }
inline G4double RHi() const { return rHi; }
inline G4double ZLo() const { return zLo; }
inline G4double ZHi() const { return zHi; }
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4IntersectingCone(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
private:
protected:
G4double zLo, zHi, // Z bounds of side
rLo, rHi; // R bounds of side
G4bool type1 = false; // True if cone is type 1
// (std::fabs(z1-z2)>std::fabs(r1-r2))
G4double A, B; // Cone radius parameter:
// type 1: r = A + B*z
// type 2: z = A + B*r
/**
* Calculating the intersection of a line with the conical surface.
* Internal methods used by LineHitsCone().
*/
G4int LineHitsCone1( const G4ThreeVector& p, const G4ThreeVector& v,
G4double* s1, G4double* s2 );
G4int LineHitsCone2( const G4ThreeVector& p, const G4ThreeVector& v,
G4double* s1, G4double* s2 );
private:
/** Z, R bounds of side. */
G4double zLo, zHi, rLo, rHi;
/** True if cone is type 1. */
G4bool type1 = false; // (std::fabs(z1-z2)>std::fabs(r1-r2))
/** Cone radius parameters - type 1: r = A + B*z; type 2: z = A + B*r. */
G4double A, B;
};
#endif
@@ -27,23 +27,22 @@
//
// Class description:
//
// A G4Paraboloid represents a solid with parabolic profile with possible
// cuts along the Z axis.
//
// Member Data:
// A G4Paraboloid represents a solid with parabolic profile with possible
// cuts along the Z axis.
//
// Member Data:
// dz z half lenght
// r1 radius at -dz
// r2 radius at dz
// r2 > r1
//
// Equation for the solid:
// rho^2 <= k1 * z + k2;
// -dz <= z <= dz
// r1^2 = k1 * (-dz) + k2
// r2^2 = k1 * ( dz) + k2
// Equation for the solid:
// rho^2 <= k1 * z + k2;
// -dz <= z <= dz
// r1^2 = k1 * (-dz) + k2
// r2^2 = k1 * ( dz) + k2
// 10.07.2007, L.Lindroos (CERN) - First implementation
// Author: Lukas Lindroos (CERN), 10.07.2007 - First implementation
// --------------------------------------------------------------------
#ifndef G4PARABOLOID_HH
#define G4PARABOLOID_HH
@@ -64,33 +63,72 @@
#include "G4VSolid.hh"
#include "G4Polyhedron.hh"
/**
* @brief G4Paraboloid represents a solid with parabolic profile
* with possible cuts along the Z axis.
*/
class G4Paraboloid : public G4VSolid
{
public:
/**
* Constructs a paraboloid, given its parameters.
* @param[in] pName The solid name.
* @param[in] pDz Half length in Z.
* @param[in] pR1 Radius at -Dz.
* @param[in] pR2 Radius at +Dz greater than pR1.
*/
G4Paraboloid(const G4String& pName,
G4double pDz,
G4double pR1,
G4double pR2);
G4double pDz,
G4double pR1,
G4double pR2);
/**
* Destructor.
*/
~G4Paraboloid() override;
// Access functions
/**
* Accessors.
*/
inline G4double GetZHalfLength() const;
inline G4double GetRadiusMinusZ() const;
inline G4double GetRadiusPlusZ() const;
// Modifiers functions
/**
* Modifiers.
*/
void SetZHalfLength(G4double dz);
void SetRadiusMinusZ(G4double R1);
void SetRadiusPlusZ(G4double R2);
// Solid standard methods
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside(const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override;
G4double DistanceToIn(const G4ThreeVector& p,
@@ -103,35 +141,64 @@ class G4Paraboloid : public G4VSolid
G4ThreeVector* n = nullptr) const override;
G4double DistanceToOut(const G4ThreeVector& p) const override;
/**
* Returns the type ID, "G4Paraboloid" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
// Visualisation functions
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
G4Polyhedron* CreatePolyhedron() const override;
G4Polyhedron* GetPolyhedron () const override;
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4Paraboloid(__void__&);
// Copy constructor and assignment operator.
/**
* Copy constructor and assignment operator.
*/
G4Paraboloid(const G4Paraboloid& rhs);
G4Paraboloid& operator=(const G4Paraboloid& rhs);
private:
/**
* Utility method to cache the computation of the solid's surface area.
*/
G4double CalculateSurfaceArea() const;
private:
G4double fSurfaceArea = 0.0;
G4double fCubicVolume = 0.0;
@@ -27,20 +27,20 @@
//
// Class description:
//
// Definition of a face that bounds a polycone or polyhedra when
// it has a phi opening:
// Definition of a face that bounds a polycone or polyhedra when
// it has a phi opening:
//
// G4PolyPhiFace( const G4ReduciblePolygon* rz,
// G4double phi,
// G4double deltaPhi,
// G4double phiOther )
//
// Specifically: a face that lies on a plane that passes through
// the z axis. It has boundaries that are straight lines of arbitrary
// length and direction, but with corners aways on the same side of
// the z axis.
// Specifically: a face that lies on a plane that passes through
// the z axis. It has boundaries that are straight lines of arbitrary
// length and direction, but with corners aways on the same side of
// the z axis.
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998
// --------------------------------------------------------------------
#ifndef G4POLYPHIFACE_HH
#define G4POLYPHIFACE_HH 1
@@ -72,138 +72,257 @@ struct G4PolyPhiFaceEdge
G4ThreeVector norm3D; // 3D edge normal vector
};
/**
* @brief G4PolyPhiFace is a face that bounds a polycone or polyhedra when
* it has a phi opening. Specifically, it is a face that lies on a plane that
* passes through the Z axis, having boundaries that are straight lines of
* arbitrary length and direction, but with corners aways on the same side of
* the Z axis.
*/
class G4PolyPhiFace : public G4VCSGface
{
public:
/**
* Constructor where points r,z should be supplied in clockwise order
* in r,z.
* For example:
* [1]---------[2] ^ R
* | | |
* | | +--> z
* [0]---------[3]
* @param[in] rz Pointer to previous r,Z section.
* @param[in] phi Initial Phi starting angle.
* @param[in] deltaPhi Total Phi angle.
* @param[in] phiOther Phi angle of next section.
*/
G4PolyPhiFace( const G4ReduciblePolygon* rz,
G4double phi, G4double deltaPhi, G4double phiOther );
// Constructor.
// Points r,z should be supplied in clockwise order in r,z.
// For example:
// [1]---------[2] ^ R
// | | |
// | | +--> z
// [0]---------[3]
/**
* Destructor. Removes edges and corners.
*/
~G4PolyPhiFace() override;
// Destructor. Removes edges and corners.
G4PolyPhiFace( const G4PolyPhiFace &source );
G4PolyPhiFace& operator=( const G4PolyPhiFace &source );
// Copy constructor and assgnment operator.
/**
* Copy constructor and assignment operator.
*/
G4PolyPhiFace( const G4PolyPhiFace& source );
G4PolyPhiFace& operator=( const G4PolyPhiFace& source );
/**
* Determines the distance along a line to the face.
* @param[in] p Position.
* @param[in] v Direction (assumed to be a unit vector).
* @param[in] outgoing Flag true, to consider only inside surfaces;
* false, to consider only outside surfaces.
* @param[in] surfTolerance Minimum distance from the surface.
* @param[out] distance Distance to intersection.
* @param[out] distFromSurface Distance from surface (along surface normal),
* < 0 if the point is in front of the surface.
* @param[out] normal Normal of surface at intersection point.
* @param[out] allBehind Flag, true, if entire surface is behind normal.
* @returns true if there is an intersection, false otherwise.
*/
G4bool Intersect( const G4ThreeVector& p, const G4ThreeVector& v,
G4bool outgoing, G4double surfTolerance,
G4double& distance, G4double& distFromSurface,
G4ThreeVector& normal, G4bool& allBehind ) override;
/**
* Determines the distance of a point from either the inside or outside
* surfaces of the face.
* @param[in] p Position.
* @param[in] outgoing Flag, true, to consider only inside surfaces
* or false, to consider only outside surfaces.
* @returns The distance to the closest surface satisfying requirements
* or kInfinity if no such surface exists.
*/
G4double Distance( const G4ThreeVector& p, G4bool outgoing ) override;
/**
* Determines whether a point is inside, outside, or on the surface of
* the face.
* @param[in] p Position.
* @param[in] tolerance Tolerance defining the bounds of the "kSurface",
* nominally equal to kCarTolerance/2.
* @param[out] bestDistance Distance to the closest surface (in or out).
* @returns kInside if the point is closest to the inside surface;
* kOutside if the point is closest to the outside surface;
* kSurface if the point is withing tolerance of the surface.
*/
EInside Inside( const G4ThreeVector& p, G4double tolerance,
G4double* bestDistance ) override;
/**
* Returns the normal of surface closest to the point.
* @param[in] p Position.
* @param[out] bestDistance Distance to the closest surface (in or out).
* @returns The normal of the surface nearest the point.
*/
G4ThreeVector Normal( const G4ThreeVector& p,
G4double* bestDistance ) override;
/**
* Returns the face extent along the axis.
* @param[in] axis Unit vector defining the direction.
* @returns The largest point along the given axis of the face's extent.
*/
G4double Extent( const G4ThreeVector axis ) override;
/**
* Calculates the extent of the face for the voxel navigator.
* @param[in] axis The axis in which to check the shapes 3D extent against.
* @param[in] voxelLimit Limits along x, y, and/or z axes.
* @param[in] tranform A coordinate transformation on which to apply to
* the shape before testing.
* @param[out] extentList The list of (voxel) extents along the axis.
*/
void CalculateExtent( const EAxis axis,
const G4VoxelLimits &voxelLimit,
const G4AffineTransform& tranform,
G4SolidExtentList& extentList ) override;
/**
* Method invoked by the copy constructor or the assignment operator.
* Its purpose is to return a pointer to a duplicate copy of the face.
*/
inline G4VCSGface* Clone() override;
// Allocates on the heap a clone of this face.
/**
* Returning an estimation of the face surface area, in internal units.
*/
G4double SurfaceArea() override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4PolyPhiFace(__void__&);
/**
* Throws an exception if something is found inconsistent with the solid.
* For debugging purposes only.
*/
void Diagnose( G4VSolid* solid );
private:
/**
* Calculates the surface area of a triangle.
* At the same time a random point in the triangle is given.
*/
G4double SurfaceTriangle( const G4ThreeVector& p1, const G4ThreeVector& p2,
const G4ThreeVector& p3, G4ThreeVector* p4);
/**
* Auxiliary method for GetPointOnSurface().
*/
G4ThreeVector GetPointOnFace() override;
// Auxiliary methods for determination of points on surface.
G4PolyPhiFace(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
void Diagnose( G4VSolid* solid );
// Throw an exception if something is found inconsistent with
// the solid. For debugging purposes only
protected:
/**
* Decides if the point in r,z is inside the edges of a face,
* **but** do so consistently with other faces.
*/
G4bool InsideEdgesExact( G4double r, G4double z, G4double normSign,
const G4ThreeVector& p, const G4ThreeVector& v );
// Decide if the point in r,z is inside the edges of our face,
// **but** do so consistently with other faces.
/**
* Methods to decide if the point in r,z is inside the edges of a face.
*/
G4bool InsideEdges( G4double r, G4double z );
G4bool InsideEdges( G4double r, G4double z, G4double* distRZ2,
G4PolyPhiFaceVertex** base3Dnorm = nullptr,
G4ThreeVector** head3Dnorm = nullptr );
// Decide if the point in r,z is inside the edges of our face.
/**
* Decides precisely whether a trajectory passes to the left, right,
* or exactly passes through the Z position of a vertex point in face.
*/
inline G4double ExactZOrder( G4double z,
G4double qx, G4double qy, G4double qz,
const G4ThreeVector& v,
G4double normSign,
const G4PolyPhiFaceVertex* vert ) const;
// Decide precisely whether a trajectory passes to the left, right,
// or exactly passes through the z position of a vertex point in face.
/**
* Copies parameters from other object; used in copy constructor and
* assignment operator.
*/
void CopyStuff( const G4PolyPhiFace& source );
// Functions used for Triangulation in Case of generic Polygone.
// The triangulation is used for GetPointOnFace()
/**
* Calculates of 2*Area of Triangle with Sign.
*/
G4double Area2( const G4TwoVector& a, const G4TwoVector& b, const G4TwoVector& c);
// Calculation of 2*Area of Triangle with Sign
/**
* Boolean functions for sign of Surface.
*/
G4bool Left( const G4TwoVector& a, const G4TwoVector& b, const G4TwoVector& c );
G4bool LeftOn( const G4TwoVector& a, const G4TwoVector& b, const G4TwoVector& c );
G4bool Collinear( const G4TwoVector& a, const G4TwoVector& b, const G4TwoVector& c );
// Boolean functions for sign of Surface
/**
* Boolean function for finding proper intersection of two
* line segments (a,b) and (c,d).
*/
G4bool IntersectProp( const G4TwoVector& a, const G4TwoVector& b,
const G4TwoVector& c, const G4TwoVector& d );
// Boolean function for finding proper intersection of two
// line segments (a,b) and (c,d).
/**
* Boolean function for determining if point c is between a and b
* where the three points (a,b,c) are on the same line.
*/
G4bool Between( const G4TwoVector& a, const G4TwoVector& b, const G4TwoVector& c );
// Boolean function for determining if point c is between a and b
// where the three points (a,b,c) are on the same line.
/**
* Boolean function for finding proper intersection or not
* of two line segments (a,b) and (c,d).
*/
G4bool Intersect( const G4TwoVector& a, const G4TwoVector& b,
const G4TwoVector& c, const G4TwoVector& d );
// Boolean function for finding proper intersection or not
// of two line segments (a,b) and (c,d).
/**
* Boolean Diagonalie help to determine if diagonal s
* of segment (a,b) is convex or reflex.
*/
G4bool Diagonalie( G4PolyPhiFaceVertex* a, G4PolyPhiFaceVertex* b );
// Boolean Diagonalie help to determine if diagonal s
// of segment (a,b) is convex or reflex.
/**
* Boolean function for determining if b is inside the cone (a0,a,a1)
* where a is the center of the cone.
*/
G4bool InCone( G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b );
// Boolean function for determining if b is inside the cone (a0,a,a1)
// where a is the center of the cone.
/**
* Boolean function for determining if Diagonal is possible
* inside Polycone or PolyHedra.
*/
G4bool Diagonal( G4PolyPhiFaceVertex* a, G4PolyPhiFaceVertex* b );
// Boolean function for determining if Diagonal is possible
// inside Polycone or PolyHedra.
/**
* Initialisation for Triangulisation by ear tips.
* For details see "Computational Geometry in C" by Joseph O'Rourke.
*/
void EarInit();
// Initialisation for Triangulisation by ear tips.
// For details see "Computational Geometry in C" by Joseph O'Rourke.
/**
* Triangularisation by ear tips for Polycone or Polyhedra.
* For details see "Computational Geometry in C" by Joseph O'Rourke.
* NOTE: a copy of the shape is made and this copy is reordered in
* order to have a list of triangles. This list is used by the
* method GetPointOnFace().
*/
void Triangulate();
// Triangularisation by ear tips for Polycone or Polyhedra.
// For details see "Computational Geometry in C" by Joseph O'Rourke.
// NOTE: a copy of the shape is made and this copy is reordered in
// order to have a list of triangles. This list is used by the
// method GetPointOnFace().
protected:
private:
G4int numEdges = 0; // Number of edges
G4PolyPhiFaceEdge* edges = nullptr; // The edges of the face
@@ -219,9 +338,10 @@ class G4PolyPhiFace : public G4VCSGface
// is behind the place of this face
G4double kCarTolerance; // Surface thickness
G4double fSurfaceArea = 0.0; // Surface Area of PolyPhiFace
/** Auxiliary pointer to 'corners' used for triangulation.
Copy structure, changing the structure of 'corners' (ear removal). */
G4PolyPhiFaceVertex* triangles = nullptr;
// Auxiliary pointer to 'corners' used for triangulation.
// Copy structure, changing the structure of 'corners' (ear removal)
};
#include "G4PolyPhiFace.icc"
@@ -27,8 +27,8 @@
//
// Class description:
//
// Class implementing a CSG-like type "PCON" Geant 3.21 volume,
// inherited from class G4VCSGfaceted:
// Class implementing a CSG-like type "PCON" Geant 3.21 volume,
// inherited from class G4VCSGfaceted:
//
// G4Polycone( const G4String& name,
// G4double phiStart, // initial phi starting angle
@@ -38,16 +38,16 @@
// const G4double rInner[], // tangent distance to inner surface
// const G4double rOuter[]) // tangent distance to outer surface
//
// Alternative constructor, but limited to increasing-only Z sections:
// Alternative constructor:
//
// G4Polycone( const G4String& name,
// G4double phiStart, // initial phi starting angle
// G4double phiTotal, // total phi angle
// G4int numRZ, // number corners in r,z space
// const G4double r[], // r coordinate of these corners
// const G4double z[]) // z coordinate of these corners
// G4int numRZ, // number corners in r,z space
// const G4double r[], // r coordinates of these corners
// const G4double z[]) // z coordinates of these corners
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - Created
// --------------------------------------------------------------------
#ifndef G4POLYCONE_HH
#define G4POLYCONE_HH
@@ -72,10 +72,26 @@ class G4EnclosingCylinder;
class G4ReduciblePolygon;
class G4VCSGface;
/**
* @brief G4Polycone represents a composed closed shape (PCON) made of
* cones and cylinders, along the Z axis with increasing Z, with or without
* cut in Phi.
*/
class G4Polycone : public G4VCSGfaceted
{
public:
/**
* Constructs a polycone shape, given its parameters.
* @param[in] name The solid name.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] phiTotal Total Phi angle.
* @param[in] numZPlanes Number of Z planes.
* @param[in] zPlane Position of Z planes, with Z in increasing order.
* @param[in] rInner Tangent distance to inner surface.
* @param[in] rOuter Tangent distance to outer surface.
*/
G4Polycone( const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
@@ -84,47 +100,30 @@ class G4Polycone : public G4VCSGfaceted
const G4double rInner[], // tangent distance to inner surface
const G4double rOuter[] ); // tangent distance to outer surface
/**
* Alternative constructor of a polycone shape, given corners coordinates.
* @param[in] name The solid name.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] phiTotal Total Phi angle.
* @param[in] numRZ Number of corners in r,Z space.
* @param[in] r r coordinates of corners.
* @param[in] z Z coordinates of corners.
*/
G4Polycone( const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
G4int numRZ, // number corners in r,z space
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
G4int numRZ, // number corners in r,z space
const G4double r[], // r coordinates of these corners
const G4double z[] ); // z coordinates of these corners
/**
* Destructor.
*/
~G4Polycone() override;
EInside Inside( const G4ThreeVector& p ) const override;
G4double DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const override;
G4double DistanceToIn( const G4ThreeVector& p ) const override;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
G4ThreeVector GetPointOnSurface() const override;
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep ) override;
G4GeometryType GetEntityType() const override;
G4VSolid* Clone() const override;
std::ostream& StreamInfo(std::ostream& os) const override;
G4Polyhedron* CreatePolyhedron() const override;
G4bool Reset();
// Accessors
/**
* Accessors.
*/
inline G4double GetStartPhi() const;
inline G4double GetEndPhi() const;
inline G4double GetSinStartPhi() const;
@@ -132,40 +131,133 @@ class G4Polycone : public G4VCSGfaceted
inline G4double GetSinEndPhi() const;
inline G4double GetCosEndPhi() const;
inline G4bool IsOpen() const;
inline G4int GetNumRZCorner() const;
inline G4int GetNumRZCorner() const;
inline G4PolyconeSideRZ GetCorner(G4int index) const;
/**
* Gets and sets the original parameters of the solid.
*/
inline G4PolyconeHistorical* GetOriginalParameters() const;
inline void SetOriginalParameters(G4PolyconeHistorical* pars);
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in G4VSolid. Remaining functions are concretely
* defined in the base class G4VCSGfaceted.
*/
EInside Inside( const G4ThreeVector& p ) const override;
G4double DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const override;
G4double DistanceToIn( const G4ThreeVector& p ) const override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep ) override;
/**
* Returns the type ID, "G4Polycone" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Returns a pointer to a generated polyhedron used for visualisation.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Clears all parameters and rebuild the shape, for use in divisions.
*/
G4bool Reset();
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4Polycone(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Copy constructor and assignment operator.
*/
G4Polycone( const G4Polycone& source );
G4Polycone &operator=( const G4Polycone& source );
// Copy constructor and assignment operator.
G4Polycone& operator=( const G4Polycone& source );
protected:
// Generic initializer, called by all constructors
private:
/**
* Generic initializer, called by all constructors.
*/
G4bool SetOriginalParameters(G4ReduciblePolygon* rz);
void Create( G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
G4ReduciblePolygon* rz ); // r/z coordinate of these corners
/**
* Copy parameters from other solid; used in copy constructor and
* assignment operator.
*/
void CopyStuff( const G4Polycone& source );
// Methods for random point generation
/**
* Sets the vector of surface elements. Auxiliary method used for
* sampling random points on surface.
*/
void SetSurfaceElements() const;
protected:
// Here are our parameters
private:
/** The original parameters. */
G4double startPhi; // Starting phi value (0 < phiStart < 2pi)
G4double endPhi; // End phi value (0 < endPhi-phiStart < 2pi)
G4bool phiIsOpen = false; // True if there is a phi segment
@@ -90,8 +90,10 @@ inline
void G4Polycone::SetOriginalParameters(G4PolyconeHistorical* pars)
{
if (pars == nullptr)
{
G4Exception("G4Polycone::SetOriginalParameters()", "GeomSolids0002",
FatalException, "NULL pointer to parameters!");
}
*original_parameters = *pars;
fCubicVolume = 0.;
fRebuildPolyhedron = true;
@@ -29,18 +29,22 @@
//
// Data structure for G4Polycone
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - Created
// --------------------------------------------------------------------
#ifndef G4POLYCONEHISTORICAL_HH
#define G4POLYCONEHISTORICAL_HH
#include "G4Types.hh"
/**
* @brief G4PolyconeHistorical is a data structure for use in G4Polycone.
*/
class G4PolyconeHistorical
{
public:
G4PolyconeHistorical();
G4PolyconeHistorical() = default;
G4PolyconeHistorical( G4int z_planes );
~G4PolyconeHistorical();
G4PolyconeHistorical( const G4PolyconeHistorical& source );
@@ -27,20 +27,18 @@
//
// Class description:
//
// Class implmenting a face that represents one conical side
// of a polycone:
// Class implementing a face that represents one conical side of a polycone:
//
// G4PolyconeSide( const G4PolyconeSideRZ *prevRZ,
// const G4PolyconeSideRZ *tail,
// const G4PolyconeSideRZ *head,
// const G4PolyconeSideRZ *nextRZ,
// G4PolyconeSide( const G4PolyconeSideRZ* prevRZ,
// const G4PolyconeSideRZ* tail,
// const G4PolyconeSideRZ* head,
// const G4PolyconeSideRZ* nextRZ,
// G4double phiStart, G4double deltaPhi,
// G4bool phiIsOpen, G4bool isAllBehind=false )
//
// Values for r1,z1 and r2,z2 should be specified in clockwise
// order in (r,z).
// Values for r1,z1 and r2,z2 should be specified in clockwise order in (r,z).
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - Created
// --------------------------------------------------------------------
#ifndef G4POLYCONESIDE_HH
#define G4POLYCONESIDE_HH
@@ -84,81 +82,210 @@ using G4PlSideManager = G4GeomSplitter<G4PlSideData>;
//
// ----------------------------------------------------------------------------
/**
* @brief G4PolyconeSide is a utility class implementing a face that
* represents one conical side of a polycone.
*/
class G4PolyconeSide : public G4VCSGface
{
public:
/**
* Constructor for the conical side of a polycone.
* @param[in] prevRZ Pointer to previous r,Z section.
* @param[in] tail Pointer to r,Z tail of section.
* @param[in] head Pointer to r,Z head of section.
* @param[in] nextRZ Pointer to next r,Z section.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] deltaPhi Total Phi angle.
* @param[in] phiIsOpen Flag indicating if it is a Phi section.
* @param[in] isAllBehind Indicating if entire surface is behind normal.
*/
G4PolyconeSide( const G4PolyconeSideRZ* prevRZ,
const G4PolyconeSideRZ* tail,
const G4PolyconeSideRZ* head,
const G4PolyconeSideRZ* nextRZ,
G4double phiStart, G4double deltaPhi,
G4bool phiIsOpen, G4bool isAllBehind = false );
/**
* Destructor.
*/
~G4PolyconeSide() override;
/**
* Copy constructor and assignment operator.
*/
G4PolyconeSide( const G4PolyconeSide& source );
G4PolyconeSide& operator=( const G4PolyconeSide& source );
/**
* Determines the distance along a line to the face.
* @param[in] p Position.
* @param[in] v Direction (assumed to be a unit vector).
* @param[in] outgoing Flag true, to consider only inside surfaces;
* false, to consider only outside surfaces.
* @param[in] surfTolerance Minimum distance from the surface.
* @param[out] distance Distance to intersection.
* @param[out] distFromSurface Distance from surface (along surface normal),
* < 0 if the point is in front of the surface.
* @param[out] normal Normal of surface at intersection point.
* @param[out] allBehind Flag, true, if entire surface is behind normal.
* @returns true if there is an intersection, false otherwise.
*/
G4bool Intersect(const G4ThreeVector& p, const G4ThreeVector& v,
G4bool outgoing, G4double surfTolerance,
G4double& distance, G4double &distFromSurface,
G4ThreeVector& normal, G4bool& isAllBehind) override;
/**
* Determines the distance of a point from either the inside or outside
* surfaces of the face.
* @param[in] p Position.
* @param[in] outgoing Flag, true, to consider only inside surfaces
* or false, to consider only outside surfaces.
* @returns The distance to the closest surface satisfying requirements
* or kInfinity if no such surface exists.
*/
G4double Distance( const G4ThreeVector& p, G4bool outgoing ) override;
/**
* Determines whether a point is inside, outside, or on the surface of
* the face.
* @param[in] p Position.
* @param[in] tolerance Tolerance defining the bounds of the "kSurface",
* nominally equal to kCarTolerance/2.
* @param[out] bestDistance Distance to the closest surface (in or out).
* @returns kInside if the point is closest to the inside surface;
* kOutside if the point is closest to the outside surface;
* kSurface if the point is withing tolerance of the surface.
*/
EInside Inside( const G4ThreeVector& p, G4double tolerance,
G4double* bestDistance ) override;
/**
* Returns the normal of surface closest to the point.
* @param[in] p Position.
* @param[out] bestDistance Distance to the closest surface (in or out).
* @returns The normal of the surface nearest the point.
*/
G4ThreeVector Normal( const G4ThreeVector& p,
G4double* bestDistance ) override;
/**
* Returns the face extent along the axis.
* @param[in] axis Unit vector defining the direction.
* @returns The largest point along the given axis of the face's extent.
*/
G4double Extent( const G4ThreeVector axis ) override;
/**
* Calculates the extent of the face for the voxel navigator.
* @param[in] axis The axis in which to check the shapes 3D extent against.
* @param[in] voxelLimit Limits along x, y, and/or z axes.
* @param[in] tranform A coordinate transformation on which to apply to
* the shape before testing.
* @param[out] extentList The list of (voxel) extents along the axis.
*/
void CalculateExtent( const EAxis axis,
const G4VoxelLimits& voxelLimit,
const G4AffineTransform& tranform,
G4SolidExtentList& extentList ) override;
G4VCSGface* Clone() override { return new G4PolyconeSide( *this ); }
/**
* Method invoked by the copy constructor or the assignment operator.
* Its purpose is to return a pointer to a duplicate copy of the face.
*/
inline G4VCSGface* Clone() override { return new G4PolyconeSide( *this ); }
/**
* Returning an estimation of the face surface area, in internal units.
*/
G4double SurfaceArea() override;
/**
* Returns a random point located and uniformly distributed on the face.
*/
G4ThreeVector GetPointOnFace() override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4PolyconeSide(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Returns the instance ID.
*/
inline G4int GetInstanceID() const { return instanceID; }
// Returns the instance ID.
/**
* Returns the private data instance manager.
*/
static const G4PlSideManager& GetSubInstanceManager();
// Returns the private data instance manager.
protected:
private:
/**
* Calculates the distance of a point from the conical surface, including
* the effect of any phi segmentation.
* @param[in] p The point to check.
* @param[in] opposite If true, check the opposite hemisphere (see below).
* @param[out] distOutside Additional distance outside the edges of surface.
* @param[out] rzNorm If negative, the point is inside.
* @returns The distance from the conical plane, if extrapolated beyond
* edges, signed by whether the point is in inside or outside
* the shape.
*/
G4double DistanceAway( const G4ThreeVector& p, G4bool opposite,
G4double& distOutside2,
G4double& distOutside,
G4double* rzNorm = nullptr );
G4double DistanceAway( const G4ThreeVector& p, G4double& distOutside2,
/**
* Special version of DistanceAway() for Inside. Opposite parameter is not
* used, instead use sign of rx for choosing the side.
* @param[in] p The point to check.
* @param[out] distOutside Additional distance outside the edges of surface.
* @param[out] edgeRZnorm If negative, the point is inside.
* @returns The distance from the conical plane.
*/
G4double DistanceAway( const G4ThreeVector& p, G4double& distOutside,
G4double* edgeRZnorm );
/**
* Decides if a point is on a cone and returns the 'normal' if it is.
* @returns true if the point is on the cone.
*/
G4bool PointOnCone( const G4ThreeVector& hit, G4double normSign,
const G4ThreeVector& p,
const G4ThreeVector& v, G4ThreeVector& normal );
/**
* Copies parameters from other object; used in copy constructor and
* assignment operator.
*/
void CopyStuff( const G4PolyconeSide& source );
/**
* Decides the point at which two 2-dimensional lines intersect.
* It is assumed that the lines are *not* parallel.
*/
static void FindLineIntersect( G4double x1, G4double y1,
G4double tx1, G4double ty1,
G4double x2, G4double y2,
G4double tx2, G4double ty2,
G4double& x, G4double& y );
/**
* Calculates Phi for a given 3-vector (point 'p'), if not already cached
* for the same point, in the attempt to avoid consecutive computation of
* the same quantity.
*/
G4double GetPhi( const G4ThreeVector& p );
protected:
private:
G4double r[2], z[2]; // r, z parameters, in specified order
G4double startPhi, // Start phi (0 to 2pi), if phiIsOpen
@@ -182,7 +309,6 @@ class G4PolyconeSide : public G4VCSGface
G4int ncorners = 0;
G4ThreeVector* corners = nullptr; // The coordinates of the corners
// (if phiIsOpen)
private:
G4double kCarTolerance; // Geometrical surface thickness
G4double fSurfaceArea = 0.0; // Used for surface calculation
@@ -27,8 +27,8 @@
//
// Class description:
//
// Class implementing a CSG-like type "PGON" Geant 3.21 volume,
// inherited from class G4VCSGfaceted:
// Class implementing a CSG-like type "PGON" Geant 3.21 volume,
// inherited from class G4VCSGfaceted:
//
// G4Polyhedra( const G4String& name,
// G4double phiStart, - initial phi starting angle
@@ -44,10 +44,10 @@
// G4double phiTotal, - total phi angle
// G4int numSide, - number sides
// G4int numRZ, - number corners in r,z space
// const G4double r[], - r coordinate of these corners
// const G4double z[] ) - z coordinate of these corners
// const G4double r[], - r coordinates of these corners
// const G4double z[] ) - z coordinates of these corners
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - First implementation
// --------------------------------------------------------------------
#ifndef G4POLYHEDRA_HH
#define G4POLYHEDRA_HH
@@ -71,10 +71,26 @@
class G4EnclosingCylinder;
class G4ReduciblePolygon;
/**
* @brief G4Polyhedra represents a composed closed polyhedra (PGON) made of
* planar sizes along the Z axis, with or without cut in Phi.
*/
class G4Polyhedra : public G4VCSGfaceted
{
public:
/**
* Constructs a polyhedra, given its parameters.
* @param[in] name The solid name.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] phiTotal Total Phi angle.
* @param[in] numSide Number of sides.
* @param[in] numZPlanes Number of Z planes.
* @param[in] zPlane Position of Z planes.
* @param[in] rInner Tangent distance to inner surface.
* @param[in] rOuter Tangent distance to outer surface.
*/
G4Polyhedra(const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
@@ -84,50 +100,32 @@ class G4Polyhedra : public G4VCSGfaceted
const G4double rInner[], // tangent distance to inner surface
const G4double rOuter[] ); // tangent distance to outer surface
/**
* Alternative constructor of a polyhedra, given corners coordinates.
* @param[in] name The solid name.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] phiTotal Total Phi angle.
* @param[in] numSide Number of sides.
* @param[in] numRZ Number of corners in r,Z space.
* @param[in] r r coordinates of corners.
* @param[in] z Z coordinates of corners.
*/
G4Polyhedra(const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
G4int numSide, // number sides
G4int numRZ, // number corners in r,z space
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
const G4double r[], // r coordinates of these corners
const G4double z[] ); // z coordinates of these corners
/**
* Destructor.
*/
~G4Polyhedra() override;
EInside Inside( const G4ThreeVector& p ) const override;
G4double DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const override;
G4double DistanceToIn( const G4ThreeVector& p ) const override;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
G4GeometryType GetEntityType() const override;
G4bool IsFaceted () const override;
G4VSolid* Clone() const override;
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
G4ThreeVector GetPointOnSurface() const override;
std::ostream& StreamInfo( std::ostream& os ) const override;
G4Polyhedron* CreatePolyhedron() const override;
G4bool Reset();
// Accessors
/**
* Accessors.
*/
inline G4int GetNumSide() const;
inline G4double GetStartPhi() const;
inline G4double GetEndPhi() const;
@@ -140,42 +138,145 @@ class G4Polyhedra : public G4VCSGfaceted
inline G4int GetNumRZCorner() const;
inline G4PolyhedraSideRZ GetCorner( const G4int index ) const;
/**
* Returns internal scaled parameters.
*/
inline G4PolyhedraHistorical* GetOriginalParameters() const;
// Returns internal scaled parameters.
/**
* Sets internal parameters. Parameters 'Rmin' and 'Rmax' in input must
* be scaled first by a factor computed as 'cos(0.5*phiTotal/theNumSide)',
* if not already scaled.
*/
inline void SetOriginalParameters(G4PolyhedraHistorical* pars);
// Sets internal parameters. Parameters 'Rmin' and 'Rmax' in input must
// be scaled first by a factor computed as 'cos(0.5*phiTotal/theNumSide)',
// if not already scaled.
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in G4VSolid. Remaining functions are concretely
* defined in the base class G4VCSGfaceted.
*/
EInside Inside( const G4ThreeVector& p ) const override;
G4double DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const override;
G4double DistanceToIn( const G4ThreeVector& p ) const override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
/**
* Returns the type ID, "G4Polyhedra" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Returns true as the solid has only planar faces.
*/
G4bool IsFaceted () const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo( std::ostream& os ) const override;
/**
* Returns a pointer to a generated polyhedron used for visualisation.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Clears all parameters and rebuild the shape, for use in divisions.
*/
G4bool Reset();
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4Polyhedra(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Copy constructor and assignment operator.
*/
G4Polyhedra( const G4Polyhedra& source );
G4Polyhedra& operator=( const G4Polyhedra& source );
// Copy constructor and assignment operator.
protected:
private:
/**
* Sets internal parameters for the generic constructor.
*/
void SetOriginalParameters(G4ReduciblePolygon* rz);
// Sets internal parameters for the generic constructor.
/**
* Generates the shape and is called by each constructor,
* after the conversion of the arguments.
*/
void Create( G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
G4int numSide, // number sides
G4ReduciblePolygon* rz ); // rz coordinates
// Generates the shape and is called by each constructor, after the
// conversion of the arguments
/**
* Copy parameters from other solid or reset them.
* Used in copy constructor and assignment operator.
*/
void CopyStuff( const G4Polyhedra& source );
void DeleteStuff();
// Methods for generation of random points on surface
/**
* Sets the vector of surface elements. Auxiliary method used for
* sampling random points on surface.
*/
void SetSurfaceElements() const;
protected:
private:
G4int numSide = 0; // Number of sides
G4double startPhi; // Starting phi value (0 < phiStart < 2pi)
@@ -27,20 +27,24 @@
//
// Class description:
//
// Data structure for G4Polyhedra
// Data structure for G4Polyhedra.
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - Created
// --------------------------------------------------------------------
#ifndef G4POLYHEDRAHISTORICAL_HH
#define G4POLYHEDRAHISTORICAL_HH
#include "G4Types.hh"
/**
* @brief G4PolyhedraHistorical is a data structure for use in G4Polyhedra.
*/
class G4PolyhedraHistorical
{
public:
G4PolyhedraHistorical();
G4PolyhedraHistorical() = default;
G4PolyhedraHistorical( G4int z_planes );
~G4PolyhedraHistorical();
G4PolyhedraHistorical( const G4PolyhedraHistorical &source );
@@ -27,8 +27,7 @@
//
// Class description:
//
// Class implementing a face that represents one segmented side
// of a polyhedra:
// Class implementing a face that represents one segmented side of a polyhedra:
//
// G4PolyhedraSide( const G4PolyhedraSideRZ* prevRZ,
// const G4PolyhedraSideRZ* tail,
@@ -36,16 +35,14 @@
// const G4PolyhedraSideRZ* nextRZ,
// G4int numSide,
// G4double phiStart, G4double phiTotal,
// G4bool phiIsOpen, G4bool isAllBehind = false )
// G4bool phiIsOpen, G4bool isAllBehind=false )
//
// Values for r1,z1 and r2,z2 should be specified in clockwise
// order in (r,z).
// Values for r1,z1 and r2,z2 should be specified in clockwise order in (r,z).
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - Created
// --------------------------------------------------------------------
#ifndef G4PolyhedraSide_hh
#define G4PolyhedraSide_hh
#ifndef G4POLYHEDRASIDE_HH
#define G4POLYHEDRASIDE_HH
#include "G4VCSGface.hh"
@@ -85,11 +82,28 @@ using G4PhSideManager = G4GeomSplitter<G4PhSideData>;
//
// ----------------------------------------------------------------------------
/**
* @brief G4PolyhedraSide is a utility class implementing a face that
* represents one segmented side of a polyhedra.
*/
class G4PolyhedraSide : public G4VCSGface
{
public:
/**
* Constructor for the segmented side of a polyhedra.
* @param[in] prevRZ Pointer to previous r,Z section.
* @param[in] tail Pointer to r,Z tail of section.
* @param[in] head Pointer to r,Z head of section.
* @param[in] nextRZ Pointer to next r,Z section.
* @param[in] numSide The number od sides.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] phiTotal Total Phi angle.
* @param[in] phiIsOpen Flag indicating if it is a Phi section.
* @param[in] isAllBehind Indicating if entire surface is behind normal.
*/
G4PolyhedraSide( const G4PolyhedraSideRZ* prevRZ,
const G4PolyhedraSideRZ* tail,
const G4PolyhedraSideRZ* head,
@@ -97,59 +111,124 @@ class G4PolyhedraSide : public G4VCSGface
G4int numSide,
G4double phiStart, G4double phiTotal,
G4bool phiIsOpen, G4bool isAllBehind = false );
/**
* Destructor.
*/
~G4PolyhedraSide() override;
/**
* Copy constructor and assignment operator.
*/
G4PolyhedraSide( const G4PolyhedraSide& source );
G4PolyhedraSide& operator=( const G4PolyhedraSide& source );
/**
* Determines the distance along a line to the face.
* @param[in] p Position.
* @param[in] v Direction (assumed to be a unit vector).
* @param[in] outgoing Flag true, to consider only inside surfaces;
* false, to consider only outside surfaces.
* @param[in] surfTolerance Minimum distance from the surface.
* @param[out] distance Distance to intersection.
* @param[out] distFromSurface Distance from surface (along surface normal),
* < 0 if the point is in front of the surface.
* @param[out] normal Normal of surface at intersection point.
* @param[out] allBehind Flag, true, if entire surface is behind normal.
* @returns true if there is an intersection, false otherwise.
*/
G4bool Intersect( const G4ThreeVector& p, const G4ThreeVector& v,
G4bool outgoing, G4double surfTolerance,
G4double& distance, G4double& distFromSurface,
G4ThreeVector& normal, G4bool& allBehind ) override;
/**
* Determines the distance of a point from either the inside or outside
* surfaces of the face.
* @param[in] p Position.
* @param[in] outgoing Flag, true, to consider only inside surfaces
* or false, to consider only outside surfaces.
* @returns The distance to the closest surface satisfying requirements
* or kInfinity if no such surface exists.
*/
G4double Distance( const G4ThreeVector& p, G4bool outgoing ) override;
/**
* Determines whether a point is inside, outside, or on the surface of
* the face.
* @param[in] p Position.
* @param[in] tolerance Tolerance defining the bounds of the "kSurface",
* nominally equal to kCarTolerance/2.
* @param[out] bestDistance Distance to the closest surface (in or out).
* @returns kInside if the point is closest to the inside surface;
* kOutside if the point is closest to the outside surface;
* kSurface if the point is withing tolerance of the surface.
*/
EInside Inside( const G4ThreeVector &p, G4double tolerance,
G4double *bestDistance ) override;
/**
* Returns the normal of surface closest to the point.
* @param[in] p Position.
* @param[out] bestDistance Distance to the closest surface (in or out).
* @returns The normal of the surface nearest the point.
*/
G4ThreeVector Normal( const G4ThreeVector& p,
G4double* bestDistance ) override;
/**
* Returns the face extent along the axis.
* @param[in] axis Unit vector defining the direction.
* @returns The largest point along the given axis of the face's extent.
*/
G4double Extent( const G4ThreeVector axis ) override;
/**
* Calculates the extent of the face for the voxel navigator.
* @param[in] axis The axis in which to check the shapes 3D extent against.
* @param[in] voxelLimit Limits along x, y, and/or z axes.
* @param[in] tranform A coordinate transformation on which to apply to
* the shape before testing.
* @param[out] extentList The list of (voxel) extents along the axis.
*/
void CalculateExtent( const EAxis axis,
const G4VoxelLimits &voxelLimit,
const G4AffineTransform& tranform,
G4SolidExtentList& extentList ) override;
G4VCSGface* Clone() override { return new G4PolyhedraSide( *this ); }
/**
* Method invoked by the copy constructor or the assignment operator.
* Its purpose is to return a pointer to a duplicate copy of the face.
*/
inline G4VCSGface* Clone() override { return new G4PolyhedraSide( *this ); }
// Methods used for GetPointOnSurface()
G4double SurfaceTriangle( const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
G4ThreeVector* p4 );
G4ThreeVector GetPointOnPlane( const G4ThreeVector& p0, const G4ThreeVector& p1,
const G4ThreeVector& p2, const G4ThreeVector& p3,
G4double* Area );
/**
* Returning an estimation of the face surface area, in internal units.
*/
G4double SurfaceArea() override;
G4ThreeVector GetPointOnFace() override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4PolyhedraSide(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Returns the instance ID.
*/
inline G4int GetInstanceID() const { return instanceID; }
// Returns the instance ID.
/**
* Returns the private data instance manager.
*/
static const G4PhSideManager& GetSubInstanceManager();
// Returns the private data instance manager.
//
// A couple internal data structures
//
private:
/**
* Internal data structures.
*/
struct sG4PolyhedraSideVec; // Secret recipe for allowing
friend struct sG4PolyhedraSideVec; // protected nested structures
@@ -171,36 +250,109 @@ class G4PolyhedraSide : public G4VCSGface
G4ThreeVector edgeNorm[2]; // RZ edge normals [i] at {r[i],z[i]}
};
protected:
/**
* Calculates the surface area of a triangle.
* At the same time a random point in the triangle is given.
*/
G4double SurfaceTriangle( const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
G4ThreeVector* p4 );
/**
* Returns a random point located and uniformly distributed on the face.
*/
G4ThreeVector GetPointOnFace() override;
/**
* Auxiliary method for GetPointOnSurface().
*/
G4ThreeVector GetPointOnPlane( const G4ThreeVector& p0, const G4ThreeVector& p1,
const G4ThreeVector& p2, const G4ThreeVector& p3,
G4double* Area );
/**
* Decides if a line correctly intersects one side plane of a segment.
* It is assumed that the correct side has been chosen, and thus only
* the Z bounds (of the entire segment) are checked.
* @param[in] p The point to check.
* @param[in] v The direction.
* @param[in] vec Description record of the side plane.
* @param[in] normSign Sign (+/- 1) to apply to normal.
* @param[in] surfTolerance Surface tolerance (generally > 0, see below).
* @param[out] distance Distance along v to intersection.
* @param[out] distFromSurface Distance from surface normal.
* @returns true is the line is intersecting, false otherwise.
*/
G4bool IntersectSidePlane( const G4ThreeVector& p, const G4ThreeVector& v,
const G4PolyhedraSideVec& vec,
G4double normSign,
G4double surfTolerance,
G4double &distance,
G4double &distFromSurface );
G4double& distance,
G4double& distFromSurface );
/**
* Calculates which phi segments a line intersects in three dimensions.
* No check is made as to whether the intersections are within the Z bounds
* of the segment.
*/
G4int LineHitsSegments( const G4ThreeVector& p,
const G4ThreeVector& v,
G4int* i1, G4int* i2 );
G4int ClosestPhiSegment( G4double phi );
/**
* Decides which phi segment an angle belongs to, counting from zero.
* A returned value of -1 indicates that the phi value is outside the
* shape (only possible if phiTotal < 360 degrees).
*/
G4int PhiSegment( G4double phi );
/**
* Decides which phi segment is closest in phi to the point.
* The result is the same as PhiSegment() if there is no phi opening.
*/
G4int ClosestPhiSegment( G4double phi );
/**
* Calculates Phi for a given 3-vector (point 'p'), if not already cached
* for the same point, in the attempt to avoid consecutive computation of
* the same quantity.
*/
G4double GetPhi( const G4ThreeVector& p );
/**
* Computes the total distance from the side.
* @param[in] p The point to check.
* @param[in] vec The vector set of this side.
* @param[out] normDist The returned distance normal to the side or edge,
* as appropriate, signed.
* @returns The total distance from the side.
*/
G4double DistanceToOneSide( const G4ThreeVector& p,
const G4PolyhedraSideVec& vec,
G4double* normDist );
/**
* Calculates the distance of a point from the segmented surface, including
* the effect of any phi segmentation.
* Adds distance from side edges, if necessary, to the total distance,
* and updates 'normDist' appropriate depending on edge normals.
* @param[in] p The point to check.
* @param[in] opposite If true, check the opposite hemisphere (see below).
* @param[out] normDist The returned normal distance.
* @returns The distance from the segmented plane.
*/
G4double DistanceAway( const G4ThreeVector& p,
const G4PolyhedraSideVec& vec,
G4double* normDist );
/**
* Copies parameters from other object; used in copy constructor and
* assignment operator.
*/
void CopyStuff( const G4PolyhedraSide& source );
protected:
private:
G4int numSide = 0; // Number sides
G4double r[2], z[2]; // r, z parameters, in specified order
@@ -218,8 +370,6 @@ class G4PolyhedraSide : public G4VCSGface
lenPhi[2]; // Phi dimensions of each side
G4double edgeNorm; // Normal in RZ/Phi space to each side
private:
G4double kCarTolerance; // Geometrical surface thickness
G4double fSurfaceArea = 0.0; // Surface Area
@@ -28,27 +28,27 @@
//
// Class description:
//
// The G4QuadrangularFacet class is used for the contruction of
// G4TessellatedSolid.
// It is defined by four fVertices, which shall be in the same plane and be
// supplied in anti-clockwise order looking from the outsider of the solid
// where it belongs. Its constructor
// The G4QuadrangularFacet class is used for the contruction of
// G4TessellatedSolid.
// It is defined by four fVertices, which shall be in the same plane and be
// supplied in anti-clockwise order looking from the outsider of the solid
// where it belongs. Its constructor:
//
// G4QuadrangularFacet (const G4ThreeVector& Pt0, const G4ThreeVector& vt1,
// const G4ThreeVector& vt2, const G4ThreeVector& vt3,
// G4FacetVertexType);
// G4QuadrangularFacet (const G4ThreeVector& Pt0, const G4ThreeVector& vt1,
// const G4ThreeVector& vt2, const G4ThreeVector& vt3,
// G4FacetVertexType);
//
// takes 5 parameters to define the four fVertices:
// 1) G4FacetvertexType = "ABSOLUTE": in this case Pt0, vt1, vt2 and vt3
// are the four fVertices required in anti-clockwise order when looking
// from the outsider.
// 2) G4FacetvertexType = "RELATIVE": in this case the first vertex is Pt0,
// the second vertex is Pt0+vt, the third vertex is Pt0+vt2 and
// the fourth vertex is Pt0+vt3, in anti-clockwise order when looking
// from the outsider.
// takes 5 parameters to define the four fVertices:
// 1) G4FacetvertexType = "ABSOLUTE": in this case Pt0, vt1, vt2 and vt3
// are the four fVertices required in anti-clockwise order when looking
// from the outsider.
// 2) G4FacetvertexType = "RELATIVE": in this case the first vertex is Pt0,
// the second vertex is Pt0+vt1, the third vertex is Pt0+vt2 and
// the fourth vertex is Pt0+vt3, 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 G4QUADRANGULARFACET_HH
#define G4QUADRANGULARFACET_HH
@@ -58,50 +58,149 @@
#include "G4ThreeVector.hh"
#include "G4TriangularFacet.hh"
/**
* @brief G4QuadrangularFacet defines a facet with 4 vertices, used for the
* contruction of G4TessellatedSolid. Vertices shall be in the same plane and
* be supplied in anti-clockwise order looking from the outsider of the solid
* where it belongs.
*/
class G4QuadrangularFacet : public G4VFacet
{
public:
/**
* Constructs a facet with 4 vertices, given its parameters.
* @param[in] Pt0 The anchor point, first vertex.
* @param[in] vt1 Second vertex.
* @param[in] vt2 Third vertex.
* @param[in] vt3 Fourth 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,
* third vertex is Pt0+vt2 and fourth is Pt0+vt3,
* still in anti-clockwise order.
*/
G4QuadrangularFacet (const G4ThreeVector& Pt0, const G4ThreeVector& vt1,
const G4ThreeVector& vt2, const G4ThreeVector& vt3,
G4FacetVertexType);
G4QuadrangularFacet (const G4QuadrangularFacet& right);
~G4QuadrangularFacet () override;
G4FacetVertexType vType);
/**
* Default Destructor.
*/
~G4QuadrangularFacet () override = default;
/**
* Copy constructor and assignment operator.
*/
G4QuadrangularFacet (const G4QuadrangularFacet& right);
G4QuadrangularFacet& operator=(const G4QuadrangularFacet& right);
/**
* Returns a pointer to a newly allocated duplicate copy of the facet.
*/
G4VFacet* GetClone () override;
/**
* 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 quadrangle 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;
/**
* Returns the normal vector to the face.
*/
G4ThreeVector GetSurfaceNormal () const 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 the type ID, "G4QuadrangularFacet" of the facet.
*/
G4GeometryType GetEntityType () const override;
/**
* Returns true if the facet is defined.
*/
inline G4bool IsDefined () const override;
/**
* Returns the number of vertices, i.e. 4.
*/
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;
private:
/**
* Private accessor/setter for the vertex index.
*/
inline G4int GetVertexIndex (G4int i) const override;
inline void SetVertexIndex (G4int i, G4int val) override;
/**
* Returns the allocated memory (sizeof) by the facet.
*/
inline G4int AllocatedMemory() override;
private:
@@ -114,92 +213,9 @@ class G4QuadrangularFacet : public G4VFacet
};
// --------------------------------------------------------------------
// Inlined Methods
// Inline Methods
// --------------------------------------------------------------------
inline G4int G4QuadrangularFacet::GetNumberOfVertices () const
{
return 4;
}
inline G4ThreeVector G4QuadrangularFacet::GetVertex (G4int i) const
{
return i == 3 ? fFacet2.GetVertex(2) : fFacet1.GetVertex(i);
}
inline G4double G4QuadrangularFacet::GetRadius () const
{
return fRadius;
}
inline G4ThreeVector G4QuadrangularFacet::GetCircumcentre () const
{
return fCircumcentre;
}
inline void G4QuadrangularFacet::SetVertex (G4int i, const G4ThreeVector &val)
{
switch (i)
{
case 0:
fFacet1.SetVertex(0, val);
fFacet2.SetVertex(0, val);
break;
case 1:
fFacet1.SetVertex(1, val);
break;
case 2:
fFacet1.SetVertex(2, val);
fFacet2.SetVertex(1, val);
break;
case 3:
fFacet2.SetVertex(2, val);
break;
}
}
inline void G4QuadrangularFacet::SetVertices(std::vector<G4ThreeVector>* v)
{
fFacet1.SetVertices(v);
fFacet2.SetVertices(v);
}
inline G4bool G4QuadrangularFacet::IsDefined () const
{
return fFacet1.IsDefined();
}
inline G4int G4QuadrangularFacet::GetVertexIndex (G4int i) const
{
return i == 3 ? fFacet2.GetVertexIndex(2) : fFacet1.GetVertexIndex(i);
}
inline void G4QuadrangularFacet::SetVertexIndex (G4int i, G4int val)
{
switch (i)
{
case 0:
fFacet1.SetVertexIndex(0, val);
fFacet2.SetVertexIndex(0, val);
break;
case 1:
fFacet1.SetVertexIndex(1, val);
break;
case 2:
fFacet1.SetVertexIndex(2, val);
fFacet2.SetVertexIndex(1, val);
break;
case 3:
fFacet2.SetVertexIndex(2, val);
break;
}
}
inline G4int G4QuadrangularFacet::AllocatedMemory()
{
return sizeof(*this) + fFacet1.AllocatedMemory() + fFacet2.AllocatedMemory();
}
#include "G4QuadrangularFacet.icc"
#endif
@@ -0,0 +1,112 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Implementation of inline methods of G4QuadrangularFacet
// --------------------------------------------------------------------
inline G4int G4QuadrangularFacet::GetNumberOfVertices () const
{
return 4;
}
inline G4ThreeVector G4QuadrangularFacet::GetVertex (G4int i) const
{
return i == 3 ? fFacet2.GetVertex(2) : fFacet1.GetVertex(i);
}
inline G4double G4QuadrangularFacet::GetRadius () const
{
return fRadius;
}
inline G4ThreeVector G4QuadrangularFacet::GetCircumcentre () const
{
return fCircumcentre;
}
inline void G4QuadrangularFacet::SetVertex (G4int i, const G4ThreeVector &val)
{
switch (i)
{
case 0:
fFacet1.SetVertex(0, val);
fFacet2.SetVertex(0, val);
break;
case 1:
fFacet1.SetVertex(1, val);
break;
case 2:
fFacet1.SetVertex(2, val);
fFacet2.SetVertex(1, val);
break;
case 3:
fFacet2.SetVertex(2, val);
break;
}
}
inline void G4QuadrangularFacet::SetVertices(std::vector<G4ThreeVector>* v)
{
fFacet1.SetVertices(v);
fFacet2.SetVertices(v);
}
inline G4bool G4QuadrangularFacet::IsDefined () const
{
return fFacet1.IsDefined();
}
inline G4int G4QuadrangularFacet::GetVertexIndex (G4int i) const
{
return i == 3 ? fFacet2.GetVertexIndex(2) : fFacet1.GetVertexIndex(i);
}
inline void G4QuadrangularFacet::SetVertexIndex (G4int i, G4int val)
{
switch (i)
{
case 0:
fFacet1.SetVertexIndex(0, val);
fFacet2.SetVertexIndex(0, val);
break;
case 1:
fFacet1.SetVertexIndex(1, val);
break;
case 2:
fFacet1.SetVertexIndex(2, val);
fFacet2.SetVertexIndex(1, val);
break;
case 3:
fFacet2.SetVertexIndex(2, val);
break;
}
}
inline G4int G4QuadrangularFacet::AllocatedMemory()
{
return sizeof(*this) + fFacet1.AllocatedMemory() + fFacet2.AllocatedMemory();
}
@@ -27,98 +27,169 @@
//
// Class description:
//
// Utility class used to specify, test, reduce, and/or otherwise
// manipulate a 2D polygon.
// Utility class used to specify, test, reduce, and/or otherwise
// manipulate a 2D polygon.
//
// For this class, a polygon consists of n > 2 points in 2D
// space (a,b). The polygon is always closed by connecting the
// last point to the first. A G4ReduciblePolygon is guaranteed
// to fulfill this definition in all instances.
// For this class, a polygon consists of n > 2 points in 2D
// space (a,b). The polygon is always closed by connecting the
// last point to the first. A G4ReduciblePolygon is guaranteed
// to fulfill this definition in all instances.
//
// Illegal manipulations (such that a valid polygon would be
// produced) result in an error return if possible and
// otherwise a G4Exception.
// Illegal manipulations (such that a valid polygon would be
// produced) result in an error return if possible and
// otherwise a G4Exception.
//
// The set of manipulations is limited currently to what
// is needed for G4Polycone and G4Polyhedra.
// The set of manipulations is limited currently to what
// is needed for G4Polycone and G4Polyhedra.
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998
// --------------------------------------------------------------------
#ifndef G4REDUCIBLEPOLYGON_HH
#define G4REDUCIBLEPOLYGON_HH 1
#define G4REDUCIBLEPOLYGON_HH
#include "G4Types.hh"
/**
* @brief G4ReduciblePolygon is a utility class used to specify, test, reduce,
* and/or otherwise manipulate a 2D polygon.
*/
class G4ReduciblePolygon
{
friend class G4ReduciblePolygonIterator;
public:
/**
* Constructor of G4ReduciblePolygon via simple a/b arrays.
* @param[in] a First array of points.
* @param[in] b Second array of points.
* @param[in] n The number of vertices of the polygon (has to be >=3).
*/
G4ReduciblePolygon( const G4double a[], const G4double b[], G4int n );
// Creator: via simple a/b arrays
/**
* Special constructor version for G4Polyhedra and G4Polycone, that takes
* two a points at planes of b (where a==r and b==z).
* @param[in] rmin Array of r-min coordinates of corners.
* @param[in] rmax Array of r-max coordinates of corners.
* @param[in] z Array of Z coordinates of corners.
* @param[in] n The number of vertices of the polygon.
*/
G4ReduciblePolygon( const G4double rmin[], const G4double rmax[],
const G4double z[], G4int n );
// Creator: a special version for G4Polygon and G4Polycone
// that takes two a points at planes of b
// (where a==r and b==z for the GEANT3 classic PCON and PGON)
/**
* Copy constructor and assignment operator not allowed.
*/
G4ReduciblePolygon(const G4ReduciblePolygon&) = delete;
G4ReduciblePolygon& operator=(const G4ReduciblePolygon&) = delete;
// Deleted copy constructor and assignment operator.
virtual ~G4ReduciblePolygon();
/**
* Destructor, taking care to clear allocated lists.
*/
~G4ReduciblePolygon();
// Queries
/**
* Accessors.
*/
inline G4int NumVertices() const { return numVertices; }
inline G4double Amin() const { return aMin; }
inline G4double Amax() const { return aMax; }
inline G4double Bmin() const { return bMin; }
inline G4double Bmax() const { return bMax; }
/**
* Copies contents of provided arrays into simple linear arrays.
*/
void CopyVertices( G4double a[], G4double b[] ) const;
// Manipulations
/**
* Methods to multiply all a or b values by a common scale.
*/
void ScaleA( G4double scale );
void ScaleB( G4double scale );
/**
* Removes adjacent vertices that are equal.
* @param[in] tolerance Provided tolerance for adjacent vertices.
* @returns false, if there is a problem (too few vertices remaining).
*/
G4bool RemoveDuplicateVertices( G4double tolerance );
/**
* Removes any unneeded vertices, i.e. those vertices which are on the
* line connecting the previous and next vertices.
* @param[in] tolerance Provided tolerance for parallel line segments.
* @returns false, if there is a problem (too few vertices remaining).
*/
G4bool RemoveRedundantVertices( G4double tolerance );
/**
* Reverses the order of the vertices.
*/
void ReverseOrder();
/**
* Method is used for G4GenericPolycone; starting always with Zmin=bMin.
*/
void StartWithZMin();
// Tests
//
G4double Area();
G4bool CrossesItself( G4double tolerance );
G4bool BisectedBy( G4double a1, G4double b1,
G4double a2, G4double b2, G4double tolerance );
void Print(); // Debugging only
G4ReduciblePolygon(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
// Methods for tests
protected:
/**
* Calculates signed polygon area, where polygons specified in a
* clockwise manner have negative area.
*/
G4double Area();
/**
* Returns "true" if the polygon crosses itself.
*/
G4bool CrossesItself( G4double tolerance );
/**
* Decides if a line through two points crosses the polygon,
* within tolerance.
*/
G4bool BisectedBy( G4double a1, G4double b1,
G4double a2, G4double b2, G4double tolerance );
/**
* Print function for debugging.
*/
void Print();
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4ReduciblePolygon(__void__&);
private:
/**
* Create the polygon; used in constructors.
*/
void Create( const G4double a[], const G4double b[], G4int n );
/**
* Re-calculates global values. To be called when the vertices are changed.
*/
void CalculateMaxMin();
// Below are member values that are *always* kept up to date (please!)
private:
// Below are member values that are *always* kept up to date
//
G4double aMin, aMax, bMin, bMax;
G4int numVertices = 0;
// A subclass which holds the vertices in a single-linked list
//
/**
* A subclass which holds the vertices in a single-linked list.
*/
struct ABVertex; // Secret recipe for allowing
friend struct ABVertex; // protected nested structures
struct ABVertex
@@ -134,29 +205,35 @@ class G4ReduciblePolygon
// A companion class for iterating over the vertices of our polygon.
// It is simple enough that all routines are declared inline here.
//
/**
* @brief G4ReduciblePolygonIterator is companion class for iterating over
* the vertices of a polygon.
*/
class G4ReduciblePolygonIterator
{
public:
G4ReduciblePolygonIterator( const G4ReduciblePolygon* theSubject )
inline G4ReduciblePolygonIterator( const G4ReduciblePolygon* theSubject )
{
subject = theSubject; current = nullptr;
}
void Begin() { current = subject->vertexHead; }
inline void Begin() { current = subject->vertexHead; }
G4bool Next()
inline G4bool Next()
{
if (current != nullptr) current=current->next;
if (current != nullptr) { current=current->next; }
return Valid();
}
G4bool Valid() const { return current != nullptr; }
inline G4bool Valid() const { return current != nullptr; }
G4double GetA() const { return current->a; }
G4double GetB() const { return current->b; }
inline G4double GetA() const { return current->a; }
inline G4double GetB() const { return current->b; }
protected:
private:
const G4ReduciblePolygon* subject = nullptr; // Who are we iterating over
G4ReduciblePolygon::ABVertex* current = nullptr; // Current vertex
@@ -27,13 +27,13 @@
//
// Class description:
//
// Defines a list of (voxel) extents along one axis.
// Defines a list of (voxel) extents along one axis.
//
// This utility class is designed for one specific purpose:
// to calculate the extent of a CSG-like solid for a voxel
// (G4VSolid::CalculateExtent).
// This utility class is designed for one specific purpose:
// to calculate the extent of a CSG-like solid for a voxel
// (G4VSolid::CalculateExtent).
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998
// --------------------------------------------------------------------
#ifndef G4SOLIDEXTENTLIST_HH
#define G4SOLIDEXTENTLIST_HH
@@ -42,28 +42,57 @@
#include "G4ClippablePolygon.hh"
/**
* @brief G4SolidExtentList is utility class designed for calculating
* the extent of a CSG-like solid for a voxel.
*/
class G4SolidExtentList
{
public:
/**
* Default Constructor.
*/
G4SolidExtentList();
/**
* Constructor provided axis and limits.
* @param[in] targetAxis Axis along which compute the extent.
* @param[in] voxelLimits The limiting space dictated by voxels.
*/
G4SolidExtentList( const EAxis targetAxis,
const G4VoxelLimits& voxelLimits );
~G4SolidExtentList();
/**
* Default Destructor.
*/
~G4SolidExtentList() = default;
/**
* Categorises polygon surfaces.
*/
void AddSurface( const G4ClippablePolygon& surface );
/**
* Returns extent after processing all surfaces.
* @param[out] min The minimum extent
* @param[out] max The maximum extent
* @returns false if no surfaces within limits or facing inwards.
*/
G4bool GetExtent( G4double& min, G4double& max ) const;
protected:
EAxis axis; // Target axis
G4bool limited = false; // True if limited
private:
/** Axis and limits... */
EAxis axis; // Target axis
G4bool limited = false; // True if limited
G4double minLimit; // ... min limit
G4double maxLimit; // ... max limit
/** Surfaces within the limits... */
G4ClippablePolygon minSurface, // Minimum surface within limits
maxSurface, // Maximum
maxSurface, // Maximum surface within limits
minAbove, // Minimum surface totally above max limit
maxBelow; // Maximum surface totally below min limit
};
@@ -27,20 +27,19 @@
//
// Class description:
//
// Manages the per-thread state of solids - those which
// have a per-thread state and dependent classes (if any)
// In particular it
// - owns the arrays that implement 'split' classes
// - classes/objects which are owned by the split classes.
// Background: the classes/objects affected are
// - 'split' classes part of its state is per-thread,
// - per-thread objects, in particular those which are owned
// by the split classes.
// Manages the per-thread state of solids - those which have a per-thread
// state and dependent classes (if any)
// In particular it owns:
// - the arrays that implement 'split' classes
// - classes/objects which are owned by the split classes.
// Background: the classes/objects affected are:
// - 'split' classes part of its state is per-thread,
// - per-thread objects, in particular those which are owned by split classes.
// Goal: Take ownership and control of per-thread state of
// classes to work with multi-threading.
// Offshoot of G4GeometryWorkspace, to deal with Solids.
// 4.10.2013 - Created: John Apostolakis, Andrea Dotti
// Authors: John Apostolakis, Andrea Dotti (CERN), 04.10.2013 - Created
// --------------------------------------------------------------------
#ifndef G4SOLIDSWORKSPACE_HH
#define G4SOLIDSWORKSPACE_HH
@@ -51,43 +50,71 @@
#include "G4PolyconeSide.hh"
#include "G4PolyhedraSide.hh"
/**
* @brief G4SolidsWorkspace manages the per-thread state of thoese solids
* which have a per-thread state and dependent classes (if any). It takes
* ownership and control of per-thread state of classes to work with
* multi-threading.
*/
class G4SolidsWorkspace
{
public:
using pool_type = G4TWorkspacePool<G4SolidsWorkspace>;
/**
* Constructor.
* @param[in] verbose Verbosity flag.
*/
G4SolidsWorkspace(G4bool verbose = false);
/**
* Default Destructor.
*/
~G4SolidsWorkspace() = default;
/**
* Methods to achieve/release ownership.
*/
void UseWorkspace(); // Take ownership
void ReleaseWorkspace(); // Release ownership
void DestroyWorkspace(); // Release ownership and destroy
/**
* Method to be called at start of each run (especially at the
* 2nd and further runs).
*/
void InitialiseWorkspace();
// To be called at start of each run (especially 2nd and further runs)
/**
* Accessor/modifier for verbosity.
*/
inline void SetVerbose(G4bool v) { fVerbose=v; }
inline G4bool GetVerbose() { return fVerbose; }
/**
* Accessor to the object pool.
*/
static pool_type* GetPool();
protected:
private:
/**
* Does nothing.
*/
void InitialiseSolids();
private:
// Helper pointers - can be per instance or shared
//
/** Helper pointers - can be per instance or shared. */
G4PlSideManager* fpPolyconeSideSIM = nullptr;
G4PhSideManager* fpPolyhedraSideSIM = nullptr;
// Per Instance variables
// NOTE: the ownership of the Data Arrays is IN this object
// Store SubInstanceManager object pointers (SIM pointers)
//
/** Store SubInstanceManager object pointers (SIM pointers). */
G4PlSideData* fPolyconeSideOffset = nullptr;
G4PhSideData* fPolyhedraSideOffset = nullptr;
@@ -37,8 +37,8 @@
// container use the Compact function, this will discard the memory
// occupied by the upper bits that are 0.
// 19.10.12 - Marek Gayer, created and adapted from original implementation
// of Root's TBits class by P.Canal
// Author: Marek Gayer (CERN), 19.10.2012 - Created and adapted from original
// implementation of Root/TBits class.
// --------------------------------------------------------------------
#ifndef G4SURFBITS_HH
#define G4SURFBITS_HH
@@ -47,63 +47,95 @@
#include "G4Types.hh"
/**
* @brief G4SurfBits provides a simple container of bits, to be used for
* optimization of tessellated surfaces. The size of the container is
* automatically extended when a bit number is either set or tested.
*/
class G4SurfBits
{
public:
/**
* Constructor given the number of bits.
* @param[in] nbits The number of bits.
*/
G4SurfBits(unsigned int nbits = 0);
G4SurfBits(const G4SurfBits&);
G4SurfBits& operator=(const G4SurfBits&);
/**
* Destructor. Clears all allocated bits.
*/
~G4SurfBits();
//----- Bit manipulation
/**
* Copy constructor and assignment operator.
*/
G4SurfBits(const G4SurfBits&);
G4SurfBits& operator=(const G4SurfBits&);
/**
* Methods for bit manipulation.
*/
void ResetAllBits(G4bool value = false); // if value=1 set all bits to 1
void ResetBitNumber(unsigned int bitnumber);
void SetBitNumber(unsigned int bitnumber, G4bool value = true);
G4bool TestBitNumber(unsigned int bitnumber) const;
inline void ResetBitNumber(unsigned int bitnumber);
inline void SetBitNumber(unsigned int bitnumber, G4bool value = true);
inline G4bool TestBitNumber(unsigned int bitnumber) const;
//----- Accessors and operator
G4bool operator[](unsigned int bitnumber) const;
/**
* Accessor operator.
*/
inline G4bool operator[](unsigned int bitnumber) const;
//----- Optimized setters
// Each of these will replace the contents of the receiver with the
// bitvector in the parameter array. The number of bits is changed
// to nbits. If nbits is smaller than fNBits, the receiver will NOT
// be compacted.
/**
* Optimized setters. Each of these will replace the contents of the
* receiver with the bitvector in the parameter array. The number of bits
* is changed to 'nbits'. If nbits is smaller than fNBits, the receiver
* will NOT be compacted.
*/
void set(unsigned int nbits, const char* array);
void set(unsigned int nbits, const G4int* array);
//----- Optimized getters
// Each of these will replace the contents of the parameter array with the
// bits in the receiver. The parameter array must be large enough to hold
// all of the bits in the receiver.
// Note on semantics: any bits in the parameter array that go beyond the
// number of the bits in the receiver will have an unspecified value. For
// example, if you call Get(Int*) with an array of one integer and the
// G4SurfBits object has less than 32 bits, then the remaining bits in the
// integer will have an unspecified value.
/**
* Optimized getters. Each of these will replace the contents of the
* parameter array with the bits in the receiver. The parameter array must
* be large enough to hold all of the bits in the receiver.
* Note on semantics: any bits in the parameter array that go beyond the
* number of the bits in the receiver will have an unspecified value. For
* example, if calling Get(Int*) with an array of one integer and the
* G4SurfBits object has less than 32 bits, then the remaining bits in the
* integer will have an unspecified value.
*/
void Get(char* array) const;
void Get(G4int* array) const;
//----- Utilities
/**
* Utilities to clear or reduce the space used.
*/
void Clear();
void Compact(); // Reduce the space used.
unsigned int GetNbits() const { return fNBits; }
unsigned int GetNbytes() const { return fNBytes; }
/**
* Accessors.
*/
inline unsigned int GetNbits() const { return fNBits; }
inline unsigned int GetNbytes() const { return fNBytes; }
/**
* Logging functions.
*/
void Print() const; // to show the list of active bits
void Output(std::ostream &) const;
protected:
void ReserveBytes(unsigned int nbytes);
public:
unsigned char* fAllBits = nullptr; // [fNBytes] array of UChars
protected:
private:
void ReserveBytes(unsigned int nbytes);
private:
unsigned int fNBits; // Highest bit set + 1
unsigned int fNBytes; // Number of UChars in fAllBits
@@ -111,54 +143,6 @@ class G4SurfBits
// inline functions...
inline void G4SurfBits::SetBitNumber(unsigned int bitnumber, G4bool value)
{
// set bit number 'bitnumber' to be value
if (bitnumber >= fNBits)
{
unsigned int new_size = (bitnumber/8) + 1;
if (new_size > fNBytes)
{
if (new_size < 100 * 1024 * 1024) new_size *= 2;
unsigned char *old_location = fAllBits;
fAllBits = new unsigned char[new_size];
std::memcpy(fAllBits,old_location,fNBytes);
std::memset(fAllBits+fNBytes ,0, new_size-fNBytes);
fNBytes = new_size;
delete [] old_location;
}
fNBits = bitnumber+1;
}
unsigned int loc = bitnumber/8;
unsigned char bit = bitnumber%8;
if (value)
fAllBits[loc] |= (1<<bit);
else
fAllBits[loc] &= (0xFF ^ (1<<bit));
}
inline G4bool G4SurfBits::TestBitNumber(unsigned int bitnumber) const
{
// Return the current value of the bit
if (bitnumber >= fNBits) return false;
unsigned int loc = bitnumber/8;
unsigned char value = fAllBits[loc];
unsigned char bit = bitnumber%8;
G4bool result = (value & (1<<bit)) != 0;
return result;
// short: return 0 != (fAllBits[bitnumber/8] & (1<< (bitnumber%8)));
}
inline void G4SurfBits::ResetBitNumber(unsigned int bitnumber)
{
SetBitNumber(bitnumber,false);
}
inline G4bool G4SurfBits::operator[](unsigned int bitnumber) const
{
return TestBitNumber(bitnumber);
}
#include "G4SurfBits.icc"
#endif
@@ -0,0 +1,81 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Implementation of inline methods of G4SurfBits
// --------------------------------------------------------------------
inline void G4SurfBits::SetBitNumber(unsigned int bitnumber, G4bool value)
{
// set bit number 'bitnumber' to be value
if (bitnumber >= fNBits)
{
unsigned int new_size = (bitnumber/8) + 1;
if (new_size > fNBytes)
{
if (new_size < 100 * 1024 * 1024) { new_size *= 2; }
unsigned char *old_location = fAllBits;
fAllBits = new unsigned char[new_size];
std::memcpy(fAllBits,old_location,fNBytes);
std::memset(fAllBits+fNBytes ,0, new_size-fNBytes);
fNBytes = new_size;
delete [] old_location;
}
fNBits = bitnumber+1;
}
unsigned int loc = bitnumber/8;
unsigned char bit = bitnumber%8;
if (value)
{
fAllBits[loc] |= (1<<bit);
}
else
{
fAllBits[loc] &= (0xFF ^ (1<<bit));
}
}
inline G4bool G4SurfBits::TestBitNumber(unsigned int bitnumber) const
{
// Return the current value of the bit
if (bitnumber >= fNBits) { return false; }
unsigned int loc = bitnumber/8;
unsigned char value = fAllBits[loc];
unsigned char bit = bitnumber%8;
G4bool result = (value & (1<<bit)) != 0;
return result;
// short: return 0 != (fAllBits[bitnumber/8] & (1<< (bitnumber%8)));
}
inline void G4SurfBits::ResetBitNumber(unsigned int bitnumber)
{
SetBitNumber(bitnumber,false);
}
inline G4bool G4SurfBits::operator[](unsigned int bitnumber) const
{
return TestBitNumber(bitnumber);
}
@@ -28,59 +28,93 @@
//
// Class description:
//
// The G4TessellatedGeometryAlgorithms class is used to contain standard
// routines to determine whether (and if so where) simple geometric shapes
// intersect.
// The G4TessellatedGeometryAlgorithms class is used to contain standard
// routines to determine whether (and if so where) simple geometric shapes
// intersect.
//
// The constructor doesn't need to do anything, and neither does the
// destructor.
// The constructor doesn't need to do anything, and neither does the
// destructor.
//
// IntersectLineAndTriangle2D
// Determines whether there is an intersection between a line defined
// by r = p + s.v and a triangle defined by verticies P0, P0+E0 and P0+E1.
// Here:
// IntersectLineAndTriangle2D
// Determines whether there is an intersection between a line defined
// by r = p + s.v and a triangle defined by verticies P0, P0+E0 and P0+E1.
// Here:
// p = 2D vector
// s = scaler on [0,infinity)
// v = 2D vector
// P0, E0 and E1 are 2D vectors
// Information about where the intersection occurs is returned in the
// variable location.
// Information about where the intersection occurs is returned in the
// variable location.
//
// IntersectLineAndLineSegment2D
// Determines whether there is an intersection between a line defined
// by r = P0 + s.D0 and a line-segment with endpoints P1 and P1+D1.
// Here:
// IntersectLineAndLineSegment2D
// Determines whether there is an intersection between a line defined
// by r = P0 + s.D0 and a line-segment with endpoints P1 and P1+D1.
// Here:
// P0 = 2D vector
// s = scaler on [0,infinity)
// D0 = 2D vector
// P1 and D1 are 2D vectors
// Information about where the intersection occurs is returned in the
// variable location.
// Information about where the intersection occurs is returned in the
// variable location.
// 07 August 2007, P R Truscott, QinetiQ Ltd, UK - Created, with member
// functions based on the work of Rickard Holmberg.
// 12 October 2012, M Gayer, CERN, - Reviewed optimized implementation.
// Author: P.R.Truscott (QinetiQ Ltd, UK), 07.08.2007 - Created, with member
// functions based on the work of Rickard Holmberg.
// M.Gayer (CERN), 12.10.2012 - Reviewed and optimized implementation.
// --------------------------------------------------------------------
#ifndef G4TESSELLATEDGEOMETRYALGORITHMS_HH
#define G4TESSELLATEDGEOMETRYALGORITHMS_HH 1
#define G4TESSELLATEDGEOMETRYALGORITHMS_HH
#include "G4TwoVector.hh"
/**
* @brief G4TessellatedGeometryAlgorithms contains standard methods to
* determine whether (and if so where) simple geometric shapes intersect.
*/
class G4TessellatedGeometryAlgorithms
{
public:
/**
* Determines whether there is an intersection between a line defined
* by r = p + s.v and a triangle defined by vertices p0, p0+e0 and p0+e1.
* @param[in] p Coefficient of line equation.
* @param[in] v Coefficient of line equation.
* @param[in] p0 First vertex of triangle.
* @param[in] e0 Second vertex of triangle.
* @param[in] e1 Third vertex of triangle.
* @param[out] location The returned location of the intersection.
* @returns false if no intersection occours.
*/
static G4bool IntersectLineAndTriangle2D (const G4TwoVector& p,
const G4TwoVector& v,
const G4TwoVector& p0,
const G4TwoVector& e0,
const G4TwoVector& e1,
G4TwoVector location[2]);
/**
* Determines whether there is an intersection between a line defined
* by r = p0 + s.d0 and a line-segment with endpoints p1 and p1+d1.
* @param[in] p0 Coefficient of line equation.
* @param[in] d0 Coefficient of line equation.
* @param[in] p1 First line-segment end-point..
* @param[in] d1 Delta line-segment end-point.
* @param[out] location The returned location of the intersection.
* @returns false if no intersection occours.
*/
static G4int IntersectLineAndLineSegment2D (const G4TwoVector& p0,
const G4TwoVector& d0,
const G4TwoVector& p1,
const G4TwoVector& d1,
G4TwoVector location[2]);
/**
* Ficticious "cross-product" function for two 2D vectors.
* @param[in] v1 First 2D vector.
* @param[in] v2 Second 2D vector.
* @returns The cross-product of v1 and v2.
*/
static G4double cross(const G4TwoVector& v1, const G4TwoVector& v2);
};
@@ -28,19 +28,19 @@
//
// Class description:
//
// G4TessellatedSolid is a special Geant4 solid defined by a number of
// facets (UVFacet). It is important that the supplied facets shall form a
// fully enclose space which is the solid.
// At the moment only two types of facet can be used for the construction of
// a G4TessellatedSolid, i.e. the G4TriangularFacet and G4QuadrangularFacet.
// G4TessellatedSolid is a special Geant4 solid defined by a number of
// facets (UVFacet). It is important that the supplied facets shall form a
// fully enclose space which is the solid.
// At the moment only two types of facet can be used for the construction of
// a G4TessellatedSolid, i.e. the G4TriangularFacet and G4QuadrangularFacet.
//
// How to contruct a G4TessellatedSolid:
// How to contruct a G4TessellatedSolid:
//
// First declare a tessellated solid:
//
// G4TessellatedSolid* solidTarget = new G4TessellatedSolid("Solid_name");
//
// Define the facets which form the solid
// Define the facets which form the solid:
//
// G4double targetSiz = 10*cm ;
// G4TriangularFacet *facet1 = new
@@ -82,11 +82,11 @@
//
// solidTarget->SetSolidClosed(true);
// 31.10.2004, P R Truscott, QinetiQ Ltd, UK - Created.
// 12.10.2012, M Gayer, CERN - New implementation with voxelization of surfaces.
// Author: P.R.Truscott (QinetiQ Ltd, UK), 31.10.2004 - Created.
// M.Gayer (CERN), 12.10.2012 - New implementation with voxelization.
// --------------------------------------------------------------------
#ifndef G4TESSELLATEDSOLID_HH
#define G4TESSELLATEDSOLID_HH 1
#define G4TESSELLATEDSOLID_HH
#include "G4GeomTypes.hh"
@@ -117,37 +117,85 @@ struct G4VertexInfo
class G4VertexComparator
{
public:
G4bool operator() (const G4VertexInfo& l, const G4VertexInfo& r) const
{
return l.mag2 == r.mag2 ? l.id < r.id : l.mag2 < r.mag2;
}
public:
G4bool operator() (const G4VertexInfo& l, const G4VertexInfo& r) const
{
return l.mag2 == r.mag2 ? l.id < r.id : l.mag2 < r.mag2;
}
};
/**
* @brief G4TessellatedSolid is a solid defined by a number of facets.
* It is important that the supplied facets shall form a fully enclose space
* which is the solid. The facets can be of two types, G4TriangularFacet and
* G4QuadrangularFacet.
*/
class G4TessellatedSolid : public G4VSolid
{
public:
/**
* Default Constructor.
*/
G4TessellatedSolid ();
~G4TessellatedSolid () override;
/**
* Constructor with solid's name.
* @param[in] name The name of the solid.
*/
G4TessellatedSolid (const G4String& name);
/**
* Destructor. Clearing all allocated facets and data.
*/
~G4TessellatedSolid () override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TessellatedSolid(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Copy constructor and assignment operator.
*/
G4TessellatedSolid (const G4TessellatedSolid& ts);
G4TessellatedSolid &operator= (const G4TessellatedSolid& right);
G4TessellatedSolid &operator+= (const G4TessellatedSolid& right);
G4TessellatedSolid& operator= (const G4TessellatedSolid& right);
/**
* Operator +=, allowing to add two tessellated solids together, so
* that the solid on the left includes all of the facets in the solid
* on the right. To note that copies of the facets are generated, rather
* than using the original facet set of the solid on the right.
*/
G4TessellatedSolid& operator+= (const G4TessellatedSolid& right);
/**
* Methods for adding or retrieving a facet given an index.
*/
G4bool AddFacet (G4VFacet* aFacet);
inline G4VFacet* GetFacet (G4int i) const;
/**
* Accessors.
*/
G4int GetNumberOfFacets () const;
G4int GetFacetIndex (const G4ThreeVector& p) const;
G4double GetMinXExtent () const;
G4double GetMaxXExtent () const;
G4double GetMinYExtent () const;
G4double GetMaxYExtent () const;
G4double GetMinZExtent () const;
G4double GetMaxZExtent () const;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside (const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
G4double DistanceToIn(const G4ThreeVector& p,
@@ -160,57 +208,147 @@ class G4TessellatedSolid : public G4VSolid
G4bool* validNorm,
G4ThreeVector* norm) const override;
/**
* Returns the outwards pointing unit normal of the shape for the
* surface closest to the point at offset 'p'.
* @param[in] p The point coordinates.
* @param[out] n The returned normal vector.
* @returns false if not a valid normal.
*/
virtual G4bool Normal (const G4ThreeVector& p, G4ThreeVector& n) const;
/**
* Returns the the safety distance from outside the solid at a point 'p'.
* @param[in] p The point coordinates.
* @param[in] aAccurate Accuracy flag, if false quickly computes and
* returns the distance to the voxels bounding-box.
* @returns The safety distance.
*/
virtual G4double SafetyFromOutside(const G4ThreeVector& p,
G4bool aAccurate = false) const;
/**
* Returns the the safety distance from inside the solid at a point 'p'.
* @param[in] p The point coordinates.
* @param[in] aAccurate Not used.
* @returns The safety distance.
*/
virtual G4double SafetyFromInside (const G4ThreeVector& p,
G4bool aAccurate = false) const;
/**
* Returns the type ID, "G4TessellatedSolid" of the solid.
*/
G4GeometryType GetEntityType () const override;
/**
* Returns true as the solid has only planar faces.
*/
G4bool IsFaceted () const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetSurfaceArea() override;
G4double GetCubicVolume() override;
/**
* Modifier and accessor to close/finalise the solid.
*/
void SetSolidClosed (const G4bool t);
G4bool GetSolidClosed () const;
/**
* Checks the structure of the solid.
* @returns A value, sum of the following defect indicators, if any
* (0 means no defects):
* 1 - cubic volume is negative, wrong orientation of facets;
* 2 - some facets have wrong orientation;
* 4 - holes in the surface.
*/
G4int CheckStructure() const;
/**
* Allowing to tune the maximum number of voxels to use for optimisation.
*/
inline void SetMaxVoxels(G4int max);
/**
* Returns the voxels structure.
*/
inline G4Voxelizer& GetVoxels();
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
G4double GetMinXExtent () const;
G4double GetMaxXExtent () const;
G4double GetMinYExtent () const;
G4double GetMaxYExtent () const;
G4double GetMinZExtent () const;
G4double GetMaxZExtent () const;
G4Polyhedron* CreatePolyhedron () const override;
G4Polyhedron* GetPolyhedron () const override;
void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent () const override;
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
G4Polyhedron* CreatePolyhedron() const override;
G4Polyhedron* GetPolyhedron() const override;
void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent() const override;
/**
* Loggers reporting the total allocated memory.
*/
G4int AllocatedMemoryWithoutVoxels();
G4int AllocatedMemory();
void DisplayAllocatedMemory();
private:
/**
* Initialisation/reset of data, used in constructors and operators.
*/
void Initialize();
/**
* Resetting/copying data, used in constructors and operators.
*/
void DeleteObjects ();
void CopyObjects (const G4TessellatedSolid& s);
/**
* Internal methods used for computing distances with or without voxels.
*/
G4double DistanceToOutNoVoxels(const G4ThreeVector& p,
const G4ThreeVector& v,
G4ThreeVector& aNormalVector,
@@ -228,19 +366,6 @@ class G4TessellatedSolid : public G4VSolid
G4double DistanceToInNoVoxels(const G4ThreeVector& p,
const G4ThreeVector& v,
G4double aPstep = kInfinity) const;
void SetExtremeFacets();
EInside InsideNoVoxels (const G4ThreeVector& p) const;
EInside InsideVoxels(const G4ThreeVector& aPoint) const;
void Voxelize();
void CreateVertexList();
void PrecalculateInsides();
void SetRandomVectors();
G4double DistanceToInCore(const G4ThreeVector &p, const G4ThreeVector& v,
G4double aPstep = kInfinity) const;
G4double DistanceToOutCore(const G4ThreeVector& p, const G4ThreeVector& v,
@@ -248,19 +373,65 @@ class G4TessellatedSolid : public G4VSolid
G4bool& aConvex,
G4double aPstep = kInfinity) const;
/**
* Finds those facets that have surface planes that bound the volume.
* To note that this is going to reject concave surfaces as being extreme.
*/
void SetExtremeFacets();
/**
* Internal methods used for checking if a point 'p' is inside the solid
* in presence or not of voxels.
*/
EInside InsideNoVoxels (const G4ThreeVector& p) const;
EInside InsideVoxels(const G4ThreeVector& p) const;
/**
* Performs the voxelisation of the shape, building the optimisation
* structure, according to the specified parameters.
*/
void Voxelize();
/**
* Creates a list of vertices with an additional sorted list, where all
* the items are sorted by magnitude of vertices vector.
*/
void CreateVertexList();
/**
* Utilities for preparation of voxels indeces. Used in Voxelize() function.
*/
void PrecalculateInsides();
G4int SetAllUsingStack(const std::vector<G4int>& voxel,
const std::vector<G4int>& max,
G4bool status, G4SurfBits& checked);
void DeleteObjects ();
void CopyObjects (const G4TessellatedSolid& s);
/**
* Utility to compare sorted voxels.
*/
static G4bool CompareSortedVoxel(const std::pair<G4int, G4double>& l,
const std::pair<G4int, G4double>& r);
/**
* Prepares a set of predefined random vectors, used to generate rays
* from a user-defined point. Used in Inside() function to determine
* whether the point is inside or outside of the tessellated solid.
* All vectors should be unit vectors.
*/
void SetRandomVectors();
/**
* Computes the minimum distance of a point 'p' from a 'facet'.
*/
G4double MinDistanceFacet(const G4ThreeVector& p, G4bool simple,
G4VFacet* &facet) const;
/**
* Computes if a point 'p' is outside or not of the computed extent,
* given a 'tolerance'. Used internally in Inside() functions.
* @returns true if the point is within the extent.
*/
inline G4bool OutsideOfExtent(const G4ThreeVector& p,
G4double tolerance = 0.0) const;
@@ -299,10 +470,10 @@ class G4TessellatedSolid : public G4VSolid
};
///////////////////////////////////////////////////////////////////////////////
// Inlined Methods
// Inline Methods
///////////////////////////////////////////////////////////////////////////////
inline G4VFacet *G4TessellatedSolid::GetFacet (G4int i) const
inline G4VFacet* G4TessellatedSolid::GetFacet (G4int i) const
{
return fFacets[i];
}
@@ -312,7 +483,7 @@ inline void G4TessellatedSolid::SetMaxVoxels(G4int max)
fVoxels.SetMaxVoxels(max);
}
inline G4Voxelizer &G4TessellatedSolid::GetVoxels()
inline G4Voxelizer& G4TessellatedSolid::GetVoxels()
{
return fVoxels;
}
@@ -31,10 +31,10 @@
//
// Class description:
//
// A G4Tet is a tetrahedra solid.
// A G4Tet is a tetrahedra solid, defined by 4 points in space.
// 03.09.2004 - M.H.Mendenhall & R.A.Weller (Vanderbilt University, USA)
// 08.01.2020 - E.Tcherniaev, complete revision, speed up
// Author: M.H.Mendenhall & R.A.Weller (Vanderbilt University, USA), 03.09.2004
// E.Tcherniaev (CERN), 08.01.2020 - Complete revision, speed up
// --------------------------------------------------------------------
#ifndef G4TET_HH
#define G4TET_HH
@@ -52,53 +52,95 @@
#include "G4VSolid.hh"
/**
* @brief G4Tet is a tetrahedra solid, defined by 4 points in space.
*/
class G4Tet : public G4VSolid
{
public:
/**
* Constructs a tetrahedra, given its parameters.
* @param[in] pName The solid name.
* @param[in] anchor The anchor point.
* @param[in] p2 Point 2.
* @param[in] p3 Point 3.
* @param[in] p4 Point 4.
* @param[in] degeneracyFlag Flag indicating degeneracy of points.
*/
G4Tet(const G4String& pName,
const G4ThreeVector& anchor,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
const G4ThreeVector& p4,
G4bool* degeneracyFlag = nullptr);
/**
* Destructor.
*/
~G4Tet() override;
/**
* Modifier and accessors, for the four vertices of the shape.
*/
void SetVertices(const G4ThreeVector& anchor,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
G4bool* degeneracyFlag = nullptr);
// Accessors, return the four vertices of the shape
void GetVertices(G4ThreeVector& anchor,
G4ThreeVector& p1,
G4ThreeVector& p2,
G4ThreeVector& p3) const;
std::vector<G4ThreeVector> GetVertices() const;
// Set warning flag - deprecated (dummy)
inline void PrintWarnings(G4bool) {};
// Return true if the tetrahedron is degenerate
/**
* Checks if the tetrahedron is degenerate. A tetrahedron is considered
* as degenerate in case its minimal height is less than the degeneracy
* tolerance
* @returns true if the tetrahedron is degenerate.
*/
G4bool CheckDegeneracy(const G4ThreeVector& p0,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3) const;
// Standard methods
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void SetBoundingLimits(const G4ThreeVector& pMin, const G4ThreeVector& pMax);
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
EInside Inside(const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override;
G4double DistanceToIn(const G4ThreeVector& p,
@@ -111,45 +153,75 @@ class G4Tet : public G4VSolid
G4ThreeVector* n = nullptr) const override;
G4double DistanceToOut(const G4ThreeVector& p) const override;
/**
* Returns the type ID, "G4Tet" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Returns true as the solid has only planar faces.
*/
G4bool IsFaceted () const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
// Methods for visualization
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent () const override;
G4Polyhedron* CreatePolyhedron () const override;
G4Polyhedron* GetPolyhedron () const override;
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4Tet(__void__&);
// Copy constructor
/**
* Copy constructor and assignment operator.
*/
G4Tet(const G4Tet& rhs);
// Assignment operator
G4Tet& operator=(const G4Tet& rhs);
private:
// Set data members
/**
* Initialises the data members.
*/
void Initialize(const G4ThreeVector& p0,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3);
// Return normal to surface closest to p
/**
* Algorithm for SurfaceNormal() following the original specification
* for points not on the surface.
*/
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
private:
@@ -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
@@ -0,0 +1,89 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Implementation of inline methods of G4TriangularFacet
// --------------------------------------------------------------------
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];
}
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;
}
@@ -29,7 +29,7 @@
//
// G4TwistBoxSide describes a twisted boundary surface for a trapezoid.
// Author: 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
// Author: Oliver Link (CERN), 27.10.2004 - Created
// --------------------------------------------------------------------
#ifndef G4TWISTBOXSIDE_HH
#define G4TWISTBOXSIDE_HH
@@ -38,15 +38,35 @@
#include <vector>
/**
* @brief G4TwistBoxSide describes a twisted boundary surface for a trapezoid.
*/
class G4TwistBoxSide : public G4VTwistSurface
{
public:
/**
* Constructs a trapezoid twisted boundary surface, given its parameters.
* @param[in] name The surface name.
* @param[in] PhiTwist The twist angle.
* @param[in] pDz Half z length.
* @param[in] pTheta Direction between end planes - polar angle.
* @param[in] pPhi Direction between end planes - azimuthal angle.
* @param[in] pDy1 Half y length at -pDz.
* @param[in] pDx1 Half x length at -pDz,-pDy.
* @param[in] pDx2 Half x length at -pDz,+pDy.
* @param[in] pDy2 Half y length at +pDz.
* @param[in] pDx3 Half x length at +pDz,-pDy.
* @param[in] pDx4 Half x length at +pDz,+pDy.
* @param[in] pAlph Tilt angle at +pDz.
* @param[in] AngleSide Parity.
*/
G4TwistBoxSide(const G4String& name,
G4double PhiTwist, // twist angle
G4double pDz, // half z lenght
G4double pDz, // half z length
G4double pTheta, // direction between end planes
G4double pPhi, // by polar and azimutal angles
G4double pPhi, // by polar and azimuthal angles
G4double pDy1, // half y length at -pDz
G4double pDx1, // half x length at -pDz,-pDy
G4double pDx2, // half x length at -pDz,+pDy
@@ -57,48 +77,100 @@ class G4TwistBoxSide : public G4VTwistSurface
G4double AngleSide // parity
);
~G4TwistBoxSide() override;
/**
* Default destructor.
*/
~G4TwistBoxSide() override = default;
G4ThreeVector GetNormal(const G4ThreeVector& xx,
G4bool isGlobal = false) override ;
/**
* Returns a normal vector at a surface (or very close to the surface)
* point at 'p'.
* @param[in] p The point where computing the normal.
* @param[in] isGlobal If true, it returns the normal in global coordinates.
* @returns The normal vector.
*/
G4ThreeVector GetNormal(const G4ThreeVector& p,
G4bool isGlobal = false) override ;
/**
* Returns the distance to surface, given point 'gp' and direction 'gv'.
* @param[in] gp The point from where computing the distance.
* @param[in] gv The direction along which computing the distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @param[out] isvalid Validity vector based on number of solutions.
* @param[in] validate Adopted validation criteria.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
EValidate validate = kValidateWithTol) override;
/**
* Returns the safety distance to surface, given point 'gp'.
* @param[in] gp The point from where computing the safety distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) override;
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistBoxSide(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
private:
/**
* Returns the area code for point 'xx' using or not surface tolerance.
*/
G4int GetAreaCode(const G4ThreeVector& xx,
G4bool withTol = true) override;
/**
* Setters.
*/
void SetCorners() override;
void SetBoundaries() override;
/**
* Finds the closest point on surface for a given point 'p', returning
* 'phi' and 'u'.
*/
void GetPhiUAtX(const G4ThreeVector& p, G4double& phi, G4double& u);
/**
* Returns projection on surface of a given point 'p'.
*/
G4ThreeVector ProjectPoint(const G4ThreeVector& p,
G4bool isglobal = false);
/**
* Returns point on surface given 'phi' and 'u'.
*/
inline G4ThreeVector SurfacePoint(G4double phi, G4double u,
G4bool isGlobal = false) override;
/**
* Internal accessors.
*/
inline G4double GetBoundaryMin(G4double phi) override;
inline G4double GetBoundaryMax(G4double phi) override;
inline G4double GetSurfaceArea() override;
void GetFacets( G4int m, G4int n, G4double xyz[][3],
G4int faces[][4], G4int iside ) override;
inline G4double GetValueA(G4double phi);
inline G4double GetValueB(G4double phi);
inline G4ThreeVector NormAng(G4double phi, G4double u);
@@ -144,77 +216,6 @@ class G4TwistBoxSide : public G4VTwistSurface
// inline functions
//========================================================
inline
G4double G4TwistBoxSide::GetValueA(G4double phi)
{
return ( fDx4plus2 + fDx4minus2 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistBoxSide::GetValueB(G4double phi)
{
return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistBoxSide::Xcoef(G4double u, G4double phi)
{
return GetValueA(phi)/2. + u*fTAlph ;
}
inline G4ThreeVector
G4TwistBoxSide::SurfacePoint( G4double phi, G4double u, G4bool isGlobal )
{
// function to calculate a point on the surface, given by parameters phi,u
G4ThreeVector SurfPoint ( Xcoef(u,phi) * std::cos(phi)
- u * std::sin(phi) + fdeltaX*phi/fPhiTwist,
Xcoef(u,phi) * std::sin(phi)
+ u * std::cos(phi) + fdeltaY*phi/fPhiTwist,
2*fDz*phi/fPhiTwist );
if (isGlobal) { return (fRot * SurfPoint + fTrans); }
return SurfPoint;
}
inline
G4double G4TwistBoxSide::GetBoundaryMin(G4double phi)
{
return -0.5*GetValueB(phi) ;
}
inline
G4double G4TwistBoxSide::GetBoundaryMax(G4double phi)
{
return 0.5*GetValueB(phi) ;
}
inline
G4double G4TwistBoxSide::GetSurfaceArea()
{
return (fDz*(std::sqrt(16*fDy1*fDy1
+ (fa1md1 + 4*fDy1*fTAlph)*(fa1md1 + 4*fDy1*fTAlph))
+ std::sqrt(16*fDy1*fDy1 + (fa2md2 + 4*fDy1*fTAlph)
* (fa2md2 + 4*fDy1*fTAlph))))/2. ;
}
inline
G4ThreeVector G4TwistBoxSide::NormAng( G4double phi, G4double u )
{
// function to calculate the norm at a given point on the surface
// replace a1-d1
G4ThreeVector nvec( 4*fDz*(std::cos(phi) + fTAlph*std::sin(phi)) ,
4*fDz*(-(fTAlph*std::cos(phi)) + std::sin(phi)),
(fDx2 + fDx4)*fPhiTwist*fTAlph
+ 2*fDx4minus2*(-1 + fTAlph*phi)
+ 2*fPhiTwist*(1 + fTAlph*fTAlph)*u
- 2*(fdeltaX - fdeltaY*fTAlph)*std::cos(phi)
- 2*(fdeltaY + fdeltaX*fTAlph)*std::sin(phi) );
return nvec.unit();
}
#include "G4TwistBoxSide.icc"
#endif
@@ -0,0 +1,100 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Implementation of inline methods of G4TwistBoxSide
// --------------------------------------------------------------------
inline
G4double G4TwistBoxSide::GetValueA(G4double phi)
{
return ( fDx4plus2 + fDx4minus2 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistBoxSide::GetValueB(G4double phi)
{
return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistBoxSide::Xcoef(G4double u, G4double phi)
{
return GetValueA(phi)/2. + u*fTAlph ;
}
inline G4ThreeVector
G4TwistBoxSide::SurfacePoint( G4double phi, G4double u, G4bool isGlobal )
{
// function to calculate a point on the surface, given by parameters phi,u
G4ThreeVector SurfPoint ( Xcoef(u,phi) * std::cos(phi)
- u * std::sin(phi) + fdeltaX*phi/fPhiTwist,
Xcoef(u,phi) * std::sin(phi)
+ u * std::cos(phi) + fdeltaY*phi/fPhiTwist,
2*fDz*phi/fPhiTwist );
if (isGlobal) { return (fRot * SurfPoint + fTrans); }
return SurfPoint;
}
inline
G4double G4TwistBoxSide::GetBoundaryMin(G4double phi)
{
return -0.5*GetValueB(phi) ;
}
inline
G4double G4TwistBoxSide::GetBoundaryMax(G4double phi)
{
return 0.5*GetValueB(phi) ;
}
inline
G4double G4TwistBoxSide::GetSurfaceArea()
{
return (fDz*(std::sqrt(16*fDy1*fDy1
+ (fa1md1 + 4*fDy1*fTAlph)*(fa1md1 + 4*fDy1*fTAlph))
+ std::sqrt(16*fDy1*fDy1 + (fa2md2 + 4*fDy1*fTAlph)
* (fa2md2 + 4*fDy1*fTAlph))))/2. ;
}
inline
G4ThreeVector G4TwistBoxSide::NormAng( G4double phi, G4double u )
{
// function to calculate the norm at a given point on the surface
// replace a1-d1
G4ThreeVector nvec( 4*fDz*(std::cos(phi) + fTAlph*std::sin(phi)) ,
4*fDz*(-(fTAlph*std::cos(phi)) + std::sin(phi)),
(fDx2 + fDx4)*fPhiTwist*fTAlph
+ 2*fDx4minus2*(-1 + fTAlph*phi)
+ 2*fPhiTwist*(1 + fTAlph*fTAlph)*u
- 2*(fdeltaX - fdeltaY*fTAlph)*std::cos(phi)
- 2*(fdeltaY + fdeltaX*fTAlph)*std::sin(phi) );
return nvec.unit();
}
@@ -29,7 +29,7 @@
//
// Class describing a twisted boundary surface for a trapezoid.
// Author: 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
// Author: Oliver Link (CERN), 27.10.2004 - Created
// --------------------------------------------------------------------
#ifndef G4TWISTTRAPALPHASIDE_HH
#define G4TWISTTRAPALPHASIDE_HH
@@ -38,10 +38,31 @@
#include <vector>
/**
* @brief G4TwistTrapAlphaSide describes a twisted boundary surface
* for a trapezoid.
*/
class G4TwistTrapAlphaSide : public G4VTwistSurface
{
public:
/**
* Constructs a trapezoid twisted boundary surface, given its parameters.
* @param[in] name The surface name.
* @param[in] PhiTwist The twist angle.
* @param[in] pDz Half z length.
* @param[in] pTheta Direction between end planes - polar angle.
* @param[in] pPhi Direction between end planes - azimuthal angle.
* @param[in] pDy1 Half y length at -pDz.
* @param[in] pDx1 Half x length at -pDz,-pDy.
* @param[in] pDx2 Half x length at -pDz,+pDy.
* @param[in] pDy2 Half y length at +pDz.
* @param[in] pDx3 Half x length at +pDz,-pDy.
* @param[in] pDx4 Half x length at +pDz,+pDy.
* @param[in] pAlph Tilt angle at +pDz.
* @param[in] AngleSide Parity.
*/
G4TwistTrapAlphaSide(const G4String& name,
G4double PhiTwist, // twist angle
G4double pDz, // half z lenght
@@ -57,48 +78,100 @@ class G4TwistTrapAlphaSide : public G4VTwistSurface
G4double AngleSide // parity
);
~G4TwistTrapAlphaSide() override;
/**
* Default destructor.
*/
~G4TwistTrapAlphaSide() override = default;
G4ThreeVector GetNormal(const G4ThreeVector& xx,
G4bool isGlobal = false) override ;
/**
* Returns a normal vector at a surface (or very close to the surface)
* point at 'p'.
* @param[in] p The point where computing the normal.
* @param[in] isGlobal If true, it returns the normal in global coordinates.
* @returns The normal vector.
*/
G4ThreeVector GetNormal(const G4ThreeVector& p,
G4bool isGlobal = false) override ;
/**
* Returns the distance to surface, given point 'gp' and direction 'gv'.
* @param[in] gp The point from where computing the distance.
* @param[in] gv The direction along which computing the distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @param[out] isvalid Validity vector based on number of solutions.
* @param[in] validate Adopted validation criteria.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
EValidate validate = kValidateWithTol) override;
/**
* Returns the safety distance to surface, given point 'gp'.
* @param[in] gp The point from where computing the safety distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) override;
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistTrapAlphaSide(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
private:
/**
* Returns the area code for point 'xx' using or not surface tolerance.
*/
G4int GetAreaCode(const G4ThreeVector& xx,
G4bool withTol = true) override;
/**
* Setters.
*/
void SetCorners() override;
void SetBoundaries() override;
/**
* Finds the closest point on surface for a given point 'p', returning
* 'phi' and 'u'.
*/
void GetPhiUAtX(const G4ThreeVector& p, G4double& phi, G4double& u);
/**
* Returns projection on surface of a given point 'p'.
*/
G4ThreeVector ProjectPoint(const G4ThreeVector& p,
G4bool isglobal = false);
/**
* Returns point on surface given 'phi' and 'u'.
*/
inline G4ThreeVector SurfacePoint(G4double phi, G4double u,
G4bool isGlobal = false ) override;
/**
* Internal accessors.
*/
inline G4double GetBoundaryMin(G4double phi) override;
inline G4double GetBoundaryMax(G4double phi) override;
inline G4double GetSurfaceArea() override;
void GetFacets( G4int m, G4int n, G4double xyz[][3],
G4int faces[][4], G4int iside ) override;
inline G4ThreeVector NormAng(G4double phi, G4double u);
inline G4double GetValueA(G4double phi);
inline G4double GetValueB(G4double phi);
@@ -145,92 +218,6 @@ class G4TwistTrapAlphaSide : public G4VTwistSurface
// inline functions
//========================================================
inline
G4double G4TwistTrapAlphaSide::GetValueA(G4double phi)
{
return ( fDx4plus2 + fDx4minus2 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistTrapAlphaSide::GetValueD(G4double phi)
{
return ( fDx3plus1 + fDx3minus1 * ( 2 * phi) / fPhiTwist ) ;
}
inline
G4double G4TwistTrapAlphaSide::GetValueB(G4double phi)
{
return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistTrapAlphaSide::Xcoef(G4double u, G4double phi)
{
return GetValueA(phi)/2. + (GetValueD(phi)-GetValueA(phi))/4.
- u*( ( GetValueD(phi)-GetValueA(phi) )/( 2 * GetValueB(phi) ) - fTAlph );
}
inline G4ThreeVector
G4TwistTrapAlphaSide::SurfacePoint(G4double phi, G4double u , G4bool isGlobal)
{
// function to calculate a point on the surface, given by parameters phi,u
G4ThreeVector SurfPoint ( Xcoef(u,phi) * std::cos(phi)
- u * std::sin(phi) + fdeltaX*phi/fPhiTwist,
Xcoef(u,phi) * std::sin(phi)
+ u * std::cos(phi) + fdeltaY*phi/fPhiTwist,
2*fDz*phi/fPhiTwist );
if (isGlobal) { return (fRot * SurfPoint + fTrans); }
return SurfPoint;
}
inline
G4double G4TwistTrapAlphaSide::GetBoundaryMin(G4double phi)
{
return -0.5*GetValueB(phi) ;
}
inline
G4double G4TwistTrapAlphaSide::GetBoundaryMax(G4double phi)
{
return 0.5*GetValueB(phi) ;
}
inline
G4double G4TwistTrapAlphaSide::GetSurfaceArea()
{
return (fDz*(std::sqrt(16*fDy1*fDy1
+ (fa1md1 + 4*fDy1*fTAlph)*(fa1md1 + 4*fDy1*fTAlph))
+ std::sqrt(16*fDy2*fDy2 + (fa2md2 + 4*fDy2*fTAlph)
* (fa2md2 + 4*fDy2*fTAlph))))/2. ;
}
inline
G4ThreeVector G4TwistTrapAlphaSide::NormAng( G4double phi, G4double u )
{
// function to calculate the norm at a given point on the surface
// replace a1-d1
G4ThreeVector nvec ( fDy1* fDz*(4*fDy1*std::cos(phi)
+ (fa1md1 + 4*fDy1*fTAlph)*std::sin(phi)),
-(fDy1* fDz*((fa1md1 + 4*fDy1*fTAlph)*std::cos(phi)
- 4*fDy1*std::sin(phi))),
(fDy1*(-8*(fDx3minus1 + fDx4minus2)*fDy1
+ fa1md1*(fDx2 + fDx3plus1 + fDx4)*fPhiTwist
+ 4*(fDx2 + fDx3plus1 + fDx4)*fDy1*fPhiTwist
*fTAlph + 2*(fDx3minus1 + fDx4minus2)
*(fa1md1 + 4*fDy1*fTAlph)*phi)
+ fPhiTwist*(16*fDy1*fDy1
+ (fa1md1 + 4*fDy1*fTAlph)
*(fa1md1 + 4*fDy1*fTAlph))*u
+ 4*fDy1*(fa1md1*fdeltaY - 4*fdeltaX*fDy1
+ 4*fdeltaY*fDy1*fTAlph)* std::cos(phi)
- 4*fDy1*(fa1md1*fdeltaX + 4*fDy1*(fdeltaY
+ fdeltaX*fTAlph))*std::sin(phi))/ 8. ) ;
return nvec.unit();
}
#include "G4TwistTrapAlphaSide.icc"
#endif
@@ -0,0 +1,115 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Implementation of inline methods of G4TwistTrapAlphaSide.
// --------------------------------------------------------------------
inline
G4double G4TwistTrapAlphaSide::GetValueA(G4double phi)
{
return ( fDx4plus2 + fDx4minus2 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistTrapAlphaSide::GetValueD(G4double phi)
{
return ( fDx3plus1 + fDx3minus1 * ( 2 * phi) / fPhiTwist ) ;
}
inline
G4double G4TwistTrapAlphaSide::GetValueB(G4double phi)
{
return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistTrapAlphaSide::Xcoef(G4double u, G4double phi)
{
return GetValueA(phi)/2. + (GetValueD(phi)-GetValueA(phi))/4.
- u*( ( GetValueD(phi)-GetValueA(phi) )/( 2 * GetValueB(phi) ) - fTAlph );
}
inline G4ThreeVector
G4TwistTrapAlphaSide::SurfacePoint(G4double phi, G4double u , G4bool isGlobal)
{
// function to calculate a point on the surface, given by parameters phi,u
G4ThreeVector SurfPoint ( Xcoef(u,phi) * std::cos(phi)
- u * std::sin(phi) + fdeltaX*phi/fPhiTwist,
Xcoef(u,phi) * std::sin(phi)
+ u * std::cos(phi) + fdeltaY*phi/fPhiTwist,
2*fDz*phi/fPhiTwist );
if (isGlobal) { return (fRot * SurfPoint + fTrans); }
return SurfPoint;
}
inline
G4double G4TwistTrapAlphaSide::GetBoundaryMin(G4double phi)
{
return -0.5*GetValueB(phi) ;
}
inline
G4double G4TwistTrapAlphaSide::GetBoundaryMax(G4double phi)
{
return 0.5*GetValueB(phi) ;
}
inline
G4double G4TwistTrapAlphaSide::GetSurfaceArea()
{
return (fDz*(std::sqrt(16*fDy1*fDy1
+ (fa1md1 + 4*fDy1*fTAlph)*(fa1md1 + 4*fDy1*fTAlph))
+ std::sqrt(16*fDy2*fDy2 + (fa2md2 + 4*fDy2*fTAlph)
* (fa2md2 + 4*fDy2*fTAlph))))/2. ;
}
inline
G4ThreeVector G4TwistTrapAlphaSide::NormAng( G4double phi, G4double u )
{
// function to calculate the norm at a given point on the surface
// replace a1-d1
G4ThreeVector nvec ( fDy1* fDz*(4*fDy1*std::cos(phi)
+ (fa1md1 + 4*fDy1*fTAlph)*std::sin(phi)),
-(fDy1* fDz*((fa1md1 + 4*fDy1*fTAlph)*std::cos(phi)
- 4*fDy1*std::sin(phi))),
(fDy1*(-8*(fDx3minus1 + fDx4minus2)*fDy1
+ fa1md1*(fDx2 + fDx3plus1 + fDx4)*fPhiTwist
+ 4*(fDx2 + fDx3plus1 + fDx4)*fDy1*fPhiTwist
*fTAlph + 2*(fDx3minus1 + fDx4minus2)
*(fa1md1 + 4*fDy1*fTAlph)*phi)
+ fPhiTwist*(16*fDy1*fDy1
+ (fa1md1 + 4*fDy1*fTAlph)
*(fa1md1 + 4*fDy1*fTAlph))*u
+ 4*fDy1*(fa1md1*fdeltaY - 4*fdeltaX*fDy1
+ 4*fdeltaY*fDy1*fTAlph)* std::cos(phi)
- 4*fDy1*(fa1md1*fdeltaX + 4*fDy1*(fdeltaY
+ fdeltaX*fTAlph))*std::sin(phi))/ 8. ) ;
return nvec.unit();
}
@@ -23,23 +23,40 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4FlatTrapSurface
// G4TwistTrapFlatSide
//
// Class description:
//
// Class describing a flat boundary surface for a trapezoid.
// Author: 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
// Author: Oliver Link (CERN), 27.10.2004 - Created
// --------------------------------------------------------------------
#ifndef G4TWISTTRAPFLATSIDE_HH
#define G4TWISTTRAPFLATSIDE_HH
#include "G4VTwistSurface.hh"
/**
* @brief G4TwistTrapFlatSide describes a flat boundary surface for a trapezoid.
*/
class G4TwistTrapFlatSide : public G4VTwistSurface
{
public:
/**
* Constructs a trapezoid flat boundary surface, given its parameters.
* @param[in] name The surface name.
* @param[in] PhiTwist The twist angle.
* @param[in] pDx1 Half x length at -pDz,-pDy.
* @param[in] pDx2 Half x length at -pDz,+pDy.
* @param[in] pDy Half y length.
* @param[in] pDz Half z length.
* @param[in] pAlpha Tilt angle at +pDz.
* @param[in] pPhi Direction between end planes - azimuthal angle.
* @param[in] pTheta Direction between end planes - polar angle.
* @param[in] handedness Orientation: +z = +ve, -z = -ve.
*/
G4TwistTrapFlatSide( const G4String& name,
G4double PhiTwist,
G4double pDx1,
@@ -50,10 +67,33 @@ class G4TwistTrapFlatSide : public G4VTwistSurface
G4double pPhi,
G4double pTheta,
G4int handedness );
~G4TwistTrapFlatSide() override;
G4ThreeVector GetNormal(const G4ThreeVector& /* xx */ ,
G4bool isGlobal = false) override;
/**
* Default destructor.
*/
~G4TwistTrapFlatSide() override = default;
/**
* Returns a normal vector at a surface (or very close to the surface)
* point at 'p'.
* @param[in] p Not used. Using current normal.
* @param[in] isGlobal If true, it returns the normal in global coordinates.
* @returns The current normal vector.
*/
G4ThreeVector GetNormal(const G4ThreeVector& /* p */ ,
G4bool isGlobal = false) override;
/**
* Returns the distance to surface, given point 'gp' and direction 'gv'.
* @param[in] gp The point from where computing the distance.
* @param[in] gv The direction along which computing the distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @param[out] isvalid Validity vector based on number of solutions.
* @param[in] validate Adopted validation criteria.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector gxx[],
@@ -62,36 +102,56 @@ class G4TwistTrapFlatSide : public G4VTwistSurface
G4bool isvalid[],
EValidate validate = kValidateWithTol) override;
/**
* Returns the safety distance to surface, given point 'gp'.
* @param[in] gp The point from where computing the safety distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistTrapFlatSide(__void__&);
private:
/**
* Returns point on surface given 'phi' and 'u'.
*/
inline G4ThreeVector SurfacePoint(G4double x, G4double y,
G4bool isGlobal = false) override;
/**
* Internal accessors.
*/
inline G4double GetBoundaryMin(G4double u) override;
inline G4double GetBoundaryMax(G4double u) override;
inline G4double GetSurfaceArea() override;
void GetFacets( G4int m, G4int n, G4double xyz[][3],
G4int faces[][4], G4int iside ) override;
inline G4double xAxisMax(G4double u, G4double fTanAlpha) const;
G4TwistTrapFlatSide(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
protected:
G4int GetAreaCode(const G4ThreeVector& xx,
G4bool withTol = true) override;
private:
/**
* Setters.
*/
void SetCorners() override;
void SetBoundaries() override;
inline G4double xAxisMax(G4double u, G4double fTanAlpha) const;
/**
* Returns the area code for point 'xx' using or not surface tolerance.
*/
G4int GetAreaCode(const G4ThreeVector& xx,
G4bool withTol = true) override;
private:
G4double fDx1;
@@ -29,7 +29,7 @@
//
// Class describing a twisted boundary surface for a trapezoid.
// Author: 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
// Author: Oliver Link (CERN), 27.10.2004 - Created
// --------------------------------------------------------------------
#ifndef G4TWISTTRAPPARALLELSIDE_HH
#define G4TWISTTRAPPARALLELSIDE_HH
@@ -38,10 +38,31 @@
#include <vector>
/**
* @brief G4TwistTrapParallelSide describes a twisted boundary surface for
* a trapezoid.
*/
class G4TwistTrapParallelSide : public G4VTwistSurface
{
public:
/**
* Constructs a trapezoid twisted boundary surface, given its parameters.
* @param[in] name The surface name.
* @param[in] PhiTwist The twist angle.
* @param[in] pDz Half z length.
* @param[in] pTheta Direction between end planes - polar angle.
* @param[in] pPhi Direction between end planes - azimuthal angle.
* @param[in] pDy1 Half y length at -pDz.
* @param[in] pDx1 Half x length at -pDz,-pDy.
* @param[in] pDx2 Half x length at -pDz,+pDy.
* @param[in] pDy2 Half y length at +pDz.
* @param[in] pDx3 Half x length at +pDz,-pDy.
* @param[in] pDx4 Half x length at +pDz,+pDy.
* @param[in] pAlph Tilt angle at +pDz.
* @param[in] AngleSide Parity.
*/
G4TwistTrapParallelSide(const G4String& name,
G4double PhiTwist, // twist angle
G4double pDz, // half z lenght
@@ -57,11 +78,32 @@ class G4TwistTrapParallelSide : public G4VTwistSurface
G4double AngleSide // parity
);
~G4TwistTrapParallelSide() override;
/**
* Default destructor.
*/
~G4TwistTrapParallelSide() override = default;
G4ThreeVector GetNormal(const G4ThreeVector& xx,
G4bool isGlobal = false) override ;
/**
* Returns a normal vector at a surface (or very close to the surface)
* point at 'p'.
* @param[in] p The point where computing the normal.
* @param[in] isGlobal If true, it returns the normal in global coordinates.
* @returns The normal vector.
*/
G4ThreeVector GetNormal(const G4ThreeVector& p,
G4bool isGlobal = false) override ;
/**
* Returns the distance to surface, given point 'gp' and direction 'gv'.
* @param[in] gp The point from where computing the distance.
* @param[in] gv The direction along which computing the distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @param[out] isvalid Validity vector based on number of solutions.
* @param[in] validate Adopted validation criteria.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector gxx[],
@@ -70,29 +112,61 @@ class G4TwistTrapParallelSide : public G4VTwistSurface
G4bool isvalid[],
EValidate validate = kValidateWithTol) override;
/**
* Returns the safety distance to surface, given point 'gp'.
* @param[in] gp The point from where computing the safety distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistTrapParallelSide(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
private:
/**
* Returns the area code for point 'xx' using or not surface tolerance.
*/
G4int GetAreaCode(const G4ThreeVector& xx,
G4bool withTol = true) override;
G4bool withTol = true) override;
/**
* Setters.
*/
void SetCorners() override;
void SetBoundaries() override;
/**
* Finds the closest point on surface for a given point 'p', returning
* 'phi' and 'u'.
*/
void GetPhiUAtX(const G4ThreeVector& p, G4double& phi, G4double& u);
/**
* Returns projection on surface of a given point 'p'.
*/
G4ThreeVector ProjectPoint(const G4ThreeVector& p,
G4bool isglobal = false);
/**
* Returns point on surface given 'phi' and 'u'.
*/
inline G4ThreeVector SurfacePoint(G4double phi, G4double u,
G4bool isGlobal = false) override;
/**
* Internal accessors.
*/
inline G4double GetBoundaryMin(G4double phi) override;
inline G4double GetBoundaryMax(G4double phi) override;
inline G4double GetSurfaceArea() override;
@@ -143,66 +217,6 @@ class G4TwistTrapParallelSide : public G4VTwistSurface
// inline functions
//========================================================
inline
G4double G4TwistTrapParallelSide::GetValueB(G4double phi)
{
return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistTrapParallelSide::Xcoef(G4double phi)
{
return GetValueB(phi)/2. ;
}
inline G4ThreeVector
G4TwistTrapParallelSide::
SurfacePoint( G4double phi, G4double u, G4bool isGlobal )
{
// function to calculate a point on the surface, given by parameters phi,u
G4ThreeVector SurfPoint ( u*std::cos(phi) - Xcoef(phi)*std::sin(phi)
+ fdeltaX*phi/fPhiTwist,
u*std::sin(phi) + Xcoef(phi)*std::cos(phi)
+ fdeltaY*phi/fPhiTwist,
2*fDz*phi/fPhiTwist );
if (isGlobal) { return (fRot * SurfPoint + fTrans); }
return SurfPoint;
}
inline
G4double G4TwistTrapParallelSide::GetBoundaryMin(G4double phi)
{
return -(fPhiTwist*(fDx2 + fDx4 - fDy2plus1*fTAlph)
+ 2*fDx4minus2*phi - 2*fDy2minus1*fTAlph*phi)/(2.*fPhiTwist) ;
}
inline
G4double G4TwistTrapParallelSide::GetBoundaryMax(G4double phi)
{
return (fDx2 + fDx4 + fDy2plus1*fTAlph)/ 2.
+ ((fDx4minus2 + fDy2minus1*fTAlph)*phi)/fPhiTwist ;
}
inline
G4double G4TwistTrapParallelSide::GetSurfaceArea()
{
return 2*fDx4plus2*fDz ;
}
inline
G4ThreeVector G4TwistTrapParallelSide::NormAng( G4double phi, G4double u )
{
// function to calculate the norm at a given point on the surface
// replace a1-d1
G4ThreeVector nvec(-2*fDz*std::sin(phi) ,
2*fDz*std::cos(phi) ,
-(fDy2minus1 + fPhiTwist*u + fdeltaY*std::cos(phi)
-fdeltaX*std::sin(phi))) ;
return nvec.unit();
}
#include "G4TwistTrapParallelSide.icc"
#endif
@@ -0,0 +1,88 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Implementation of inline methods of G4TwistTrapParallelSide.
// --------------------------------------------------------------------
inline
G4double G4TwistTrapParallelSide::GetValueB(G4double phi)
{
return ( fDy2plus1 + fDy2minus1 * ( 2 * phi ) / fPhiTwist ) ;
}
inline
G4double G4TwistTrapParallelSide::Xcoef(G4double phi)
{
return GetValueB(phi)/2. ;
}
inline G4ThreeVector
G4TwistTrapParallelSide::
SurfacePoint( G4double phi, G4double u, G4bool isGlobal )
{
// function to calculate a point on the surface, given by parameters phi,u
G4ThreeVector SurfPoint ( u*std::cos(phi) - Xcoef(phi)*std::sin(phi)
+ fdeltaX*phi/fPhiTwist,
u*std::sin(phi) + Xcoef(phi)*std::cos(phi)
+ fdeltaY*phi/fPhiTwist,
2*fDz*phi/fPhiTwist );
if (isGlobal) { return (fRot * SurfPoint + fTrans); }
return SurfPoint;
}
inline
G4double G4TwistTrapParallelSide::GetBoundaryMin(G4double phi)
{
return -(fPhiTwist*(fDx2 + fDx4 - fDy2plus1*fTAlph)
+ 2*fDx4minus2*phi - 2*fDy2minus1*fTAlph*phi)/(2.*fPhiTwist) ;
}
inline
G4double G4TwistTrapParallelSide::GetBoundaryMax(G4double phi)
{
return (fDx2 + fDx4 + fDy2plus1*fTAlph)/ 2.
+ ((fDx4minus2 + fDy2minus1*fTAlph)*phi)/fPhiTwist ;
}
inline
G4double G4TwistTrapParallelSide::GetSurfaceArea()
{
return 2*fDx4plus2*fDz ;
}
inline
G4ThreeVector G4TwistTrapParallelSide::NormAng( G4double phi, G4double u )
{
// function to calculate the norm at a given point on the surface
// replace a1-d1
G4ThreeVector nvec(-2*fDz*std::sin(phi) ,
2*fDz*std::cos(phi) ,
-(fDy2minus1 + fPhiTwist*u + fdeltaY*std::cos(phi)
-fdeltaX*std::sin(phi))) ;
return nvec.unit();
}
@@ -29,8 +29,8 @@
//
// Class describing a flat boundary surface for a cylinder.
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp), created.
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// Author: Kotoyo Hoshina (Chiba University), 01.08.2002 - Created.
// Oliver Link (CERN), 13.11.2003 - Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef G4TWISTTUBSFLATSIDE_HH
@@ -38,32 +38,82 @@
#include "G4VTwistSurface.hh"
/**
* @brief G4TwistTubsFlatSide describes a flat boundary surface for a cylinder.
*/
class G4TwistTubsFlatSide : public G4VTwistSurface
{
public:
G4TwistTubsFlatSide(const G4String& name,
/**
* Constructs a cylinder flat boundary surface, given its parameters.
* @param[in] name The surface name.
* @param[in] rot Rotation.
* @param[in] tlate Translation.
* @param[in] n Normal vector.
* @param[in] axis0 Rho axis.
* @param[in] axis1 Phi axis.
* @param[in] axis0min Minimum in Rho.
* @param[in] axis1min Minimum in Phi.
* @param[in] axis0max Maximum in Rho.
* @param[in] axis1max Maximum in Phi.
*/
G4TwistTubsFlatSide(const G4String& name,
const G4RotationMatrix& rot,
const G4ThreeVector& tlate,
const G4ThreeVector& n,
const EAxis axis1 = kRho, // RHO axis !
const EAxis axis2 = kPhi, // PHI axis !
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity);
const G4ThreeVector& tlate,
const G4ThreeVector& n,
const EAxis axis0 = kRho, // RHO axis !
const EAxis axis1 = kPhi, // PHI axis !
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity);
G4TwistTubsFlatSide(const G4String& name,
G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
G4double DPhi,
G4double EndPhi[2],
G4double EndZ[2],
G4int handedness);
/**
* Alternative Construct for a cylinder flat boundary surface.
* @param[in] name The surface name.
* @param[in] EndInnerRadius Inner-hype radius at z=0.
* @param[in] EndOuterRadius Outer-hype radius at z=0.
* @param[in] DPhi Phi angle.
* @param[in] EndPhi Total Phi.
* @param[in] EndZ Z length.
* @param[in] handedness Orientation: +z = +ve, -z = -ve.
*/
G4TwistTubsFlatSide(const G4String& name,
G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
G4double DPhi,
G4double EndPhi[2],
G4double EndZ[2],
G4int handedness);
~G4TwistTubsFlatSide() override;
G4ThreeVector GetNormal(const G4ThreeVector& /* xx */ ,
G4bool isGlobal = false) override;
/**
* Default destructor.
*/
~G4TwistTubsFlatSide() override = default;
/**
* Returns a normal vector at a surface (or very close to the surface)
* point at 'p'.
* @param[in] p Not used. Using current normal.
* @param[in] isGlobal If true, it returns the normal in global coordinates.
* @returns The current normal vector.
*/
G4ThreeVector GetNormal(const G4ThreeVector& /* p */ ,
G4bool isGlobal = false) override;
/**
* Returns the distance to surface, given point 'gp' and direction 'gv'.
* @param[in] gp The point from where computing the distance.
* @param[in] gv The direction along which computing the distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @param[out] isvalid Validity vector based on number of solutions.
* @param[in] validate Adopted validation criteria.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector gxx[],
@@ -72,31 +122,52 @@ class G4TwistTubsFlatSide : public G4VTwistSurface
G4bool isvalid[],
EValidate validate = kValidateWithTol) override;
/**
* Returns the safety distance to surface, given point 'gp'.
* @param[in] gp The point from where computing the safety distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistTubsFlatSide(__void__&);
private:
/**
* Returns point on surface given 'phi' and 'u'.
*/
inline G4ThreeVector SurfacePoint(G4double, G4double,
G4bool isGlobal = false) override;
/**
* Internal accessors.
*/
inline G4double GetBoundaryMin(G4double phi) override;
inline G4double GetBoundaryMax(G4double phi) override;
inline G4double GetSurfaceArea() override { return fSurfaceArea ; }
void GetFacets( G4int m, G4int n, G4double xyz[][3],
G4int faces[][4], G4int iside ) override;
G4TwistTubsFlatSide(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
protected:
/**
* Returns the area code for point 'xx' using or not surface tolerance.
*/
G4int GetAreaCode(const G4ThreeVector& xx,
G4bool withTol = true) override ;
private:
/**
* Setters.
*/
void SetCorners() override;
void SetBoundaries() override;
@@ -105,6 +176,10 @@ class G4TwistTubsFlatSide : public G4VTwistSurface
G4double fSurfaceArea = 0.0;
};
//========================================================
// inline functions
//========================================================
inline G4ThreeVector G4TwistTubsFlatSide::
SurfacePoint(G4double phi , G4double rho , G4bool isGlobal )
{
@@ -29,8 +29,8 @@
//
// Class describing a hyperbolic boundary surface for a cylinder.
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp), created.
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// Author: Kotoyo Hoshina (Chiba University), 01.08.2002 - Created.
// Oliver Link (CERN), 13.11.2003 - Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef G4TWISTTUBSHYPESIDE_HH
@@ -40,24 +40,60 @@
#include "G4Integrator.hh"
#include "G4SimpleIntegration.hh"
/**
* @brief G4TwistTubsHypeSide describes hyperbolic boundary surface
* for a cylinder.
*/
class G4TwistTubsHypeSide : public G4VTwistSurface
{
public:
G4TwistTubsHypeSide(const G4String& name,
/**
* Constructs a cylinder hyperbolic boundary surface, given its parameters.
* @param[in] name The surface name.
* @param[in] rot Rotation: 0.5*(phi-width segment).
* @param[in] tlate Translation.
* @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
* @param[in] kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
* @param[in] tanstereo Tangent of the stereo angle.
* @param[in] r0 Radius at z = 0.
* @param[in] axis0 Phi axis.
* @param[in] axis1 Z axis.
* @param[in] axis0min Minimum in Phi.
* @param[in] axis1min Minimum in Z.
* @param[in] axis0max Maximum in Phi.
* @param[in] axis1max Maximum in Z.
*/
G4TwistTubsHypeSide(const G4String& name,
const G4RotationMatrix& rot, // 0.5*(phi-width segment)
const G4ThreeVector& tlate,
const G4int handedness,// R-hand = 1, L-hand = -1
const G4double kappa, // tan(TwistAngle/2)/fZHalfLen
const G4double tanstereo, // tan(stereo angle)
const G4double r0, // radius at z = 0
const EAxis axis0 = kPhi,
const EAxis axis1 = kZAxis,
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity);
const G4ThreeVector& tlate,
const G4int handedness, // R-hand = 1, L-hand = -1
const G4double kappa, // tan(TwistAngle/2)/fZHalfLen
const G4double tanstereo, // tan(stereo angle)
const G4double r0, // radius at z = 0
const EAxis axis0 = kPhi,
const EAxis axis1 = kZAxis,
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity);
/**
* Alternative Construct for a cylinder hyperbolic boundary surface.
* @param[in] name The surface name.
* @param[in] EndInnerRadius Inner-hype radius at z=0.
* @param[in] EndOuterRadius Outer-hype radius at z=0.
* @param[in] DPhi Phi angle.
* @param[in] EndPhi Total Phi.
* @param[in] EndZ Z length.
* @param[in] InnerRadius Inner radius.
* @param[in] OuterRadius Outer radius.
* @param[in] Kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
* @param[in] TanInnerStereo Tangent inner stereo angle.
* @param[in] TanOuterStereo Tangent outer stereo angle.
* @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
*/
G4TwistTubsHypeSide(const G4String& name,
G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
@@ -71,8 +107,22 @@ class G4TwistTubsHypeSide : public G4VTwistSurface
G4double TanOuterStereo,
G4int handedness) ;
~G4TwistTubsHypeSide() override;
/**
* Default destructor.
*/
~G4TwistTubsHypeSide() override = default;
/**
* Returns the distance to surface, given point 'gp' and direction 'gv'.
* @param[in] gp The point from where computing the distance.
* @param[in] gv The direction along which computing the distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @param[out] isvalid Validity vector based on number of solutions.
* @param[in] validate Adopted validation criteria.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector gxx[],
@@ -81,62 +131,100 @@ class G4TwistTubsHypeSide : public G4VTwistSurface
G4bool isvalid[],
EValidate validate = kValidateWithTol) override;
/**
* Returns the safety distance to surface, given point 'gp'.
* @param[in] gp The point from where computing the safety distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) override;
G4ThreeVector GetNormal(const G4ThreeVector& xx,
/**
* Returns a normal vector at a surface (or very close to the surface)
* point at 'p'.
* @param[in] p The point where computing the normal.
* @param[in] isGlobal If true, it returns the normal in global coordinates.
* @returns The normal vector.
*/
G4ThreeVector GetNormal(const G4ThreeVector& p,
G4bool isGlobal = false) override ;
/**
* Returns if point at 'gp' is inside surface.
*/
EInside Inside(const G4ThreeVector& gp) ;
/**
* Gets Rho at p.z() on Hyperbolic Surface.
*/
inline G4double GetRhoAtPZ(const G4ThreeVector& p,
G4bool isglobal = false) const ;
inline G4ThreeVector SurfacePoint(G4double, G4double,
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistTubsHypeSide(__void__&);
private:
/**
* Returns point on surface given 'phi' and 'z'.
*/
inline G4ThreeVector SurfacePoint(G4double phi, G4double z,
G4bool isGlobal = false) override ;
/**
* Internal accessors.
*/
inline G4double GetBoundaryMin(G4double phi) override ;
inline G4double GetBoundaryMax(G4double phi) override ;
inline G4double GetSurfaceArea() override ;
void GetFacets( G4int m, G4int n, G4double xyz[][3],
G4int faces[][4], G4int iside ) override ;
G4TwistTubsHypeSide(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Returns the area code for point 'xx' using or not surface tolerance.
*/
G4int GetAreaCode(const G4ThreeVector& xx,
G4bool withTol = true) override;
G4int GetAreaCodeInPhi(const G4ThreeVector& xx,
G4bool withTol = true);
private:
G4int GetAreaCode(const G4ThreeVector& xx,
G4bool withTol = true) override;
G4int GetAreaCodeInPhi(const G4ThreeVector& xx,
G4bool withTol = true);
void SetCorners() override;
void SetCorners(G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
G4double DPhi,
G4double EndPhi[2],
G4double EndZ[2]);
void SetBoundaries() override;
/**
* Setters.
*/
void SetCorners() override;
void SetCorners(G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
G4double DPhi,
G4double EndPhi[2],
G4double EndZ[2]);
void SetBoundaries() override;
private:
G4double fKappa; // std::tan(TwistedAngle/2)/HalfLenZ;
G4double fTanStereo; // std::tan(StereoAngle)
G4double fTan2Stereo; // std::tan(StereoAngle)**2
G4double fR0; // radius at z = 0
G4double fR02; // radius**2 at z = 0
G4double fDPhi ; // segment
G4double fKappa; // std::tan(TwistedAngle/2)/HalfLenZ;
G4double fTanStereo; // std::tan(StereoAngle)
G4double fTan2Stereo; // std::tan(StereoAngle)**2
G4double fR0; // radius at z = 0
G4double fR02; // radius**2 at z = 0
G4double fDPhi ; // segment
class Insidetype
{
public:
G4ThreeVector gp;
EInside inside;
};
Insidetype fInside;
class Insidetype
{
public:
G4ThreeVector gp;
EInside inside;
};
Insidetype fInside;
};
//========================================================
@@ -29,8 +29,8 @@
//
// Class describing a twisted boundary surface for a cylinder.
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp), created
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// Author: Kotoyo Hoshina (Chiba University), 01.08.2002 - Created.
// Oliver Link (CERN), 13.11.2003 - Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef G4TWISTTUBSSIDE_HH
@@ -38,10 +38,29 @@
#include "G4VTwistSurface.hh"
/**
* @brief G4TwistTubsFlatSide describes a twisted boundary surface for
* a cylinder.
*/
class G4TwistTubsSide : public G4VTwistSurface
{
public:
/**
* Constructs a cylinder twisted boundary surface, given its parameters.
* @param[in] name The surface name.
* @param[in] rot Rotation: 0.5*(phi-width segment).
* @param[in] tlate Translation.
* @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
* @param[in] kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
* @param[in] axis0 X axis.
* @param[in] axis1 Z axis.
* @param[in] axis0min Minimum in X.
* @param[in] axis1min Minimum in Z.
* @param[in] axis0max Maximum in X.
* @param[in] axis1max Maximum in Z.
*/
G4TwistTubsSide(const G4String& name,
const G4RotationMatrix& rot, // 0.5*(phi-width segment)
const G4ThreeVector& tlate,
@@ -54,6 +73,19 @@ class G4TwistTubsSide : public G4VTwistSurface
G4double axis0max = kInfinity,
G4double axis1max = kInfinity );
/**
* Alternative Construct for a cylinder twisted boundary surface.
* @param[in] name The surface name.
* @param[in] EndInnerRadius Inner-hype radius at z=0.
* @param[in] EndOuterRadius Outer-hype radius at z=0.
* @param[in] DPhi Phi angle.
* @param[in] EndPhi Total Phi.
* @param[in] EndZ Z length.
* @param[in] InnerRadius Inner radius.
* @param[in] OuterRadius Outer radius.
* @param[in] Kappa Kappa=tan(TwistAngle/2)/fZHalfLen.
* @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
*/
G4TwistTubsSide(const G4String& name,
G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
@@ -65,11 +97,32 @@ class G4TwistTubsSide : public G4VTwistSurface
G4double Kappa,
G4int handedness);
~G4TwistTubsSide() override;
/**
* Default destructor.
*/
~G4TwistTubsSide() override = default;
G4ThreeVector GetNormal(const G4ThreeVector& xx,
/**
* Returns a normal vector at a surface (or very close to the surface)
* point at 'p'.
* @param[in] p The point where computing the normal.
* @param[in] isGlobal If true, it returns the normal in global coordinates.
* @returns The normal vector.
*/
G4ThreeVector GetNormal(const G4ThreeVector& p,
G4bool isGlobal = false) override ;
/**
* Returns the distance to surface, given point 'gp' and direction 'gv'.
* @param[in] gp The point from where computing the distance.
* @param[in] gv The direction along which computing the distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @param[out] isvalid Validity vector based on number of solutions.
* @param[in] validate Adopted validation criteria.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector gxx[],
@@ -78,22 +131,25 @@ class G4TwistTubsSide : public G4VTwistSurface
G4bool isvalid[],
EValidate validate = kValidateWithTol) override;
/**
* Returns the safety distance to surface, given point 'gp'.
* @param[in] gp The point from where computing the safety distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @returns The number of solutions.
*/
G4int DistanceToSurface(const G4ThreeVector& gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) override;
/**
* Get projection at p.z() on the surface.
*/
inline G4ThreeVector ProjectAtPXPZ(const G4ThreeVector& p,
G4bool isglobal = false) const ;
inline G4ThreeVector SurfacePoint(G4double, G4double,
G4bool isGlobal = false) override ;
inline G4double GetBoundaryMin(G4double phi) override ;
inline G4double GetBoundaryMax(G4double phi) override ;
inline G4double GetSurfaceArea() override ;
void GetFacets( G4int m, G4int n, G4double xyz[][3],
G4int faces[][4], G4int iside ) override ;
G4TwistTubsSide(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
@@ -101,30 +157,52 @@ class G4TwistTubsSide : public G4VTwistSurface
private:
/**
* Returns point on surface given 'x' and 'z'.
*/
inline G4ThreeVector SurfacePoint(G4double x, G4double z,
G4bool isGlobal = false) override ;
/**
* Internal accessors.
*/
inline G4double GetBoundaryMin(G4double phi) override ;
inline G4double GetBoundaryMax(G4double phi) override ;
inline G4double GetSurfaceArea() override ;
void GetFacets( G4int m, G4int n, G4double xyz[][3],
G4int faces[][4], G4int iside ) override ;
/**
* Internal method to compute the distance to a plane.
*/
G4double DistanceToPlane(const G4ThreeVector& p,
const G4ThreeVector& A,
const G4ThreeVector& B,
const G4ThreeVector& C,
const G4ThreeVector& D,
const G4int parity,
const G4int parity,
G4ThreeVector& xx,
G4ThreeVector& n);
/**
* Returns the area code for point 'xx' using or not surface tolerance.
*/
G4int GetAreaCode(const G4ThreeVector& xx,
G4bool withTol = true) override;
G4bool withTol = true) override;
/**
* Setters.
*/
void SetCorners() override;
void SetCorners( G4double endInnerRad[2],
G4double endOuterRad[2],
G4double endPhi[2],
G4double endZ[2] ) ;
void SetBoundaries() override;
private:
G4double fKappa; // std::tan(TwistedAngle/2)/HalfLenZ;
G4double fKappa; // std::tan(TwistedAngle/2)/HalfLenZ;
};
@@ -27,60 +27,96 @@
//
// Class description:
//
// A G4TwistedBox is a twisted cuboid of given half lengths pDx,pDy,pDz
// and twist angle pPhiTwist.
// The Box is centred on the origin with sides parallel to the x/y/z axes.
// A G4TwistedBox is a twisted cuboid of given half lengths pDx,pDy,pDz
// and twist angle pPhiTwist.
// The Box is centred on the origin with sides parallel to the x/y/z axes.
//
// Member Data:
// Member Data:
//
// pDx Half-length along x axis
// pDy Half-length along y asis
// pDz Half-length along z axis
// pPhiTwist Twist angle
// pDx Half-length along x axis
// pDy Half-length along y asis
// pDz Half-length along z axis
// pPhiTwist Twist angle
// Author: 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
// Author: Oliver Link (CERN), 27.10.2004 - Created
// --------------------------------------------------------------------
#ifndef G4TWISTEDBOX_HH
#define G4TWISTEDBOX_HH
#include "G4VTwistedFaceted.hh"
/**
* @brief G4TwistedBox is a twisted cuboid of given half lengths and twist
* angle. The box is centred on the origin with sides parallel to the
* Cartesian axes.
*/
class G4TwistedBox : public G4VTwistedFaceted
{
public:
/**
* Constructs a twisted box, given its parameters.
* @param[in] pName The solid name.
* @param[in] pPhiTwist Twist angle.
* @param[in] pDx Half-length along X axis.
* @param[in] pDy Half-length along Y axis.
* @param[in] pDz Half-length along Z axis.
*/
G4TwistedBox(const G4String& pName,
G4double pPhiTwist,
G4double pDx,
G4double pDy,
G4double pDz );
~G4TwistedBox() override;
// accessors
/**
* Default destructor.
*/
~G4TwistedBox() override = default;
/**
* Accessors.
*/
inline G4double GetXHalfLength() const { return GetDx1() ; }
inline G4double GetYHalfLength() const { return GetDy1() ; }
inline G4double GetZHalfLength() const { return GetDz() ; }
inline G4double GetPhiTwist() const { return GetTwistAngle() ; }
G4GeometryType GetEntityType() const override;
/**
* Returns the type ID, "G4TwistedBox" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistedBox(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Copy constructor and assignment operator.
*/
G4TwistedBox(const G4TwistedBox& rhs);
G4TwistedBox& operator=(const G4TwistedBox& rhs);
// Copy constructor and assignment operator.
};
#endif
@@ -27,40 +27,55 @@
//
// Class description:
//
// A G4TwistedTrap is a general twisted trapezoid: The faces perpendicular to the
// z planes are trapezia, and their centres are not necessarily on
// a line parallel to the z axis.
// A G4TwistedTrap is a general twisted trapezoid: The faces perpendicular to the
// z planes are trapezia, and their centres are not necessarily on
// a line parallel to the z axis.
//
// pDz Half-length along the z-axis
// pTheta Polar angle of the line joining the centres of the faces
// at -/+pDz
// pPhi Azimuthal angle of the line joing the centre of the face at
// -pDz to the centre of the face at +pDz
// pDy1 Half-length along y of the face at -pDz
// pDx1 Half-length along x of the side at y=-pDy1 of the face at -pDz
// pDx2 Half-length along x of the side at y=+pDy1 of the face at -pDz
// pDz Half-length along the z-axis
// pTheta Polar angle of the line joining the centres of the faces
// at -/+pDz
// pPhi Azimuthal angle of the line joining the centre of the face at
// -pDz to the centre of the face at +pDz
// pDy1 Half-length along y of the face at -pDz
// pDx1 Half-length along x of the side at y=-pDy1 of the face at -pDz
// pDx2 Half-length along x of the side at y=+pDy1 of the face at -pDz
//
// pDy2 Half-length along y of the face at +pDz
// pDx3 Half-length along x of the side at y=-pDy2 of the face at +pDz
// pDx4 Half-length along x of the side at y=+pDy2 of the face at +pDz
// pAlph Angle with respect to the y axis from the centre of the side
// pDy2 Half-length along y of the face at +pDz
// pDx3 Half-length along x of the side at y=-pDy2 of the face at +pDz
// pDx4 Half-length along x of the side at y=+pDy2 of the face at +pDz
// pAlph Angle with respect to the y axis from the centre of the side
//
//
// A special regular case of a trapezoid with equal endcaps is available,
// with polar,azimuthal and tilt angles set to zero.
// A special regular case of a trapezoid with equal endcaps is available,
// with polar,azimuthal and tilt angles set to zero.
//
// Author: 27-Oct-2004 - O.Link (Oliver.Link@cern.ch)
// Author: Oliver Link (CERN), 27.10.2004 - Created
// --------------------------------------------------------------------
#ifndef G4TWISTEDTRAP_HH
#define G4TWISTEDTRAP_HH
#include "G4VTwistedFaceted.hh"
/**
* @brief G4TwistedTrap is a general twisted trapezoid. The faces perpendicular
* to the Z planes are trapezia, and their centres are not necessarily on
* a line parallel to the Z axis.
*/
class G4TwistedTrap : public G4VTwistedFaceted
{
public:
/**
* Constructs a twisted trapezoid, given its parameters.
* @param[in] pName The solid name.
* @param[in] pPhiTwist The twist angle.
* @param[in] pDx1 Half X length at -pDz,-pDy.
* @param[in] pDx2 Half X length at -pDz,+pDy.
* @param[in] pDy Half-length along the Y axis.
* @param[in] pDz Half-length along the Z axis.
*/
G4TwistedTrap(const G4String& pName,
G4double pPhiTwist,
G4double pDx1, // half x length at -pDz,-pDy
@@ -68,7 +83,23 @@ class G4TwistedTrap : public G4VTwistedFaceted
G4double pDy,
G4double pDz);
/**
* Alternative construct of a twisted trapezoid, given its parameters.
* @param[in] pName The solid name.
* @param[in] pPhiTwist The twist angle.
* @param[in] pDz Half-length along the Z axis.
* @param[in] pTheta Polar angle of the line joining the centres of the
* faces at -/+pDz.
* @param[in] pPhi Azimuthal angle of the line joining the centres of the
* faces at -/+pDz.
* @param[in] pDy1 Half Y length at -pDz.
* @param[in] pDx1 Half X length at -pDz, y=-pDy1.
* @param[in] pDx2 Half X length at -pDz, y=+pDy1.
* @param[in] pDy2 Half Y length at +pDz.
* @param[in] pDx3 Half X length at +pDz, y=-pDy2.
* @param[in] pDx4 Half X length at +pDz, y=+pDy2.
* @param[in] pAlph Angle with respect to the Y axis from centre of side.
*/
G4TwistedTrap(const G4String& pName, // Name of instance
G4double pPhiTwist, // twist angle
G4double pDz, // half z length
@@ -83,10 +114,14 @@ class G4TwistedTrap : public G4VTwistedFaceted
G4double pAlph // tilt angle
);
~G4TwistedTrap() override;
// accessors
/**
* Default destructor.
*/
~G4TwistedTrap() override = default;
/**
* Accessors.
*/
inline G4double GetY1HalfLength() const { return GetDy1() ; }
inline G4double GetX1HalfLength() const { return GetDx1() ; }
inline G4double GetX2HalfLength() const { return GetDx2() ; }
@@ -99,20 +134,34 @@ class G4TwistedTrap : public G4VTwistedFaceted
inline G4double GetPolarAngleTheta() const { return GetTheta() ; }
inline G4double GetAzimuthalAnglePhi() const { return GetPhi() ; }
/**
* Returns the type ID, "G4TwistedTrap" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream &StreamInfo(std::ostream& os) const override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistedTrap(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Copy constructor and assignment operator.
*/
G4TwistedTrap(const G4TwistedTrap& rhs);
G4TwistedTrap& operator=(const G4TwistedTrap& rhs);
// Copy constructor and assignment operator.
} ;
#endif
@@ -27,30 +27,45 @@
//
// Class description:
//
// A G4TwistedTrd is a twisted trapezoid with the x and y dimensions
// varying along z
// A G4TwistedTrd is a twisted trapezoid with the X and Y dimensions
// varying along Z.
//
//
// Member Data:
// Member Data:
//
// pDx1 Half-length along x at the surface positioned at -dz
// pDx2 Half-length along x at the surface positioned at +dz
// pDy1 Half-length along y at the surface positioned at -dz
// pDy2 Half-length along y at the surface positioned at +dz
// pDz Half-length along z axis
// pPhiTwist Twist angle
// pDx1 Half-length along x at the surface positioned at -dz
// pDx2 Half-length along x at the surface positioned at +dz
// pDy1 Half-length along y at the surface positioned at -dz
// pDy2 Half-length along y at the surface positioned at +dz
// pDz Half-length along z axis
// pPhiTwist Twist angle
// Author: Oliver Link (Oliver.Link@cern.ch)
// Author: Oliver Link (CERN), 18.03.2005 - Created
// --------------------------------------------------------------------
#ifndef G4TWISTEDTRD_HH
#define G4TWISTEDTRD_HH
#include "G4VTwistedFaceted.hh"
/**
* @brief G4TwistedTrd is a twisted trapezoid with the X and Y dimensions
* varying along Z.
*/
class G4TwistedTrd : public G4VTwistedFaceted
{
public:
/**
* Constructs a twisted Trd, given its parameters.
* @param[in] pName The solid name.
* @param[in] pDx1 Half-length along X at the surface positioned at -dz.
* @param[in] pDx2 Half-length along X at the surface positioned at +dz.
* @param[in] pDy1 Half-length along Y at the surface positioned at -dz.
* @param[in] pDy2 Half-length along Y at the surface positioned at +dz.
* @param[in] pDz Half-length along Z axis.
* @param[in] pPhiTwist The twist angle.
*/
G4TwistedTrd( const G4String& pName,
G4double pDx1,
G4double pDx2,
@@ -59,10 +74,14 @@ class G4TwistedTrd : public G4VTwistedFaceted
G4double pDz,
G4double pPhiTwist );
~G4TwistedTrd() override;
// accessors
/**
* Default destructor.
*/
~G4TwistedTrd() override = default;
/**
* Accessors.
*/
inline G4double GetX1HalfLength() const { return GetDx1() ; }
inline G4double GetX2HalfLength() const { return GetDx3() ; }
inline G4double GetY1HalfLength() const { return GetDy1() ; }
@@ -70,24 +89,41 @@ class G4TwistedTrd : public G4VTwistedFaceted
inline G4double GetZHalfLength() const { return GetDz() ; }
inline G4double GetPhiTwist() const { return GetTwistAngle() ; }
/**
* Returns the type ID, "G4TwistedTrd" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistedTrd(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Copy constructor and assignment operator.
*/
G4TwistedTrd(const G4TwistedTrd& rhs);
G4TwistedTrd& operator=(const G4TwistedTrd& rhs);
// Copy constructor and assignment operator.
} ;
#endif
@@ -27,19 +27,19 @@
//
// Class description:
//
// G4TwistedTubs is a sector of a twisted hollow cylinder.
// A twisted cylinder which is placed along with z-axis and is
// separated into phi-segments should become a hyperboloid, and
// its each segmented piece should be tilted with a stereo angle.
// G4TwistedTubs is a G4VSolid.
// G4TwistedTubs is a sector of a twisted hollow cylinder.
// A twisted cylinder which is placed along with z-axis and is
// separated into phi-segments should become a hyperboloid, and
// its each segmented piece should be tilted with a stereo angle.
// G4TwistedTubs is a G4VSolid.
//
// Details of the implementation: "Development of a Geant4 solid
// for stereo mini-jet cells in a cylindrical drift chamber",
// Computer Physics Communications 153 (2003) pp.373391
// Details of the implementation: "Development of a Geant4 solid
// for stereo mini-jet cells in a cylindrical drift chamber",
// Computer Physics Communications 153 (2003) pp.373-391
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp), created.
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// Author: Kotoyo Hoshina (Chiba University), 01.08.2002 - created.
// Oliver Link (CERN), 13.11.2003 - Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef G4TWISTEDTUBS_HH
#define G4TWISTEDTUBS_HH
@@ -52,33 +52,81 @@
class G4SolidExtentList;
class G4ClippablePolygon;
/**
* @brief G4TwistedTubs is a sector of a twisted hollow cylinder.
* A twisted cylinder which is placed along with Z axis and is separated into
* phi-segments should become a hyperboloid, and its each segmented piece
* should be tilted with a stereo angle.
*/
class G4TwistedTubs : public G4VSolid
{
public:
/**
* Constructs a twisted tube, given radii and twist angle.
* @param[in] pName The solid name.
* @param[in] twistedangle The twisted angle.
* @param[in] endinnerrad Inner radius at endcap.
* @param[in] endouterrad Outer radius at endcap.
* @param[in] halfzlen Half Z length.
* @param[in] dphi Phi angle of a segment.
*/
G4TwistedTubs(const G4String& pname, // Name of instance
G4double twistedangle, // Twisted angle
G4double endinnerrad, // Inner radius at endcap
G4double endouterrad, // Outer radius at endcap
G4double halfzlen, // half z length
G4double endinnerrad, // Inner radius at endcap
G4double endouterrad, // Outer radius at endcap
G4double halfzlen, // half z length
G4double dphi); // Phi angle of a segment
/**
* Constructs a twisted tube, given radii, twist angle and number of segments.
* @param[in] pName The solid name.
* @param[in] twistedangle The twisted angle.
* @param[in] endinnerrad Inner radius at endcap.
* @param[in] endouterrad Outer radius at endcap.
* @param[in] halfzlen Half Z length.
* @param[in] nseg Number of segments in Phi.
* @param[in] totphi Total angle of all segments.
*/
G4TwistedTubs(const G4String& pname, // Name of instance
G4double twistedangle, // Stereo angle
G4double endinnerrad, // Inner radius at endcap
G4double endouterrad, // Outer radius at endcap
G4double endinnerrad, // Inner radius at endcap
G4double endouterrad, // Outer radius at endcap
G4double halfzlen, // half z length
G4int nseg, // Number of segments in totalPhi
G4double totphi); // Total angle of all segments
/**
* Constructs a twisted tube, given radii, twist angle and EndZ values.
* @param[in] pName The solid name.
* @param[in] twistedangle The twisted angle.
* @param[in] innerrad Inner radius at z=0.
* @param[in] outerrad Outer radius at z=0.
* @param[in] negativeEndz -ve Z endplate.
* @param[in] positiveEndz +ve Z endplate.
* @param[in] dphi Phi angle of a segment.
*/
G4TwistedTubs(const G4String& pname, // Name of instance
G4double twistedangle, // Twisted angle
G4double innerrad, // Inner radius at z=0
G4double outerrad, // Outer radius at z=0
G4double innerrad, // Inner radius at z=0
G4double outerrad, // Outer radius at z=0
G4double negativeEndz, // -ve z endplate
G4double positiveEndz, // +ve z endplate
G4double dphi); // Phi angle of a segment
/**
* Constructs a twisted tube, given radii, twist angle, EndZ values
* and number of segments.
* @param[in] pName The solid name.
* @param[in] twistedangle The twisted angle.
* @param[in] innerrad Inner radius at z=0.
* @param[in] outerrad Outer radius at z=0.
* @param[in] negativeEndz -ve Z endplate.
* @param[in] positiveEndz +ve Z endplate.
* @param[in] nseg Number of segments in Phi.
* @param[in] totphi Total angle of all segments.
*/
G4TwistedTubs(const G4String& pname, // Name of instance
G4double twistedangle, // Stereo angle
G4double innerrad, // Inner radius at z=0
@@ -88,45 +136,73 @@ class G4TwistedTubs : public G4VSolid
G4int nseg, // Number of segments in totalPhi
G4double totphi); // Total angle of all segments
~G4TwistedTubs() override;
/**
* Destructor.
*/
~G4TwistedTubs() override;
/**
* Thows a fatal exception. Parameterisations are not allowed on this shape.
*/
void ComputeDimensions(G4VPVParameterisation* /* p */ ,
const G4int /* n */ ,
const G4VPhysicalVolume* /* prep */ ) override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const override;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
G4double DistanceToIn (const G4ThreeVector& p,
const G4ThreeVector& v ) const override;
G4double DistanceToIn (const G4ThreeVector& p ) const override;
G4double DistanceToOut(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcnorm = false,
G4bool* validnorm = nullptr,
G4ThreeVector* n = nullptr ) const override;
G4double DistanceToOut(const G4ThreeVector& p) const override;
EInside Inside (const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
G4Polyhedron* CreatePolyhedron () const override;
G4Polyhedron* GetPolyhedron () const override;
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
G4Polyhedron* CreatePolyhedron () const override;
G4Polyhedron* GetPolyhedron () const override;
G4VisExtent GetExtent () const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream &StreamInfo(std::ostream& os) const override;
// accessors
/**
* Accessors.
*/
inline G4double GetDPhi () const { return fDPhi ; }
inline G4double GetPhiTwist () const { return fPhiTwist ; }
inline G4double GetInnerRadius () const { return fInnerRadius; }
@@ -135,12 +211,12 @@ class G4TwistedTubs : public G4VSolid
inline G4double GetOuterStereo () const { return fOuterStereo; }
inline G4double GetZHalfLength () const { return fZHalfLength; }
inline G4double GetKappa () const { return fKappa ; }
//
inline G4double GetTanInnerStereo () const { return fTanInnerStereo ; }
inline G4double GetTanInnerStereo2() const { return fTanInnerStereo2 ; }
inline G4double GetTanOuterStereo () const { return fTanOuterStereo ; }
inline G4double GetTanOuterStereo2() const { return fTanOuterStereo2 ; }
//
inline G4double GetEndZ (G4int i) const { return fEndZ[i] ; }
inline G4double GetEndPhi (G4int i) const { return fEndPhi[i]; }
inline G4double GetEndInnerRadius (G4int i) const
@@ -154,38 +230,64 @@ class G4TwistedTubs : public G4VSolid
{ return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
fEndOuterRadius[0] : fEndOuterRadius[1]); }
G4VisExtent GetExtent () const override;
/**
* Returns the type ID, "G4TwistedTubs" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Returning an estimation of the solid volume (capacity) and surface area,
* in internal units. Caches the computed value once computed the first time.
*/
G4double GetCubicVolume() override;
// Returns an estimation of the geometrical cubic volume of the
// solid. Caches the computed value once computed the first time.
G4double GetSurfaceArea() override;
// Returns the geometrical surface area of the solid.
// Caches the computed value once computed the first time.
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override ;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4TwistedTubs(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Copy constructor and assignment operator.
*/
G4TwistedTubs(const G4TwistedTubs& rhs);
G4TwistedTubs& operator=(const G4TwistedTubs& rhs);
// Copy constructor and assignment operator.
#ifdef G4TWISTDEBUG
G4VTwistSurface* GetOuterHype() const { return fOuterHype; }
inline G4VTwistSurface* GetOuterHype() const { return fOuterHype; }
#endif
private:
/**
* Initialiser of data.
*/
inline void SetFields(G4double phitwist, G4double innerrad,
G4double outerrad,
G4double negativeEndz, G4double positiveEndz);
/**
* Generates the surfaces. Used in constructors.
*/
void CreateSurfaces();
/**
* Utilities for area computation.
*/
G4double GetLateralArea(G4double a, G4double r, G4double z) const;
G4double GetPhiCutArea(G4double a, G4double r, G4double z) const;
@@ -29,7 +29,7 @@
//
// Wrapper class for G4Ellipsoid to make use of VecGeom Ellipsoid.
// 13.09.19 Gabriele Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 13.09.2019
// --------------------------------------------------------------------
#ifndef G4UELLIPSOID_HH
#define G4UELLIPSOID_HH
@@ -42,6 +42,11 @@
#include "G4Polyhedron.hh"
/**
* @brief G4UEllipsoid is a wrapper class for G4Ellipsoid to make use
* of VecGeom Ellipsoid.
*/
class G4UEllipsoid : public G4UAdapter<vecgeom::UnplacedEllipsoid>
{
using Shape_t = vecgeom::UnplacedEllipsoid;
@@ -49,36 +54,86 @@ class G4UEllipsoid : public G4UAdapter<vecgeom::UnplacedEllipsoid>
public:
G4UEllipsoid(const G4String& name, G4double pxSemiAxis,
G4double pySemiAxis,
G4double pzSemiAxis,
G4double pzBottomCut = 0.0,
G4double pzTopCut = 0.0);
~G4UEllipsoid() override;
/**
* Constructs an ellipsoid, given its input parameters.
* @param[in] name The solid name.
* @param[in] pxSemiAxis Semiaxis in X.
* @param[in] pySemiAxis Semiaxis in Y.
* @param[in] pzSemiAxis Semiaxis in Z.
* @param[in] pzBottomCut Optional lower cut plane level in Z.
* @param[in] pzTopCut Optional upper cut plane level in Z.
*/
G4UEllipsoid(const G4String& name,
G4double pxSemiAxis,
G4double pySemiAxis,
G4double pzSemiAxis,
G4double pzBottomCut = 0.0,
G4double pzTopCut = 0.0);
/**
* Default destructor.
*/
~G4UEllipsoid() override = default;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Accessors.
*/
G4double GetDx() const;
G4double GetDy() const;
G4double GetDz() const;
G4double GetSemiAxisMax (G4int i) const;
G4double GetZBottomCut() const;
G4double GetZTopCut() const;
/**
* Modifiers.
*/
void SetSemiAxis (G4double x, G4double y, G4double z);
void SetZCuts (G4double newzBottomCut, G4double newzTopCut);
/**
* Returns the type ID, "G4Ellipsoid" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
G4UEllipsoid( const G4UEllipsoid &source );
G4UEllipsoid &operator=( const G4UEllipsoid &source );
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Copy constructor and assignment operator.
*/
G4UEllipsoid( const G4UEllipsoid &source );
G4UEllipsoid &operator=( const G4UEllipsoid &source );
};
// --------------------------------------------------------------------
@@ -29,7 +29,7 @@
//
// Wrapper class for G4EllipticalCone to make use of VecGeom EllipticalCone.
// 13.09.19 Gabriele Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 13.09.2019
// --------------------------------------------------------------------
#ifndef G4UELLIPTICALCONE_HH
#define G4UELLIPTICALCONE_HH
@@ -42,6 +42,11 @@
#include "G4Polyhedron.hh"
/**
* @brief G4UEllipticalCone is a wrapper class for G4EllipticalCone
* to make use of VecGeom EllipticalCone.
*/
class G4UEllipticalCone : public G4UAdapter<vecgeom::UnplacedEllipticalCone>
{
using Shape_t = vecgeom::UnplacedEllipticalCone;
@@ -49,35 +54,84 @@ class G4UEllipticalCone : public G4UAdapter<vecgeom::UnplacedEllipticalCone>
public:
G4UEllipticalCone(const G4String& name, G4double pxSemiAxis,
G4double pySemiAxis,
G4double zMax,
G4double pzTopCut);
~G4UEllipticalCone() override;
/**
* Constructs an elliptical cone, with cut in Z.
* @param[in] name The solid name.
* @param[in] pxSemiAxis Scalar value, defining the scaling along X-axis.
* @param[in] pySemiAxis Scalar value, defining the scaling along Y-axis.
* @param[in] zMax The Z-coordinate at the apex.
* @param[in] pzTopCut Upper cut plane level.
*/
G4UEllipticalCone(const G4String& name,
G4double pxSemiAxis,
G4double pySemiAxis,
G4double zMax,
G4double pzTopCut);
/**
* Default destructor.
*/
~G4UEllipticalCone() override = default;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Accessors.
*/
G4double GetSemiAxisMin () const;
G4double GetSemiAxisMax () const;
G4double GetSemiAxisX () const;
G4double GetSemiAxisY () const;
G4double GetZMax() const;
G4double GetZTopCut() const;
/**
* Modifiers.
*/
void SetSemiAxis (G4double x, G4double y, G4double z);
void SetZCut (G4double newzTopCut);
/**
* Returns the type ID, "G4EllipticalCone" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
G4UEllipticalCone( const G4UEllipticalCone& source );
G4UEllipticalCone& operator=( const G4UEllipticalCone& source );
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Copy constructor and assignment operator.
*/
G4UEllipticalCone( const G4UEllipticalCone& source );
G4UEllipticalCone& operator=( const G4UEllipticalCone& source );
};
// --------------------------------------------------------------------
@@ -29,7 +29,7 @@
//
// Wrapper class for G4EllipticalTube to make use of VecGeom EllipticalTube.
// 13.09.19 Gabriele Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 13.09.2019
// --------------------------------------------------------------------
#ifndef G4UELLIPTICALTUBE_HH
#define G4UELLIPTICALTUBE_HH
@@ -42,6 +42,11 @@
#include "G4Polyhedron.hh"
/**
* @brief G4UEllipticalTube is a wrapper class for G4EllipticalTube
* to make use of VecGeom EllipticalTube.
*/
class G4UEllipticalTube : public G4UAdapter<vecgeom::UnplacedEllipticalTube>
{
using Shape_t = vecgeom::UnplacedEllipticalTube;
@@ -49,33 +54,81 @@ class G4UEllipticalTube : public G4UAdapter<vecgeom::UnplacedEllipticalTube>
public:
G4UEllipticalTube(const G4String& name, G4double dx,
G4double dy,
G4double dz);
~G4UEllipticalTube() override;
/**
* Constructs an elliptical tube, given its parameters.
* @param[in] name The solid name.
* @param[in] dx Half length of axis along X.
* @param[in] dy Half length of axis along Y.
* @param[in] dz Half length in Z.
*/
G4UEllipticalTube(const G4String& name,
G4double dx,
G4double dy,
G4double dz);
/**
* Default destructor.
*/
~G4UEllipticalTube() override = default;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Accessors.
*/
G4double GetDx() const;
G4double GetDy() const;
G4double GetDz() const;
/**
* Modifiers.
*/
void SetDx(G4double dx);
void SetDy(G4double dy);
void SetDz(G4double dz);
/**
* Returns the type ID, "G4EllipticalTube" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
G4UEllipticalTube( const G4UEllipticalTube& source );
G4UEllipticalTube &operator=( const G4UEllipticalTube& source );
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Copy constructor and assignment operator.
*/
G4UEllipticalTube( const G4UEllipticalTube& source );
G4UEllipticalTube &operator=( const G4UEllipticalTube& source );
};
// --------------------------------------------------------------------
@@ -29,7 +29,7 @@
//
// Wrapper class for G4ExtrudedSolid to make use of VecGeom ExtrudedSolid.
// 17.11.17 G.Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 17.11.2017
// --------------------------------------------------------------------
#ifndef G4UEXTRUDEDSOLID_HH
#define G4UEXTRUDEDSOLID_HH
@@ -43,6 +43,11 @@
#include "G4Polyhedron.hh"
/**
* @brief G4UExtrudedSolid is a wrapper class for G4ExtrudedSolid
* to make use of VecGeom ExtrudedSolid.
*/
class G4UExtrudedSolid : public G4UAdapter<vecgeom::UnplacedExtruded>
{
using Shape_t = vecgeom::UnplacedExtruded;
@@ -50,6 +55,9 @@ class G4UExtrudedSolid : public G4UAdapter<vecgeom::UnplacedExtruded>
public:
/**
* Structure defining a Z section composing the solid.
*/
struct ZSection
{
ZSection() : fZ(0.), fOffset(0.,0.), fScale(1.) {}
@@ -61,11 +69,30 @@ class G4UExtrudedSolid : public G4UAdapter<vecgeom::UnplacedExtruded>
G4double fScale;
};
/**
* General constructor for an extruded polygon, through contour and polyline.
* @param[in] pName The solid name.
* @param[in] polygon The 2D polygonal contour, i.e. the vertices of the
* outlined polygon defined in clock-wise order.
* @param[in] zsections The 3D polyline with scale factors, i.e. the
* Z-sections defined by Z position in increasing order.
*/
G4UExtrudedSolid(const G4String& pName,
const std::vector<G4TwoVector>& polygon,
const std::vector<ZSection>& zsections);
// General constructor
/**
* Special constructor for an extruded polygon with 2 Z-sections.
* @param[in] pName The solid name.
* @param[in] polygon The 2D polygonal contour, i.e. the vertices of the
* outlined polygon defined in clock-wise order.
* @param[in] halfZ Half length in Z, i.e. the distance from the origin
* to the sections.
* @param[in] off1 (X, Y) position of the first polygon in -halfZ.
* @param[in] scale1 Scale factor at -halfZ.
* @param[in] off2 (X, Y) position of the second polygon in +halfZ.
* @param[in] scale2 Scale factor at +halfZ.
*/
G4UExtrudedSolid(const G4String& pName,
const std::vector<G4TwoVector>& polygon,
G4double halfZ,
@@ -73,10 +100,15 @@ class G4UExtrudedSolid : public G4UAdapter<vecgeom::UnplacedExtruded>
G4double scale1 = 1.,
const G4TwoVector& off2 = G4TwoVector(0.,0.),
G4double scale2 = 1. );
// Special constructor for solid with 2 z-sections
~G4UExtrudedSolid() override;
/**
* Default Destructor.
*/
~G4UExtrudedSolid() override = default;
/**
* Accessors.
*/
G4int GetNofVertices() const;
G4TwoVector GetVertex(G4int index) const;
std::vector<G4TwoVector> GetPolygon() const;
@@ -84,21 +116,48 @@ class G4UExtrudedSolid : public G4UAdapter<vecgeom::UnplacedExtruded>
ZSection GetZSection(G4int index) const;
std::vector<ZSection> GetZSections() const;
/**
* Returns the type ID, "G4ExtrudedSolid" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
/**
* Returns true as the solid has only planar faces.
*/
inline G4bool IsFaceted() const override;
G4UExtrudedSolid( const G4UExtrudedSolid& source );
G4UExtrudedSolid &operator=(const G4UExtrudedSolid& source);
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Copy constructor and assignment operator.
*/
G4UExtrudedSolid( const G4UExtrudedSolid& source );
G4UExtrudedSolid &operator=(const G4UExtrudedSolid& source);
};
// --------------------------------------------------------------------
@@ -29,7 +29,7 @@
//
// Wrapper class for G4GenericPolycone to make use of VecGeom GenericPolycone.
// 30.10.13 G.Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 30.10.2013
// --------------------------------------------------------------------
#ifndef G4UGENERICPOLYCONE_HH
#define G4UGENERICPOLYCONE_HH
@@ -43,6 +43,11 @@
#include "G4TwoVector.hh"
#include "G4PolyconeSide.hh"
/**
* @brief G4UGenericPolycone is a wrapper class for G4GenericPolycone
* to make use of VecGeom GenericPolycone.
*/
class G4UGenericPolycone : public G4UAdapter<vecgeom::UnplacedGenericPolycone>
{
using Shape_t = vecgeom::UnplacedGenericPolycone;
@@ -50,6 +55,15 @@ class G4UGenericPolycone : public G4UAdapter<vecgeom::UnplacedGenericPolycone>
public:
/**
* Constructs a generic polycone shape, given its parameters.
* @param[in] name The solid name.
* @param[in] phiStart The initial Phi starting angle.
* @param[in] phiTotal The total Phi angle.
* @param[in] numRZ Number of corners in r,Z space.
* @param[in] r Vector of r coordinate of corners.
* @param[in] z Vector of Z coordinate of corners.
*/
G4UGenericPolycone(const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
@@ -57,8 +71,14 @@ class G4UGenericPolycone : public G4UAdapter<vecgeom::UnplacedGenericPolycone>
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
~G4UGenericPolycone() override;
/**
* Default destructor.
*/
~G4UGenericPolycone() override = default;
/**
* Accessors.
*/
G4double GetStartPhi() const;
G4double GetEndPhi() const;
G4double GetSinStartPhi() const;
@@ -69,23 +89,50 @@ class G4UGenericPolycone : public G4UAdapter<vecgeom::UnplacedGenericPolycone>
G4int GetNumRZCorner() const;
G4PolyconeSideRZ GetCorner(G4int index) const;
/**
* Returns the type ID, "G4GenericPolycone" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
G4UGenericPolycone( const G4UGenericPolycone& source );
G4UGenericPolycone& operator=(const G4UGenericPolycone& source);
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Copy constructor and assignment operator.
*/
G4UGenericPolycone( const G4UGenericPolycone& source );
G4UGenericPolycone& operator=(const G4UGenericPolycone& source);
private:
G4double wrStart;
@@ -29,7 +29,7 @@
//
// Wrapper class for G4GenericTrap to make use of VecGeom GenericTrap.
// 30.10.13 G.Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 30.10.2013
// --------------------------------------------------------------------
#ifndef G4UGENERICTRAP_HH
#define G4UGENERICTRAP_HH
@@ -43,6 +43,11 @@
#include "G4Polyhedron.hh"
/**
* @brief G4UGenericTrap is a wrapper class for G4GenericTrap
* to make use of VecGeom GenericTrap.
*/
class G4UGenericTrap : public G4UAdapter<vecgeom::UnplacedGenTrap>
{
using Shape_t = vecgeom::UnplacedGenTrap;
@@ -50,11 +55,23 @@ class G4UGenericTrap : public G4UAdapter<vecgeom::UnplacedGenTrap>
public:
/**
* Constructs an generic trapezoid, given its vertices.
* @param[in] name The solid name.
* @param[in] halfZ Half length in Z.
* @param[in] vertices The (x,y) coordinates of the vertices.
*/
G4UGenericTrap(const G4String& name, G4double halfZ,
const std::vector<G4TwoVector>& vertices);
~G4UGenericTrap() override;
/**
* Default destructor.
*/
~G4UGenericTrap() override = default;
/**
* Accessors.
*/
G4double GetZHalfLength() const;
G4int GetNofVertices() const;
G4TwoVector GetVertex(G4int index) const;
@@ -62,27 +79,63 @@ class G4UGenericTrap : public G4UAdapter<vecgeom::UnplacedGenTrap>
G4double GetTwistAngle(G4int index) const;
G4bool IsTwisted() const;
G4int GetVisSubdivisions() const;
/**
* Modifiers.
*/
void SetVisSubdivisions(G4int subdiv);
void SetZHalfLength(G4double);
void Initialise(const std::vector<G4TwoVector>& v);
/**
* Returns the type ID, "G4GenericTrap" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
/**
* Returns true as the solid has only planar faces.
*/
inline G4bool IsFaceted() const override;
G4UGenericTrap( const G4UGenericTrap& source );
G4UGenericTrap& operator=(const G4UGenericTrap& source);
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Copy constructor and assignment operator.
*/
G4UGenericTrap( const G4UGenericTrap& source );
G4UGenericTrap& operator=(const G4UGenericTrap& source);
private:
/**
* Initialises data. Used in constructor.
*/
void Initialise(const std::vector<G4TwoVector>& v);
private:
G4int fVisSubdivisions;
@@ -29,7 +29,7 @@
//
// Wrapper class for G4Hype to make use of VecGeom Hyperboloid.
// 16.10.17 G.Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 16.10.2017
// --------------------------------------------------------------------
#ifndef G4UHYPE_HH
#define G4UHYPE_HH
@@ -42,6 +42,11 @@
#include "G4Polyhedron.hh"
/**
* @brief G4UHype is a wrapper class for G4Hype to make use
* of VecGeom Hyperboloid.
*/
class G4UHype : public G4UAdapter<vecgeom::GenericUnplacedHype>
{
using Shape_t = vecgeom::GenericUnplacedHype;
@@ -49,44 +54,96 @@ class G4UHype : public G4UAdapter<vecgeom::GenericUnplacedHype>
public:
/**
* Constructs a hyperbolic tube, given its parameters.
* @param[in] name The solid name.
* @param[in] newInnerRadius Inner radius.
* @param[in] newOuterRadius Outer radius.
* @param[in] newInnerStereo Inner stereo angle in radians.
* @param[in] newOuterStereo Outer stereo angle in radians.
* @param[in] newHalfLenZ Half length in Z.
*/
G4UHype(const G4String& name,
G4double newInnerRadius,
G4double newOuterRadius,
G4double newInnerStereo,
G4double newOuterStereo,
G4double newHalfLenZ);
~G4UHype() override;
void ComputeDimensions( G4VPVParameterisation* p,
/**
* Default destructor.
*/
~G4UHype() override = default;
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Accessors.
*/
G4double GetInnerRadius () const;
G4double GetOuterRadius () const;
G4double GetZHalfLength () const;
G4double GetInnerStereo () const;
G4double GetOuterStereo () const;
/**
* Modifiers.
*/
void SetInnerRadius (G4double newIRad);
void SetOuterRadius (G4double newORad);
void SetZHalfLength (G4double newHLZ);
void SetInnerStereo (G4double newISte);
void SetOuterStereo (G4double newOSte);
/**
* Returns the type ID, "G4Hype" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
G4UHype( const G4UHype& source );
G4UHype& operator=( const G4UHype& source );
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Copy constructor and assignment operator.
*/
G4UHype( const G4UHype& source );
G4UHype& operator=( const G4UHype& source );
};
// --------------------------------------------------------------------
@@ -29,7 +29,7 @@
//
// Wrapper class for G4Paraboloid to make use of VecGeom Paraboloid.
// 19.08.15 Guilherme Lima, FNAL
// Author: Guilherme Lima (FNAL), 19.08.2015
// --------------------------------------------------------------------
#ifndef G4UPARABOLOID_HH
#define G4UPARABOLOID_HH
@@ -42,6 +42,11 @@
#include "G4Polyhedron.hh"
/**
* @brief G4UParaboloid is a wrapper class for G4Paraboloid
* to make use of VecGeom Paraboloid.
*/
class G4UParaboloid : public G4UAdapter<vecgeom::UnplacedParaboloid>
{
using Shape_t = vecgeom::UnplacedParaboloid;
@@ -49,33 +54,80 @@ class G4UParaboloid : public G4UAdapter<vecgeom::UnplacedParaboloid>
public:
G4UParaboloid(const G4String& name, G4double dz,
G4double rlo,
G4double rhi);
~G4UParaboloid() override;
/**
* Constructs a paraboloid, given its parameters.
* @param[in] name The solid name.
* @param[in] dz Half length in Z.
* @param[in] rlo Radius at -Dz.
* @param[in] rhi Radius at +Dz greater than pR1.
*/
G4UParaboloid(const G4String& name,
G4double dz,
G4double rlo,
G4double rhi);
/**
* Default destructor.
*/
~G4UParaboloid() override = default;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Accessors.
*/
G4double GetZHalfLength() const;
G4double GetRadiusMinusZ() const;
G4double GetRadiusPlusZ() const;
/**
* Modifiers.
*/
void SetZHalfLength(G4double dz);
void SetRadiusMinusZ(G4double r1);
void SetRadiusPlusZ(G4double r2);
/**
* Returns the type ID, "G4Paraboloid" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
G4UParaboloid( const G4UParaboloid& source );
G4UParaboloid& operator=( const G4UParaboloid& source );
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Copy constructor and assignment operator.
*/
G4UParaboloid( const G4UParaboloid& source );
G4UParaboloid& operator=( const G4UParaboloid& source );
};
// --------------------------------------------------------------------
@@ -29,7 +29,7 @@
//
// Wrapper class for G4Polycone to make use of VecGeom Polycone.
// 31.10.13 G.Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 31.10.2013
// --------------------------------------------------------------------
#ifndef G4UPOLYCONE_HH
#define G4UPOLYCONE_HH
@@ -45,6 +45,11 @@
#include "G4PolyconeHistorical.hh"
#include "G4Polyhedron.hh"
/**
* @brief G4UPolycone is a wrapper class for G4Polycone to make use
* of VecGeom Polycone.
*/
class G4UPolycone : public G4UAdapter<vecgeom::GenericUnplacedPolycone>
{
using Shape_t = vecgeom::GenericUnplacedPolycone;
@@ -52,6 +57,16 @@ class G4UPolycone : public G4UAdapter<vecgeom::GenericUnplacedPolycone>
public:
/**
* Constructs a polycone shape, given its parameters.
* @param[in] name The solid name.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] phiTotal Total Phi angle.
* @param[in] numZPlanes Number of Z planes.
* @param[in] zPlane Position of Z planes, with Z in increasing order.
* @param[in] rInner Tangent distance to inner surface.
* @param[in] rOuter Tangent distance to outer surface.
*/
G4UPolycone(const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
@@ -60,6 +75,15 @@ class G4UPolycone : public G4UAdapter<vecgeom::GenericUnplacedPolycone>
const G4double rInner[], // tangent distance to inner surface
const G4double rOuter[] ); // tangent distance to outer surface
/**
* Alternative constructor of a polycone shape, given corners coordinates.
* @param[in] name The solid name.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] phiTotal Total Phi angle.
* @param[in] numRZ Number of corners in r,Z space.
* @param[in] r r coordinates of corners.
* @param[in] z Z coordinates of corners.
*/
G4UPolycone(const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
@@ -67,14 +91,28 @@ class G4UPolycone : public G4UAdapter<vecgeom::GenericUnplacedPolycone>
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
~G4UPolycone() override;
/**
* Default destructor.
*/
~G4UPolycone() override = default;
void ComputeDimensions( G4VPVParameterisation* p,
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Accessors.
*/
G4double GetStartPhi() const;
G4double GetDeltaPhi() const;
G4double GetEndPhi() const;
@@ -86,34 +124,67 @@ class G4UPolycone : public G4UAdapter<vecgeom::GenericUnplacedPolycone>
G4int GetNumRZCorner() const;
G4PolyconeSideRZ GetCorner(G4int index) const;
G4PolyconeHistorical* GetOriginalParameters() const;
/**
* Modifier.
*/
void SetOriginalParameters(G4PolyconeHistorical* pars);
/**
* Clears all parameters and rebuild the shape, for use in divisions.
*/
G4bool Reset();
/**
* Returns the type ID, "G4Polycone" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
G4UPolycone( const G4UPolycone& source );
G4UPolycone& operator=( const G4UPolycone& source );
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
protected:
/**
* Copy constructor and assignment operator.
*/
G4UPolycone( const G4UPolycone& source );
G4UPolycone& operator=( const G4UPolycone& source );
private:
/**
* Generic initializer, called by all constructors.
*/
void SetOriginalParameters();
private:
G4bool fGenericPcon; // true if created through the 2nd generic constructor
G4PolyconeHistorical fOriginalParameters; // original input parameters
private:
G4double wrStart;
G4double wrDelta;
std::vector<G4TwoVector> rzcorners;
@@ -29,7 +29,7 @@
//
// Wrapper class for G4Polyhedra to make use of VecGeom Polyhedron.
// 31.10.13 G.Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 31.10.2013
// --------------------------------------------------------------------
#ifndef G4UPOLYHEDRA_HH
#define G4UPOLYHEDRA_HH
@@ -48,6 +48,11 @@
class G4EnclosingCylinder;
class G4ReduciblePolygon;
/**
* @brief G4UPolyhedra is a wrapper class for G4Polyhedra to make use
* of VecGeom Polyhedron.
*/
class G4UPolyhedra : public G4UAdapter<vecgeom::UnplacedPolyhedron>
{
using Shape_t = vecgeom::UnplacedPolyhedron;
@@ -55,6 +60,17 @@ class G4UPolyhedra : public G4UAdapter<vecgeom::UnplacedPolyhedron>
public:
/**
* Constructs a polyhedra, given its parameters.
* @param[in] name The solid name.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] phiTotal Total Phi angle.
* @param[in] numSide Number of sides.
* @param[in] numZPlanes Number of Z planes.
* @param[in] zPlane Position of Z planes.
* @param[in] rInner Tangent distance to inner surface.
* @param[in] rOuter Tangent distance to outer surface.
*/
G4UPolyhedra( const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
@@ -64,6 +80,16 @@ class G4UPolyhedra : public G4UAdapter<vecgeom::UnplacedPolyhedron>
const G4double rInner[], // tangent distance to inner surface
const G4double rOuter[] ); // tangent distance to outer surface
/**
* Alternative constructor of a polyhedra, given corners coordinates.
* @param[in] name The solid name.
* @param[in] phiStart Initial Phi starting angle.
* @param[in] phiTotal Total Phi angle.
* @param[in] numSide Number of sides.
* @param[in] numRZ Number of corners in r,Z space.
* @param[in] r r coordinates of corners.
* @param[in] z Z coordinates of corners.
*/
G4UPolyhedra( const G4String& name,
G4double phiStart, // initial phi starting angle
G4double phiTotal, // total phi angle
@@ -72,14 +98,28 @@ class G4UPolyhedra : public G4UAdapter<vecgeom::UnplacedPolyhedron>
const G4double r[], // r coordinate of these corners
const G4double z[] ); // z coordinate of these corners
~G4UPolyhedra() override;
/**
* Default destructor.
*/
~G4UPolyhedra() override = default;
void ComputeDimensions( G4VPVParameterisation* p,
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Accessors.
*/
G4int GetNumSide() const;
G4double GetStartPhi() const;
G4double GetEndPhi() const;
@@ -92,36 +132,72 @@ class G4UPolyhedra : public G4UAdapter<vecgeom::UnplacedPolyhedron>
G4int GetNumRZCorner() const;
G4PolyhedraSideRZ GetCorner( const G4int index ) const;
G4PolyhedraHistorical* GetOriginalParameters() const;
/**
* Modifier.
*/
void SetOriginalParameters(G4PolyhedraHistorical* pars);
/**
* Clears all parameters and rebuild the shape, for use in divisions.
*/
G4bool Reset();
/**
* Returns the type ID, "G4Polyhedra" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
/**
* Returns true as the solid has only planar faces.
*/
inline G4bool IsFaceted() const override;
G4UPolyhedra( const G4UPolyhedra& source );
G4UPolyhedra& operator=( const G4UPolyhedra& source );
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
protected:
/**
* Copy constructor and assignment operator.
*/
G4UPolyhedra( const G4UPolyhedra& source );
G4UPolyhedra& operator=( const G4UPolyhedra& source );
private:
/**
* Sets internal parameters for the generic constructor.
*/
void SetOriginalParameters();
private:
G4bool fGenericPgon; // true if created through the 2nd generic constructor
G4PolyhedraHistorical fOriginalParameters; // original input parameters
private:
G4double wrStart;
G4double wrDelta;
G4int wrNumSide;
@@ -29,7 +29,7 @@
//
// Wrapper class for G4TessellatedSolid to make use of VecGeom TessellatedSolid.
// 11.01.18 G.Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 11.01.2018
// --------------------------------------------------------------------
#ifndef G4UTESSELLATEDSOLID_HH
#define G4UTESSELLATEDSOLID_HH
@@ -43,6 +43,11 @@
#include "G4Polyhedron.hh"
#include "G4VFacet.hh"
/**
* @brief G4UTessellatedSolid is a wrapper class for G4TessellatedSolid
* to make use of VecGeom TessellatedSolid.
*/
class G4UTessellatedSolid : public G4UAdapter<vecgeom::UnplacedTessellated>
{
using Shape_t = vecgeom::UnplacedTessellated;
@@ -50,46 +55,104 @@ class G4UTessellatedSolid : public G4UAdapter<vecgeom::UnplacedTessellated>
public:
/**
* Default Constructor.
*/
G4UTessellatedSolid();
/**
* Constructor with solid's name.
* @param[in] name The name of the solid.
*/
G4UTessellatedSolid(const G4String& pName);
/**
* Destructor. Clearing all allocated facets and data.
*/
~G4UTessellatedSolid() override;
/**
* Methods for adding or retrieving a facet given an index.
*/
G4bool AddFacet(G4VFacet* aFacet);
G4VFacet* GetFacet(G4int i) const;
/**
* Returns the total number of facets.
*/
G4int GetNumberOfFacets() const;
/**
* Returns the type ID, "G4TessellatedSolid" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
/**
* Returns true as the solid has only planar faces.
*/
inline G4bool IsFaceted() const override;
/**
* Modifier and accessor to close/finalise the solid.
*/
void SetSolidClosed(const G4bool t);
G4bool GetSolidClosed() const;
/**
* Allowing to tune the maximum number of voxels to use for optimisation.
*/
void SetMaxVoxels(G4int);
/**
* Accessors.
*/
G4double GetMinXExtent() const;
G4double GetMaxXExtent() const;
G4double GetMinYExtent() const;
G4double GetMaxYExtent() const;
G4double GetMinZExtent() const;
G4double GetMaxZExtent() const;
/**
* Loggers reporting the total allocated memory.
*/
G4int AllocatedMemoryWithoutVoxels();
G4int AllocatedMemory();
void DisplayAllocatedMemory();
G4UTessellatedSolid( const G4UTessellatedSolid& source );
G4UTessellatedSolid& operator=(const G4UTessellatedSolid& source);
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Copy constructor and assignment operator.
*/
G4UTessellatedSolid( const G4UTessellatedSolid& source );
G4UTessellatedSolid& operator=(const G4UTessellatedSolid& source);
private:
std::vector<G4VFacet*> fFacets;
@@ -29,7 +29,7 @@
//
// Wrapper class for G4Tet to make use of VecGeom Tet.
// 1.11.13 G.Cosmo, CERN
// Author: Gabriele Cosmo (CERN), 01.11.2013
// --------------------------------------------------------------------
#ifndef G4UTET_HH
#define G4UTET_HH
@@ -42,6 +42,10 @@
#include "G4Polyhedron.hh"
/**
* @brief G4UTet is a wrapper class for G4Tet to make use of VecGeom Tet.
*/
class G4UTet : public G4UAdapter<vecgeom::UnplacedTet>
{
@@ -50,58 +54,109 @@ class G4UTet : public G4UAdapter<vecgeom::UnplacedTet>
public:
/**
* Constructs a tetrahedra, given its parameters.
* @param[in] pName The solid name.
* @param[in] anchor The anchor point.
* @param[in] p2 Point 2.
* @param[in] p3 Point 3.
* @param[in] p4 Point 4.
* @param[in] degeneracyFlag Flag indicating degeneracy of points.
*/
G4UTet(const G4String& pName,
const G4ThreeVector& anchor,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
const G4ThreeVector& p4,
G4bool* degeneracyFlag = nullptr);
~G4UTet() override;
/**
* Default destructor.
*/
~G4UTet() override = default;
void ComputeDimensions( G4VPVParameterisation* p,
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions(G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep) override;
/**
* Makes a clone of the object for use in multi-treading.
* @returns A pointer to the new cloned allocated solid.
*/
G4VSolid* Clone() const override;
/**
* Returns the type ID, "G4Tet" of the solid.
*/
inline G4GeometryType GetEntityType() const override;
/**
* Returns true as the solid has only planar faces.
*/
inline G4bool IsFaceted() const override;
G4UTet(const G4UTet& rhs);
G4UTet& operator=(const G4UTet& rhs);
// Copy constructor and assignment operator.
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void SetBoundingLimits(const G4ThreeVector& pMin, const G4ThreeVector& pMax);
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const override;
/**
* Returns a generated polyhedron as graphical representations.
*/
G4Polyhedron* CreatePolyhedron() const override;
/**
* Modifier and accessors, for the four vertices of the shape.
*/
void SetVertices(const G4ThreeVector& anchor,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
G4bool* degeneracyFlag = nullptr);
// Set new position of the vertices.
void GetVertices(G4ThreeVector& anchor,
G4ThreeVector& p1,
G4ThreeVector& p2,
G4ThreeVector& p3) const;
std::vector<G4ThreeVector> GetVertices() const;
// Return the four vertices of the shape.
/**
* Checks if the tetrahedron is degenerate. A tetrahedron is considered
* as degenerate in case its minimal height is less than the degeneracy
* tolerance
* @returns true if the tetrahedron is degenerate.
*/
G4bool CheckDegeneracy(const G4ThreeVector& p0,
const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3) const;
// Return true if the tetrahedron is degenerate.
/**
* Copy constructor and assignment operator.
*/
G4UTet(const G4UTet& rhs);
G4UTet& operator=(const G4UTet& rhs);
private:
@@ -27,140 +27,16 @@
//
// Class description:
//
// Definition of the virtual base class G4VCSGface, one side (or face)
// of a CSG-like solid. It should be possible to build a CSG entirely
// out of connecting CSG faces.
// Definition of the virtual base class G4VCSGface, one side (or face)
// of a CSG-like solid. It should be possible to build a CSG entirely
// out of connecting CSG faces.
//
// Each face has an inside and outside surface, the former represents
// the inside of the volume, the latter, the outside.
// Each face has an inside and outside surface, the former represents
// the inside of the volume, the latter, the outside.
//
// Virtual members:
// -------------------------------------------------------------------
//
// -------------------------------------------------------------------
// Intersect( const G4ThreeVector& p, const G4ThreeVector& v,
// G4bool outGoing, G4double surfTolerance,
// G4double& distance, G4double& distFromSurface,
// G4ThreeVector& normal, G4bool& allBehind );
//
// p - (in) position
// v - (in) direction (assumed to be a unit vector)
// outgoing - (in) true, to consider only inside surfaces
// false, to consider only outside surfaces
// distance - (out) distance to intersection
// distFromSurface - (out) distance from surface (along surface normal),
// < 0 if the point is in front of the surface
// normal - (out) normal of surface at intersection point
// allBehind - (out) true, if entire surface is behind normal
//
// return value = true if there is an intersection,
// false if there is no intersection
// (all output arguments undefined)
//
// Determine the distance along a line to the face.
//
// -------------------------------------------------------------------
// Distance( const G4ThreeVector& p, const G4bool outgoing );
//
// p - (in) position
// outgoing - (in) true, to consider only inside surfaces
// false, to consider only outside surfaces
//
// return value = distance to closest surface satisifying requirements
// or kInfinity if no such surface exists
//
// Determine the distance of a point from either the inside or outside
// surfaces of the face.
//
// -------------------------------------------------------------------
// Inside( const G4ThreeVector& p, const G4double tolerance,
// G4double* bestDistance );
//
// p - (in) position
// tolerance - (in) tolerance defining the bounds of the "kSurface",
// nominally equal to kCarTolerance/2
// bestDistance - (out) distance to closest surface (in or out)
//
// return value = kInside if the point is closest to the inside surface
// kOutside if the point is closest to the outside surface
// kSurface if the point is withing tolerance of the surface
//
// Determine whether a point is inside, outside, or on the surface of
// the face.
//
// -------------------------------------------------------------------
// Normal( const G4ThreeVector& p, G4double* bestDistance );
//
// p - (in) position
// bestDistance - (out) distance to closest surface (in or out)
//
// return value = the normal of the surface nearest the point
//
// Return normal of surface closest to the point.
//
// -------------------------------------------------------------------
// Extent( const G4ThreeVector axis );
//
// axis - (in) unit vector defining direction
//
// return value = the largest point along the given axis of the
// the face's extent.
//
// -------------------------------------------------------------------
// CalculateExtent( const EAxis pAxis,
// const G4VoxelLimit& pVoxelLimit,
// const G4AffineTransform& pTransform,
// G4double& min, G4double& max )
//
// pAxis - (in) The x,y, or z axis in which to check
// the shapes 3D extent against
// pVoxelLimit - (in) Limits along x, y, and/or z axes
// pTransform - (in) A coordinate transformation on which
// to apply to the shape before testing
// min - (out) If the face has any point on its
// surface after tranformation and limits
// along pAxis that is smaller than the value
// of min, than it is used to replace min.
// Undefined if the return value is false.
// max - (out) Same as min, except for the largest
// point.
// Undefined if the return value is false.
//
// return value = true if anything remains of the face
//
// Calculate the extent of the face for the voxel navigator.
// In analogy with CalculateExtent for G4VCSGfaceted, this is
// done in the following steps:
//
// 1. Transform the face using pTranform, an arbitrary 3D
// rotation/offset/reflection
// 2. Clip the face to those boundaries as specified in
// pVoxelLimit. This may include limits in any number
// of x, y, or z axes.
// 3. For each part of the face that remains (there could
// be many separate pieces in general):
// 4. Check to see if the piece overlaps the currently
// existing limits along axis pAxis. For
// pVoxelLimit.IsLimited(pAxis) = false, there are
// no limits.
// 5. For a piece that does overlap, update min/max
// accordingly (within confines of pre-existing
// limits) along the direction pAxis.
// 6. If min/max were updated, return true
//
// -------------------------------------------------------------------
// G3VCSGface *Clone()
//
// This method is invoked by G4CSGfaceted during the copy constructor
// or the assignment operator. Its purpose is to return a pointer
// (of type G4VCSGface) to a duplicate copy of the face.
// The implementation is straight forward for inherited classes. Example:
//
// G4VCSGface G4PolySideFace::Clone() { return new G4PolySideFace(*this); }
//
// Of course, this assumes the copy constructor of G4PolySideFace is
// correctly implemented.
//
// Implementation notes:
// Implementation notes:
// * distance.
// The meaning of distance includes the boundaries of the face.
// For example, for a rectangular, planer face:
@@ -186,7 +62,7 @@
// a point falls off the edge and then act accordingly.
//
//
// Usage:
// Usage:
//
// A CSG shape can be defined by putting together any number of generic
// faces, as long as the faces cover the entire surface of the shape
@@ -209,11 +85,13 @@
// EInside answer;
// G4VCSGface *face = faces;
// G4double best = kInfinity;
// do {
// do
// {
// G4double distance;
// EInside result = (*face)->Inside( p, kCarTolerance/2, distance );
// if (result == kSurface) return kSurface;
// if (distance < best) {
// if (distance < best)
// {
// best = distance;
// answer = result;
// }
@@ -247,7 +125,7 @@
// and save the answer that is smallest. If there is more than one answer,
// or if allBehind is false for the one answer, return validNorm as false.
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - Created
// --------------------------------------------------------------------
#ifndef G4VCSGFACE_HH
#define G4VCSGFACE_HH
@@ -261,36 +139,110 @@ class G4VoxelLimits;
class G4AffineTransform;
class G4SolidExtentList;
/**
* @brief G4VCSGface is virtual base class, representing one side (or face)
* of a CSG-like solid. It should be possible to build a CSG entirely
* out of connecting CSG faces. Each face has an inside and outside surface,
* the former represents the inside of the volume, the latter, the outside.
*/
class G4VCSGface
{
public:
/**
* Default Constructor and Destructor.
*/
G4VCSGface() = default;
virtual ~G4VCSGface() = default;
/**
* Determines the distance along a line to the face.
* @param[in] p Position.
* @param[in] v Direction (assumed to be a unit vector).
* @param[in] outgoing Flag true, to consider only inside surfaces;
* false, to consider only outside surfaces.
* @param[in] surfTolerance Minimum distance from the surface.
* @param[out] distance Distance to intersection.
* @param[out] distFromSurface Distance from surface (along surface normal),
* < 0 if the point is in front of the surface.
* @param[out] normal Normal of surface at intersection point.
* @param[out] allBehind Flag, true, if entire surface is behind normal.
* @returns true if there is an intersection, false otherwise.
*/
virtual G4bool Intersect( const G4ThreeVector& p, const G4ThreeVector& v,
G4bool outgoing, G4double surfTolerance,
G4double& distance, G4double& distFromSurface,
G4ThreeVector& normal, G4bool& allBehind ) = 0;
/**
* Determines the distance of a point from either the inside or outside
* surfaces of the face.
* @param[in] p Position.
* @param[in] outgoing Flag, true, to consider only inside surfaces
* or false, to consider only outside surfaces.
* @returns The distance to the closest surface satisfying requirements
* or kInfinity if no such surface exists.
*/
virtual G4double Distance( const G4ThreeVector& p, G4bool outgoing ) = 0;
/**
* Determines whether a point is inside, outside, or on the surface of
* the face.
* @param[in] p Position.
* @param[in] tolerance Tolerance defining the bounds of the "kSurface",
* nominally equal to kCarTolerance/2.
* @param[out] bestDistance Distance to the closest surface (in or out).
* @returns kInside if the point is closest to the inside surface;
* kOutside if the point is closest to the outside surface;
* kSurface if the point is withing tolerance of the surface.
*/
virtual EInside Inside( const G4ThreeVector& p, G4double tolerance,
G4double* bestDistance ) = 0;
/**
* Returns the normal of surface closest to the point.
* @param[in] p Position.
* @param[out] bestDistance Distance to the closest surface (in or out).
* @returns The normal of the surface nearest the point.
*/
virtual G4ThreeVector Normal( const G4ThreeVector& p,
G4double* bestDistance ) = 0;
/**
* Returns the face extent along the axis.
* @param[in] axis Unit vector defining the direction.
* @returns The largest point along the given axis of the face's extent.
*/
virtual G4double Extent( const G4ThreeVector axis ) = 0;
/**
* Calculates the extent of the face for the voxel navigator.
* @param[in] axis The axis in which to check the shapes 3D extent against.
* @param[in] voxelLimit Limits along x, y, and/or z axes.
* @param[in] tranform A coordinate transformation on which to apply to
* the shape before testing.
* @param[out] extentList The list of (voxel) extents along the axis.
*/
virtual void CalculateExtent( const EAxis axis,
const G4VoxelLimits& voxelLimit,
const G4AffineTransform& tranform,
G4SolidExtentList& extentList ) = 0;
/**
* Method invoked by the copy constructor or the assignment operator.
* Its purpose is to return a pointer to a duplicate copy of the face.
*/
virtual G4VCSGface* Clone() = 0;
/**
* Returning an estimation of the face surface area, in internal units.
*/
virtual G4double SurfaceArea() = 0;
/**
* Auxiliary method for GetPointOnSurface().
*/
virtual G4ThreeVector GetPointOnFace() = 0;
};
@@ -27,10 +27,10 @@
//
// Class description:
//
// Virtual class defining CSG-like type shape that is built entirely
// of G4CSGface faces.
// Virtual class defining CSG-like type shape that is built entirely
// of G4CSGface faces.
// Author: David C. Williams (davidw@scipp.ucsc.edu)
// Author: David C. Williams (UCSC), 1998 - Created
// --------------------------------------------------------------------
#ifndef G4VCSGFACETED_HH
#define G4VCSGFACETED_HH 1
@@ -40,25 +40,52 @@
class G4VCSGface;
class G4VisExtent;
/**
* @brief G4VCSGfaceted is a virtual class defining a CSG-like type shape
* that is built entirely of G4CSGface faces.
*/
class G4VCSGfaceted : public G4VSolid
{
public:
/**
* Constructor taking a 'name'.
*/
G4VCSGfaceted( const G4String& name );
/**
* Destructor.
*/
~G4VCSGfaceted() override;
/**
* Copy constructor and assignment operator.
*/
G4VCSGfaceted( const G4VCSGfaceted& source );
G4VCSGfaceted& operator=( const G4VCSGfaceted& source );
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pmin, G4double& pmax) const override;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in G4VSolid.
*/
EInside Inside( const G4ThreeVector& p ) const override;
G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
G4double DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const override;
G4double DistanceToIn( const G4ThreeVector& p ) const override;
@@ -69,18 +96,31 @@ class G4VCSGfaceted : public G4VSolid
G4ThreeVector* n = nullptr ) const override;
G4double DistanceToOut( const G4ThreeVector& p ) const override;
/**
* Returns the type ID, "G4CSGfaceted" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Returns a pointer to a generated polyhedron used for visualisation.
*/
G4Polyhedron* CreatePolyhedron() const override = 0;
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
void DescribeYourselfTo( G4VGraphicsScene& scene ) const override;
G4VisExtent GetExtent() const override;
G4Polyhedron* GetPolyhedron () const override;
/**
* Accessors and modifiers for capacity and area computation.
*/
G4int GetCubVolStatistics() const;
G4double GetCubVolEpsilon() const;
void SetCubVolStatistics(G4int st);
@@ -90,17 +130,41 @@ class G4VCSGfaceted : public G4VSolid
void SetAreaStatistics(G4int st);
void SetAreaAccuracy(G4double ep);
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units. Caches the computed value
* once computed the first time.
*/
G4double GetCubicVolume() override;
// Returns an estimation of the geometrical cubic volume of the
// solid. Caches the computed value once computed the first time.
G4double GetSurfaceArea() override;
// Returns an estimation of the geometrical surface area of the
// solid. Caches the computed value once computed the first time.
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4VCSGfaceted(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
protected:
/**
* Protected method used in DistanceToIn() and DistanceToOut().
*/
virtual G4double DistanceTo( const G4ThreeVector& p,
const G4bool outgoing ) const;
/**
* Returns a random point located on the surface of the solid
* in case of generic Polycone or generic Polyhedra.
*/
G4ThreeVector GetPointOnSurfaceGeneric()const;
/**
* Copy parameters from other solid or reset them.
* Used in copy constructor and assignment operator.
*/
void CopyStuff( const G4VCSGfaceted& source );
void DeleteStuff();
protected:
@@ -111,22 +175,12 @@ class G4VCSGfaceted : public G4VSolid
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr;
virtual G4double DistanceTo( const G4ThreeVector& p,
const G4bool outgoing ) const;
G4ThreeVector GetPointOnSurfaceGeneric()const;
// Returns a random point located on the surface of the solid
// in case of generic Polycone or generic Polyhedra.
void CopyStuff( const G4VCSGfaceted& source );
void DeleteStuff();
private:
G4int fStatistics;
/** Statistics, error accuracy for volume estimation. */
G4int fStatistics;
G4double fCubVolEpsilon;
G4double fAreaAccuracy;
// Statistics, error accuracy for volume estimation.
};
#endif
@@ -28,11 +28,11 @@
//
// Class description:
//
// Base class defining the facets which are components of a
// G4TessellatedSolid shape.
// Base class defining the facets which are components of a
// G4TessellatedSolid shape.
// 31 October 2004, P R Truscott, QinetiQ Ltd, UK - Created.
// 12 October 2012, M Gayer, CERN, - Reviewed optimised implementation.
// Author: P.R.Truscott (QinetiQ Ltd, UK), 31.10.2004 - Created.
// M.Gayer (CERN), 12.10.2012 - Reviewed optimised implementation.
// --------------------------------------------------------------------
#ifndef G4VFACET_HH
#define G4VFACET_HH
@@ -47,45 +47,137 @@
enum G4FacetVertexType { ABSOLUTE, RELATIVE };
/**
* @brief G4VFacet is a base class defining the facets which are components
* of a G4TessellatedSolid shape.
*/
class G4VFacet
{
public:
/**
* Constructor and default Destructor.
*/
G4VFacet();
virtual ~G4VFacet ();
virtual ~G4VFacet() = default;
/**
* Equality operator.
*/
G4bool operator== (const G4VFacet& right) const;
/**
* Returns the number of vertices of the facet.
*/
virtual G4int GetNumberOfVertices () const = 0;
/**
* Returns the vertex based on the index 'i'.
*/
virtual G4ThreeVector GetVertex (G4int i) const = 0;
/**
* Methods to set the vertices.
*/
virtual void SetVertex (G4int i, const G4ThreeVector& val) = 0;
virtual void SetVertices(std::vector<G4ThreeVector>* vertices) = 0;
/**
* Returns the type ID of the facet.
*/
virtual G4GeometryType GetEntityType () const = 0;
/**
* Returns the normal vector to the facet.
*/
virtual G4ThreeVector GetSurfaceNormal () const = 0;
/**
* Returns true if the facet is defined.
*/
virtual G4bool IsDefined () const = 0;
/**
* Returns the circumcentre point of the facet.
*/
virtual G4ThreeVector GetCircumcentre () const = 0;
/**
* Returns the radius to the anchor point and centered on the circumcentre.
*/
virtual G4double GetRadius () const = 0;
/**
* Returns a pointer to a newly allocated duplicate copy of the facet.
*/
virtual G4VFacet* GetClone () = 0;
virtual G4double Distance (const G4ThreeVector&, G4double) = 0;
virtual G4double Distance (const G4ThreeVector&, G4double,
/**
* Determines the closest distance between point p and the facet.
*/
virtual G4double Distance (const G4ThreeVector&, G4double minDist) = 0;
/**
* 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.
*/
virtual G4double Distance (const G4ThreeVector&, G4double minDist,
const G4bool) = 0;
virtual G4double Extent (const G4ThreeVector) = 0;
virtual G4bool Intersect (const G4ThreeVector&, const G4ThreeVector&,
const G4bool, G4double&, G4double&,
G4ThreeVector&) = 0;
/**
* Calculates the furthest the triangle extends in fA particular
* direction defined by the vector axis.
*/
virtual G4double Extent (const G4ThreeVector axis) = 0;
/**
* 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.
*/
virtual G4bool Intersect (const G4ThreeVector& p, const G4ThreeVector& v,
const G4bool outgoing, G4double& distance,
G4double& distFromSurface,
G4ThreeVector& normal) = 0;
/**
* Auxiliary method for returning the surface area.
*/
virtual G4double GetArea() const = 0;
/**
* Auxiliary method to get a uniform random point on the facet.
*/
virtual G4ThreeVector GetPointOnFace() const = 0;
/**
* Adds a translation 'v' to the vertices of the facet.
*/
void ApplyTranslation (const G4ThreeVector& v);
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const;
/**
* Returns true if point 'p' is inside the facet.
*/
G4bool IsInside(const G4ThreeVector& p) const;
/**
* Logger methods for allocated memory of facets.
*/
virtual G4int AllocatedMemory() = 0;
virtual void SetVertexIndex (G4int i, G4int j) = 0;
virtual G4int GetVertexIndex (G4int i) const = 0;
virtual void SetVertices(std::vector<G4ThreeVector>* vertices) = 0;
protected:
@@ -29,8 +29,8 @@
//
// Abstract base class for boundary surface of G4VSolid.
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp), created.
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// Author: Kotoyo Hoshina (Chiba University), 01.08.2002 - Created.
// Oliver Link (CERN), 13.11.2003 - Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef G4VTWISTSURFACE_HH
@@ -45,324 +45,455 @@
#define G4VSURFACENXX 10
/**
* @brief G4VTwistSurface is a base class for boundary surface of a G4VSolid.
*/
class G4VTwistSurface
{
public:
public:
enum EValidate { kDontValidate = 0, kValidateWithTol = 1,
kValidateWithoutTol = 2, kUninitialized = 3 };
enum EValidate { kDontValidate = 0, kValidateWithTol = 1,
kValidateWithoutTol = 2, kUninitialized = 3 };
G4VTwistSurface (const G4String& name);
G4VTwistSurface (const G4String& name,
const G4RotationMatrix& rot,
const G4ThreeVector& tlate,
G4int handedness,
const EAxis axis1,
const EAxis axis2,
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity);
/**
* Base constructor, given a name.
* @param[in] name The surface name.
*/
G4VTwistSurface (const G4String& name);
virtual ~G4VTwistSurface() = default;
/**
* Constructs a surface, given its parameters.
* @param[in] name The surface name.
* @param[in] rot Rotation: 0.5*(phi-width segment).
* @param[in] tlate Translation.
* @param[in] handedness Orientation: R-hand = 1, L-hand = -1.
* @param[in] axis0 First axis.
* @param[in] axis1 Second axis.
* @param[in] axis0min Minimum in first axis.
* @param[in] axis1min Minimum in second axis.
* @param[in] axis0max Maximum in first axis.
* @param[in] axis1max Maximum in second axis.
*/
G4VTwistSurface (const G4String& name,
const G4RotationMatrix& rot,
const G4ThreeVector& tlate,
G4int handedness,
const EAxis axis0,
const EAxis axis1,
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity);
/**
* Default destructor.
*/
virtual ~G4VTwistSurface() = default;
virtual G4int AmIOnLeftSide(const G4ThreeVector& me,
const G4ThreeVector& vec,
G4bool withTol = true);
/**
* Returns the phi-location of point 'me' (phi relation between 'me' and
* 'vec' projected on z=0 plane). If 'me' is on -ve-phi-side of 'vec', it
* returns 1; on the other hand, if 'me' is on +ve-phi-side of 'vec',
* it returns -1. If 'me' is on boundary of 'vec', it returns 0.
* @returns The z-coordinate of normal vector of me.cross(vec).
*/
virtual G4int AmIOnLeftSide(const G4ThreeVector& me,
const G4ThreeVector& vec,
G4bool withTol = true);
virtual G4double DistanceToBoundary( G4int areacode,
G4ThreeVector& xx,
/**
* Returns the distance to the nearest boundary from an arbitrary point 'p'
* in local coodinate.
* @param[in] areacode Point location code according to axes.
* @param[out] xx The returned reference point on boundary.
* @param[in] p The arbitrary point in input.
*/
virtual G4double DistanceToBoundary(G4int areacode,
G4ThreeVector& xx,
const G4ThreeVector& p) ;
virtual G4double DistanceToIn(const G4ThreeVector& gp,
/**
* Returns the distance from outside to a boundary from an arbitrary
* point 'gp' and direction 'gv'.
* @param[in] gp The arbitrary point.
* @param[in] gv The direction vector.
* @param[out] gxxbest The returned reference point on boundary.
*/
virtual G4double DistanceToIn(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector& gxxbest);
virtual G4double DistanceToOut(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector& gxxbest);
virtual G4double DistanceTo(const G4ThreeVector& gp,
/**
* Returns the distance from inside to a boundary from an arbitrary
* point 'gp' and direction 'gv'.
* @param[in] gp The arbitrary point.
* @param[in] gv The direction vector.
* @param[out] gxxbest The returned reference point on boundary.
*/
virtual G4double DistanceToOut(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector& gxxbest);
/**
* Returns the safety distance to a boundary from an arbitrary point 'gp'.
* @param[in] gp The arbitrary point.
* @param[out] gxxbest The returned reference point on boundary.
*/
virtual G4double DistanceTo(const G4ThreeVector& gp,
G4ThreeVector& gxx);
virtual G4int DistanceToSurface(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
EValidate validate=kValidateWithTol) = 0;
/**
* Returns the distance to surface, given point 'gp' and direction 'gv'.
* @param[in] gp The point from where computing the distance.
* @param[in] gv The direction along which computing the distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @param[out] isvalid Validity vector based on number of solutions.
* @param[in] validate Adopted validation criteria.
* @returns The number of solutions.
*/
virtual G4int DistanceToSurface(const G4ThreeVector& gp,
const G4ThreeVector& gv,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
EValidate validate = kValidateWithTol) = 0;
virtual G4int DistanceToSurface(const G4ThreeVector& gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) = 0;
/**
* Returns the safety distance to surface, given point 'gp'.
* @param[in] gp The point from where computing the safety distance.
* @param[out] gxx Vector of global points based on number of solutions.
* @param[out] distance The distance vector based on number of solutions.
* @param[out] areacode The location vector based on number of solutions.
* @returns The number of solutions.
*/
virtual G4int DistanceToSurface(const G4ThreeVector& gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) = 0;
void DebugPrint() const;
virtual G4ThreeVector GetNormal(const G4ThreeVector& xx,G4bool isGlobal) = 0;
/**
* Returns a normal vector at a surface (or very close to the surface)
* point at 'p'.
* @param[in] p The point where computing the normal.
* @param[in] isGlobal If true, it returns the normal in global coordinates.
* @returns The normal vector.
*/
virtual G4ThreeVector GetNormal(const G4ThreeVector& p,
G4bool isGlobal) = 0;
virtual G4String GetName() const { return fName; }
virtual void GetBoundaryParameters(const G4int& areacode,
G4ThreeVector& d,
G4ThreeVector& x0,
G4int& boundarytype) const;
virtual G4ThreeVector GetBoundaryAtPZ(G4int areacode,
const G4ThreeVector& p) const;
/**
* Returns parameters of boundaries.
* @param[in] areacode The location code.
* @param[out] d Boundary direction.
* @param[out] x0 The point on boundary.
* @param[out] boundarytype The boundary code.
*/
virtual void GetBoundaryParameters(const G4int& areacode,
G4ThreeVector& d,
G4ThreeVector& x0,
G4int& boundarytype) const;
inline G4double DistanceToPlaneWithV(const G4ThreeVector& p,
/**
* Returns Z projection of point 'p' on boundary.
* @param[in] areacode The location code.
* @param[out] p The arbitrary point.
* @returns The Z projection on boundary.
*/
virtual G4ThreeVector GetBoundaryAtPZ(G4int areacode,
const G4ThreeVector& p) const;
/**
* Utility methods to compute the distance from a plane/line.
*/
inline G4double DistanceToPlaneWithV(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4ThreeVector& x0,
const G4ThreeVector& n0,
G4ThreeVector& xx);
inline G4double DistanceToPlane(const G4ThreeVector& p,
inline G4double DistanceToPlane(const G4ThreeVector& p,
const G4ThreeVector& x0,
const G4ThreeVector& n0,
G4ThreeVector& xx);
inline G4double DistanceToPlane(const G4ThreeVector& p,
inline G4double DistanceToPlane(const G4ThreeVector& p,
const G4ThreeVector& x0,
const G4ThreeVector& t1,
const G4ThreeVector& t2,
G4ThreeVector& xx,
G4ThreeVector& n);
inline G4double DistanceToLine (const G4ThreeVector& p,
inline G4double DistanceToLine (const G4ThreeVector& p,
const G4ThreeVector& x0,
const G4ThreeVector& d,
G4ThreeVector& xx);
inline G4bool IsAxis0 (G4int areacode) const;
inline G4bool IsAxis1 (G4int areacode) const;
inline G4bool IsOutside (G4int areacode) const;
inline G4bool IsInside (G4int areacode, G4bool testbitmode = false) const;
inline G4bool IsBoundary (G4int areacode, G4bool testbitmode = false) const;
inline G4bool IsCorner (G4int areacode, G4bool testbitmode = false) const;
inline G4bool IsValidNorm() const { return fIsValidNorm; }
G4bool IsSameBoundary (G4VTwistSurface* surface1, G4int areacode1,
G4VTwistSurface* surface2, G4int areacode2 ) const;
inline G4int GetAxisType(G4int areacode, G4int whichaxis) const;
/**
* Test functions/accessors, based on 'areacode' location.
*/
inline G4bool IsAxis0 (G4int areacode) const;
inline G4bool IsAxis1 (G4int areacode) const;
inline G4bool IsOutside (G4int areacode) const;
inline G4bool IsInside (G4int areacode, G4bool testbitmode = false) const;
inline G4bool IsBoundary (G4int areacode, G4bool testbitmode = false) const;
inline G4bool IsCorner (G4int areacode, G4bool testbitmode = false) const;
inline G4bool IsValidNorm() const { return fIsValidNorm; }
G4bool IsSameBoundary (G4VTwistSurface* surface1, G4int areacode1,
G4VTwistSurface* surface2, G4int areacode2 ) const;
inline G4int GetAxisType(G4int areacode, G4int whichaxis) const;
inline G4ThreeVector ComputeGlobalPoint (const G4ThreeVector& lp) const;
inline G4ThreeVector ComputeLocalPoint (const G4ThreeVector& gp) const;
inline G4ThreeVector ComputeGlobalDirection (const G4ThreeVector& lp) const;
inline G4ThreeVector ComputeLocalDirection (const G4ThreeVector& gp) const;
/**
* Utility functions computing global/local point/direction.
*/
inline G4ThreeVector ComputeGlobalPoint (const G4ThreeVector& lp) const;
inline G4ThreeVector ComputeLocalPoint (const G4ThreeVector& gp) const;
inline G4ThreeVector ComputeGlobalDirection (const G4ThreeVector& lp) const;
inline G4ThreeVector ComputeLocalDirection (const G4ThreeVector& gp) const;
// set methods
/**
* Modifiers for axes.
*/
inline void SetAxis(G4int i, const EAxis axis) { fAxis[i] = axis; }
inline void SetNeighbours(G4VTwistSurface* ax0min, G4VTwistSurface* ax1min,
G4VTwistSurface* ax0max, G4VTwistSurface* ax1max);
inline void SetAxis(G4int i, const EAxis axis) { fAxis[i] = axis; }
inline void SetNeighbours(G4VTwistSurface* ax0min, G4VTwistSurface* ax1min,
G4VTwistSurface* ax0max, G4VTwistSurface* ax1max);
/**
* Returns point on surface given the axes.
*/
virtual G4ThreeVector SurfacePoint(G4double, G4double,
G4bool isGlobal = false ) = 0 ;
virtual G4ThreeVector SurfacePoint(G4double, G4double,
G4bool isGlobal = false ) = 0 ;
virtual G4double GetBoundaryMin(G4double) = 0 ;
virtual G4double GetBoundaryMax(G4double) = 0 ;
virtual G4double GetSurfaceArea() = 0 ;
virtual void GetFacets(G4int m, G4int n, G4double xyz[][3],
G4int faces[][4], G4int iside) = 0 ;
G4int GetNode( G4int i, G4int j, G4int m, G4int n, G4int iside ) ;
G4int GetFace( G4int i, G4int j, G4int m, G4int n, G4int iside ) ;
G4int GetEdgeVisibility( G4int i, G4int j, G4int m, G4int n,
G4int number, G4int orientation) ;
/**
* Internal accessors to be implemented in concrete derived classes.
*/
virtual G4double GetBoundaryMin(G4double) = 0 ;
virtual G4double GetBoundaryMax(G4double) = 0 ;
virtual G4double GetSurfaceArea() = 0 ;
virtual void GetFacets(G4int m, G4int n, G4double xyz[][3],
G4int faces[][4], G4int iside) = 0 ;
G4VTwistSurface(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Node/face mapping functions.
*/
G4int GetNode( G4int i, G4int j, G4int m, G4int n, G4int iside ) ;
G4int GetFace( G4int i, G4int j, G4int m, G4int n, G4int iside ) ;
protected:
/**
* Checks face visibility, based on verteces and orientation.
* @returns -1 if invisible; 1 if visible.
*/
G4int GetEdgeVisibility( G4int i, G4int j, G4int m, G4int n,
G4int number, G4int orientation) ;
/**
* Returns the surface name.
*/
inline const G4String& GetName() const { return fName; }
/**
* Prints on standard output surface data.
*/
void DebugPrint() const;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4VTwistSurface(__void__&);
protected:
inline G4VTwistSurface** GetNeighbours() { return fNeighbours; }
inline G4int GetNeighbours(G4int areacode, G4VTwistSurface* surfaces[]);
inline G4ThreeVector GetCorner(G4int areacode) const;
void GetBoundaryAxis(G4int areacode, EAxis axis[]) const;
void GetBoundaryLimit(G4int areacode, G4double limit[]) const;
virtual G4int GetAreaCode(const G4ThreeVector& xx, G4bool withtol=true) = 0;
/**
* Internal accessors.
*/
inline G4VTwistSurface** GetNeighbours() { return fNeighbours; }
inline G4int GetNeighbours(G4int areacode, G4VTwistSurface* surfaces[]);
inline G4ThreeVector GetCorner(G4int areacode) const;
void GetBoundaryAxis(G4int areacode, EAxis axis[]) const;
void GetBoundaryLimit(G4int areacode, G4double limit[]) const;
virtual G4int GetAreaCode(const G4ThreeVector& xx, G4bool withtol=true) = 0;
virtual void SetBoundary(const G4int& axiscode,
const G4ThreeVector& direction,
const G4ThreeVector& x0,
const G4int& boundarytype);
// areacode must be one of them:
// sAxis0 & sAxisMin, sAxis0 & sAxisMax,
// sAxis1 & sAxisMin, sAxis1 & sAxisMax.
// boundarytype represents the shape of locus
// from the start point to end point of boundary.
// ex.
// sAxisRho = linear line which start point is fixed at origin.
// sAxisPhi = part of circle which center placed at the origin.
void SetCorner(G4int areacode, G4double x, G4double y, G4double z);
/**
* Modifier for boundaries.
* @param[in] axiscode The location code, either: sAxis0 & sAxisMin,
* sAxis0 & sAxisMax, sAxis1 & sAxisMin, sAxis1 & sAxisMax.
* @param[in] direction Direction.
* @param[in] x0 Point on boundary.
* @param[in] boundarytype The shape of locus from the start point to
* end point of boundary (ex. sAxisRho = linear line which
* start point is fixed at origin; sAxisPhi = part of circle
* which center placed at the origin.
*/
virtual void SetBoundary(const G4int& axiscode,
const G4ThreeVector& direction,
const G4ThreeVector& x0,
const G4int& boundarytype);
private:
/**
* Modifier for corners.
*/
void SetCorner(G4int areacode, G4double x, G4double y, G4double z);
virtual void SetBoundaries() = 0;
virtual void SetCorners() = 0;
private:
/**
* Internal setters to be implemented in concrete dereived classes.
*/
virtual void SetBoundaries() = 0;
virtual void SetCorners() = 0;
// data members ---------------------------------------------------------
// data members ---------------------------------------------------------
public:
public:
static const G4int sOutside ;
static const G4int sInside ;
static const G4int sBoundary;
static const G4int sCorner;
static const G4int sC0Min1Min;
static const G4int sC0Max1Min;
static const G4int sC0Max1Max;
static const G4int sC0Min1Max;
static const G4int sAxisMin;
static const G4int sAxisMax;
static const G4int sAxisX;
static const G4int sAxisY;
static const G4int sAxisZ;
static const G4int sAxisRho;
static const G4int sAxisPhi;
static const G4int sAxis0;
static const G4int sAxis1;
static const G4int sSizeMask;
static const G4int sAxisMask;
static const G4int sAreaMask;
/** Boundary types. */
static const G4int sOutside ;
static const G4int sInside ;
static const G4int sBoundary;
static const G4int sCorner;
static const G4int sC0Min1Min;
static const G4int sC0Max1Min;
static const G4int sC0Max1Max;
static const G4int sC0Min1Max;
static const G4int sAxisMin;
static const G4int sAxisMax;
static const G4int sAxisX;
static const G4int sAxisY;
static const G4int sAxisZ;
static const G4int sAxisRho;
static const G4int sAxisPhi;
static const G4int sAxis0;
static const G4int sAxis1;
static const G4int sSizeMask;
static const G4int sAxisMask;
static const G4int sAreaMask;
protected:
protected:
class CurrentStatus
{
public:
class CurrentStatus
{
/**
* @brief Internal class defining the surface status.
*/
public:
CurrentStatus();
virtual ~CurrentStatus();
CurrentStatus();
virtual ~CurrentStatus();
inline G4ThreeVector GetXX(G4int i) const { return fXX[i]; }
inline G4double GetDistance(G4int i) const { return fDistance[i]; }
inline G4int GetAreacode(G4int i) const { return fAreacode[i]; }
inline G4int GetNXX() const { return fNXX; }
inline G4bool IsDone() const { return fDone; }
inline G4bool IsValid(G4int i) const { return fIsValid[i]; }
inline G4ThreeVector GetXX(G4int i) const { return fXX[i]; }
inline G4double GetDistance(G4int i) const { return fDistance[i]; }
inline G4int GetAreacode(G4int i) const { return fAreacode[i]; }
inline G4int GetNXX() const { return fNXX; }
inline G4bool IsDone() const { return fDone; }
inline G4bool IsValid(G4int i) const { return fIsValid[i]; }
void SetCurrentStatus(G4int i,
G4ThreeVector& xx,
G4double& dist,
G4int& areacode,
G4bool& isvalid,
G4int nxx,
EValidate validate,
const G4ThreeVector* p,
const G4ThreeVector* v = nullptr);
void SetCurrentStatus(G4int i,
G4ThreeVector& xx,
G4double& dist,
G4int& areacode,
G4bool& isvalid,
G4int nxx,
EValidate validate,
const G4ThreeVector* p,
const G4ThreeVector* v = nullptr);
void ResetfDone(EValidate validate,
const G4ThreeVector* p,
const G4ThreeVector* v = nullptr);
void ResetfDone(EValidate validate,
const G4ThreeVector* p,
const G4ThreeVector* v = nullptr);
void DebugPrint() const;
void DebugPrint() const;
private:
private:
G4double fDistance[G4VSURFACENXX];
G4ThreeVector fXX[G4VSURFACENXX];
G4int fAreacode[G4VSURFACENXX];
G4bool fIsValid[G4VSURFACENXX];
G4int fNXX;
G4ThreeVector fLastp;
G4ThreeVector fLastv;
EValidate fLastValidate;
G4bool fDone;
};
G4double fDistance[G4VSURFACENXX];
G4ThreeVector fXX[G4VSURFACENXX];
G4int fAreacode[G4VSURFACENXX];
G4bool fIsValid[G4VSURFACENXX];
G4int fNXX;
G4ThreeVector fLastp;
G4ThreeVector fLastv;
EValidate fLastValidate;
G4bool fDone;
};
class Boundary
{
public:
class Boundary
{
/**
* @brief Internal class defining a surface boundary type.
*/
public:
Boundary() = default;
virtual ~Boundary() = default;
Boundary() = default;
virtual ~Boundary() = default;
void SetFields(const G4int& areacode,
const G4ThreeVector& d,
const G4ThreeVector& x0,
const G4int& boundarytype);
void SetFields(const G4int& areacode,
const G4ThreeVector& d,
const G4ThreeVector& x0,
const G4int& boundarytype);
G4bool IsEmpty() const;
G4bool IsEmpty() const;
G4bool GetBoundaryParameters(const G4int& areacode,
G4ThreeVector& d,
G4ThreeVector& x0,
G4int& boundarytype) const;
G4bool GetBoundaryParameters(const G4int& areacode,
G4ThreeVector& d,
G4ThreeVector& x0,
G4int& boundarytype) const;
private:
private:
G4int fBoundaryAcode{-1};
G4ThreeVector fBoundaryDirection;
G4ThreeVector fBoundaryX0;
G4int fBoundaryType{0};
};
G4int fBoundaryAcode{-1};
G4ThreeVector fBoundaryDirection;
G4ThreeVector fBoundaryX0;
G4int fBoundaryType{0};
};
EAxis fAxis[2];
G4double fAxisMin[2];
G4double fAxisMax[2];
CurrentStatus fCurStatWithV;
CurrentStatus fCurStat;
G4RotationMatrix fRot;
G4ThreeVector fTrans;
G4int fHandedness;
class G4SurfCurNormal
{
public:
EAxis fAxis[2];
G4double fAxisMin[2];
G4double fAxisMax[2];
CurrentStatus fCurStatWithV;
CurrentStatus fCurStat;
G4RotationMatrix fRot;
G4ThreeVector fTrans;
G4int fHandedness;
G4ThreeVector p;
G4ThreeVector normal;
};
G4SurfCurNormal fCurrentNormal;
G4bool fIsValidNorm;
G4double kCarTolerance;
private:
class G4SurfCurNormal
{
public:
G4ThreeVector p;
G4ThreeVector normal;
};
G4SurfCurNormal fCurrentNormal;
G4bool fIsValidNorm;
G4double kCarTolerance;
private:
G4VTwistSurface* fNeighbours[4]; // {0,1,2,3} = sAxis0min, sAxis1min,
// sAxis0max, sAxis1max
G4ThreeVector fCorners[4]; // corners of the surface in local coordinate
Boundary fBoundaries[4]; // boundaries of the surface.
G4String fName;
G4VTwistSurface* fNeighbours[4]; // {0,1,2,3} = sAxis0min, sAxis1min,
// sAxis0max, sAxis1max
G4ThreeVector fCorners[4]; // corners of the surface in local coordinate
Boundary fBoundaries[4]; // boundaries of the surface.
G4String fName;
class G4SurfSideQuery
{
public:
class G4SurfSideQuery
{
public:
G4ThreeVector me;
G4ThreeVector vec;
G4bool withTol;
G4int amIOnLeftSide;
};
G4SurfSideQuery fAmIOnLeftSide;
G4ThreeVector me;
G4ThreeVector vec;
G4bool withTol;
G4int amIOnLeftSide;
};
G4SurfSideQuery fAmIOnLeftSide;
};
//========================================================
// inline functions
//========================================================
struct Intersection
{
G4double phi ; // parameter phi
G4double u ; // parameter u
G4ThreeVector xx ; // intersection point in cartesian
G4double distance ; // distance to intersection
G4int areacode ; // the areacode of the intersection
G4bool isvalid ; // valid intersection ??
};
inline
G4bool DistanceSort( const Intersection& a, const Intersection& b)
{
return a.distance < b.distance ;
}
inline
G4bool EqualIntersection( const Intersection& a, const Intersection& b)
{
return ( ( a.xx - b.xx ).mag() < 1E-9*CLHEP::mm ) ;
}
#include "G4VTwistSurface.icc"
#endif
@@ -25,20 +25,43 @@
//
// G4VTwistSurface class inline methods
//
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp), created.
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// Author: Kotoyo Hoshina (Chiba University), 01.08.2002 - Created.
// Oliver Link (CERN), 13.11.2003 - Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
struct Intersection
{
G4double phi ; // parameter phi
G4double u ; // parameter u
G4ThreeVector xx ; // intersection point in cartesian
G4double distance ; // distance to intersection
G4int areacode ; // the areacode of the intersection
G4bool isvalid ; // valid intersection ??
};
inline
G4bool DistanceSort( const Intersection& a, const Intersection& b)
{
return a.distance < b.distance ;
}
inline
G4bool EqualIntersection( const Intersection& a, const Intersection& b)
{
return ( ( a.xx - b.xx ).mag() < 1E-9*CLHEP::mm ) ;
}
//=====================================================================
//* DistanceToPlaneWithV ----------------------------------------------
inline
G4double G4VTwistSurface::DistanceToPlaneWithV(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4ThreeVector& x0,
const G4ThreeVector& n0,
G4ThreeVector& xx)
const G4ThreeVector& v,
const G4ThreeVector& x0,
const G4ThreeVector& n0,
G4ThreeVector& xx)
{
G4double q = n0 * v;
G4double t = kInfinity;
@@ -177,14 +200,13 @@ G4bool G4VTwistSurface::IsOutside(G4int areacode) const
inline
G4bool G4VTwistSurface::IsInside(G4int areacode, G4bool testbitmode) const
{
if ((areacode & sInside) != 0) {
if (testbitmode) {
return true;
} else {
if (((areacode & sBoundary) == 0) && ((areacode & sCorner) == 0)) return true;
}
}
return false;
if ((areacode & sInside) != 0)
{
if (testbitmode) { return true; }
if (((areacode & sBoundary) == 0)
&& ((areacode & sCorner) == 0)) { return true; }
}
return false;
}
//=====================================================================
@@ -193,14 +215,12 @@ G4bool G4VTwistSurface::IsInside(G4int areacode, G4bool testbitmode) const
inline
G4bool G4VTwistSurface::IsBoundary(G4int areacode, G4bool testbitmode) const
{
if ((areacode & sBoundary) == sBoundary) {
if (testbitmode) {
return true;
} else {
if ((areacode & sInside) == sInside) return true;
}
}
return false;
if ((areacode & sBoundary) == sBoundary)
{
if (testbitmode) { return true; }
if ((areacode & sInside) == sInside) { return true; }
}
return false;
}
//=====================================================================
@@ -209,14 +229,12 @@ G4bool G4VTwistSurface::IsBoundary(G4int areacode, G4bool testbitmode) const
inline
G4bool G4VTwistSurface::IsCorner(G4int areacode, G4bool testbitmode) const
{
if ((areacode & sCorner) == sCorner) {
if (testbitmode) {
return true;
} else {
if ((areacode & sInside) == sInside) return true;
}
}
return false;
if ((areacode & sCorner) == sCorner)
{
if (testbitmode) { return true; }
if ((areacode & sInside) == sInside) { return true; }
}
return false;
}
//=====================================================================
@@ -225,31 +243,40 @@ G4bool G4VTwistSurface::IsCorner(G4int areacode, G4bool testbitmode) const
inline
G4int G4VTwistSurface::GetAxisType(G4int areacode, G4int whichaxis) const
{
G4int axiscode = areacode & sAxisMask & whichaxis;
if (axiscode == (sAxisX & sAxis0) ||
axiscode == (sAxisX & sAxis1)) {
return sAxisX;
} else if (axiscode == (sAxisY & sAxis0) ||
axiscode == (sAxisY & sAxis1)) {
return sAxisY;
} else if (axiscode == (sAxisZ & sAxis0) ||
axiscode == (sAxisZ & sAxis1)) {
return sAxisZ;
} else if (axiscode == (sAxisRho & sAxis0) ||
axiscode == (sAxisRho & sAxis1)) {
return sAxisRho;
} else if (axiscode == (sAxisPhi & sAxis0) ||
axiscode == (sAxisPhi & sAxis1)) {
return sAxisPhi;
} else {
std::ostringstream message;
message << "Configuration not supported." << G4endl
<< " areacode = " << areacode;
G4Exception("G4VTwistSurface::GetAxisType()","GeomSolids0001",
FatalException, message);
}
return 1;
G4int axiscode = areacode & sAxisMask & whichaxis;
if (axiscode == (sAxisX & sAxis0) ||
axiscode == (sAxisX & sAxis1))
{
return sAxisX;
}
if (axiscode == (sAxisY & sAxis0) ||
axiscode == (sAxisY & sAxis1))
{
return sAxisY;
}
if (axiscode == (sAxisZ & sAxis0) ||
axiscode == (sAxisZ & sAxis1))
{
return sAxisZ;
}
if (axiscode == (sAxisRho & sAxis0) ||
axiscode == (sAxisRho & sAxis1))
{
return sAxisRho;
}
if (axiscode == (sAxisPhi & sAxis0) ||
axiscode == (sAxisPhi & sAxis1))
{
return sAxisPhi;
}
std::ostringstream message;
message << "Configuration not supported." << G4endl
<< " areacode = " << areacode;
G4Exception("G4VTwistSurface::GetAxisType()","GeomSolids0001",
FatalException, message);
return 1;
}
//=====================================================================
@@ -325,21 +352,21 @@ G4VTwistSurface::GetNeighbours(G4int areacode, G4VTwistSurface** surfaces)
{
surfaces[i] = fNeighbours[1] ;
++i ;
if ( i == 2 ) return i ;
if ( i == 2 ) { return i ; }
}
if ( ( areacode & sAxis0Max ) == sAxis0Max )
{
surfaces[i] = fNeighbours[2] ;
++i ;
if ( i == 2 ) return i ;
if ( i == 2 ) { return i ; }
}
if ( ( areacode & sAxis1Max ) == sAxis1Max )
{
surfaces[i] = fNeighbours[3] ;
++i ;
if ( i == 2 ) return i ;
if ( i == 2 ) { return i ; }
}
return i ;
@@ -351,29 +378,37 @@ G4VTwistSurface::GetNeighbours(G4int areacode, G4VTwistSurface** surfaces)
inline
G4ThreeVector G4VTwistSurface::GetCorner(G4int areacode) const
{
if ((areacode & sCorner) == 0)
{
std::ostringstream message;
message << "Area code must represent corner." << G4endl
<< " areacode = " << areacode;
G4Exception("G4VTwistSurface::GetCorner()","GeomSolids0002",
FatalException, message);
}
if ((areacode & sCorner) == 0)
{
std::ostringstream message;
message << "Area code must represent corner." << G4endl
<< " areacode = " << areacode;
G4Exception("G4VTwistSurface::GetCorner()","GeomSolids0002",
FatalException, message);
}
if ((areacode & sC0Min1Min) == sC0Min1Min) {
return fCorners[0];
} else if ((areacode & sC0Max1Min) == sC0Max1Min) {
return fCorners[1];
} else if ((areacode & sC0Max1Max) == sC0Max1Max) {
return fCorners[2];
} else if ((areacode & sC0Min1Max) == sC0Min1Max) {
return fCorners[3];
} else {
std::ostringstream message;
message << "Configuration not supported." << G4endl
<< " areacode = " << areacode;
G4Exception("G4VTwistSurface::GetCorner()", "GeomSolids0001",
FatalException, message);
}
return fCorners[0];
if ((areacode & sC0Min1Min) == sC0Min1Min)
{
return fCorners[0];
}
if ((areacode & sC0Max1Min) == sC0Max1Min)
{
return fCorners[1];
}
if ((areacode & sC0Max1Max) == sC0Max1Max)
{
return fCorners[2];
}
if ((areacode & sC0Min1Max) == sC0Min1Max)
{
return fCorners[3];
}
std::ostringstream message;
message << "Configuration not supported." << G4endl
<< " areacode = " << areacode;
G4Exception("G4VTwistSurface::GetCorner()", "GeomSolids0001",
FatalException, message);
return fCorners[0];
}
@@ -27,10 +27,10 @@
//
// Class description:
//
// G4VTwistedFaceted is an abstract base class for twisted boxoids:
// G4TwistedTrd, G4TwistedTrap and G4TwistedBox
// G4VTwistedFaceted is a base class for twisted boxoids:
// G4TwistedTrd, G4TwistedTrap and G4TwistedBox
// Author: 27-Oct-2004 - O.Link (CERN)
// Author: Oliver Link (CERN), 27.10.2004 - Created
// --------------------------------------------------------------------
#ifndef G4VTWISTEDFACETED_HH
#define G4VTWISTEDFACETED_HH 1
@@ -45,10 +45,32 @@
class G4SolidExtentList;
class G4ClippablePolygon;
/**
* @brief G4VTwistedFaceted is a base class for twisted boxoids:
* G4TwistedTrd, G4TwistedTrap and G4TwistedBox.
*/
class G4VTwistedFaceted: public G4VSolid
{
public:
/**
* Constructs a faceted solid, given its parameters.
* @param[in] pName The solid name.
* @param[in] pPhiTwist Twist angle.
* @param[in] pDz Half-length along Z axis.
* @param[in] pTheta Polar angle of the line joining the centres of the
* faces at -/+pDz.
* @param[in] pPhi Azimuthal angle of the line joining the centres of the
* faces at -/+pDz.
* @param[in] pDy1 Half Y length at -pDz.
* @param[in] pDx1 Half X length at -pDz, y=-pDy1.
* @param[in] pDx2 Half X length at -pDz, y=+pDy1.
* @param[in] pDy2 Half Y length at +pDz.
* @param[in] pDx3 Half X length at +pDz, y=-pDy2.
* @param[in] pDx4 Half X length at +pDz, y=+pDy2.
* @param[in] pAlph Angle with respect to the Y axis from centre of side.
*/
G4VTwistedFaceted(const G4String& pname, // Name of instance
G4double PhiTwist, // twist angle
G4double pDz, // half z lenght
@@ -60,56 +82,90 @@ class G4VTwistedFaceted: public G4VSolid
G4double pDy2, // half y length at +pDz
G4double pDx3, // half x length at +pDz,-pDy
G4double pDx4, // half x length at +pDz,+pDy
G4double pAlph // tilt angle at +pDz
);
G4double pAlph ); // tilt angle at +pDz
/**
* Destructor.
*/
~G4VTwistedFaceted() override;
void ComputeDimensions( G4VPVParameterisation*,
/**
* Dispatch method for parameterisation replication mechanism and
* dimension computation.
*/
void ComputeDimensions(G4VPVParameterisation*,
const G4int,
const G4VPhysicalVolume* ) override;
/**
* Computes the bounding limits of the solid.
* @param[out] pMin The minimum bounding limit point.
* @param[out] pMax The maximum bounding limit point.
*/
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const override;
/**
* Calculates the minimum and maximum extent of the solid, when under the
* specified transform, and within the specified limits.
* @param[in] pAxis The axis along which compute the extent.
* @param[in] pVoxelLimit The limiting space dictated by voxels.
* @param[in] pTransform The internal transformation applied to the solid.
* @param[out] pMin The minimum extent value.
* @param[out] pMax The maximum extent value.
* @returns True if the solid is intersected by the extent region.
*/
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin,
G4double& pMax ) const override;
/**
* Concrete implementations of the expected query interfaces for
* solids, as defined in the base class G4VSolid.
*/
G4double DistanceToIn (const G4ThreeVector& p,
const G4ThreeVector& v ) const override;
G4double DistanceToIn (const G4ThreeVector& p ) const override;
G4double DistanceToOut(const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcnorm = false,
G4bool* validnorm = nullptr,
G4ThreeVector* n = nullptr ) const override;
G4double DistanceToOut(const G4ThreeVector& p) const override;
EInside Inside (const G4ThreeVector& p) const override;
G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
/**
* Returns a random point located and uniformly distributed on the
* surface of the solid.
*/
G4ThreeVector GetPointOnSurface() const override;
G4ThreeVector GetPointInSolid(G4double z) const;
/**
* Returning an estimation of the solid volume (capacity) and
* surface area, in internal units.
*/
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
/**
* Methods for creating graphical representations (i.e. for visualisation).
*/
void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
G4Polyhedron* CreatePolyhedron () const override;
G4Polyhedron* GetPolyhedron () const override;
G4Polyhedron* CreatePolyhedron () const override;
G4Polyhedron* GetPolyhedron () const override;
G4VisExtent GetExtent () const override;
std::ostream &StreamInfo(std::ostream& os) const override;
// accessors
/**
* Streams the object contents to an output stream.
*/
std::ostream& StreamInfo(std::ostream& os) const override;
/**
* Accessors.
*/
inline G4double GetTwistAngle() const { return fPhiTwist; }
inline G4double GetDx1 () const { return fDx1 ; }
inline G4double GetDx2 () const { return fDx2 ; }
inline G4double GetDx3 () const { return fDx3 ; }
@@ -120,25 +176,28 @@ class G4VTwistedFaceted: public G4VSolid
inline G4double GetPhi () const { return fPhi ; }
inline G4double GetTheta () const { return fTheta ; }
inline G4double GetAlpha () const { return fAlph ; }
inline G4double Xcoef(G4double u, G4double phi, G4double ftg) const;
// For calculating the w(u) function
inline G4double GetValueA(G4double phi) const;
inline G4double GetValueB(G4double phi) const;
inline G4double GetValueD(G4double phi) const;
G4VisExtent GetExtent () const override;
G4GeometryType GetEntityType() const override;
/**
* Returns the type ID, "G4VTwistedFaceted" of the solid.
*/
G4GeometryType GetEntityType() const override;
/**
* Fake default constructor for usage restricted to direct object
* persistency for clients requiring preallocation of memory for
* persistifiable objects.
*/
G4VTwistedFaceted(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
/**
* Copy constructor and assignment operator.
*/
G4VTwistedFaceted(const G4VTwistedFaceted& rhs);
G4VTwistedFaceted& operator=(const G4VTwistedFaceted& rhs);
// Copy constructor and assignment operator.
protected:
@@ -150,10 +209,17 @@ class G4VTwistedFaceted: public G4VSolid
private:
double GetLateralFaceArea(const G4TwoVector& p1,
const G4TwoVector& p2,
const G4TwoVector& p3,
const G4TwoVector& p4) const;
/**
* Utility used for computing the surface area.
*/
G4double GetLateralFaceArea(const G4TwoVector& p1,
const G4TwoVector& p2,
const G4TwoVector& p3,
const G4TwoVector& p4) const;
/**
* Utility used in constructor for creating the surfaces.
*/
void CreateSurfaces();
private:
@@ -30,7 +30,7 @@
// Voxelizer for tessellated surfaces and solids positioning in 3D space,
// used in G4TessellatedSolid and G4MultiUnion.
// 19.10.12 Marek Gayer, created
// Author: Marek Gayer (CERN), 19.10.2012 - Created
// --------------------------------------------------------------------
#ifndef G4VOXELIZER_HH
#define G4VOXELIZER_HH
@@ -59,33 +59,64 @@ struct G4VoxelInfo
G4int next;
};
/**
* @brief G4Voxelizer is a tool for generating the optimisation structure
* of tessellated surfaces and solids positioned in 3D space; it is used in
* G4TessellatedSolid and G4MultiUnion.
*/
class G4Voxelizer
{
public:
template <typename T>
static inline G4int BinarySearch(const std::vector<T>& vec, T value);
/**
* Constructor and default Destructor.
*/
G4Voxelizer();
~G4Voxelizer() = default;
/**
* Builds the voxelisation structure for solids positioned in space.
* @param[in] solids The list of solids.
* @param[in] transforms The associated transformation in space.
*/
void Voxelize(std::vector<G4VSolid*>& solids,
std::vector<G4Transform3D>& transforms);
/**
* Builds the voxelisation structure for facets forming a shape.
* @param[in] facets The list of facets.
*/
void Voxelize(std::vector<G4VFacet*>& facets);
/**
* Displays the dX, dY, dZ, pX, pY and pZ for each node.
*/
void DisplayVoxelLimits() const;
/**
* Prints the positions of the boundaries of the slices on the three axes.
*/
void DisplayBoundaries();
/**
* Prints which solids are present in the slices previously elaborated.
*/
void DisplayListNodes() const;
G4Voxelizer();
~G4Voxelizer();
/**
* Displays the nodes located in a voxel characterised by its three indexes.
*/
void GetCandidatesVoxel(std::vector<G4int>& voxels);
// Method displaying the nodes located in a voxel characterized
// by its three indexes.
/**
* Methods returning in a vector container the nodes located in a voxel
* characterised by its three indexes.
* @returns The total candidates number.
*/
G4int GetCandidatesVoxelArray(const G4ThreeVector& point,
std::vector<G4int>& list,
G4SurfBits* crossed = nullptr) const;
// Method returning in a vector container the nodes located in a voxel
// characterized by its three indexes.
G4int GetCandidatesVoxelArray(const std::vector<G4int>& voxels,
const G4SurfBits bitmasks[],
std::vector<G4int>& list,
@@ -94,72 +125,162 @@ class G4Voxelizer
std::vector<G4int>& list,
G4SurfBits* crossed = nullptr)const;
/**
* Returns the pointer to the array containing the characteristics
* of each box.
*/
inline const std::vector<G4VoxelBox>& GetBoxes() const;
// Method returning the pointer to the array containing the
// characteristics of each box.
/**
* Returns the boundary vector, given an 'index'.
*/
inline const std::vector<G4double>& GetBoundary(G4int index) const;
/**
* Utility method for checking/updating current voxel given in input.
*/
G4bool UpdateCurrentVoxel(const G4ThreeVector& point,
const G4ThreeVector& direction,
std::vector<G4int>& curVoxel) const;
/**
* Updates current voxel based on provided 'point'.
*/
inline void GetVoxel(std::vector<G4int>& curVoxel,
const G4ThreeVector& point) const;
/**
* Returns memory size of a slice.
*/
inline G4int GetBitsPerSlice () const;
/**
* Returns true if 'point' is contained within boundaries.
*/
G4bool Contains(const G4ThreeVector& point) const;
/**
* Returns the distance to next boundary, given 'point' and 'direction'
* and updates current voxel 'curVoxel', using the index corresponding
* to the closest voxel boundary on the ray.
*/
G4double DistanceToNext(const G4ThreeVector& point,
const G4ThreeVector& direction,
std::vector<G4int>& curVoxel) const;
/**
* Returns the distance to first bounding box, given 'point' and 'direction'.
*/
G4double DistanceToFirst(const G4ThreeVector& point,
const G4ThreeVector& direction) const;
/**
* Returns the minimum distance of 'point' to the bounding box.
*/
G4double DistanceToBoundingBox(const G4ThreeVector& point) const;
/**
* Utility for estimating the isotropic safety from a point 'p' outside
* the current solid to any of its surfaces. The algorithm may be accurate
* or should provide a fast underestimate, based on safety point 'f'.
*/
G4double MinDistanceToBox (const G4ThreeVector& p,
const G4ThreeVector& f) const;
/**
* Accessors for voxels and points.
*/
inline G4int GetVoxelsIndex(G4int x, G4int y, G4int z) const;
inline G4int GetVoxelsIndex(const std::vector<G4int>& voxels) const;
inline G4bool GetPointVoxel(const G4ThreeVector& p,
std::vector<G4int>& voxels) const;
inline G4int GetPointIndex(const G4ThreeVector& p) const;
/**
* Returns the empty bits container.
*/
inline const G4SurfBits& Empty() const;
/**
* Returns true if empty bit in container, given an 'index'.
*/
inline G4bool IsEmpty(G4int index) const;
/**
* Setters/getter for the maximum number of voxels.
*/
void SetMaxVoxels(G4int max);
void SetMaxVoxels(const G4ThreeVector& reductionRatio);
inline G4int GetMaxVoxels(G4ThreeVector& ratioOfReduction);
/**
* Logger returning the size of total allocated memory.
*/
G4int AllocatedMemory();
/**
* Utility accessors/functions for voxels.
*/
inline long long GetCountOfVoxels() const;
inline long long CountVoxels(std::vector<G4double> boundaries[]) const;
inline const std::vector<G4int>&
GetCandidates(std::vector<G4int>& curVoxel) const;
inline G4int GetVoxelBoxesSize() const;
inline const G4VoxelBox &GetVoxelBox(G4int i) const;
inline const G4VoxelBox& GetVoxelBox(G4int i) const;
inline const std::vector<G4int>& GetVoxelBoxCandidates(G4int i) const;
inline G4int GetTotalCandidates() const;
static G4double MinDistanceToBox (const G4ThreeVector& aPoint,
const G4ThreeVector& f);
static void SetDefaultVoxelsCount(G4int count);
static G4int GetDefaultVoxelsCount();
private:
/**
* Binary search function for retrieving a value in a vector.
*/
template <typename T>
inline G4int BinarySearch(const std::vector<T>& vec, T value) const;
/**
* Utilities.
*/
G4String GetCandidatesAsString(const G4SurfBits& bits) const;
void CreateSortedBoundary(std::vector<G4double>& boundaryRaw, G4int axis);
void DisplayBoundaries(std::vector<G4double>& fBoundaries);
void FindComponentsFastest(unsigned int mask,
std::vector<G4int>& list, G4int i) const;
inline G4ThreeVector GetGlobalPoint(const G4Transform3D& trans,
const G4ThreeVector& lpoint) const;
void TransformLimits(G4ThreeVector& min, G4ThreeVector& max,
const G4Transform3D& transformation) const;
/**
* Build utilities.
*/
void BuildEmpty ();
void BuildBoundaries();
void BuildReduceVoxels(std::vector<G4double> fBoundaries[],
G4ThreeVector reductionRatio);
void BuildReduceVoxels2(std::vector<G4double> fBoundaries[],
G4ThreeVector reductionRatio);
void BuildVoxelLimits(std::vector<G4VSolid*>& solids,
std::vector<G4Transform3D>& transforms);
void BuildVoxelLimits(std::vector<G4VFacet*>& facets);
void CreateMiniVoxels(std::vector<G4double> fBoundaries[],
G4SurfBits bitmasks[]);
void BuildBitmasks(std::vector<G4double> fBoundaries[],
G4SurfBits bitmasks[], G4bool countsOnly = false);
void BuildBoundingBox();
void BuildBoundingBox(G4ThreeVector& amin, G4ThreeVector& amax,
G4double tolerance = 0.0);
void SetReductionRatio(G4int maxVoxels, G4ThreeVector& reductionRatio);
private:
/**
* @brief G4VoxelComparator is utility class used for comparing voxels.
*/
class G4VoxelComparator
{
public:
@@ -177,47 +298,7 @@ class G4Voxelizer
}
};
void BuildEmpty ();
G4String GetCandidatesAsString(const G4SurfBits& bits) const;
void CreateSortedBoundary(std::vector<G4double>& boundaryRaw, G4int axis);
void BuildBoundaries();
void BuildReduceVoxels(std::vector<G4double> fBoundaries[],
G4ThreeVector reductionRatio);
void BuildReduceVoxels2(std::vector<G4double> fBoundaries[],
G4ThreeVector reductionRatio);
void BuildVoxelLimits(std::vector<G4VSolid*>& solids,
std::vector<G4Transform3D>& transforms);
void BuildVoxelLimits(std::vector<G4VFacet*>& facets);
void DisplayBoundaries(std::vector<G4double>& fBoundaries);
void BuildBitmasks(std::vector<G4double> fBoundaries[],
G4SurfBits bitmasks[], G4bool countsOnly = false);
void BuildBoundingBox();
void BuildBoundingBox(G4ThreeVector& amin, G4ThreeVector& amax,
G4double tolerance = 0.0);
void SetReductionRatio(G4int maxVoxels, G4ThreeVector& reductionRatio);
void CreateMiniVoxels(std::vector<G4double> fBoundaries[],
G4SurfBits bitmasks[]);
static void FindComponentsFastest(unsigned int mask,
std::vector<G4int>& list, G4int i);
inline G4ThreeVector GetGlobalPoint(const G4Transform3D& trans,
const G4ThreeVector& lpoint) const;
void TransformLimits(G4ThreeVector& min, G4ThreeVector& max,
const G4Transform3D& transformation) const;
private:
static G4ThreadLocal G4int fDefaultVoxelsCount;
static G4int fDefaultVoxelsCount;
std::vector<G4VoxelBox> fVoxelBoxes;
std::vector<std::vector<G4int> > fVoxelBoxesCandidates;
@@ -29,7 +29,7 @@
// --------------------------------------------------------------------
template <typename T> inline
G4int G4Voxelizer::BinarySearch(const std::vector<T>& vec, T value)
G4int G4Voxelizer::BinarySearch(const std::vector<T>& vec, T value) const
{
auto begin=vec.cbegin(), end=vec.cend();
return G4int(std::upper_bound(begin, end, value) - begin - 1);