Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:52:04

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4SubtractionSolid
0027 //
0028 // Class description:
0029 //
0030 // Class for description of subtraction of two solids: A - B.
0031 
0032 // Author: Vladimir Grichine (CERN), 14.10.1998 - First implementation
0033 // --------------------------------------------------------------------
0034 #ifndef G4SUBTRACTIONSOLID_HH
0035 #define G4SUBTRACTIONSOLID_HH
0036 
0037 #include "G4BooleanSolid.hh"
0038 #include "G4VSolid.hh"
0039 
0040 #include "G4RotationMatrix.hh"
0041 #include "G4ThreeVector.hh"
0042 #include "G4Transform3D.hh"
0043 #include "G4AffineTransform.hh"
0044 
0045 /**
0046  * @brief G4SubtractionSolid is a solid describing the Boolean subtraction
0047  * of two solids.
0048  */
0049 
0050 class G4SubtractionSolid : public G4BooleanSolid
0051 {
0052   public:
0053 
0054     /**
0055      * Constructor of a Boolean subtraction between two solids with no
0056      * displacement.
0057      *  @param[in] pName The name of the Boolean composition.
0058      *  @param[in] pSolidA Pointer to the first reference solid.
0059      *  @param[in] pSolidB Pointer to the second solid to form the composition.
0060      */
0061     G4SubtractionSolid(  const G4String& pName,
0062                                G4VSolid* pSolidA ,
0063                                G4VSolid* pSolidB   ) ;
0064 
0065     /**
0066      * Constructor of a Boolean subtraction between two solids with rotation
0067      * and translation, used to transform the coordinate system of the second
0068      * solid to the coordinate system of the first solid.
0069      *  @param[in] pName The name of the Boolean composition.
0070      *  @param[in] pSolidA Pointer to the first reference solid.
0071      *  @param[in] pSolidB Pointer to the second solid to form the composition.
0072      *  @param[in] rotMatrix Pointer to the rotation vector.
0073      *  @param[in] transVector The translation vector.
0074      */
0075     G4SubtractionSolid(  const G4String& pName,
0076                                G4VSolid* pSolidA ,
0077                                G4VSolid* pSolidB ,
0078                                G4RotationMatrix* rotMatrix,
0079                          const G4ThreeVector& transVector   ) ;
0080 
0081     /**
0082      * Constructor of a Boolean subtraction between two solids with a
0083      * transformation that moves the second solid from its desired position
0084      * to its standard position.
0085      *  @param[in] pName The name of the Boolean composition.
0086      *  @param[in] pSolidA Pointer to the first reference solid.
0087      *  @param[in] pSolidB Pointer to the second solid to form the composition.
0088      *  @param[in] transform The composed 3D transformation.
0089      */
0090     G4SubtractionSolid(  const G4String& pName,
0091                                G4VSolid* pSolidA ,
0092                                G4VSolid* pSolidB ,
0093                          const G4Transform3D& transform   ) ;
0094 
0095     /**
0096      * Default destructor.
0097      */
0098     ~G4SubtractionSolid() override = default ;
0099 
0100     /**
0101      * Fake default constructor for usage restricted to direct object
0102      * persistency for clients requiring preallocation of memory for
0103      * persistifiable objects.
0104      */
0105     G4SubtractionSolid(__void__&);
0106 
0107     /**
0108      * Copy constructor and assignment operator.
0109      */
0110     G4SubtractionSolid(const G4SubtractionSolid& rhs);
0111     G4SubtractionSolid& operator=(const G4SubtractionSolid& rhs);
0112 
0113     /**
0114      * Returns the type ID, "G4SubtractionSolid" of the solid.
0115      */
0116     G4GeometryType GetEntityType() const override ;
0117 
0118     /**
0119      * Makes a clone of the object for use in multi-treading.
0120      *  @returns A pointer to the new cloned allocated solid.
0121      */
0122     G4VSolid* Clone() const override;
0123 
0124     /**
0125      * Computes the bounding limits of the solid.
0126      *  @param[out] pMin The minimum bounding limit point.
0127      *  @param[out] pMax The maximum bounding limit point.
0128      */
0129     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0130 
0131     /**
0132      * Calculates the minimum and maximum extent of the solid, when under the
0133      * specified transform, and within the specified limits.
0134      *  @param[in] pAxis The axis along which compute the extent.
0135      *  @param[in] pVoxelLimit The limiting space dictated by voxels.
0136      *  @param[in] pTransform The internal transformation applied to the solid.
0137      *  @param[out] pMin The minimum extent value.
0138      *  @param[out] pMax The maximum extent value.
0139      *  @returns True if the solid is intersected by the extent region.
0140      */
0141     G4bool CalculateExtent( const EAxis pAxis,
0142                             const G4VoxelLimits& pVoxelLimit,
0143                             const G4AffineTransform& pTransform,
0144                                   G4double& pMin, G4double& pMax) const override ;
0145        
0146     /**
0147      * Returns if the given point "p" is inside or not the solid.
0148      */
0149     EInside Inside( const G4ThreeVector& p ) const override ;
0150 
0151     /**
0152      * Returns the outwards pointing unit normal of the shape for the
0153      * surface closest to the point at offset "p".
0154      */
0155     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override ;
0156 
0157     /**
0158      * Returns the distance along the normalised vector "v" to the shape,
0159      * from the point at offset "p". If there is no intersection, return
0160      * kInfinity. The first intersection resulting from leaving a
0161      * surface/volume is discarded. Hence, it is tolerant of points on
0162      * the surface of the shape.
0163      */
0164     G4double DistanceToIn( const G4ThreeVector& p,
0165                            const G4ThreeVector& v  ) const override ;
0166 
0167     /**
0168      * Calculates the safety distance to the nearest surface of a shape from
0169      * an outside point. The distance can be an underestimate.
0170      */
0171     G4double DistanceToIn( const G4ThreeVector& p) const override ;
0172 
0173     /**
0174      * Returns the distance along the normalised vector "v" to the shape,
0175      * from a point at an offset "p" inside or on the surface of the shape.
0176      * Intersections with surfaces, when the point is < Tolerance/2 from a
0177      * surface must be ignored. Must be called as solid.DistanceToOut(p,v)
0178      * or by specifying all the parameters.
0179      *  @param[in] p The reference point in space.
0180      *  @param[in] v The normalised direction.
0181      *  @param[in] calcNorm Flag to enable the normal computation or not.
0182      *  @param[out] validNorm Set to true if the solid lies entirely behind
0183      *              or on the exiting surface (calcNorm must be true, otherwise
0184      *              it is unused).
0185      *  @param[out] n The exiting outwards normal vector (undefined Magnitude).
0186      *              (calcNorm must be true, otherwise it is unused). 
0187      *  @returns The distance value to exit the volume.
0188      */
0189     G4double DistanceToOut( const G4ThreeVector& p,
0190                             const G4ThreeVector& v,
0191                             const G4bool calcNorm = false,
0192                                   G4bool* validNorm = nullptr,
0193                                   G4ThreeVector* n = nullptr ) const override ;
0194 
0195     /**
0196      * Calculates the safety distance to the nearest surface of a shape from
0197      * an inside point "p". The distance can be an underestimate.
0198      */
0199     G4double DistanceToOut( const G4ThreeVector& p ) const override ;
0200 
0201     /**
0202      * Throws an exception as paramterisations are not allowed for these solids.
0203      */
0204     void ComputeDimensions(       G4VPVParameterisation* p,
0205                             const G4int n,
0206                             const G4VPhysicalVolume* pRep ) override ;
0207                                    
0208     /**
0209      * Methods for creating graphical representations (i.e. for visualisation).
0210      */
0211     void DescribeYourselfTo ( G4VGraphicsScene& scene ) const override ;
0212     G4Polyhedron* CreatePolyhedron () const override ;
0213 
0214     /**
0215      * Returns an estimate of the capacity of the Boolean composition.
0216      */
0217     G4double GetCubicVolume() final;
0218 };
0219 
0220 #endif