Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:01

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 and of QinetiQ Ltd,   *
0020 // * subject to DEFCON 705 IPR conditions.                            *
0021 // * By using,  copying,  modifying or  distributing the software (or *
0022 // * any work based  on the software)  you  agree  to acknowledge its *
0023 // * use  in  resulting  scientific  publications,  and indicate your *
0024 // * acceptance of all terms of the Geant4 Software license.          *
0025 // ********************************************************************
0026 //
0027 // G4QuadrangularFacet
0028 //
0029 // Class description:
0030 //
0031 //   The G4QuadrangularFacet class is used for the contruction of
0032 //   G4TessellatedSolid.
0033 //   It is defined by four fVertices, which shall be in the same plane and be
0034 //   supplied in anti-clockwise order looking from the outsider of the solid
0035 //   where it belongs. Its constructor
0036 //   
0037 //     G4QuadrangularFacet (const G4ThreeVector& Pt0, const G4ThreeVector& vt1,
0038 //                          const G4ThreeVector& vt2, const G4ThreeVector& vt3,
0039 //                          G4FacetVertexType);
0040 //
0041 //   takes 5 parameters to define the four fVertices:
0042 //     1) G4FacetvertexType = "ABSOLUTE": in this case Pt0, vt1, vt2 and vt3
0043 //        are the four fVertices required in anti-clockwise order when looking
0044 //        from the outsider.
0045 //     2) G4FacetvertexType = "RELATIVE": in this case the first vertex is Pt0,
0046 //        the second vertex is Pt0+vt, the third vertex is Pt0+vt2 and 
0047 //        the fourth vertex is Pt0+vt3, in anti-clockwise order when looking 
0048 //        from the outsider.
0049 
0050 // 31 October 2004, P R Truscott, QinetiQ Ltd, UK - Created.
0051 // 12 October 2012, M Gayer, CERN, - Reviewed optimized implementation.
0052 // --------------------------------------------------------------------
0053 #ifndef G4QUADRANGULARFACET_HH
0054 #define G4QUADRANGULARFACET_HH
0055 
0056 #include "G4VFacet.hh"
0057 #include "G4Types.hh"
0058 #include "G4ThreeVector.hh"
0059 #include "G4TriangularFacet.hh"
0060 
0061 class G4QuadrangularFacet : public G4VFacet
0062 {
0063   public:
0064 
0065     G4QuadrangularFacet (const G4ThreeVector& Pt0, const G4ThreeVector& vt1,
0066                          const G4ThreeVector& vt2, const G4ThreeVector& vt3,
0067                                G4FacetVertexType);
0068     G4QuadrangularFacet (const G4QuadrangularFacet& right);
0069    ~G4QuadrangularFacet () override;
0070 
0071     G4QuadrangularFacet& operator=(const G4QuadrangularFacet& right);    
0072 
0073     G4VFacet* GetClone () override;
0074 
0075     G4ThreeVector Distance (const G4ThreeVector& p);
0076     G4double Distance (const G4ThreeVector& p, G4double minDist) override;
0077     G4double Distance (const G4ThreeVector& p, G4double minDist,
0078                        const G4bool outgoing) override;
0079     G4double Extent   (const G4ThreeVector axis) override;
0080     G4bool Intersect  (const G4ThreeVector& p, const G4ThreeVector& v,
0081                        const G4bool outgoing, G4double& distance,
0082                              G4double& distFromSurface,
0083                              G4ThreeVector& normal) override;
0084     G4ThreeVector GetSurfaceNormal () const override;
0085 
0086     G4double GetArea () const override;
0087     G4ThreeVector GetPointOnFace () const override;
0088 
0089     G4GeometryType GetEntityType () const override;
0090 
0091     inline G4bool IsDefined () const override;
0092     inline G4int GetNumberOfVertices () const override;
0093     inline G4ThreeVector GetVertex (G4int i) const override;
0094     inline void SetVertex (G4int i, const G4ThreeVector& val) override;
0095     inline void SetVertices(std::vector<G4ThreeVector>* v) override;
0096 
0097     inline G4double GetRadius () const override;
0098     inline G4ThreeVector GetCircumcentre () const override;
0099 
0100   private:
0101 
0102     inline G4int GetVertexIndex (G4int i) const override;
0103     inline void SetVertexIndex (G4int i, G4int val) override;
0104 
0105     inline G4int AllocatedMemory() override;
0106 
0107   private:
0108 
0109     G4double fRadius = 0.0;
0110 
0111     G4ThreeVector fCircumcentre;
0112 
0113     G4TriangularFacet fFacet1, fFacet2;
0114 };
0115 
0116 // --------------------------------------------------------------------
0117 // Inlined Methods
0118 // --------------------------------------------------------------------
0119 
0120 inline G4int G4QuadrangularFacet::GetNumberOfVertices () const
0121 {
0122   return 4;
0123 }
0124 
0125 inline G4ThreeVector G4QuadrangularFacet::GetVertex (G4int i) const
0126 {
0127   return i == 3 ? fFacet2.GetVertex(2) : fFacet1.GetVertex(i);
0128 }
0129 
0130 
0131 inline G4double G4QuadrangularFacet::GetRadius () const
0132 {
0133   return fRadius;
0134 }
0135 
0136 inline G4ThreeVector G4QuadrangularFacet::GetCircumcentre () const
0137 {
0138   return fCircumcentre;
0139 }
0140 
0141 inline void G4QuadrangularFacet::SetVertex (G4int i, const G4ThreeVector &val)
0142 {
0143   switch (i)
0144   {
0145     case 0:
0146       fFacet1.SetVertex(0, val);
0147       fFacet2.SetVertex(0, val);
0148       break;
0149     case 1:
0150       fFacet1.SetVertex(1, val);
0151       break;
0152     case 2:
0153       fFacet1.SetVertex(2, val);
0154       fFacet2.SetVertex(1, val);
0155       break;
0156     case 3:
0157       fFacet2.SetVertex(2, val);
0158       break;
0159     }
0160 }
0161 
0162 inline void G4QuadrangularFacet::SetVertices(std::vector<G4ThreeVector>* v)
0163 {
0164   fFacet1.SetVertices(v);
0165   fFacet2.SetVertices(v);
0166 }
0167 
0168 inline G4bool G4QuadrangularFacet::IsDefined () const
0169 {
0170   return fFacet1.IsDefined();
0171 }
0172 
0173 inline G4int G4QuadrangularFacet::GetVertexIndex (G4int i) const
0174 {
0175   return i == 3 ? fFacet2.GetVertexIndex(2) : fFacet1.GetVertexIndex(i);
0176 }
0177 
0178 
0179 inline void G4QuadrangularFacet::SetVertexIndex (G4int i, G4int val)
0180 {
0181   switch (i)
0182   {
0183     case 0:
0184       fFacet1.SetVertexIndex(0, val);
0185       fFacet2.SetVertexIndex(0, val);
0186       break;
0187     case 1:
0188       fFacet1.SetVertexIndex(1, val);
0189       break;
0190     case 2:
0191       fFacet1.SetVertexIndex(2, val);
0192       fFacet2.SetVertexIndex(1, val);
0193       break;
0194     case 3:
0195       fFacet2.SetVertexIndex(2, val);
0196       break;
0197   }
0198 }
0199 
0200 inline G4int G4QuadrangularFacet::AllocatedMemory()
0201 {
0202   return sizeof(*this) + fFacet1.AllocatedMemory() + fFacet2.AllocatedMemory();
0203 }
0204 
0205 #endif