Geant4  10.02.p02
G4Box.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4Box.hh 79491 2014-03-05 15:24:29Z gcosmo $
28 //
29 // --------------------------------------------------------------------
30 // GEANT 4 class header file
31 //
32 //
33 // G4Box
34 //
35 // Class description:
36 //
37 // A Box is a cuboid of given half lengths dx,dy,dz. The Box is
38 // centred on the origin with sides parallel to the x/y/z axes.
39 
40 // History:
41 // 30.06.95 P.Kent: Converted from source code developed end 94
42 // 27.03.96 J.Allison: Added virtual functions DescribeYourselfTo() and
43 // SendWireframeTo(G4VGraphicsModel&)
44 // 22.07.96 J.Allison: Changed G4VGraphicsModel to G4VGraphicsScene
45 // and SendPolyhedronTo() to CreatePolyhedron()
46 // 27.03.98 J.Apostolakis: Inherit from G4CSGSolid (not G4VSolid)
47 // 18.11.99 J.Apostolakis, V.Grichine: kUndefined was added to ESide
48 // --------------------------------------------------------------------
49 #ifndef G4BOX_HH
50 #define G4BOX_HH
51 
52 #if defined(G4GEOM_USE_USOLIDS)
53 #define G4GEOM_USE_UBOX 1
54 #endif
55 
56 #if defined(G4GEOM_USE_UBOX)
57  #define G4UBox G4Box
58  #include "G4UBox.hh"
59 #else
60 
61 #include "G4CSGSolid.hh"
62 #include "G4Polyhedron.hh"
63 
64 class G4Box : public G4CSGSolid
65 {
66  public: // with description
67 
68  G4Box(const G4String& pName, G4double pX, G4double pY, G4double pZ);
69  // Construct a box with name, and half lengths pX,pY,pZ
70 
71  virtual ~G4Box();
72 
73 
75  const G4int n,
76  const G4VPhysicalVolume* pRep);
77 
78  G4bool CalculateExtent(const EAxis pAxis,
79  const G4VoxelLimits& pVoxelLimit,
80  const G4AffineTransform& pTransform,
81  G4double& pmin, G4double& pmax) const;
82 
83  // Accessors and modifiers
84 
85  inline G4double GetXHalfLength() const;
86  inline G4double GetYHalfLength() const;
87  inline G4double GetZHalfLength() const;
88 
89  void SetXHalfLength(G4double dx) ;
90  void SetYHalfLength(G4double dy) ;
91  void SetZHalfLength(G4double dz) ;
92 
93  // Methods for solid
94 
95  inline G4double GetCubicVolume();
96  inline G4double GetSurfaceArea();
97 
98  EInside Inside(const G4ThreeVector& p) const;
99  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
100  G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
101  G4double DistanceToIn(const G4ThreeVector& p) const;
103  const G4bool calcNorm=false,
104  G4bool *validNorm=0, G4ThreeVector *n=0) const;
105  G4double DistanceToOut(const G4ThreeVector& p) const;
106 
109 
110  G4VSolid* Clone() const;
111 
112  std::ostream& StreamInfo(std::ostream& os) const;
113 
114  // Utilities for visualization
115 
116  void DescribeYourselfTo (G4VGraphicsScene& scene) const;
117  G4VisExtent GetExtent () const;
118  G4Polyhedron* CreatePolyhedron () const;
119 
120  public: // without description
121 
122  G4Box(__void__&);
123  // Fake default constructor for usage restricted to direct object
124  // persistency for clients requiring preallocation of memory for
125  // persistifiable objects.
126 
127  G4Box(const G4Box& rhs);
128  G4Box& operator=(const G4Box& rhs);
129  // Copy constructor and assignment operator.
130 
131  protected: // with description
132 
134  CreateRotatedVertices(const G4AffineTransform& pTransform) const;
135  // Create the List of transformed vertices in the format required
136  // for G4VSolid:: ClipCrossSection and ClipBetweenSections.
137 
138  protected: // without description
139 
141  // Codes for faces (kPX= +x face, kMY= -y face, etc...)
142 
143  private:
144 
146  // Algorithm for SurfaceNormal() following the original
147  // specification for points not on the surface
148 
149  private:
150 
152  G4double delta; // Cached half Cartesian tolerance
153 };
154 
155 #include "G4Box.icc"
156 
157 #endif
158 
159 #endif
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Box.cc:196
G4ThreeVector GetPointOnSurface() const
Definition: G4Box.cc:989
G4double GetXHalfLength() const
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:171
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
Definition: G4Box.cc:692
G4double fDy
Definition: G4Box.hh:151
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
Definition: G4Box.cc:207
CLHEP::Hep3Vector G4ThreeVector
G4Box & operator=(const G4Box &rhs)
Definition: G4Box.cc:109
G4double delta
Definition: G4Box.hh:152
Definition: G4Box.hh:64
G4GeometryType GetEntityType() const
Definition: G4Box.cc:956
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Box.cc:1037
G4Box(const G4String &pName, G4double pX, G4double pY, G4double pZ)
Definition: G4Box.cc:60
G4VisExtent GetExtent() const
Definition: G4Box.cc:1042
G4VSolid * Clone() const
Definition: G4Box.cc:1028
int G4int
Definition: G4Types.hh:78
G4double GetZHalfLength() const
G4Polyhedron * CreatePolyhedron() const
Definition: G4Box.cc:1047
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Box.cc:965
G4double fDz
Definition: G4Box.hh:151
bool G4bool
Definition: G4Types.hh:79
G4double fDx
Definition: G4Box.hh:151
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
G4double GetYHalfLength() const
const G4int n
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const
Definition: G4Box.cc:917
G4double GetCubicVolume()
G4double GetSurfaceArea()
ESide
Definition: G4Box.hh:140
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Box.cc:404
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Box.cc:555
EInside Inside(const G4ThreeVector &p) const
Definition: G4Box.cc:371
EInside
Definition: geomdefs.hh:58
virtual ~G4Box()
Definition: G4Box.cc:92
EAxis
Definition: geomdefs.hh:54
void SetYHalfLength(G4double dy)
Definition: G4Box.cc:151
void SetXHalfLength(G4double dx)
Definition: G4Box.cc:131
double G4double
Definition: G4Types.hh:76
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
Definition: G4Box.cc:494