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