Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Para.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: G4Para.hh 69788 2013-05-15 12:06:57Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // G4Para
34 //
35 // Class description:
36 //
37 // A G4Parallepiped, essentially a box with half lengths dx,dy,dz
38 // `skewed' so that there are angles theta & phi of the polar line
39 // joining the faces at +-dz in z, and alpha formed by the y axis
40 // and the plane joinng the centre of the faces G4Parallel to the
41 // z-x plane at -dy and +dy.
42 //
43 // A G4Para is defined by:
44 // dx,dy,dz - Half-length in x,y,z
45 // alpha - Angle formed by the y axis and by the plane joining
46 // the centre of the faces G4Parallel to the z-x plane
47 // at -dy and +dy
48 // theta - Polar angle of the line joining the centres of the
49 // faces at -dz and +dz in z
50 // phi - Azimuthal angle of the line joining the centres of the
51 // faces at -dz and +dz in z
52 // Member data:
53 //
54 // Note that the angles parameters are not stored - precomputed trig is
55 // stored instead.
56 //
57 // fDx Half-length in x
58 // fDy Half-length in y
59 // fDz Half-length in z
60 //
61 // fTalpha Tan of alpha
62 // fTthetaCphi Tan theta * Cos phi
63 // fTthetaSphi Tan theta * Sin phi
64 
65 // History:
66 // 21.3.94 P.Kent Old C++ code converted to tolerant geometry
67 // 31.10.96 V.Grichine Modifications according G4Box/Tubs before to commit
68 // 18.11.99 V.Grichine , kUndefined was added to ESide
69 // --------------------------------------------------------------------
70 
71 #ifndef G4Para_HH
72 #define G4Para_HH
73 
74 #include "G4CSGSolid.hh"
75 
76 class G4Para : public G4CSGSolid
77 {
78  public: // with description
79 
80  G4Para(const G4String& pName,
81  G4double pDx, G4double pDy, G4double pDz,
82  G4double pAlpha, G4double pTheta, G4double pPhi);
83 
84  G4Para(const G4String& pName,
85  const G4ThreeVector pt[8]);
86 
87  virtual ~G4Para();
88 
89  // Accessors
90 
91  inline G4double GetZHalfLength() const;
92  inline G4ThreeVector GetSymAxis() const;
93  inline G4double GetYHalfLength() const;
94  inline G4double GetXHalfLength() const;
95  inline G4double GetTanAlpha() const;
96 
97  // Modifiers
98 
99  inline void SetXHalfLength(G4double val);
100  inline void SetYHalfLength(G4double val);
101  inline void SetZHalfLength(G4double val);
102  inline void SetAlpha(G4double alpha);
103  inline void SetTanAlpha(G4double val);
104  inline void SetThetaAndPhi(double pTheta, double pPhi);
105 
106  void SetAllParameters(G4double pDx, G4double pDy, G4double pDz,
107  G4double pAlpha, G4double pTheta, G4double pPhi);
108 
109  // Other methods of solid
110 
111  inline G4double GetCubicVolume();
112  inline G4double GetSurfaceArea();
113 
115  const G4int n,
116  const G4VPhysicalVolume* pRep);
117 
118  G4bool CalculateExtent(const EAxis pAxis,
119  const G4VoxelLimits& pVoxelLimit,
120  const G4AffineTransform& pTransform,
121  G4double& pMin, G4double& pMax) const;
122 
123  EInside Inside(const G4ThreeVector& p) const;
124 
125  G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const;
126 
128  const G4ThreeVector& v) const;
129  G4double DistanceToIn(const G4ThreeVector& p) const;
130 
132  const G4bool calcNorm=G4bool(false),
133  G4bool *validNorm=0, G4ThreeVector *n=0) const;
134  G4double DistanceToOut(const G4ThreeVector& p) const;
135 
137 
139 
140  G4VSolid* Clone() const;
141 
142  std::ostream& StreamInfo(std::ostream& os) const;
143 
144  // Visualisation functions
145 
146  void DescribeYourselfTo (G4VGraphicsScene& scene) const;
147  G4Polyhedron* CreatePolyhedron () const;
148  G4NURBS* CreateNURBS () const;
149 
150  public: // without description
151 
152  G4Para(__void__&);
153  // Fake default constructor for usage restricted to direct object
154  // persistency for clients requiring preallocation of memory for
155  // persistifiable objects.
156 
157  G4Para(const G4Para& rhs);
158  G4Para& operator=(const G4Para& rhs);
159  // Copy constructor and assignment operator.
160 
161  protected: // without description
162 
164  CreateRotatedVertices(const G4AffineTransform& pTransform) const;
165 
166  private:
167 
168  G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p) const;
169  // Algorithm for SurfaceNormal() following the original
170  // specification for points not on the surface
171 
172  G4ThreeVector GetPointOnPlane(G4ThreeVector p0, G4ThreeVector p1,
174  G4double& area) const;
175  // Returns a random point on the surface of one of the faces.
176 
177  private:
178 
179  G4double fDx,fDy,fDz;
180  G4double fTalpha,fTthetaCphi,fTthetaSphi;
181 };
182 
183 #include "G4Para.icc"
184 
185 #endif