Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VTwistedFaceted.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// G4VTwistedFaceted
27//
28// Class description:
29//
30// G4VTwistedFaceted is an abstract base class for twisted boxoids:
31// G4TwistedTrd, G4TwistedTrap and G4TwistedBox
32
33// Author: 27-Oct-2004 - O.Link ([email protected])
34// --------------------------------------------------------------------
35#ifndef G4VTWISTEDFACETED_HH
36#define G4VTWISTEDFACETED_HH
37
38#include "G4VSolid.hh"
41#include "G4TwistBoxSide.hh"
42#include "G4TwistTrapFlatSide.hh"
43
46
48{
49 public: // with description
50
51 G4VTwistedFaceted(const G4String& pname, // Name of instance
52 G4double PhiTwist, // twist angle
53 G4double pDz, // half z lenght
54 G4double pTheta, // direction between end planes
55 G4double pPhi, // defined by polar & azim. angles
56 G4double pDy1, // half y length at -pDz
57 G4double pDx1, // half x length at -pDz,-pDy
58 G4double pDx2, // half x length at -pDz,+pDy
59 G4double pDy2, // half y length at +pDz
60 G4double pDx3, // half x length at +pDz,-pDy
61 G4double pDx4, // half x length at +pDz,+pDy
62 G4double pAlph // tilt angle at +pDz
63 );
64
65 virtual ~G4VTwistedFaceted();
66
68 const G4int,
69 const G4VPhysicalVolume* );
70
71 virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const;
72
73 virtual G4bool CalculateExtent(const EAxis pAxis,
74 const G4VoxelLimits& pVoxelLimit,
75 const G4AffineTransform& pTransform,
76 G4double& pMin,
77 G4double& pMax ) const;
78
79 virtual G4double DistanceToIn (const G4ThreeVector& p,
80 const G4ThreeVector& v ) const;
81
82 virtual G4double DistanceToIn (const G4ThreeVector& p ) const;
83
84 virtual G4double DistanceToOut(const G4ThreeVector& p,
85 const G4ThreeVector& v,
86 const G4bool calcnorm = false,
87 G4bool* validnorm = nullptr,
88 G4ThreeVector* n = nullptr ) const;
89
90 virtual G4double DistanceToOut(const G4ThreeVector& p) const;
91
92 virtual EInside Inside (const G4ThreeVector& p) const;
93
94 virtual G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
95
98
99 virtual inline G4double GetCubicVolume();
100 virtual inline G4double GetSurfaceArea();
101
102 virtual void DescribeYourselfTo (G4VGraphicsScene& scene) const;
103 virtual G4Polyhedron* CreatePolyhedron () const;
104 virtual G4Polyhedron* GetPolyhedron () const;
105
106 virtual std::ostream &StreamInfo(std::ostream& os) const;
107
108 // accessors
109
110 inline G4double GetTwistAngle() const { return fPhiTwist; }
111
112 inline G4double GetDx1 () const { return fDx1 ; }
113 inline G4double GetDx2 () const { return fDx2 ; }
114 inline G4double GetDx3 () const { return fDx3 ; }
115 inline G4double GetDx4 () const { return fDx4 ; }
116 inline G4double GetDy1 () const { return fDy1 ; }
117 inline G4double GetDy2 () const { return fDy2 ; }
118 inline G4double GetDz () const { return fDz ; }
119 inline G4double GetPhi () const { return fPhi ; }
120 inline G4double GetTheta () const { return fTheta ; }
121 inline G4double GetAlpha () const { return fAlph ; }
122
123 inline G4double Xcoef(G4double u, G4double phi, G4double ftg) const;
124 // For calculating the w(u) function
125
126 inline G4double GetValueA(G4double phi) const;
127 inline G4double GetValueB(G4double phi) const;
128 inline G4double GetValueD(G4double phi) const;
129
130 virtual G4VisExtent GetExtent () const;
131 virtual G4GeometryType GetEntityType() const;
132
133 public: // without description
134
135 G4VTwistedFaceted(__void__&);
136 // Fake default constructor for usage restricted to direct object
137 // persistency for clients requiring preallocation of memory for
138 // persistifiable objects.
139
142 // Copy constructor and assignment operator.
143
144 protected: // with description
145
146 mutable G4bool fRebuildPolyhedron = false;
147 mutable G4Polyhedron* fpPolyhedron = nullptr; // polyhedron for vis
148
149 private:
150
151 void CreateSurfaces();
152
153 private:
154
155 G4double fTheta;
156 G4double fPhi ;
157
158 G4double fDy1;
159 G4double fDx1;
160 G4double fDx2;
161
162 G4double fDy2;
163 G4double fDx3;
164 G4double fDx4;
165
166 G4double fDz; // Half-length along the z axis
167
168 G4double fDx ; // maximum side in x
169 G4double fDy ; // maximum side in y
170
171 G4double fAlph ;
172 G4double fTAlph ; // std::tan(fAlph)
173
174 G4double fdeltaX ;
175 G4double fdeltaY ;
176
177 G4double fPhiTwist; // twist angle ( dphi in surface equation)
178
179 G4VTwistSurface* fLowerEndcap ; // surface of -ve z
180 G4VTwistSurface* fUpperEndcap ; // surface of +ve z
181
182 G4VTwistSurface* fSide0 ; // Twisted Side at phi = 0 deg
183 G4VTwistSurface* fSide90 ; // Twisted Side at phi = 90 deg
184 G4VTwistSurface* fSide180 ; // Twisted Side at phi = 180 deg
185 G4VTwistSurface* fSide270 ; // Twisted Side at phi = 270 deg
186
187 G4double fCubicVolume = 0.0; // volume of the solid
188 G4double fSurfaceArea = 0.0; // area of the solid
189
190 class LastState // last Inside result
191 {
192 public:
193 LastState()
194 {
195 p.set(kInfinity,kInfinity,kInfinity); inside = kOutside;
196 }
197 ~LastState(){}
198 LastState(const LastState& r) : p(r.p), inside(r.inside){}
199 LastState& operator=(const LastState& r)
200 {
201 if (this == &r) { return *this; }
202 p = r.p; inside = r.inside;
203 return *this;
204 }
205 public:
207 EInside inside;
208 };
209
210 class LastVector // last SurfaceNormal result
211 {
212 public:
213 LastVector()
214 {
215 p.set(kInfinity,kInfinity,kInfinity);
216 vec.set(kInfinity,kInfinity,kInfinity);
217 surface = new G4VTwistSurface*[1];
218 }
219 ~LastVector()
220 {
221 delete [] surface;
222 }
223 LastVector(const LastVector& r) : p(r.p), vec(r.vec)
224 {
225 surface = new G4VTwistSurface*[1];
226 surface[0] = r.surface[0];
227 }
228 LastVector& operator=(const LastVector& r)
229 {
230 if (&r == this) { return *this; }
231 p = r.p; vec = r.vec;
232 delete [] surface; surface = new G4VTwistSurface*[1];
233 surface[0] = r.surface[0];
234 return *this;
235 }
236 public:
238 G4ThreeVector vec;
239 G4VTwistSurface **surface;
240 };
241
242 class LastValue // last G4double value
243 {
244 public:
245 LastValue()
246 {
247 p.set(kInfinity,kInfinity,kInfinity);
248 value = DBL_MAX;
249 }
250 ~LastValue(){}
251 LastValue(const LastValue& r) : p(r.p), value(r.value){}
252 LastValue& operator=(const LastValue& r)
253 {
254 if (this == &r) { return *this; }
255 p = r.p; value = r.value;
256 return *this;
257 }
258 public:
260 G4double value;
261 };
262
263 class LastValueWithDoubleVector // last G4double value
264 {
265 public:
266 LastValueWithDoubleVector()
267 {
268 p.set(kInfinity,kInfinity,kInfinity);
269 vec.set(kInfinity,kInfinity,kInfinity);
270 value = DBL_MAX;
271 }
272 ~LastValueWithDoubleVector(){}
273 LastValueWithDoubleVector(const LastValueWithDoubleVector& r)
274 : p(r.p), vec(r.vec), value(r.value){}
275 LastValueWithDoubleVector& operator=(const LastValueWithDoubleVector& r)
276 {
277 if (this == &r) { return *this; }
278 p = r.p; vec = r.vec; value = r.value;
279 return *this;
280 }
281 public:
283 G4ThreeVector vec;
284 G4double value;
285 };
286
287 LastState fLastInside;
288 LastVector fLastNormal;
289 LastValue fLastDistanceToIn;
290 LastValue fLastDistanceToOut;
291 LastValueWithDoubleVector fLastDistanceToInWithV;
292 LastValueWithDoubleVector fLastDistanceToOutWithV;
293 };
294
295//=====================================================================
296
297inline
299{
300 if(fCubicVolume != 0.) ;
301 else fCubicVolume = 2 * fDz
302 * ( ( fDx1 + fDx2 ) * fDy1 + ( fDx3 + fDx4 ) * fDy2 );
303 return fCubicVolume;
304}
305
306inline
308{
309 if(fSurfaceArea != 0.) ;
310 else fSurfaceArea = G4VSolid::GetSurfaceArea();
311 return fSurfaceArea;
312}
313
314inline
316{
317 return ( fDx4 + fDx2 + ( fDx4 - fDx2 ) * ( 2 * phi ) / fPhiTwist ) ;
318}
319
320inline
322{
323 return ( fDx3 + fDx1 + ( fDx3 - fDx1 ) * ( 2 * phi ) / fPhiTwist ) ;
324}
325
326inline
328{
329 return ( fDy2 + fDy1 + ( fDy2 - fDy1 ) * ( 2 * phi ) / fPhiTwist ) ;
330}
331
332inline
334{
335 return GetValueA(phi)/2. + (GetValueD(phi)-GetValueA(phi))/4.
336 - u*( ( GetValueD(phi)-GetValueA(phi) ) / ( 2 * GetValueB(phi) ) - ftg );
337}
338
339#endif
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
void set(double x, double y, double z)
virtual G4double GetSurfaceArea()
Definition: G4VSolid.cc:238
G4double GetValueD(G4double phi) const
G4double GetDy1() const
virtual G4double GetCubicVolume()
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4double GetValueA(G4double phi) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double GetDy2() const
G4double GetTheta() const
G4VTwistedFaceted & operator=(const G4VTwistedFaceted &rhs)
G4Polyhedron * fpPolyhedron
G4double GetPhi() const
virtual G4Polyhedron * GetPolyhedron() const
G4ThreeVector GetPointOnSurface() const
virtual G4GeometryType GetEntityType() const
G4double GetDx3() const
G4double GetTwistAngle() const
G4ThreeVector GetPointInSolid(G4double z) const
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4double GetDx4() const
G4double GetAlpha() const
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcnorm=false, G4bool *validnorm=nullptr, G4ThreeVector *n=nullptr) const
virtual EInside Inside(const G4ThreeVector &p) const
virtual std::ostream & StreamInfo(std::ostream &os) const
virtual void ComputeDimensions(G4VPVParameterisation *, const G4int, const G4VPhysicalVolume *)
G4double GetDz() const
virtual G4VisExtent GetExtent() const
virtual G4Polyhedron * CreatePolyhedron() const
G4double GetDx1() const
G4double GetDx2() const
virtual void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4double GetValueB(G4double phi) const
G4double Xcoef(G4double u, G4double phi, G4double ftg) const
virtual G4double GetSurfaceArea()
EAxis
Definition: geomdefs.hh:54
EInside
Definition: geomdefs.hh:67
@ kOutside
Definition: geomdefs.hh:68
#define DBL_MAX
Definition: templates.hh:62