Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 99469 2016-09-22 15:04:36Z 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  void Extent(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
79 
80  G4bool CalculateExtent(const EAxis pAxis,
81  const G4VoxelLimits& pVoxelLimit,
82  const G4AffineTransform& pTransform,
83  G4double& pMin, G4double& pMax) const;
84 
85  // Accessors and modifiers
86 
87  inline G4double GetXHalfLength() const;
88  inline G4double GetYHalfLength() const;
89  inline G4double GetZHalfLength() const;
90 
91  void SetXHalfLength(G4double dx) ;
92  void SetYHalfLength(G4double dy) ;
93  void SetZHalfLength(G4double dz) ;
94 
95  // Methods for solid
96 
97  inline G4double GetCubicVolume();
98  inline G4double GetSurfaceArea();
99 
100  EInside Inside(const G4ThreeVector& p) const;
101  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
102  G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
103  G4double DistanceToIn(const G4ThreeVector& p) const;
105  const G4bool calcNorm=false,
106  G4bool *validNorm=0, G4ThreeVector *n=0) const;
107  G4double DistanceToOut(const G4ThreeVector& p) const;
108 
111 
112  G4VSolid* Clone() const;
113 
114  std::ostream& StreamInfo(std::ostream& os) const;
115 
116  // Utilities for visualization
117 
118  void DescribeYourselfTo (G4VGraphicsScene& scene) const;
119  G4VisExtent GetExtent () const;
120  G4Polyhedron* CreatePolyhedron () const;
121 
122  public: // without description
123 
124  G4Box(__void__&);
125  // Fake default constructor for usage restricted to direct object
126  // persistency for clients requiring preallocation of memory for
127  // persistifiable objects.
128 
129  G4Box(const G4Box& rhs);
130  G4Box& operator=(const G4Box& rhs);
131  // Copy constructor and assignment operator.
132 
133  protected: // without description
134 
136  // Codes for faces (kPX= +x face, kMY= -y face, etc...)
137 
138  private:
139 
140  G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
141  // Algorithm for SurfaceNormal() following the original
142  // specification for points not on the surface
143 
144  private:
145 
146  G4double fDx,fDy,fDz;
147  G4double delta; // Cached half Cartesian tolerance
148 };
149 
150 #include "G4Box.icc"
151 
152 #endif
153 
154 #endif
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Box.cc:199
G4ThreeVector GetPointOnSurface() const
Definition: G4Box.cc:825
G4double GetXHalfLength() const
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:174
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
Definition: G4Box.cc:573
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
Definition: G4Box.cc:233
G4Box & operator=(const G4Box &rhs)
Definition: G4Box.cc:112
Definition: G4Box.hh:64
const char * p
Definition: xmltok.h:285
G4GeometryType GetEntityType() const
Definition: G4Box.cc:792
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Box.cc:873
G4Box(const G4String &pName, G4double pX, G4double pY, G4double pZ)
Definition: G4Box.cc:63
G4VisExtent GetExtent() const
Definition: G4Box.cc:878
G4VSolid * Clone() const
Definition: G4Box.cc:864
int G4int
Definition: G4Types.hh:78
G4double GetZHalfLength() const
G4Polyhedron * CreatePolyhedron() const
Definition: G4Box.cc:883
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Box.cc:801
bool G4bool
Definition: G4Types.hh:79
G4double GetYHalfLength() const
G4double GetCubicVolume()
G4double GetSurfaceArea()
ESide
Definition: G4Box.hh:135
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Box.cc:285
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Box.cc:436
EInside Inside(const G4ThreeVector &p) const
Definition: G4Box.cc:252
EInside
Definition: geomdefs.hh:58
virtual ~G4Box()
Definition: G4Box.cc:95
EAxis
Definition: geomdefs.hh:54
void SetYHalfLength(G4double dy)
Definition: G4Box.cc:154
void SetXHalfLength(G4double dx)
Definition: G4Box.cc:134
double G4double
Definition: G4Types.hh:76
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4Box.cc:210