Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-13 09:11:41

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 // G4Box
0027 //
0028 // Class description:
0029 //
0030 // A Box is a cuboid of given half lengths dx,dy,dz. The Box is
0031 // centred on the origin with sides parallel to the x/y/z axes.
0032 
0033 // Author: Paul Kent (CERN), 30.06.1995 - Converted from code developed end 94
0034 // --------------------------------------------------------------------
0035 #ifndef G4BOX_HH
0036 #define G4BOX_HH
0037 
0038 #include "G4GeomTypes.hh"
0039 
0040 #if defined(G4GEOM_USE_USOLIDS)
0041 #define G4GEOM_USE_UBOX 1
0042 #endif
0043 
0044 #if defined(G4GEOM_USE_UBOX)
0045   #define G4UBox G4Box
0046   #include "G4UBox.hh"
0047 #else
0048 
0049 #include "G4CSGSolid.hh"
0050 #include "G4Polyhedron.hh"
0051 
0052 /**
0053  * @brief G4Box is a cuboid of given half lengths dx,dy,dz. The Box is
0054  * centred on the origin with sides parallel to the x/y/z axes.
0055  */
0056 
0057 class G4Box : public G4CSGSolid
0058 {
0059   public:
0060 
0061     /**
0062      * Constructs a box with name, and half lengths pX, pY, pZ.
0063      *  @param[in] pName The name of the solid.
0064      *  @param[in] pX Half length in X.
0065      *  @param[in] pY Half length in Y.
0066      *  @param[in] pZ Half length in Z.
0067      */
0068     G4Box(const G4String& pName, G4double pX, G4double pY, G4double pZ);
0069 
0070     /**
0071      * Default destructor.
0072      */
0073     ~G4Box() override = default;
0074 
0075     /**
0076      * Dispatch method for parameterisation replication mechanism and
0077      * dimension computation.
0078      */
0079     void ComputeDimensions(G4VPVParameterisation* p,
0080                            const G4int n,
0081                            const G4VPhysicalVolume* pRep) override;
0082 
0083     /**
0084      * Computes the bounding limits of the solid.
0085      *  @param[out] pMin The minimum bounding limit point.
0086      *  @param[out] pMax The maximum bounding limit point.
0087      */
0088     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0089 
0090     /**
0091      * Calculates the minimum and maximum extent of the solid, when under the
0092      * specified transform, and within the specified limits.
0093      *  @param[in] pAxis The axis along which compute the extent.
0094      *  @param[in] pVoxelLimit The limiting space dictated by voxels.
0095      *  @param[in] pTransform The internal transformation applied to the solid.
0096      *  @param[out] pMin The minimum extent value.
0097      *  @param[out] pMax The maximum extent value.
0098      *  @returns True if the solid is intersected by the extent region.
0099      */
0100     G4bool CalculateExtent(const EAxis pAxis,
0101                            const G4VoxelLimits& pVoxelLimit,
0102                            const G4AffineTransform& pTransform,
0103                                  G4double& pMin, G4double& pMax) const override;
0104 
0105     /**
0106      * Accessors and modifiers.
0107      */
0108     inline G4double GetXHalfLength() const;
0109     inline G4double GetYHalfLength() const;
0110     inline G4double GetZHalfLength() const;
0111     void SetXHalfLength(G4double dx) ;
0112     void SetYHalfLength(G4double dy) ;
0113     void SetZHalfLength(G4double dz) ;
0114 
0115     /**
0116      * Returning an estimation of the solid volume (capacity) and
0117      * surface area, in internal units.
0118      */
0119     G4double GetCubicVolume() override;
0120     G4double GetSurfaceArea() override;
0121 
0122     /**
0123      * Concrete implementations of the expected query interfaces for
0124      * solids, as defined in the base class G4VSolid.
0125      */
0126     EInside Inside(const G4ThreeVector& p) const override;
0127     G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const override;
0128     G4double DistanceToIn(const G4ThreeVector& p,
0129                           const G4ThreeVector& v) const override;
0130     G4double DistanceToIn(const G4ThreeVector& p) const override;
0131     G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
0132                            const G4bool calcNorm = false,
0133                                  G4bool* validNorm = nullptr,
0134                                  G4ThreeVector* n = nullptr) const override;
0135     G4double DistanceToOut(const G4ThreeVector& p) const override;
0136 
0137     /**
0138      * Returns the type ID, "G4Box" of the solid.
0139      */
0140     G4GeometryType GetEntityType() const override;
0141 
0142     /**
0143      * Returns a random point located and uniformly distributed on the
0144      * surface of the solid.
0145      */
0146     G4ThreeVector GetPointOnSurface() const override;
0147 
0148     /**
0149      * Returns true as the solid has only planar faces.
0150      */
0151     G4bool IsFaceted() const override;
0152 
0153     /**
0154      * Makes a clone of the object for use in multi-treading.
0155      *  @returns A pointer to the new cloned allocated solid.
0156      */
0157     G4VSolid* Clone() const override;
0158 
0159     /**
0160      * Streams the object contents to an output stream.
0161      */
0162     std::ostream& StreamInfo(std::ostream& os) const override;
0163 
0164     /**
0165      * Methods for creating graphical representations (i.e. for visualisation).
0166      */
0167     void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0168     G4VisExtent GetExtent() const override;
0169     G4Polyhedron* CreatePolyhedron() const override;
0170 
0171     /**
0172      * Fake default constructor for usage restricted to direct object
0173      * persistency for clients requiring preallocation of memory for
0174      * persistifiable objects.
0175      */
0176     G4Box(__void__&);
0177 
0178     /**
0179      * Copy constructor and assignment operator.
0180      */
0181     G4Box(const G4Box& rhs) = default;
0182     G4Box& operator=(const G4Box& rhs);
0183 
0184   private:
0185 
0186     /**
0187      * Algorithm for SurfaceNormal() following the original specification
0188      * for points not on the surface.
0189      */
0190     G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
0191 
0192   private:
0193 
0194     G4double fDx = 0.0, fDy = 0.0, fDz = 0.0;
0195     G4double delta;  // Cached half Cartesian tolerance
0196 };
0197 
0198 #include "G4Box.icc"
0199 
0200 #endif
0201 
0202 #endif