Import Geant4 11.4.0 source tree
This commit is contained in:
@@ -27,10 +27,9 @@
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Abstract base class for solids created by boolean operations
|
||||
// between other solids.
|
||||
// Base class for solids created by Boolean operations between other solids.
|
||||
|
||||
// 10.09.98 V.Grichine - created
|
||||
// Author: Vladimir Grichine (CERN), 10.09.1998 - Created.
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4BOOLEANSOLID_HH
|
||||
#define G4BOOLEANSOLID_HH
|
||||
@@ -45,98 +44,198 @@
|
||||
|
||||
class HepPolyhedronProcessor;
|
||||
|
||||
/**
|
||||
* @brief G4BooleanSolid is the base class for solids created by Boolean
|
||||
* operations between other solids.
|
||||
*/
|
||||
|
||||
class G4BooleanSolid : public G4VSolid
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean composition between two solids with no
|
||||
* displacement.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
*/
|
||||
G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB );
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean composition between two solids with rotation
|
||||
* and translation, used to transform the coordinate system of the second
|
||||
* solid to the coordinate system of the first solid.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
* @param[in] rotMatrix Pointer to the rotation vector.
|
||||
* @param[in] transVector The translation vector.
|
||||
*/
|
||||
G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector );
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean composition between two solids with a
|
||||
* transformation that moves the second solid from its desired position
|
||||
* to its standard position.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
* @param[in] transform The composed 3D transformation.
|
||||
*/
|
||||
G4BooleanSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
const G4Transform3D& transform );
|
||||
|
||||
/**
|
||||
* Destructor. If using a displaced solid, deletes all cached
|
||||
* transformations.
|
||||
*/
|
||||
~G4BooleanSolid() override;
|
||||
|
||||
const G4VSolid* GetConstituentSolid(G4int no) const override;
|
||||
G4VSolid* GetConstituentSolid(G4int no) override;
|
||||
// If Solid is made up from a Boolean operation of two solids,
|
||||
// return the corresponding solid (for no=0 and 1).
|
||||
// If the solid is not a "Boolean", return 0.
|
||||
|
||||
G4double GetCubicVolume() override;
|
||||
inline G4double GetSurfaceArea() override;
|
||||
|
||||
G4GeometryType GetEntityType() const override;
|
||||
G4Polyhedron* GetPolyhedron() const override;
|
||||
|
||||
std::ostream& StreamInfo(std::ostream& os) const override;
|
||||
|
||||
inline G4int GetCubVolStatistics() const;
|
||||
inline G4double GetCubVolEpsilon() const;
|
||||
void SetCubVolStatistics(G4int st);
|
||||
void SetCubVolEpsilon(G4double ep);
|
||||
|
||||
inline G4int GetAreaStatistics() const;
|
||||
inline G4double GetAreaAccuracy() const;
|
||||
inline void SetAreaStatistics(G4int st);
|
||||
inline void SetAreaAccuracy(G4double ep);
|
||||
|
||||
G4ThreeVector GetPointOnSurface() const override;
|
||||
|
||||
G4int GetNumOfConstituents() const override;
|
||||
G4bool IsFaceted() const override;
|
||||
|
||||
/**
|
||||
* Fake default constructor for usage restricted to direct object
|
||||
* persistency for clients requiring preallocation of memory for
|
||||
* persistifiable objects.
|
||||
*/
|
||||
G4BooleanSolid(__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.
|
||||
*/
|
||||
G4BooleanSolid(const G4BooleanSolid& rhs);
|
||||
G4BooleanSolid& operator=(const G4BooleanSolid& rhs);
|
||||
// Copy constructor and assignment operator.
|
||||
|
||||
static void SetExternalBooleanProcessor(G4VBooleanProcessor* extProcessor);
|
||||
// Set Boolean processor to replace default processor.
|
||||
/**
|
||||
* Methods returning the component solids of the Boolean composition.
|
||||
* If the solid is made up from a Boolean operation of two solids,
|
||||
* return the corresponding solid (for no=0 and 1). A fatal exception
|
||||
* is thrown if the index provided is different from 0 or 1.
|
||||
* @param[in] no Index 0/1 of the components.
|
||||
* @returns The pointer to (const or not const) of the component solid.
|
||||
* If the solid is not a "Boolean", returns nullptr.
|
||||
*/
|
||||
const G4VSolid* GetConstituentSolid(G4int no) const override;
|
||||
G4VSolid* GetConstituentSolid(G4int no) override;
|
||||
|
||||
/**
|
||||
* Methods returning the computed capacity and surface area of the
|
||||
* composition. The quantities returned are an estimate obtained by
|
||||
* randomly sampling the Boolean composition and caching them for reuse.
|
||||
*/
|
||||
G4double GetCubicVolume() override;
|
||||
G4double GetSurfaceArea() override;
|
||||
|
||||
/**
|
||||
* Returns the type ID, "G4BooleanSolid" of the solid.
|
||||
*/
|
||||
G4GeometryType GetEntityType() const override;
|
||||
|
||||
/**
|
||||
* Returns a pointer to the generated polyhedron representation of the
|
||||
* composition, for use in visualisation.
|
||||
*/
|
||||
G4Polyhedron* GetPolyhedron() const override;
|
||||
|
||||
/**
|
||||
* Streams the object contents to an output stream.
|
||||
*/
|
||||
std::ostream& StreamInfo(std::ostream& os) const override;
|
||||
|
||||
/**
|
||||
* Accessor and setter for controlling/tuning the number of random points
|
||||
* to be used for computing the cubic volume.
|
||||
*/
|
||||
inline G4int GetCubVolStatistics() const;
|
||||
void SetCubVolStatistics(G4int st);
|
||||
|
||||
/**
|
||||
* Accessor and setter for controlling/tuning the epsilon used for
|
||||
* computing the cubic volume.
|
||||
*/
|
||||
inline G4double GetCubVolEpsilon() const;
|
||||
void SetCubVolEpsilon(G4double ep);
|
||||
|
||||
/**
|
||||
* Accessor and setter for controlling/tuning the number of random points
|
||||
* to be used for computing the surface area.
|
||||
*/
|
||||
inline G4int GetAreaStatistics() const;
|
||||
inline void SetAreaStatistics(G4int st);
|
||||
|
||||
/**
|
||||
* Accessor and setter for controlling/tuning the level of accuracy used
|
||||
* for computing the surface area.
|
||||
*/
|
||||
inline G4double GetAreaAccuracy() const;
|
||||
inline void SetAreaAccuracy(G4double ep);
|
||||
|
||||
/**
|
||||
* Returns a point (G4ThreeVector) randomly and uniformly generated
|
||||
* on the surface of the solid.
|
||||
*/
|
||||
G4ThreeVector GetPointOnSurface() const override;
|
||||
|
||||
/**
|
||||
* Returns the total number of constituent solids forming the Boolean
|
||||
* composition.
|
||||
*/
|
||||
G4int GetNumOfConstituents() const override;
|
||||
|
||||
/**
|
||||
* Return true if the resulting solid has only planar faces.
|
||||
*/
|
||||
G4bool IsFaceted() const override;
|
||||
|
||||
/**
|
||||
* Gets/sets the Boolean processor for polyhedron to replace the default
|
||||
* processor.
|
||||
*/
|
||||
static G4VBooleanProcessor* GetExternalBooleanProcessor();
|
||||
// Get Boolean processor needed for G4MultiUnion.
|
||||
static void SetExternalBooleanProcessor(G4VBooleanProcessor* extProcessor);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Gets the list of constituent primitives of the solid and their placements.
|
||||
*/
|
||||
void GetListOfPrimitives(std::vector<std::pair<G4VSolid *,G4Transform3D>>&,
|
||||
const G4Transform3D&) const;
|
||||
// Get list of constituent primitives of the solid and their placements.
|
||||
//
|
||||
|
||||
/**
|
||||
* Stacks the polyhedra for processing.
|
||||
* @returns A pointer to the top polyhedron.
|
||||
*/
|
||||
G4Polyhedron* StackPolyhedron(HepPolyhedronProcessor&,
|
||||
const G4VSolid*) const;
|
||||
// Stack polyhedra for processing. Return top polyhedron.
|
||||
|
||||
protected:
|
||||
|
||||
/** Pointers to the costituent solids. */
|
||||
G4VSolid* fPtrSolidA = nullptr;
|
||||
G4VSolid* fPtrSolidB = nullptr;
|
||||
|
||||
/** Cached value of the capacity. */
|
||||
G4double fCubicVolume = -1.0;
|
||||
// Cached value of Cubic Volume
|
||||
G4double fSurfaceArea = -1.0;
|
||||
// Cached value of Surface Area
|
||||
|
||||
/** Cached value of the surface area. */
|
||||
G4double fSurfaceArea = -1.0;
|
||||
|
||||
/** Static pointer to the external Boolean processor. */
|
||||
static G4VBooleanProcessor* fExternalBoolProcessor;
|
||||
// External Boolean processor
|
||||
|
||||
private:
|
||||
|
||||
G4int fCubVolStatistics = 1000000;
|
||||
G4int fAreaStatistics = 1000000;
|
||||
G4int fCubVolStatistics = 1000000;
|
||||
G4int fAreaStatistics = 1000000;
|
||||
G4double fCubVolEpsilon = 0.001;
|
||||
G4double fAreaAccuracy = -1;
|
||||
|
||||
@@ -146,8 +245,8 @@ class G4BooleanSolid : public G4VSolid
|
||||
mutable std::vector<std::pair<G4VSolid *,G4Transform3D>> fPrimitives;
|
||||
mutable G4double fPrimitivesSurfaceArea = 0.0;
|
||||
|
||||
G4bool createdDisplacedSolid = false;
|
||||
// If & only if this object created it, it must delete it
|
||||
/** If & only if this object created it, it must delete it. */
|
||||
G4bool createdDisplacedSolid = false;
|
||||
};
|
||||
|
||||
#include "G4BooleanSolid.icc"
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
//
|
||||
// Class G4BooleanSolid inline implementation
|
||||
//
|
||||
// Author: Vladimir Grichine (CERN), 10.09.1998.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
inline
|
||||
@@ -64,13 +65,3 @@ void G4BooleanSolid::SetAreaAccuracy(G4double ep)
|
||||
if (ep != fAreaAccuracy) { fSurfaceArea = -1.; }
|
||||
fAreaAccuracy = ep;
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4BooleanSolid::GetSurfaceArea()
|
||||
{
|
||||
if(fSurfaceArea < 0.)
|
||||
{
|
||||
fSurfaceArea = EstimateSurfaceArea(fAreaStatistics, fAreaAccuracy);
|
||||
}
|
||||
return fSurfaceArea;
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
// Class description:
|
||||
//
|
||||
// A displaced solid is a solid that has been shifted from its original
|
||||
// frame of reference to a new one. It is meant to be used only for
|
||||
// simplifying the implementation of "Boolean solids".
|
||||
// frame of reference to a new one. It is meant to be used **internally only**
|
||||
// for simplifying the implementation of "Boolean solids".
|
||||
|
||||
// 28.10.98 V.Grichine - created
|
||||
// Author: Vladimir Grichine (CERN), 28.10.1998 - Created.
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4DISPLACEDSOLID_HH
|
||||
#define G4DISPLACEDSOLID_HH
|
||||
@@ -42,111 +42,243 @@
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
/**
|
||||
* @brief G4DisplacedSolid is a solid that has been shifted from its original
|
||||
* frame of reference to a new one. It is meant to be used **internally only**,
|
||||
* for simplifying the implementation of "Boolean solids".
|
||||
*/
|
||||
|
||||
class G4DisplacedSolid : public G4VSolid
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor of a displaced solid rotation and translation vectors.
|
||||
* @param[in] pName The name of the diplaced solid.
|
||||
* @param[in] pSolid Pointer to the original reference solid.
|
||||
* @param[in] rotMatrix Pointer to the rotation vector.
|
||||
* @param[in] transVector The translation vector.
|
||||
*/
|
||||
G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ) ;
|
||||
|
||||
/**
|
||||
* Constructor of a displaced solid with a transformation.
|
||||
* @param[in] pName The name of the displaced solid.
|
||||
* @param[in] pSolid Pointer to the original reference solid.
|
||||
* @param[in] transform The composed 3D transformation.
|
||||
*/
|
||||
G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4Transform3D& transform ) ;
|
||||
|
||||
/**
|
||||
* Constructor for use in instantiating a transient instance from a
|
||||
* persistent one.
|
||||
* @param[in] pName The name of the displaced solid.
|
||||
* @param[in] pSolid Pointer to the original reference solid.
|
||||
* @param[in] directTransform The internal transformation.
|
||||
*/
|
||||
G4DisplacedSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4AffineTransform directTransform );
|
||||
// For use in instantiating a transient instance from a persistent one.
|
||||
|
||||
/**
|
||||
* Destructor. Deletes all cached transformations.
|
||||
*/
|
||||
~G4DisplacedSolid() override ;
|
||||
|
||||
/**
|
||||
* Fake default constructor for usage restricted to direct object
|
||||
* persistency for clients requiring preallocation of memory for
|
||||
* persistifiable objects.
|
||||
*/
|
||||
G4DisplacedSolid(__void__&);
|
||||
|
||||
/**
|
||||
* Copy constructor and assignment operator.
|
||||
*/
|
||||
G4DisplacedSolid(const G4DisplacedSolid& rhs);
|
||||
G4DisplacedSolid& operator=(const G4DisplacedSolid& rhs);
|
||||
|
||||
/**
|
||||
* Returns if the given point "p" is inside or not the solid.
|
||||
*/
|
||||
EInside Inside( 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 outwards pointing unit normal of the shape for the
|
||||
* surface closest to the point at offset "p".
|
||||
*/
|
||||
G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override ;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from the point at offset "p". If there is no intersection, return
|
||||
* kInfinity. The first intersection resulting from leaving a
|
||||
* surface/volume is discarded. Hence, it is tolerant of points on
|
||||
* the surface of the shape.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const override ;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an outside point. The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p) const override ;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from a point at an offset "p" inside or on the surface of the shape.
|
||||
* Intersections with surfaces, when the point is < Tolerance/2 from a
|
||||
* surface must be ignored. Must be called as solid.DistanceToOut(p,v)
|
||||
* or by specifying all the parameters.
|
||||
* @param[in] p The reference point in space.
|
||||
* @param[in] v The normalised direction.
|
||||
* @param[in] calcNorm Flag to enable the normal computation or not.
|
||||
* @param[out] validNorm Set to true if the solid lies entirely behind
|
||||
* or on the exiting surface (calcNorm must be true, otherwise
|
||||
* it is unused).
|
||||
* @param[out] n The exiting outwards normal vector (undefined Magnitude).
|
||||
* (calcNorm must be true, otherwise it is unused).
|
||||
* @returns The distance value to exit the volume.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm=false,
|
||||
G4bool *validNorm=nullptr,
|
||||
G4ThreeVector *n=nullptr ) const override ;
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* n = nullptr ) const override ;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an inside point "p". The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p ) const override ;
|
||||
|
||||
|
||||
/**
|
||||
* Throws an exception as paramterisations are not allowed for these solids.
|
||||
*/
|
||||
void ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep ) override ;
|
||||
|
||||
/**
|
||||
* Deletes cached transformations. Used in destructor.
|
||||
*/
|
||||
void CleanTransformations();
|
||||
|
||||
/**
|
||||
* Methods 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 on the surface of the solid.
|
||||
* Points returned may not necessarily be uniformly distributed.
|
||||
*/
|
||||
G4ThreeVector GetPointOnSurface() const override;
|
||||
|
||||
/**
|
||||
* Returns the number of constituents of the solid.
|
||||
* For non-Boolean solids the return value is one.
|
||||
*/
|
||||
G4int GetNumOfConstituents() const override;
|
||||
|
||||
/**
|
||||
* Returns true if the solid has only planar faces, false otherwise.
|
||||
*/
|
||||
G4bool IsFaceted() const override;
|
||||
|
||||
/**
|
||||
* Returns the type ID, "G4DisplacedSolid" 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;
|
||||
|
||||
/**
|
||||
* If the Solid is a "G4DisplacedSolid", return a self pointer else
|
||||
* return nullptr.
|
||||
*/
|
||||
const G4DisplacedSolid* GetDisplacedSolidPtr() const override;
|
||||
G4DisplacedSolid* GetDisplacedSolidPtr() override;
|
||||
// If the Solid is a "G4DisplacedSolid",
|
||||
// return a self pointer else return 0.
|
||||
|
||||
/**
|
||||
* Returns a pointer to the original not displaced solid.
|
||||
*/
|
||||
G4VSolid* GetConstituentMovedSolid() const;
|
||||
|
||||
/**
|
||||
* Accessor/modifier for the associated internal transformation.
|
||||
*/
|
||||
G4AffineTransform GetTransform() const;
|
||||
void SetTransform(G4AffineTransform& );
|
||||
void SetTransform(G4AffineTransform& );
|
||||
|
||||
/**
|
||||
* Accessor/modifier for the associated internal transformation, as above.
|
||||
*/
|
||||
G4AffineTransform GetDirectTransform() const;
|
||||
void SetDirectTransform(G4AffineTransform&);
|
||||
// Access/Set methods.
|
||||
void SetDirectTransform(G4AffineTransform&);
|
||||
|
||||
/**
|
||||
* Get/Set the rotation/translation, as applied to the frame of reference.
|
||||
*/
|
||||
G4RotationMatrix GetFrameRotation() const;
|
||||
void SetFrameRotation(const G4RotationMatrix&);
|
||||
|
||||
G4ThreeVector GetFrameTranslation() const;
|
||||
void SetFrameTranslation(const G4ThreeVector&);
|
||||
// Get/Set the rotation/translation, as applied to the frame of reference.
|
||||
|
||||
/**
|
||||
* Get/Set the rotation/translation, as applied to the object.
|
||||
*/
|
||||
G4RotationMatrix GetObjectRotation() const;
|
||||
void SetObjectRotation(const G4RotationMatrix&);
|
||||
|
||||
G4ThreeVector GetObjectTranslation() const;
|
||||
void SetObjectTranslation(const G4ThreeVector&);
|
||||
// Get/Set the rotation/translation, as applied to the object.
|
||||
|
||||
/**
|
||||
* Streams the object contents to an output stream.
|
||||
*/
|
||||
std::ostream& StreamInfo(std::ostream& os) const override;
|
||||
|
||||
G4DisplacedSolid(__void__&);
|
||||
// Fake default constructor for usage restricted to direct object
|
||||
// persistency for clients requiring preallocation of memory for
|
||||
// persistifiable objects.
|
||||
|
||||
G4DisplacedSolid(const G4DisplacedSolid& rhs);
|
||||
G4DisplacedSolid& operator=(const G4DisplacedSolid& rhs);
|
||||
// Copy constructor and assignment operator.
|
||||
|
||||
/**
|
||||
* Methods for creating graphical representations (i.e. for visualisation).
|
||||
*/
|
||||
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override ;
|
||||
G4Polyhedron* CreatePolyhedron () const override ;
|
||||
G4Polyhedron* GetPolyhedron () const override ;
|
||||
// For creating graphical representations (ie for visualisation).
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
//
|
||||
// Class for description of intersection of two solids.
|
||||
|
||||
// 12.09.98 V.Grichine: initial design and implementation
|
||||
// Author: Vladimir Grichine (CERN), 12.09.1998 - Created.
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4INTERSECTIONSOLID_HH
|
||||
#define G4INTERSECTIONSOLID_HH
|
||||
@@ -42,69 +42,173 @@
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
/**
|
||||
* @brief G4IntersectionSolid is a solid describing the Boolean intersection
|
||||
* of two solids.
|
||||
*/
|
||||
|
||||
class G4IntersectionSolid : public G4BooleanSolid
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean intersection between two solids with no
|
||||
* displacement.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
*/
|
||||
G4IntersectionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ) ;
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean intersection between two solids with rotation
|
||||
* and translation, used to transform the coordinate system of the second
|
||||
* solid to the coordinate system of the first solid.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
* @param[in] rotMatrix Pointer to the rotation vector.
|
||||
* @param[in] transVector The translation vector.
|
||||
*/
|
||||
G4IntersectionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ) ;
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean intersection between two solids with a
|
||||
* transformation that moves the second solid from its desired position
|
||||
* to its standard position.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
* @param[in] transform The composed 3D transformation.
|
||||
*/
|
||||
G4IntersectionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB,
|
||||
const G4Transform3D& transform ) ;
|
||||
|
||||
~G4IntersectionSolid() override ;
|
||||
|
||||
G4GeometryType GetEntityType() const override;
|
||||
|
||||
G4VSolid* Clone() const override;
|
||||
/**
|
||||
* Default destructor.
|
||||
*/
|
||||
~G4IntersectionSolid() override = default;
|
||||
|
||||
/**
|
||||
* Fake default constructor for usage restricted to direct object
|
||||
* persistency for clients requiring preallocation of memory for
|
||||
* persistifiable objects.
|
||||
*/
|
||||
G4IntersectionSolid(__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.
|
||||
*/
|
||||
G4IntersectionSolid(const G4IntersectionSolid& rhs);
|
||||
G4IntersectionSolid& operator=(const G4IntersectionSolid& rhs);
|
||||
// Copy constructor and assignment operator.
|
||||
|
||||
/**
|
||||
* Returns the type ID, "G4IntersectionSolid" 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;
|
||||
|
||||
/**
|
||||
* 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 if the given point "p" is inside or not the solid.
|
||||
*/
|
||||
EInside Inside( const G4ThreeVector& p ) const override ;
|
||||
|
||||
/**
|
||||
* Returns the outwards pointing unit normal of the shape for the
|
||||
* surface closest to the point at offset "p".
|
||||
*/
|
||||
G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override ;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from the point at offset "p". If there is no intersection, return
|
||||
* kInfinity. The first intersection resulting from leaving a
|
||||
* surface/volume is discarded. Hence, it is tolerant of points on
|
||||
* the surface of the shape.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const override ;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an outside point. The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p) const override ;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from a point at an offset "p" inside or on the surface of the shape.
|
||||
* Intersections with surfaces, when the point is < Tolerance/2 from a
|
||||
* surface must be ignored. Must be called as solid.DistanceToOut(p,v)
|
||||
* or by specifying all the parameters.
|
||||
* @param[in] p The reference point in space.
|
||||
* @param[in] v The normalised direction.
|
||||
* @param[in] calcNorm Flag to enable the normal computation or not.
|
||||
* @param[out] validNorm Set to true if the solid lies entirely behind
|
||||
* or on the exiting surface (calcNorm must be true, otherwise
|
||||
* it is unused).
|
||||
* @param[out] n The exiting outwards normal vector (undefined Magnitude).
|
||||
* (calcNorm must be true, otherwise it is unused).
|
||||
* @returns The distance value to exit the volume.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm=false,
|
||||
G4bool *validNorm=nullptr,
|
||||
G4ThreeVector *n=nullptr ) const override ;
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* n = nullptr ) const override ;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an inside point "p". The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p ) const override ;
|
||||
|
||||
|
||||
/**
|
||||
* Throws an exception as paramterisations are not allowed for these solids.
|
||||
*/
|
||||
void ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep ) override ;
|
||||
|
||||
/**
|
||||
* Methods for creating graphical representations (i.e. for visualisation).
|
||||
*/
|
||||
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override ;
|
||||
G4Polyhedron* CreatePolyhedron () const override ;
|
||||
};
|
||||
|
||||
@@ -27,13 +27,14 @@
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// An instance of "G4MultiUnion" constitutes a grouping of several solids.
|
||||
// The constituent solids are stored with their respective location in an
|
||||
// instance of "G4Node". An instance of "G4MultiUnion" is subsequently
|
||||
// composed of one or several nodes.
|
||||
// An instance of "G4MultiUnion" constitutes a grouping of several solids.
|
||||
// The constituent solids are stored with their respective location in a node
|
||||
// instance. An instance of "G4MultiUnion" is subsequently composed of one
|
||||
// or several nodes.
|
||||
|
||||
// 19.10.12 M.Gayer - Original implementation from USolids module
|
||||
// 06.04.17 G.Cosmo - Adapted implementation in Geant4 for VecGeom migration
|
||||
// Author: Marek Gayer (CERN), 19.10.2012 - Original implementation from USolids
|
||||
// Gabriele Cosmo (CERN) 06.04.2017 - Adapted implementation in Geant4
|
||||
// for VecGeom migration
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4MULTIUNION_HH
|
||||
#define G4MULTIUNION_HH
|
||||
@@ -50,111 +51,233 @@
|
||||
|
||||
class G4Polyhedron;
|
||||
|
||||
/**
|
||||
* @brief An instance of G4MultiUnion constitutes a grouping of several solids.
|
||||
* The constituent solids are stored with their respective location in a node
|
||||
* instance. An instance of G4MultiUnion is subsequently composed of one or
|
||||
* several nodes.
|
||||
*/
|
||||
|
||||
class G4MultiUnion : public G4VSolid
|
||||
{
|
||||
friend class G4Voxelizer;
|
||||
friend class G4Voxelizer;
|
||||
|
||||
public:
|
||||
|
||||
G4MultiUnion() : G4VSolid("") {}
|
||||
G4MultiUnion(const G4String& name);
|
||||
~G4MultiUnion() override;
|
||||
/**
|
||||
* Empty default constructor.
|
||||
*/
|
||||
G4MultiUnion();
|
||||
|
||||
// Build the multiple union by adding nodes
|
||||
|
||||
/**
|
||||
* Constructor assigning a name and initialising components.
|
||||
*/
|
||||
G4MultiUnion(const G4String& name);
|
||||
|
||||
/**
|
||||
* Default destructor.
|
||||
*/
|
||||
~G4MultiUnion() override = default;
|
||||
|
||||
/**
|
||||
* Fake default constructor for usage restricted to direct object
|
||||
* persistency for clients requiring preallocation of memory for
|
||||
* persistifiable objects.
|
||||
*/
|
||||
G4MultiUnion(__void__&);
|
||||
|
||||
/**
|
||||
* Methods to build the multiple union by adding nodes (by pointer or ref).
|
||||
* @param[in] solid The solid to be added to the structure.
|
||||
* @param[in] trans The 3D transformation relative to the structure.
|
||||
*/
|
||||
void AddNode(G4VSolid& solid, const G4Transform3D& trans);
|
||||
void AddNode(G4VSolid* solid, const G4Transform3D& trans);
|
||||
|
||||
/**
|
||||
* Copy constructor and assignment operator.
|
||||
*/
|
||||
G4MultiUnion(const G4MultiUnion& rhs);
|
||||
G4MultiUnion& operator=(const G4MultiUnion& rhs);
|
||||
|
||||
// Accessors
|
||||
/**
|
||||
* Accessors to retrieve a transformation or a solid, given an index
|
||||
* and the total number of solids in the structure.
|
||||
*/
|
||||
inline const G4Transform3D& GetTransformation(G4int index) const;
|
||||
inline G4VSolid* GetSolid(G4int index) const;
|
||||
inline G4int GetNumberOfSolids()const;
|
||||
|
||||
// Navigation methods
|
||||
/**
|
||||
* Returns if the given point "aPoint" is inside or not the solid.
|
||||
*/
|
||||
EInside Inside(const G4ThreeVector& aPoint) const override;
|
||||
|
||||
EInside InsideIterator(const G4ThreeVector& aPoint) const;
|
||||
|
||||
// Safety methods
|
||||
G4double DistanceToIn(const G4ThreeVector& aPoint) const override;
|
||||
G4double DistanceToOut(const G4ThreeVector& aPoint) const override;
|
||||
inline void SetAccurateSafety(G4bool flag);
|
||||
|
||||
// Exact distance methods
|
||||
/**
|
||||
* Returns the distance along the normalised vector "aDirection" to the
|
||||
* shape, from the point at offset "aPoint". If there is no intersection,
|
||||
* return kInfinity. The first intersection resulting from leaving a
|
||||
* surface/volume is discarded. Hence, it is tolerant of points on
|
||||
* the surface of the shape.
|
||||
*/
|
||||
G4double DistanceToIn(const G4ThreeVector& aPoint,
|
||||
const G4ThreeVector& aDirection) const override;
|
||||
|
||||
/**
|
||||
* Computes distance from a point presumably inside the solid to the solid
|
||||
* surface. Ignores first surface along each axis systematically (for points
|
||||
* inside or outside. Early returns zero in case the second surface is
|
||||
* behind the starting point.
|
||||
* The normal vector to the crossed surface is always filled.
|
||||
* In the case the considered point is located inside the G4MultiUnion
|
||||
* structure, it acts as follows:
|
||||
* - investigation of the candidates for the passed point
|
||||
* - progressive moving of the point towards the surface, along the
|
||||
* provided direction
|
||||
* - processing of the normal.
|
||||
* @param[in] aPoint The reference point in space.
|
||||
* @param[in] aDirection The normalised direction.
|
||||
* @param[in] calcNorm Flag unused.
|
||||
* @param[out] validNorm Unused.
|
||||
* @param[out] aNormalVector The exiting outwards normal vector (undefined
|
||||
* Magnitude).
|
||||
* @returns The distance value to exit a volume.
|
||||
*/
|
||||
G4double DistanceToOut(const G4ThreeVector& aPoint,
|
||||
const G4ThreeVector& aDirection,
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* aNormalVector = nullptr) const override;
|
||||
|
||||
/**
|
||||
* Methods to compute the distance to enter/exit a volume, given point and
|
||||
* direction, in presence of voxels-based optimisation structure or not.
|
||||
*/
|
||||
G4double DistanceToInNoVoxels(const G4ThreeVector& aPoint,
|
||||
const G4ThreeVector& aDirection) const;
|
||||
G4double DistanceToOutVoxels(const G4ThreeVector& aPoint,
|
||||
const G4ThreeVector& aDirection,
|
||||
G4ThreeVector* aNormalVector) const;
|
||||
G4double DistanceToOutVoxelsCore(const G4ThreeVector& aPoint,
|
||||
const G4ThreeVector& aDirection,
|
||||
G4ThreeVector* aNormalVector,
|
||||
G4bool& aConvex,
|
||||
std::vector<G4int>& candidates) const;
|
||||
G4ThreeVector* aNormalVector) const;
|
||||
G4double DistanceToOutNoVoxels(const G4ThreeVector& aPoint,
|
||||
const G4ThreeVector& aDirection,
|
||||
G4ThreeVector* aNormalVector) const;
|
||||
G4ThreeVector* aNormalVector) const;
|
||||
|
||||
/**
|
||||
* Returns the outwards pointing unit normal of the shape for the
|
||||
* surface closest to the point at offset "aPoint".
|
||||
*/
|
||||
G4ThreeVector SurfaceNormal(const G4ThreeVector& aPoint) const override;
|
||||
|
||||
/**
|
||||
* Determines the bounding box for the considered instance of G4MultiUnion.
|
||||
* @param[in] aAxis The axis along which computing the extent.
|
||||
* @param[out] aMin The minimum bounding limit point.
|
||||
* @param[out] aMax The maximum bounding limit point.
|
||||
*/
|
||||
void Extent(EAxis aAxis, G4double& aMin, G4double& aMax) const;
|
||||
|
||||
/**
|
||||
* Computes the bounding limits of the solid.
|
||||
* @param[out] aMin The minimum bounding limit point.
|
||||
* @param[out] aMax The maximum bounding limit point.
|
||||
*/
|
||||
void BoundingLimits(G4ThreeVector& aMin, G4ThreeVector& aMax) const override;
|
||||
|
||||
/**
|
||||
* Calculates the minimum and maximum extent of a 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 an estimate of the structure capacity or surface area.
|
||||
*/
|
||||
G4double GetCubicVolume() override;
|
||||
G4double GetSurfaceArea() override;
|
||||
|
||||
/**
|
||||
* Returns the number of solids part of the structure.
|
||||
*/
|
||||
G4int GetNumOfConstituents() const override;
|
||||
|
||||
/**
|
||||
* Returns false if any of the solids part of the structure is not faceted.
|
||||
*/
|
||||
G4bool IsFaceted() const override;
|
||||
|
||||
/**
|
||||
* Returns a new allocated clone of the multi-union structure.
|
||||
*/
|
||||
G4VSolid* Clone() const override ;
|
||||
|
||||
/**
|
||||
* Returns the type ID, "G4MultiUnion" of the solid.
|
||||
*/
|
||||
G4GeometryType GetEntityType() const override { return "G4MultiUnion"; }
|
||||
|
||||
/**
|
||||
* Finalises and prepares for use, creating the optimisation structure
|
||||
* for all solids in the structure. It must be called once before
|
||||
* navigation use.
|
||||
*/
|
||||
void Voxelize();
|
||||
// Finalize and prepare for use. User MUST call it once before
|
||||
// navigation use.
|
||||
|
||||
EInside InsideNoVoxels(const G4ThreeVector& aPoint) const;
|
||||
/**
|
||||
* Returns the xoxelised optimisation structure.
|
||||
*/
|
||||
inline G4Voxelizer& GetVoxels() const;
|
||||
|
||||
/**
|
||||
* Streams the object contents to an output stream.
|
||||
*/
|
||||
std::ostream& StreamInfo(std::ostream& os) const override;
|
||||
|
||||
/**
|
||||
* Returns a point (G4ThreeVector) randomly and uniformly generated
|
||||
* on the surface of a solid.
|
||||
*/
|
||||
G4ThreeVector GetPointOnSurface() 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;
|
||||
|
||||
G4MultiUnion(__void__&);
|
||||
// Fake default constructor for usage restricted to direct object
|
||||
// persistency for clients requiring preallocation of memory for
|
||||
// persistifiable objects.
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Utility methods for safety and distance computation.
|
||||
*/
|
||||
EInside InsideNoVoxels(const G4ThreeVector& aPoint) const;
|
||||
EInside InsideWithExclusion(const G4ThreeVector& aPoint,
|
||||
G4SurfBits* bits = nullptr) const;
|
||||
G4SurfBits* bits = nullptr) const;
|
||||
G4int SafetyFromOutsideNumberNode(const G4ThreeVector& aPoint,
|
||||
G4double& safety) const;
|
||||
G4double& safety) const;
|
||||
G4double DistanceToInCandidates(const G4ThreeVector& aPoint,
|
||||
const G4ThreeVector& aDirection,
|
||||
std::vector<G4int>& candidates,
|
||||
G4SurfBits& bits) const;
|
||||
std::vector<G4int>& candidates,
|
||||
G4SurfBits& bits) const;
|
||||
|
||||
// Conversion utilities
|
||||
/**
|
||||
* Conversion utilities.
|
||||
*/
|
||||
inline G4ThreeVector GetLocalPoint(const G4Transform3D& trans,
|
||||
const G4ThreeVector& gpoint) const;
|
||||
inline G4ThreeVector GetLocalVector(const G4Transform3D& trans,
|
||||
@@ -165,6 +288,7 @@ class G4MultiUnion : public G4VSolid
|
||||
const G4ThreeVector& lvec) const;
|
||||
void TransformLimits(G4ThreeVector& min, G4ThreeVector& max,
|
||||
const G4Transform3D& transformation) const;
|
||||
|
||||
private:
|
||||
|
||||
struct G4MultiUnionSurface
|
||||
@@ -185,106 +309,6 @@ class G4MultiUnion : public G4VSolid
|
||||
mutable G4Polyhedron* fpPolyhedron = nullptr;
|
||||
};
|
||||
|
||||
//______________________________________________________________________________
|
||||
inline G4Voxelizer& G4MultiUnion::GetVoxels() const
|
||||
{
|
||||
return (G4Voxelizer&)fVoxels;
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
inline const G4Transform3D& G4MultiUnion::GetTransformation(G4int index) const
|
||||
{
|
||||
return fTransformObjs[index];
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
inline G4VSolid* G4MultiUnion::GetSolid(G4int index) const
|
||||
{
|
||||
return fSolids[index];
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
inline G4int G4MultiUnion::GetNumberOfSolids() const
|
||||
{
|
||||
return G4int(fSolids.size());
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
inline void G4MultiUnion::SetAccurateSafety(G4bool flag)
|
||||
{
|
||||
fAccurate = flag;
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
inline
|
||||
G4ThreeVector G4MultiUnion::GetLocalPoint(const G4Transform3D& trans,
|
||||
const G4ThreeVector& global) const
|
||||
{
|
||||
// Returns local point coordinates converted from the global frame defined
|
||||
// by the transformation. This is defined by multiplying the inverse
|
||||
// transformation with the global vector.
|
||||
|
||||
G4double px = global.x() - trans.dx();
|
||||
G4double py = global.y() - trans.dy();
|
||||
G4double pz = global.z() - trans.dz();
|
||||
G4double x = trans.xx()*px + trans.yx()*py + trans.zx()*pz;
|
||||
G4double y = trans.xy()*px + trans.yy()*py + trans.zy()*pz;
|
||||
G4double z = trans.xz()*px + trans.yz()*py + trans.zz()*pz;
|
||||
return { x, y, z };
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
inline
|
||||
G4ThreeVector G4MultiUnion::GetLocalVector(const G4Transform3D& trans,
|
||||
const G4ThreeVector& global) const
|
||||
{
|
||||
// Returns local point coordinates converted from the global frame defined
|
||||
// by the transformation. This is defined by multiplying the inverse
|
||||
// transformation with the global vector.
|
||||
|
||||
G4double vx = global.x();
|
||||
G4double vy = global.y();
|
||||
G4double vz = global.z();
|
||||
G4double x = trans.xx()*vx + trans.yx()*vy + trans.zx()*vz;
|
||||
G4double y = trans.xy()*vx + trans.yy()*vy + trans.zy()*vz;
|
||||
G4double z = trans.xz()*vx + trans.yz()*vy + trans.zz()*vz;
|
||||
return { x, y, z };
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
inline
|
||||
G4ThreeVector G4MultiUnion::GetGlobalPoint(const G4Transform3D& trans,
|
||||
const G4ThreeVector& local) const
|
||||
{
|
||||
// Returns global point coordinates converted from the local frame defined
|
||||
// by the transformation. This is defined by multiplying this transformation
|
||||
// with the local vector.
|
||||
|
||||
G4double px = local.x();
|
||||
G4double py = local.y();
|
||||
G4double pz = local.z();
|
||||
G4double x = trans.xx()*px + trans.xy()*py + trans.xz()*pz + trans.dx();
|
||||
G4double y = trans.yx()*px + trans.yy()*py + trans.yz()*pz + trans.dy();
|
||||
G4double z = trans.zx()*px + trans.zy()*py + trans.zz()*pz + trans.dz();
|
||||
return { x, y, z };
|
||||
}
|
||||
|
||||
//______________________________________________________________________________
|
||||
inline
|
||||
G4ThreeVector G4MultiUnion::GetGlobalVector(const G4Transform3D& trans,
|
||||
const G4ThreeVector& local) const
|
||||
{
|
||||
// Returns vector components converted from the local frame defined by the
|
||||
// transformation to the global one. This is defined by multiplying this
|
||||
// transformation with the local vector while ignoring the translation.
|
||||
|
||||
G4double vx = local.x();
|
||||
G4double vy = local.y();
|
||||
G4double vz = local.z();
|
||||
G4double x = trans.xx()*vx + trans.xy()*vy + trans.xz()*vz;
|
||||
G4double y = trans.yx()*vx + trans.yy()*vy + trans.yz()*vz;
|
||||
G4double z = trans.zx()*vx + trans.zy()*vy + trans.zz()*vz;
|
||||
return { x, y, z };
|
||||
}
|
||||
#include "G4MultiUnion.icc"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Class G4MultiUnion inline implementation.
|
||||
|
||||
// Author: Marek Gayer (CERN), 19.10.2012 - Original implementation from USolids
|
||||
// Gabriele Cosmo (CERN) 06.04.2017 - Adapted implementation in Geant4
|
||||
// for VecGeom migration
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
inline G4Voxelizer& G4MultiUnion::GetVoxels() const
|
||||
{
|
||||
return (G4Voxelizer&)fVoxels;
|
||||
}
|
||||
|
||||
inline const G4Transform3D& G4MultiUnion::GetTransformation(G4int index) const
|
||||
{
|
||||
return fTransformObjs[index];
|
||||
}
|
||||
|
||||
inline G4VSolid* G4MultiUnion::GetSolid(G4int index) const
|
||||
{
|
||||
return fSolids[index];
|
||||
}
|
||||
|
||||
inline G4int G4MultiUnion::GetNumberOfSolids() const
|
||||
{
|
||||
return G4int(fSolids.size());
|
||||
}
|
||||
|
||||
inline void G4MultiUnion::SetAccurateSafety(G4bool flag)
|
||||
{
|
||||
fAccurate = flag;
|
||||
}
|
||||
|
||||
inline
|
||||
G4ThreeVector G4MultiUnion::GetLocalPoint(const G4Transform3D& trans,
|
||||
const G4ThreeVector& global) const
|
||||
{
|
||||
// Returns local point coordinates converted from the global frame defined
|
||||
// by the transformation. This is defined by multiplying the inverse
|
||||
// transformation with the global vector.
|
||||
|
||||
G4double px = global.x() - trans.dx();
|
||||
G4double py = global.y() - trans.dy();
|
||||
G4double pz = global.z() - trans.dz();
|
||||
G4double x = trans.xx()*px + trans.yx()*py + trans.zx()*pz;
|
||||
G4double y = trans.xy()*px + trans.yy()*py + trans.zy()*pz;
|
||||
G4double z = trans.xz()*px + trans.yz()*py + trans.zz()*pz;
|
||||
return { x, y, z };
|
||||
}
|
||||
|
||||
inline
|
||||
G4ThreeVector G4MultiUnion::GetLocalVector(const G4Transform3D& trans,
|
||||
const G4ThreeVector& global) const
|
||||
{
|
||||
// Returns local point coordinates converted from the global frame defined
|
||||
// by the transformation. This is defined by multiplying the inverse
|
||||
// transformation with the global vector.
|
||||
|
||||
G4double vx = global.x();
|
||||
G4double vy = global.y();
|
||||
G4double vz = global.z();
|
||||
G4double x = trans.xx()*vx + trans.yx()*vy + trans.zx()*vz;
|
||||
G4double y = trans.xy()*vx + trans.yy()*vy + trans.zy()*vz;
|
||||
G4double z = trans.xz()*vx + trans.yz()*vy + trans.zz()*vz;
|
||||
return { x, y, z };
|
||||
}
|
||||
|
||||
inline
|
||||
G4ThreeVector G4MultiUnion::GetGlobalPoint(const G4Transform3D& trans,
|
||||
const G4ThreeVector& local) const
|
||||
{
|
||||
// Returns global point coordinates converted from the local frame defined
|
||||
// by the transformation. This is defined by multiplying this transformation
|
||||
// with the local vector.
|
||||
|
||||
G4double px = local.x();
|
||||
G4double py = local.y();
|
||||
G4double pz = local.z();
|
||||
G4double x = trans.xx()*px + trans.xy()*py + trans.xz()*pz + trans.dx();
|
||||
G4double y = trans.yx()*px + trans.yy()*py + trans.yz()*pz + trans.dy();
|
||||
G4double z = trans.zx()*px + trans.zy()*py + trans.zz()*pz + trans.dz();
|
||||
return { x, y, z };
|
||||
}
|
||||
|
||||
inline
|
||||
G4ThreeVector G4MultiUnion::GetGlobalVector(const G4Transform3D& trans,
|
||||
const G4ThreeVector& local) const
|
||||
{
|
||||
// Returns vector components converted from the local frame defined by the
|
||||
// transformation to the global one. This is defined by multiplying this
|
||||
// transformation with the local vector while ignoring the translation.
|
||||
|
||||
G4double vx = local.x();
|
||||
G4double vy = local.y();
|
||||
G4double vz = local.z();
|
||||
G4double x = trans.xx()*vx + trans.xy()*vy + trans.xz()*vz;
|
||||
G4double y = trans.yx()*vx + trans.yy()*vy + trans.yz()*vz;
|
||||
G4double z = trans.zx()*vx + trans.zy()*vy + trans.zz()*vz;
|
||||
return { x, y, z };
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
// A scaled solid is a solid that has been scaled in dimensions
|
||||
// in X, Y or Z, from its original description.
|
||||
|
||||
// 27.10.15 G.Cosmo: created
|
||||
// Author: Gabriele Cosmo (CERN), 27.10.2015 - Created
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4SCALEDSOLID_HH
|
||||
#define G4SCALEDSOLID_HH
|
||||
@@ -42,77 +42,184 @@
|
||||
|
||||
class G4ScaleTransform;
|
||||
|
||||
/**
|
||||
* @brief G4ScaledSolid is a solid that has been scaled in dimensions
|
||||
* in X, Y or Z, from its original description.
|
||||
*/
|
||||
|
||||
class G4ScaledSolid : public G4VSolid
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor of a solid with scaled transformation.
|
||||
* @param[in] pName The name of the solid.
|
||||
* @param[in] pSolid Pointer to the original reference solid.
|
||||
* @param[in] pScale The scaling transformation.
|
||||
*/
|
||||
G4ScaledSolid( const G4String& pName,
|
||||
G4VSolid* pSolid ,
|
||||
const G4Scale3D& pScale );
|
||||
|
||||
/**
|
||||
* The destructor, clearing the cached transformation.
|
||||
*/
|
||||
~G4ScaledSolid() override;
|
||||
|
||||
/**
|
||||
* Fake default constructor for usage restricted to direct object
|
||||
* persistency for clients requiring preallocation of memory for
|
||||
* persistifiable objects.
|
||||
*/
|
||||
G4ScaledSolid(__void__&);
|
||||
|
||||
/**
|
||||
* Copy constructor and assignment operator.
|
||||
*/
|
||||
G4ScaledSolid(const G4ScaledSolid& rhs);
|
||||
G4ScaledSolid& operator=(const G4ScaledSolid& rhs);
|
||||
|
||||
/**
|
||||
* Returns if the given point "p" is inside or not the solid.
|
||||
*/
|
||||
EInside Inside( 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 outwards pointing unit normal of the shape for the
|
||||
* surface closest to the point at offset "p".
|
||||
*/
|
||||
G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from the point at offset "p". If there is no intersection, return
|
||||
* kInfinity. The first intersection resulting from leaving a
|
||||
* surface/volume is discarded. Hence, it is tolerant of points on
|
||||
* the surface of the shape.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const override;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an outside point. The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p) const override;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from a point at an offset "p" inside or on the surface of the shape.
|
||||
* Intersections with surfaces, when the point is < Tolerance/2 from a
|
||||
* surface must be ignored. Must be called as solid.DistanceToOut(p,v)
|
||||
* or by specifying all the parameters.
|
||||
* @param[in] p The reference point in space.
|
||||
* @param[in] v The normalised direction.
|
||||
* @param[in] calcNorm Flag to enable the normal computation or not.
|
||||
* @param[out] validNorm Set to true if the solid lies entirely behind
|
||||
* or on the exiting surface (calcNorm must be true, otherwise
|
||||
* it is unused).
|
||||
* @param[out] n The exiting outwards normal vector (undefined Magnitude).
|
||||
* (calcNorm must be true, otherwise it is unused).
|
||||
* @returns The distance value to exit the volume.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* n = nullptr ) const override;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an inside point "p". The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p ) const override;
|
||||
|
||||
/**
|
||||
* Throws an exception as paramterisations are not allowed for these solids.
|
||||
*/
|
||||
void ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep ) override;
|
||||
|
||||
/**
|
||||
* Methods returning an estimation of the solid volume (capacity) and
|
||||
* surface area, in internal units.
|
||||
*/
|
||||
G4double GetCubicVolume() override;
|
||||
G4double GetSurfaceArea() override;
|
||||
|
||||
void CleanTransformations();
|
||||
|
||||
/**
|
||||
* Returns a random point located on the surface of the solid.
|
||||
* Points returned may not necessarily be uniformly distributed.
|
||||
*/
|
||||
G4ThreeVector GetPointOnSurface() const override;
|
||||
|
||||
/**
|
||||
* Returns the number of constituents of the solid.
|
||||
* For non-Boolean solids the return value is one.
|
||||
*/
|
||||
G4int GetNumOfConstituents() const override;
|
||||
|
||||
/**
|
||||
* Returns true if the solid has only planar faces, false otherwise.
|
||||
*/
|
||||
G4bool IsFaceted() const override;
|
||||
|
||||
G4Scale3D GetScaleTransform() const;
|
||||
/**
|
||||
* Accessor and setter for the scaling transformation.
|
||||
*/
|
||||
G4Scale3D GetScaleTransform() const;
|
||||
void SetScaleTransform(const G4Scale3D& scale);
|
||||
|
||||
/**
|
||||
* Returns a pointer to the original not scaled solid.
|
||||
*/
|
||||
G4VSolid* GetUnscaledSolid() const;
|
||||
|
||||
/**
|
||||
* Returns the type ID, "G4ScaledSolid" 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;
|
||||
|
||||
G4ScaledSolid(__void__&);
|
||||
// Fake default constructor for usage restricted to direct object
|
||||
// persistency for clients requiring preallocation of memory for
|
||||
// persistifiable objects.
|
||||
|
||||
G4ScaledSolid(const G4ScaledSolid& rhs);
|
||||
G4ScaledSolid& operator=(const G4ScaledSolid& rhs);
|
||||
// Copy constructor and assignment operator.
|
||||
|
||||
/**
|
||||
* Methods for creating graphical representations (i.e. for visualisation).
|
||||
*/
|
||||
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override;
|
||||
G4Polyhedron* CreatePolyhedron () const override;
|
||||
G4Polyhedron* GetPolyhedron () const override;
|
||||
// For creating graphical representations (i.e. for visualisation).
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
//
|
||||
// Class for description of subtraction of two solids: A - B.
|
||||
|
||||
// 14.10.98 V.Grichine: first implementation
|
||||
// Author: Vladimir Grichine (CERN), 14.10.1998 - First implementation
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4SUBTRACTIONSOLID_HH
|
||||
#define G4SUBTRACTIONSOLID_HH
|
||||
@@ -42,73 +42,178 @@
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
/**
|
||||
* @brief G4SubtractionSolid is a solid describing the Boolean subtraction
|
||||
* of two solids.
|
||||
*/
|
||||
|
||||
class G4SubtractionSolid : public G4BooleanSolid
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean subtraction between two solids with no
|
||||
* displacement.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
*/
|
||||
G4SubtractionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ) ;
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean subtraction between two solids with rotation
|
||||
* and translation, used to transform the coordinate system of the second
|
||||
* solid to the coordinate system of the first solid.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
* @param[in] rotMatrix Pointer to the rotation vector.
|
||||
* @param[in] transVector The translation vector.
|
||||
*/
|
||||
G4SubtractionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ) ;
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean subtraction between two solids with a
|
||||
* transformation that moves the second solid from its desired position
|
||||
* to its standard position.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
* @param[in] transform The composed 3D transformation.
|
||||
*/
|
||||
G4SubtractionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
const G4Transform3D& transform ) ;
|
||||
|
||||
~G4SubtractionSolid() override ;
|
||||
|
||||
G4GeometryType GetEntityType() const override ;
|
||||
|
||||
G4VSolid* Clone() const override;
|
||||
/**
|
||||
* Default destructor.
|
||||
*/
|
||||
~G4SubtractionSolid() override = default ;
|
||||
|
||||
/**
|
||||
* Fake default constructor for usage restricted to direct object
|
||||
* persistency for clients requiring preallocation of memory for
|
||||
* persistifiable objects.
|
||||
*/
|
||||
G4SubtractionSolid(__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.
|
||||
*/
|
||||
G4SubtractionSolid(const G4SubtractionSolid& rhs);
|
||||
G4SubtractionSolid& operator=(const G4SubtractionSolid& rhs);
|
||||
// Copy constructor and assignment operator.
|
||||
|
||||
/**
|
||||
* Returns the type ID, "G4SubtractionSolid" 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;
|
||||
|
||||
/**
|
||||
* 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 if the given point "p" is inside or not the solid.
|
||||
*/
|
||||
EInside Inside( const G4ThreeVector& p ) const override ;
|
||||
|
||||
/**
|
||||
* Returns the outwards pointing unit normal of the shape for the
|
||||
* surface closest to the point at offset "p".
|
||||
*/
|
||||
G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override ;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from the point at offset "p". If there is no intersection, return
|
||||
* kInfinity. The first intersection resulting from leaving a
|
||||
* surface/volume is discarded. Hence, it is tolerant of points on
|
||||
* the surface of the shape.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const override ;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an outside point. The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p) const override ;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from a point at an offset "p" inside or on the surface of the shape.
|
||||
* Intersections with surfaces, when the point is < Tolerance/2 from a
|
||||
* surface must be ignored. Must be called as solid.DistanceToOut(p,v)
|
||||
* or by specifying all the parameters.
|
||||
* @param[in] p The reference point in space.
|
||||
* @param[in] v The normalised direction.
|
||||
* @param[in] calcNorm Flag to enable the normal computation or not.
|
||||
* @param[out] validNorm Set to true if the solid lies entirely behind
|
||||
* or on the exiting surface (calcNorm must be true, otherwise
|
||||
* it is unused).
|
||||
* @param[out] n The exiting outwards normal vector (undefined Magnitude).
|
||||
* (calcNorm must be true, otherwise it is unused).
|
||||
* @returns The distance value to exit the volume.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* n = nullptr ) const override ;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an inside point "p". The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p ) const override ;
|
||||
|
||||
|
||||
/**
|
||||
* Throws an exception as paramterisations are not allowed for these solids.
|
||||
*/
|
||||
void ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep ) override ;
|
||||
|
||||
/**
|
||||
* Methods for creating graphical representations (i.e. for visualisation).
|
||||
*/
|
||||
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override ;
|
||||
G4Polyhedron* CreatePolyhedron () const override ;
|
||||
|
||||
/**
|
||||
* Returns an estimate of the capacity of the Boolean composition.
|
||||
*/
|
||||
G4double GetCubicVolume() final;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
//
|
||||
// Class for description of union of two solids.
|
||||
|
||||
// 12.09.98 V.Grichine - created
|
||||
// Author: Vladimir Grichine (CERN), 12.09.1998 - Created
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4UNIONSOLID_HH
|
||||
#define G4UNIONSOLID_HH
|
||||
@@ -42,76 +42,184 @@
|
||||
#include "G4Transform3D.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
|
||||
/**
|
||||
* @brief G4UnionSolid is a solid describing the Boolean union of two solids.
|
||||
*/
|
||||
|
||||
class G4UnionSolid : public G4BooleanSolid
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean union between two solids with no
|
||||
* displacement.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
*/
|
||||
G4UnionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ) ;
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean union between two solids with rotation
|
||||
* and translation, used to transform the coordinate system of the second
|
||||
* solid to the coordinate system of the first solid.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
* @param[in] rotMatrix Pointer to the rotation vector.
|
||||
* @param[in] transVector The translation vector.
|
||||
*/
|
||||
G4UnionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
G4RotationMatrix* rotMatrix,
|
||||
const G4ThreeVector& transVector ) ;
|
||||
|
||||
/**
|
||||
* Constructor of a Boolean union between two solids with a
|
||||
* transformation that moves the second solid from its desired position
|
||||
* to its standard position.
|
||||
* @param[in] pName The name of the Boolean composition.
|
||||
* @param[in] pSolidA Pointer to the first reference solid.
|
||||
* @param[in] pSolidB Pointer to the second solid to form the composition.
|
||||
* @param[in] transform The composed 3D transformation.
|
||||
*/
|
||||
G4UnionSolid( const G4String& pName,
|
||||
G4VSolid* pSolidA ,
|
||||
G4VSolid* pSolidB ,
|
||||
const G4Transform3D& transform ) ;
|
||||
|
||||
~G4UnionSolid() override ;
|
||||
|
||||
G4GeometryType GetEntityType() const override ;
|
||||
|
||||
G4VSolid* Clone() const override;
|
||||
/**
|
||||
* Default destructor.
|
||||
*/
|
||||
~G4UnionSolid() override = default ;
|
||||
|
||||
/**
|
||||
* Fake default constructor for usage restricted to direct object
|
||||
* persistency for clients requiring preallocation of memory for
|
||||
* persistifiable objects.
|
||||
*/
|
||||
G4UnionSolid(__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.
|
||||
*/
|
||||
G4UnionSolid(const G4UnionSolid& rhs);
|
||||
G4UnionSolid& operator=(const G4UnionSolid& rhs);
|
||||
// Copy constructor and assignment operator.
|
||||
|
||||
/**
|
||||
* Returns the type ID, "G4UnionSolid" 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;
|
||||
|
||||
/**
|
||||
* 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 if the given point "p" is inside or not the solid.
|
||||
*/
|
||||
EInside Inside( const G4ThreeVector& p ) const override ;
|
||||
|
||||
/**
|
||||
* Returns the outwards pointing unit normal of the shape for the
|
||||
* surface closest to the point at offset "p".
|
||||
*/
|
||||
G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override ;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from the point at offset "p". If there is no intersection, return
|
||||
* kInfinity. The first intersection resulting from leaving a
|
||||
* surface/volume is discarded. Hence, it is tolerant of points on
|
||||
* the surface of the shape.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v ) const override ;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an outside point. The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToIn( const G4ThreeVector& p ) const override ;
|
||||
|
||||
/**
|
||||
* Returns the distance along the normalised vector "v" to the shape,
|
||||
* from a point at an offset "p" inside or on the surface of the shape.
|
||||
* Intersections with surfaces, when the point is < Tolerance/2 from a
|
||||
* surface must be ignored. Must be called as solid.DistanceToOut(p,v)
|
||||
* or by specifying all the parameters.
|
||||
* @param[in] p The reference point in space.
|
||||
* @param[in] v The normalised direction.
|
||||
* @param[in] calcNorm Flag to enable the normal computation or not.
|
||||
* @param[out] validNorm Set to true if the solid lies entirely behind
|
||||
* or on the exiting surface (calcNorm must be true, otherwise
|
||||
* it is unused).
|
||||
* @param[out] n The exiting outwards normal vector (undefined Magnitude).
|
||||
* (calcNorm must be true, otherwise it is unused).
|
||||
* @returns The distance value to exit the volume.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p,
|
||||
const G4ThreeVector& v,
|
||||
const G4bool calcNorm = false,
|
||||
G4bool* validNorm = nullptr,
|
||||
G4ThreeVector* n = nullptr ) const override ;
|
||||
|
||||
/**
|
||||
* Calculates the safety distance to the nearest surface of a shape from
|
||||
* an inside point "p". The distance can be an underestimate.
|
||||
*/
|
||||
G4double DistanceToOut( const G4ThreeVector& p ) const override ;
|
||||
|
||||
|
||||
/**
|
||||
* Throws an exception as paramterisations are not allowed for these solids.
|
||||
*/
|
||||
void ComputeDimensions( G4VPVParameterisation* p,
|
||||
const G4int n,
|
||||
const G4VPhysicalVolume* pRep ) override ;
|
||||
|
||||
/**
|
||||
* Methods for creating graphical representations (i.e. for visualisation).
|
||||
*/
|
||||
void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override ;
|
||||
G4Polyhedron* CreatePolyhedron () const override ;
|
||||
|
||||
/**
|
||||
* Returns an estimate of the capacity of the Boolean composition.
|
||||
*/
|
||||
G4double GetCubicVolume() final;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Initialisation method used in constructors.
|
||||
*/
|
||||
void Init();
|
||||
|
||||
G4ThreeVector fPMin, fPMax; // bounding box extended by half-tolerance
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
//
|
||||
// Virtual base class for Boolean solid processing.
|
||||
|
||||
// 20.03.2023 Stewart Boogert - created
|
||||
// Author: Stewart Boogert (Manchester University), 20.03.2023 - Created
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4VBOOLEANPROCESSOR_HH
|
||||
#define G4VBOOLEANPROCESSOR_HH
|
||||
@@ -39,13 +39,25 @@ class G4PolyhedronArbitrary;
|
||||
class G4BooleanSolid;
|
||||
class G4VSolid;
|
||||
|
||||
/**
|
||||
* @brief G4VBooleanProcessor is a virtual base class for Boolean solid
|
||||
* processing.
|
||||
*/
|
||||
|
||||
class G4VBooleanProcessor
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor and destructor.
|
||||
*/
|
||||
G4VBooleanProcessor() = default;
|
||||
virtual ~G4VBooleanProcessor() = default;
|
||||
|
||||
/**
|
||||
* Boolean operations on polyhedrons of the component solids.
|
||||
* To be implemented in derived classes.
|
||||
*/
|
||||
virtual G4PolyhedronArbitrary* Intersection(G4Polyhedron* /*p1*/,
|
||||
G4Polyhedron* /*p2*/)
|
||||
{ return nullptr; }
|
||||
@@ -56,6 +68,10 @@ class G4VBooleanProcessor
|
||||
G4Polyhedron* /*p2*/)
|
||||
{ return nullptr; }
|
||||
|
||||
/**
|
||||
* Processing method of the final solid.
|
||||
* To be implemented in derived classes.
|
||||
*/
|
||||
virtual G4PolyhedronArbitrary* Process(const G4VSolid* /*bs*/)
|
||||
{ return nullptr; }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user