Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:59

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 // 30.06.95 P.Kent: Converted from source code developed end 94
0034 // 27.03.96 J.Allison: Added virtual functions DescribeYourselfTo() and
0035 //                     SendWireframeTo(G4VGraphicsModel&)
0036 // 27.03.98 J.Apostolakis: Inherit from G4CSGSolid (not G4VSolid)
0037 // --------------------------------------------------------------------
0038 #ifndef G4BOX_HH
0039 #define G4BOX_HH
0040 
0041 #include "G4GeomTypes.hh"
0042 
0043 #if defined(G4GEOM_USE_USOLIDS)
0044 #define G4GEOM_USE_UBOX 1
0045 #endif
0046 
0047 #if defined(G4GEOM_USE_UBOX)
0048   #define G4UBox G4Box
0049   #include "G4UBox.hh"
0050 #else
0051 
0052 #include "G4CSGSolid.hh"
0053 #include "G4Polyhedron.hh"
0054 
0055 class G4Box : public G4CSGSolid
0056 {
0057   public:
0058 
0059     G4Box(const G4String& pName, G4double pX, G4double pY, G4double pZ);
0060       // Construct a box with name, and half lengths pX,pY,pZ
0061 
0062     ~G4Box() override;
0063 
0064     void ComputeDimensions(G4VPVParameterisation* p,
0065                            const G4int n,
0066                            const G4VPhysicalVolume* pRep) override;
0067 
0068     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0069 
0070     G4bool CalculateExtent(const EAxis pAxis,
0071                            const G4VoxelLimits& pVoxelLimit,
0072                            const G4AffineTransform& pTransform,
0073                                  G4double& pMin, G4double& pMax) const override;
0074 
0075   // Accessors and modifiers
0076 
0077     inline G4double GetXHalfLength() const;
0078     inline G4double GetYHalfLength() const;
0079     inline G4double GetZHalfLength() const;
0080 
0081     void SetXHalfLength(G4double dx) ;
0082     void SetYHalfLength(G4double dy) ;
0083     void SetZHalfLength(G4double dz) ;
0084 
0085   // Methods for solid
0086 
0087     inline G4double GetCubicVolume() override;
0088     inline G4double GetSurfaceArea() override;
0089 
0090     EInside Inside(const G4ThreeVector& p) const override;
0091     G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override;
0092     G4double DistanceToIn(const G4ThreeVector& p,
0093                           const G4ThreeVector& v) const override;
0094     G4double DistanceToIn(const G4ThreeVector& p) const override;
0095     G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
0096                            const G4bool calcNorm = false,
0097                                  G4bool* validNorm = nullptr,
0098                                  G4ThreeVector* n = nullptr) const override;
0099     G4double DistanceToOut(const G4ThreeVector& p) const override;
0100 
0101     G4GeometryType GetEntityType() const override;
0102     G4ThreeVector GetPointOnSurface() const override;
0103 
0104     G4VSolid* Clone() const override;
0105 
0106     std::ostream& StreamInfo(std::ostream& os) const override;
0107 
0108   // Utilities for visualization
0109 
0110     void          DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0111     G4VisExtent   GetExtent          () const override;
0112     G4Polyhedron* CreatePolyhedron   () const override;
0113 
0114     G4Box(__void__&);
0115       // Fake default constructor for usage restricted to direct object
0116       // persistency for clients requiring preallocation of memory for
0117       // persistifiable objects.
0118 
0119     G4Box(const G4Box& rhs);
0120     G4Box& operator=(const G4Box& rhs);
0121       // Copy constructor and assignment operator.
0122 
0123   private:
0124 
0125     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
0126       // Algorithm for SurfaceNormal() following the original
0127       // specification for points not on the surface
0128 
0129   private:
0130 
0131     G4double fDx = 0.0, fDy = 0.0, fDz = 0.0;
0132     G4double delta;  // Cached half Cartesian tolerance
0133 };
0134 
0135 #include "G4Box.icc"
0136 
0137 #endif
0138 
0139 #endif