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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 // G4EllipticalTube
 27 //
 28 // Class description:
 29 //
 30 //   Declaration of a CSG volume representing a tube with elliptical
 31 //   cross section (geant3 solid 'ELTU'):
 32 //
 33 //   G4EllipticalTube( const G4String& name,
 34 //                           G4double  Dx,
 35 //                           G4double  Dy,
 36 //                           G4double  Dz )
 37 //
 38 //   The equation of the lateral surface : (x/dx)^2 + (y/dy)^2 = 1
 39 
 40 // Author: David C. Williams (davidw@scipp.ucsc.edu)
 41 // Revision: Evgueni Tcherniaev (evgueni.tcherniaev@cern.ch), 23.12.2019
 42 // --------------------------------------------------------------------
 43 #ifndef G4ELLIPTICALTUBE_HH
 44 #define G4ELLIPTICALTUBE_HH
 45 
 46 #include "G4GeomTypes.hh"
 47 
 48 #if defined(G4GEOM_USE_USOLIDS)
 49 #define G4GEOM_USE_UELLIPTICALTUBE 1
 50 #endif
 51 
 52 #if (defined(G4GEOM_USE_UELLIPTICALTUBE) && defined(G4GEOM_USE_SYS_USOLIDS))
 53   #define G4UEllipticalTube G4EllipticalTube
 54   #include "G4UEllipticalTube.hh"
 55 #else
 56 
 57 #include "G4VSolid.hh"
 58 #include "G4Polyhedron.hh"
 59 
 60 class G4EllipticalTube : public G4VSolid
 61 {
 62   public:
 63 
 64     G4EllipticalTube( const G4String& name,
 65                             G4double Dx,
 66                             G4double Dy,
 67                             G4double Dz );
 68 
 69     ~G4EllipticalTube() override;
 70 
 71     // Standard methods
 72     //
 73     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
 74 
 75     G4bool CalculateExtent(const EAxis pAxis,
 76                            const G4VoxelLimits& pVoxelLimit,
 77                            const G4AffineTransform& pTransform,
 78                                  G4double& pmin, G4double& pmax) const override;
 79 
 80     EInside Inside( const G4ThreeVector& p ) const override;
 81 
 82     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
 83 
 84     G4double DistanceToIn( const G4ThreeVector& p,
 85                            const G4ThreeVector& v ) const override;
 86 
 87     G4double DistanceToIn( const G4ThreeVector& p ) const override;
 88 
 89     G4double DistanceToOut( const G4ThreeVector& p,
 90                             const G4ThreeVector& v,
 91                             const G4bool calcNorm = false,
 92                                   G4bool* validNorm = nullptr,
 93                                   G4ThreeVector* n = nullptr ) const override;
 94 
 95     G4double DistanceToOut( const G4ThreeVector& p ) const override;
 96 
 97     G4GeometryType GetEntityType() const override;
 98 
 99     G4VSolid* Clone() const override;
100 
101     std::ostream& StreamInfo(std::ostream& os) const override;
102 
103     G4double GetCubicVolume() override;
104     G4double GetSurfaceArea() override;
105 
106     G4ThreeVector GetPointOnSurface() const override;
107 
108     // Visualisation methods
109     //
110     G4Polyhedron* CreatePolyhedron() const override;
111     G4Polyhedron* GetPolyhedron () const override;
112     void DescribeYourselfTo( G4VGraphicsScene& scene ) const override;
113     G4VisExtent GetExtent() const override;
114 
115     // Accessors
116     //
117     inline G4double GetDx() const;
118     inline G4double GetDy() const;
119     inline G4double GetDz() const;
120   
121     inline void SetDx( G4double Dx );
122     inline void SetDy( G4double Dy );
123     inline void SetDz( G4double Dz );
124  
125     G4EllipticalTube(__void__&);
126       // Fake default constructor for usage restricted to direct object
127       // persistency for clients requiring preallocation of memory for
128       // persistifiable objects
129 
130     G4EllipticalTube(const G4EllipticalTube& rhs);
131     G4EllipticalTube& operator=(const G4EllipticalTube& rhs);
132       // Copy constructor and assignment operator
133 
134   private:
135 
136     void CheckParameters();
137       // Check parameters and set pre-calculated values
138 
139     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
140       // Algorithm for SurfaceNormal() following the original
141       // specification for points not on the surface
142 
143     G4double GetCachedSurfaceArea() const;
144       // Calculate surface area and cache it
145 
146   private:
147 
148     G4double halfTolerance;
149 
150     G4double fDx; // semi-axis in X
151     G4double fDy; // semi-axis in Y
152     G4double fDz; // half length in Z
153 
154     G4double fCubicVolume = 0.0; // volume
155     G4double fSurfaceArea = 0.0; // surface area  
156 
157     // Cached pre-calculated values
158     G4double fRsph;    // R of bounding sphere
159     G4double fDDx;     // Dx squared
160     G4double fDDy;     // Dy squared
161     G4double fSx;      // X scale factor
162     G4double fSy;      // Y scale factor
163     G4double fR;       // resulting Radius, after scaling elipse to circle
164     G4double fQ1;      // distance approximation : dist = Q1*(x^2 + y^2) - Q2
165     G4double fQ2;      // distance approximation : dist = Q1*(x^2 + y^2) - Q2
166     G4double fScratch; // half length of scratching segment squared
167 
168     mutable G4bool fRebuildPolyhedron = false;
169     mutable G4Polyhedron* fpPolyhedron = nullptr;
170 };
171 
172 #include "G4EllipticalTube.icc"
173 
174 #endif  // defined(G4GEOM_USE_UELLIPTICALTUBE) && defined(G4GEOM_USE_SYS_USOLIDS)
175 
176 #endif // G4ELLIPTICALTUBE_HH
177