Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4Tet.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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  intellectual property  of the *
0019 // * Vanderbilt University Free Electron Laser Center                 *
0020 // * Vanderbilt University, Nashville, TN, USA                        *
0021 // * Development supported by:                                        *
0022 // * United States MFEL program  under grant FA9550-04-1-0045         *
0023 // * and NASA under contract number NNG04CT05P.                       *
0024 // * Written by Marcus H. Mendenhall and Robert A. Weller.            *
0025 // *                                                                  *
0026 // * Contributed to the Geant4 Core, January, 2005.                   *
0027 // *                                                                  *
0028 // ********************************************************************
0029 //
0030 // G4Tet
0031 //
0032 // Class description:
0033 //
0034 // A G4Tet is a tetrahedra solid.
0035 
0036 // 03.09.2004 - M.H.Mendenhall & R.A.Weller (Vanderbilt University, USA)
0037 // 08.01.2020 - E.Tcherniaev, complete revision, speed up
0038 // --------------------------------------------------------------------
0039 #ifndef G4TET_HH
0040 #define G4TET_HH
0041 
0042 #include "G4GeomTypes.hh"
0043 
0044 #if defined(G4GEOM_USE_USOLIDS)
0045 #define G4GEOM_USE_UTET 1
0046 #endif
0047 
0048 #if defined(G4GEOM_USE_UTET)
0049   #define G4UTet G4Tet
0050   #include "G4UTet.hh"
0051 #else
0052 
0053 #include "G4VSolid.hh"
0054 
0055 class G4Tet : public G4VSolid
0056 {
0057   public:
0058 
0059     G4Tet(const G4String& pName,
0060           const G4ThreeVector& anchor,
0061           const G4ThreeVector& p1,
0062           const G4ThreeVector& p2,
0063           const G4ThreeVector& p3,
0064                 G4bool* degeneracyFlag = nullptr);
0065 
0066     ~G4Tet() override;
0067 
0068     void SetVertices(const G4ThreeVector& anchor,
0069                      const G4ThreeVector& p1,
0070                      const G4ThreeVector& p2,
0071                      const G4ThreeVector& p3,
0072                      G4bool* degeneracyFlag = nullptr);
0073 
0074     // Accessors, return the four vertices of the shape
0075     void GetVertices(G4ThreeVector& anchor,
0076                      G4ThreeVector& p1,
0077                      G4ThreeVector& p2,
0078                      G4ThreeVector& p3) const;
0079     std::vector<G4ThreeVector> GetVertices() const;
0080 
0081     // Set warning flag - deprecated (dummy)
0082     inline void PrintWarnings(G4bool) {};
0083 
0084     // Return true if the tetrahedron is degenerate
0085     G4bool CheckDegeneracy(const G4ThreeVector& p0,
0086                            const G4ThreeVector& p1,
0087                            const G4ThreeVector& p2,
0088                            const G4ThreeVector& p3) const;
0089 
0090     // Standard methods
0091     void ComputeDimensions(G4VPVParameterisation* p,
0092                            const G4int n,
0093                            const G4VPhysicalVolume* pRep) override;
0094 
0095     void SetBoundingLimits(const G4ThreeVector& pMin, const G4ThreeVector& pMax);
0096     void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
0097     G4bool CalculateExtent(const EAxis pAxis,
0098                            const G4VoxelLimits& pVoxelLimit,
0099                            const G4AffineTransform& pTransform,
0100                                  G4double& pmin, G4double& pmax) const override;
0101 
0102     EInside Inside(const G4ThreeVector& p) const override;
0103     G4ThreeVector SurfaceNormal( const G4ThreeVector& p) const override;
0104     G4double DistanceToIn(const G4ThreeVector& p,
0105                           const G4ThreeVector& v) const override;
0106     G4double DistanceToIn(const G4ThreeVector& p) const override;
0107     G4double DistanceToOut(const G4ThreeVector& p,
0108                            const G4ThreeVector& v,
0109                            const G4bool calcNorm = false,
0110                                  G4bool* validNorm = nullptr,
0111                                  G4ThreeVector* n = nullptr) const override;
0112     G4double DistanceToOut(const G4ThreeVector& p) const override;
0113 
0114     G4GeometryType GetEntityType() const override;
0115 
0116     G4VSolid* Clone() const override;
0117 
0118     std::ostream& StreamInfo(std::ostream& os) const override;
0119 
0120     G4double GetCubicVolume() override;
0121     G4double GetSurfaceArea() override;
0122 
0123     G4ThreeVector GetPointOnSurface() const override;
0124 
0125     // Methods for visualization
0126     void DescribeYourselfTo (G4VGraphicsScene& scene) const override;
0127     G4VisExtent GetExtent () const override;
0128     G4Polyhedron* CreatePolyhedron () const override;
0129     G4Polyhedron* GetPolyhedron () const override;
0130 
0131     // Fake default constructor for usage restricted to direct object
0132     // persistency for clients requiring preallocation of memory for
0133     // persistifiable objects
0134     G4Tet(__void__&);
0135 
0136     // Copy constructor
0137     G4Tet(const G4Tet& rhs);
0138 
0139     // Assignment operator
0140     G4Tet& operator=(const G4Tet& rhs);
0141 
0142   private:
0143 
0144     // Set data members
0145     void Initialize(const G4ThreeVector& p0,
0146                     const G4ThreeVector& p1,
0147                     const G4ThreeVector& p2,
0148                     const G4ThreeVector& p3);
0149 
0150     // Return normal to surface closest to p
0151     G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
0152 
0153   private:
0154 
0155     G4double halfTolerance = 0;
0156     G4double fCubicVolume = 0; // Volume
0157     G4double fSurfaceArea = 0; // Surface area
0158     mutable G4bool fRebuildPolyhedron = false;
0159     mutable G4Polyhedron* fpPolyhedron = nullptr;
0160 
0161     G4ThreeVector fVertex[4];   // thetrahedron vertices
0162     G4ThreeVector fNormal[4];   // normals to faces
0163     G4double fDist[4] = {0};    // distances from origin to faces
0164     G4double fArea[4] = {0};    // face areas
0165     G4ThreeVector fBmin, fBmax; // bounding box
0166 };
0167 
0168 #endif
0169 
0170 #endif