Geant4_10
G4Cons.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: G4Cons.hh 76263 2013-11-08 11:41:52Z gcosmo $
28 //
29 //
30 // --------------------------------------------------------------------
31 // GEANT 4 class header file
32 //
33 // G4Cons
34 //
35 // Class description:
36 //
37 // A G4Cons is, in the general case, a Phi segment of a cone, with
38 // half-length fDz, inner and outer radii specified at -fDz and +fDz.
39 // The Phi segment is described by a starting fSPhi angle, and the
40 // +fDPhi delta angle for the shape.
41 // If the delta angle is >=2*pi, the shape is treated as continuous
42 // in Phi
43 //
44 // Member Data:
45 //
46 // fRmin1 inside radius at -fDz
47 // fRmin2 inside radius at +fDz
48 // fRmax1 outside radius at -fDz
49 // fRmax2 outside radius at +fDz
50 // fDz half length in z
51 //
52 // fSPhi starting angle of the segment in radians
53 // fDPhi delta angle of the segment in radians
54 //
55 // fPhiFullCone Boolean variable used for indicate the Phi Section
56 //
57 // Note:
58 // Internally fSPhi & fDPhi are adjusted so that fDPhi<=2PI,
59 // and fDPhi+fSPhi<=2PI. This enables simpler comparisons to be
60 // made with (say) Phi of a point.
61 
62 // History:
63 // 19.3.94 P.Kent: Old C++ code converted to tolerant geometry
64 // 13.9.96 V.Grichine: Final modifications to commit
65 // --------------------------------------------------------------------
66 #ifndef G4Cons_HH
67 #define G4Cons_HH
68 
69 #if defined(G4GEOM_USE_USOLIDS)
70 #define G4GEOM_USE_UCONS 1
71 #endif
72 
73 #if defined(G4GEOM_USE_UCONS)
74  #define G4UCons G4Cons
75  #include "G4UCons.hh"
76 #else
77 
79 
80 #include "G4CSGSolid.hh"
81 
82 class G4Cons : public G4CSGSolid
83 {
84  public: // with description
85 
86  G4Cons(const G4String& pName,
87  G4double pRmin1, G4double pRmax1,
88  G4double pRmin2, G4double pRmax2,
89  G4double pDz,
90  G4double pSPhi, G4double pDPhi);
91  //
92  // Constructs a cone with the given name and dimensions
93 
94  ~G4Cons() ;
95  //
96  // Destructor
97 
98  // Accessors
99 
100  inline G4double GetInnerRadiusMinusZ() const;
101  inline G4double GetOuterRadiusMinusZ() const;
102  inline G4double GetInnerRadiusPlusZ() const;
103  inline G4double GetOuterRadiusPlusZ() const;
104  inline G4double GetZHalfLength() const;
105  inline G4double GetStartPhiAngle() const;
106  inline G4double GetDeltaPhiAngle() const;
107 
108  // Modifiers
109 
110  inline void SetInnerRadiusMinusZ (G4double Rmin1 );
111  inline void SetOuterRadiusMinusZ (G4double Rmax1 );
112  inline void SetInnerRadiusPlusZ (G4double Rmin2 );
113  inline void SetOuterRadiusPlusZ (G4double Rmax2 );
114  inline void SetZHalfLength (G4double newDz );
115  inline void SetStartPhiAngle (G4double newSPhi, G4bool trig=true);
116  inline void SetDeltaPhiAngle (G4double newDPhi);
117 
118  // Other methods for solid
119 
120  inline G4double GetCubicVolume();
121  inline G4double GetSurfaceArea();
122 
124  const G4int n,
125  const G4VPhysicalVolume* pRep );
126 
127  G4bool CalculateExtent( const EAxis pAxis,
128  const G4VoxelLimits& pVoxelLimit,
129  const G4AffineTransform& pTransform,
130  G4double& pmin, G4double& pmax ) const;
131 
132  EInside Inside( const G4ThreeVector& p ) const;
133 
134  G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const;
135 
137  const G4ThreeVector& v) const;
138  G4double DistanceToIn (const G4ThreeVector& p) const;
140  const G4ThreeVector& v,
141  const G4bool calcNorm=G4bool(false),
142  G4bool *validNorm=0,
143  G4ThreeVector *n=0) const;
144  G4double DistanceToOut(const G4ThreeVector& p) const;
145 
147 
149 
150  G4VSolid* Clone() const;
151 
152  std::ostream& StreamInfo(std::ostream& os) const;
153 
154  // Visualisation functions
155 
156  void DescribeYourselfTo( G4VGraphicsScene& scene ) const;
158 
159  public: // without description
160 
161  G4Cons(__void__&);
162  //
163  // Fake default constructor for usage restricted to direct object
164  // persistency for clients requiring preallocation of memory for
165  // persistifiable objects.
166 
167  G4Cons(const G4Cons& rhs);
168  G4Cons& operator=(const G4Cons& rhs);
169  // Copy constructor and assignment operator.
170 
171  // Old access functions
172 
173  inline G4double GetRmin1() const;
174  inline G4double GetRmax1() const;
175  inline G4double GetRmin2() const;
176  inline G4double GetRmax2() const;
177  inline G4double GetDz() const;
178  inline G4double GetSPhi() const;
179  inline G4double GetDPhi() const;
180 
181  private:
182 
184  CreateRotatedVertices(const G4AffineTransform& pTransform) const;
185 
186  inline void Initialize();
187  //
188  // Reset relevant values to zero
189 
190  inline void CheckSPhiAngle(G4double sPhi);
191  inline void CheckDPhiAngle(G4double dPhi);
192  inline void CheckPhiAngles(G4double sPhi, G4double dPhi);
193  //
194  // Reset relevant flags and angle values
195 
196  inline void InitializeTrigonometry();
197  //
198  // Recompute relevant trigonometric values and cache them
199 
200  G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
201  //
202  // Algorithm for SurfaceNormal() following the original
203  // specification for points not on the surface
204 
205  private:
206 
207  // Used by distanceToOut
208  //
209  enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
210 
211  // used by normal
212  //
213  enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
214 
215  G4double kRadTolerance, kAngTolerance;
216  //
217  // Radial and angular tolerances
218 
219  G4double fRmin1, fRmin2, fRmax1, fRmax2, fDz, fSPhi, fDPhi;
220  //
221  // Radial and angular dimensions
222 
223  G4double sinCPhi, cosCPhi, cosHDPhiOT, cosHDPhiIT,
224  sinSPhi, cosSPhi, sinEPhi, cosEPhi;
225  //
226  // Cached trigonometric values
227 
228  G4bool fPhiFullCone;
229  //
230  // Flag for identification of section or full cone
231 
232  G4double halfCarTolerance, halfRadTolerance, halfAngTolerance;
233  //
234  // Cached half tolerance values
235 };
236 
237 #include "G4Cons.icc"
238 
239 #endif
240 
241 #endif
G4Cons(const G4String &pName, G4double pRmin1, G4double pRmax1, G4double pRmin2, G4double pRmax2, G4double pDz, G4double pSPhi, G4double pDPhi)
Definition: G4Cons.cc:79
void SetZHalfLength(G4double newDz)
void SetInnerRadiusMinusZ(G4double Rmin1)
G4double GetDz() const
G4Cons & operator=(const G4Cons &rhs)
Definition: G4Cons.cc:170
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4Cons.cc:718
EInside Inside(const G4ThreeVector &p) const
Definition: G4Cons.cc:203
const char * p
Definition: xmltok.h:285
G4double GetRmin2() const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
Definition: G4Cons.cc:1450
void SetOuterRadiusPlusZ(G4double Rmax2)
std::ostream & StreamInfo(std::ostream &os) const
Definition: G4Cons.cc:2263
G4double GetOuterRadiusMinusZ() const
int G4int
Definition: G4Types.hh:78
G4GeometryType GetEntityType() const
Definition: G4Cons.cc:2245
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4Cons.cc:258
G4double GetSPhi() const
Char_t n[5]
void SetDeltaPhiAngle(G4double newDPhi)
bool G4bool
Definition: G4Types.hh:79
Definition: G4Cons.hh:82
std::vector< G4ThreeVector > G4ThreeVectorList
Definition: G4VSolid.hh:79
G4double GetStartPhiAngle() const
G4double GetInnerRadiusPlusZ() const
tuple v
Definition: test.py:18
G4double GetCubicVolume()
~G4Cons()
Definition: G4Cons.cc:144
EInside
Definition: geomdefs.hh:58
G4double GetRmin1() const
G4double GetSurfaceArea()
EAxis
Definition: geomdefs.hh:54
G4Polyhedron * CreatePolyhedron() const
Definition: G4Cons.cc:2382
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Definition: G4Cons.cc:2377
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
Definition: G4Cons.cc:270
G4double GetDPhi() const
void SetOuterRadiusMinusZ(G4double Rmax1)
void SetStartPhiAngle(G4double newSPhi, G4bool trig=true)
G4ThreeVector GetPointOnSurface() const
Definition: G4Cons.cc:2290
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Definition: G4Cons.cc:488
double G4double
Definition: G4Types.hh:76
G4double GetInnerRadiusMinusZ() const
G4VSolid * Clone() const
Definition: G4Cons.cc:2254
void SetInnerRadiusPlusZ(G4double Rmin2)
G4double GetOuterRadiusPlusZ() const
G4double GetRmax2() const
G4double GetZHalfLength() const
G4double GetDeltaPhiAngle() const
G4double GetRmax1() const