Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-01 09:08:26

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 // G4VFacet
0028 //
0029 // Class description:
0030 //
0031 // Base class defining the facets which are components of a
0032 // G4TessellatedSolid shape.
0033 
0034 // Author: P.R.Truscott (QinetiQ Ltd, UK), 31.10.2004 - Created.
0035 //         M.Gayer (CERN), 12.10.2012 - Reviewed optimised implementation.
0036 // --------------------------------------------------------------------
0037 #ifndef G4VFACET_HH
0038 #define G4VFACET_HH
0039 
0040 #include <iostream>
0041 #include <vector>
0042 
0043 #include "globals.hh"
0044 #include "windefs.hh"
0045 #include "G4ThreeVector.hh"
0046 #include "G4VSolid.hh"
0047 
0048 enum G4FacetVertexType { ABSOLUTE, RELATIVE };
0049 
0050 /**
0051  * @brief G4VFacet is a base class defining the facets which are components
0052  * of a G4TessellatedSolid shape.
0053  */
0054 
0055 class G4VFacet
0056 {
0057   public:
0058 
0059     /**
0060      * Constructor and default Destructor.
0061      */
0062     G4VFacet();
0063     virtual ~G4VFacet() = default;
0064 
0065     /**
0066      * Equality operator.
0067      */
0068     G4bool operator== (const G4VFacet& right) const;
0069 
0070     /**
0071      * Returns the number of vertices of the facet.
0072      */
0073     virtual G4int GetNumberOfVertices () const = 0;
0074 
0075     /**
0076      * Returns the vertex based on the index 'i'.
0077      */
0078     virtual G4ThreeVector GetVertex (G4int i) const = 0;
0079 
0080     /**
0081      * Methods to set the vertices.
0082      */
0083     virtual void SetVertex (G4int i, const G4ThreeVector& val) = 0;
0084     virtual void SetVertices(std::vector<G4ThreeVector>* vertices) = 0;
0085 
0086     /**
0087      * Returns the type ID of the facet.
0088      */
0089     virtual G4GeometryType GetEntityType () const = 0;
0090 
0091     /**
0092      * Returns the normal vector to the facet.
0093      */
0094     virtual G4ThreeVector GetSurfaceNormal () const = 0;
0095 
0096     /**
0097      * Returns true if the facet is defined.
0098      */
0099     virtual G4bool IsDefined () const = 0;
0100 
0101     /**
0102      * Returns the circumcentre point of the facet.
0103      */
0104     virtual G4ThreeVector GetCircumcentre () const = 0;
0105 
0106     /**
0107      * Returns the radius to the anchor point and centered on the circumcentre.
0108      */
0109     virtual G4double GetRadius () const = 0;
0110 
0111     /**
0112      * Returns a pointer to a newly allocated duplicate copy of the facet.
0113      */
0114     virtual G4VFacet* GetClone () = 0;
0115 
0116     /**
0117      * Determines the closest distance between point p and the facet.
0118      */
0119     virtual G4double Distance (const G4ThreeVector&, G4double minDist) = 0;
0120 
0121     /**
0122      * Determines the distance to point 'p'. kInfinity is returned if either:
0123      * (1) outgoing is TRUE and the dot product of the normal vector to the
0124      * facet and the displacement vector from p to the triangle is negative.
0125      * (2) outgoing is FALSE and the dot product of the normal vector to the
0126      * facet and the displacement vector from p to the triangle is positive.
0127      */
0128     virtual G4double Distance (const G4ThreeVector&, G4double minDist,
0129                                const G4bool) = 0;
0130 
0131     /**
0132      * Calculates the furthest the triangle extends in fA particular
0133      * direction defined by the vector axis.
0134      */
0135     virtual G4double Extent (const G4ThreeVector axis) = 0;
0136 
0137     /**
0138      * Finds the next intersection when going from 'p' in the direction of 'v'.
0139      * If 'outgoing' is true, only consider the face if we are going out
0140      * through the face; otherwise, if false, only consider the face if we are
0141      * going in through the face.
0142      *  @returns true if there is an intersection, false otherwise.
0143      */
0144     virtual G4bool Intersect (const G4ThreeVector& p, const G4ThreeVector& v,
0145                               const G4bool outgoing, G4double& distance,
0146                                     G4double& distFromSurface,
0147                                     G4ThreeVector& normal) = 0;
0148 
0149     /**
0150      * Auxiliary method for returning the surface area.
0151      */
0152     virtual G4double GetArea() const = 0;
0153 
0154     /**
0155      * Auxiliary method to get a uniform random point on the facet.
0156      */
0157     virtual G4ThreeVector GetPointOnFace() const = 0;
0158 
0159     /**
0160      * Adds a translation 'v' to the vertices of the facet.
0161      */
0162     void ApplyTranslation (const G4ThreeVector& v);
0163 
0164     /**
0165      * Streams the object contents to an output stream.
0166      */
0167     std::ostream& StreamInfo(std::ostream& os) const;
0168 
0169     /**
0170      * Returns true if point 'p' is inside the facet.
0171      */
0172     G4bool IsInside(const G4ThreeVector& p) const;
0173 
0174     /**
0175      * Logger methods for allocated memory of facets.
0176      */
0177     virtual G4int AllocatedMemory() = 0;
0178     virtual void SetVertexIndex (G4int i, G4int j) = 0;
0179     virtual G4int GetVertexIndex (G4int i) const = 0;
0180 
0181 
0182   protected:
0183 
0184     static const G4double dirTolerance;
0185     G4double kCarTolerance;
0186 };
0187 
0188 #endif