Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:11

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4EllipticalTube
0027 //
0028 // Class description:
0029 //
0030 //   Declaration of a CSG volume representing a tube with elliptical
0031 //   cross section (geant3 solid 'ELTU'):
0032 //
0033 //   G4EllipticalTube( const G4String& name,
0034 //                           G4double  Dx,
0035 //                           G4double  Dy,
0036 //                           G4double  Dz )
0037 //
0038 //   The equation of the lateral surface : (x/dx)^2 + (y/dy)^2 = 1
0039 
0040 // Author: David C. Williams (davidw@scipp.ucsc.edu)
0041 // Revision: Evgueni Tcherniaev (evgueni.tcherniaev@cern.ch), 23.12.2019
0042 // --------------------------------------------------------------------
0043 #ifndef G4ELLIPTICALTUBE_HH
0044 #define G4ELLIPTICALTUBE_HH
0045 
0046 #include "G4GeomTypes.hh"
0047 
0048 #if defined(G4GEOM_USE_USOLIDS)
0049 #define G4GEOM_USE_UELLIPTICALTUBE 1
0050 #endif
0051 
0052 #if (defined(G4GEOM_USE_UELLIPTICALTUBE) && defined(G4GEOM_USE_SYS_USOLIDS))
0053   #define G4UEllipticalTube G4EllipticalTube
0054   #include "G4UEllipticalTube.hh"
0055 #else
0056 
0057 #include "G4VSolid.hh"
0058 #include "G4Polyhedron.hh"
0059 
0060 class G4EllipticalTube : public G4VSolid
0061 {
0062   public:
0063 
0064     G4EllipticalTube( const G4String& name,
0065                             G4double Dx,
0066                             G4double Dy,
0067                             G4double Dz );
0068 
0069     ~G4EllipticalTube() override;
0070 
0071     // Standard methods
0072     //
0073     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0074 
0075     G4bool CalculateExtent(const EAxis pAxis,
0076                            const G4VoxelLimits& pVoxelLimit,
0077                            const G4AffineTransform& pTransform,
0078                                  G4double& pmin, G4double& pmax) const override;
0079 
0080     EInside Inside( const G4ThreeVector& p ) const override;
0081 
0082     G4ThreeVector SurfaceNormal( const G4ThreeVector& p ) const override;
0083 
0084     G4double DistanceToIn( const G4ThreeVector& p,
0085                            const G4ThreeVector& v ) const override;
0086 
0087     G4double DistanceToIn( const G4ThreeVector& p ) const override;
0088 
0089     G4double DistanceToOut( const G4ThreeVector& p,
0090                             const G4ThreeVector& v,
0091                             const G4bool calcNorm = false,
0092                                   G4bool* validNorm = nullptr,
0093                                   G4ThreeVector* n = nullptr ) const override;
0094 
0095     G4double DistanceToOut( const G4ThreeVector& p ) const override;
0096 
0097     G4GeometryType GetEntityType() const override;
0098 
0099     G4VSolid* Clone() const override;
0100 
0101     std::ostream& StreamInfo(std::ostream& os) const override;
0102 
0103     G4double GetCubicVolume() override;
0104     G4double GetSurfaceArea() override;
0105 
0106     G4ThreeVector GetPointOnSurface() const override;
0107 
0108     // Visualisation methods
0109     //
0110     G4Polyhedron* CreatePolyhedron() const override;
0111     G4Polyhedron* GetPolyhedron () const override;
0112     void DescribeYourselfTo( G4VGraphicsScene& scene ) const override;
0113     G4VisExtent GetExtent() const override;
0114 
0115     // Accessors
0116     //
0117     inline G4double GetDx() const;
0118     inline G4double GetDy() const;
0119     inline G4double GetDz() const;
0120   
0121     inline void SetDx( G4double Dx );
0122     inline void SetDy( G4double Dy );
0123     inline void SetDz( G4double Dz );
0124  
0125     G4EllipticalTube(__void__&);
0126       // Fake default constructor for usage restricted to direct object
0127       // persistency for clients requiring preallocation of memory for
0128       // persistifiable objects
0129 
0130     G4EllipticalTube(const G4EllipticalTube& rhs);
0131     G4EllipticalTube& operator=(const G4EllipticalTube& rhs);
0132       // Copy constructor and assignment operator
0133 
0134   private:
0135 
0136     void CheckParameters();
0137       // Check parameters and set pre-calculated values
0138 
0139     G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
0140       // Algorithm for SurfaceNormal() following the original
0141       // specification for points not on the surface
0142 
0143     G4double GetCachedSurfaceArea() const;
0144       // Calculate surface area and cache it
0145 
0146   private:
0147 
0148     G4double halfTolerance;
0149 
0150     G4double fDx; // semi-axis in X
0151     G4double fDy; // semi-axis in Y
0152     G4double fDz; // half length in Z
0153 
0154     G4double fCubicVolume = 0.0; // volume
0155     G4double fSurfaceArea = 0.0; // surface area  
0156 
0157     // Cached pre-calculated values
0158     G4double fRsph;    // R of bounding sphere
0159     G4double fDDx;     // Dx squared
0160     G4double fDDy;     // Dy squared
0161     G4double fSx;      // X scale factor
0162     G4double fSy;      // Y scale factor
0163     G4double fR;       // resulting Radius, after scaling elipse to circle
0164     G4double fQ1;      // distance approximation : dist = Q1*(x^2 + y^2) - Q2
0165     G4double fQ2;      // distance approximation : dist = Q1*(x^2 + y^2) - Q2
0166     G4double fScratch; // half length of scratching segment squared
0167 
0168     mutable G4bool fRebuildPolyhedron = false;
0169     mutable G4Polyhedron* fpPolyhedron = nullptr;
0170 };
0171 
0172 #include "G4EllipticalTube.icc"
0173 
0174 #endif  // defined(G4GEOM_USE_UELLIPTICALTUBE) && defined(G4GEOM_USE_SYS_USOLIDS)
0175 
0176 #endif // G4ELLIPTICALTUBE_HH