Geant4-11
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 (Oliver.Link@cern.ch)
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,
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
157
161
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
172 G4double fTAlph ; // std::tan(fAlph)
173
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:
194 {
196 }
198 LastState(const LastState& r) : p(r.p), inside(r.inside){}
200 {
201 if (this == &r) { return *this; }
202 p = r.p; inside = r.inside;
203 return *this;
204 }
205 public:
208 };
209
210 class LastVector // last SurfaceNormal result
211 {
212 public:
214 {
217 surface = new G4VTwistSurface*[1];
218 }
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 }
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:
240 };
241
242 class LastValue // last G4double value
243 {
244 public:
246 {
248 value = DBL_MAX;
249 }
251 LastValue(const LastValue& r) : p(r.p), value(r.value){}
253 {
254 if (this == &r) { return *this; }
255 p = r.p; value = r.value;
256 return *this;
257 }
258 public:
261 };
262
263 class LastValueWithDoubleVector // last G4double value
264 {
265 public:
267 {
270 value = DBL_MAX;
271 }
274 : p(r.p), vec(r.vec), value(r.value){}
276 {
277 if (this == &r) { return *this; }
278 p = r.p; vec = r.vec; value = r.value;
279 return *this;
280 }
281 public:
285 };
286
293 };
294
295//=====================================================================
296
297inline
299{
300 if(fCubicVolume == 0.)
301 {
302 fCubicVolume = ((fDx1 + fDx2 + fDx3 + fDx4)*(fDy1 + fDy2) +
303 (fDx4 + fDx3 - fDx2 - fDx1)*(fDy2 - fDy1)/3)*fDz;
304 }
305 return fCubicVolume;
306}
307
308inline
310{
311 if(fSurfaceArea != 0.) ;
313 return fSurfaceArea;
314}
315
316inline
318{
319 return ( fDx4 + fDx2 + ( fDx4 - fDx2 ) * ( 2 * phi ) / fPhiTwist ) ;
320}
321
322inline
324{
325 return ( fDx3 + fDx1 + ( fDx3 - fDx1 ) * ( 2 * phi ) / fPhiTwist ) ;
326}
327
328inline
330{
331 return ( fDy2 + fDy1 + ( fDy2 - fDy1 ) * ( 2 * phi ) / fPhiTwist ) ;
332}
333
334inline
336{
337 return GetValueA(phi)/2. + (GetValueD(phi)-GetValueA(phi))/4.
338 - u*( ( GetValueD(phi)-GetValueA(phi) ) / ( 2 * GetValueB(phi) ) - ftg );
339}
340
341#endif
static const G4double pMax
static const G4double pMin
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:250
LastState & operator=(const LastState &r)
LastValueWithDoubleVector & operator=(const LastValueWithDoubleVector &r)
LastValueWithDoubleVector(const LastValueWithDoubleVector &r)
LastValue & operator=(const LastValue &r)
LastVector & operator=(const LastVector &r)
G4VTwistSurface * fSide180
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
G4VTwistSurface * fSide0
G4ThreeVector GetPointOnSurface() const
virtual G4GeometryType GetEntityType() const
G4double GetDx3() const
G4double GetTwistAngle() const
G4VTwistSurface * fSide90
G4ThreeVector GetPointInSolid(G4double z) const
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4VTwistSurface * fLowerEndcap
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
G4VTwistSurface * fSide270
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
G4VTwistSurface * fUpperEndcap
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
G4double GetDx2() const
LastValueWithDoubleVector fLastDistanceToOutWithV
virtual void DescribeYourselfTo(G4VGraphicsScene &scene) const
LastValueWithDoubleVector fLastDistanceToInWithV
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
static const G4double kInfinity
Definition: geomdefs.hh:41
string pname
Definition: eplot.py:33
#define DBL_MAX
Definition: templates.hh:62