ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VTwistedFaceted.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VTwistedFaceted.hh
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"
39 #include "G4TwistTrapAlphaSide.hh"
41 #include "G4TwistBoxSide.hh"
42 #include "G4TwistTrapFlatSide.hh"
43 
44 class G4SolidExtentList;
45 class G4ClippablePolygon;
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 
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 
297 inline
299 {
300  if(fCubicVolume != 0.) ;
301  else fCubicVolume = 2 * fDz
302  * ( ( fDx1 + fDx2 ) * fDy1 + ( fDx3 + fDx4 ) * fDy2 );
303  return fCubicVolume;
304 }
305 
306 inline
308 {
309  if(fSurfaceArea != 0.) ;
311  return fSurfaceArea;
312 }
313 
314 inline
316 {
317  return ( fDx4 + fDx2 + ( fDx4 - fDx2 ) * ( 2 * phi ) / fPhiTwist ) ;
318 }
319 
320 inline
322 {
323  return ( fDx3 + fDx1 + ( fDx3 - fDx1 ) * ( 2 * phi ) / fPhiTwist ) ;
324 }
325 
326 inline
328 {
329  return ( fDy2 + fDy1 + ( fDy2 - fDy1 ) * ( 2 * phi ) / fPhiTwist ) ;
330 }
331 
332 inline
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