Back to home page

EIC code displayed by LXR

 
 

    


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

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 //
0027 
0028 #ifndef G4POLYHEDRON_HH
0029 #define G4POLYHEDRON_HH
0030 
0031 // Class Description:
0032 // G4Polyhedron is an intermediate class between G4 and visualization
0033 // systems. It is intended to provide some service like:
0034 //   - polygonization of the G4 shapes with triangulization
0035 //     (quadrilaterization) of complex polygons;
0036 //   - calculation of normals for faces and vertices.
0037 //
0038 // Inherits from HepPolyhedron, to which reference should be made for
0039 // functionality.
0040 //
0041 // Public constructors:
0042 //   G4PolyhedronBox(dx,dy,dz)            - create G4Polyhedron for G4 Box;
0043 //   G4PolyhedronTrd1(dx1,dx2,dy,dz)      - create G4Polyhedron for G4 Trd1;
0044 //   G4PolyhedronTrd2(dx1,dx2,dy1,dy2,dz) - create G4Polyhedron for G4 Trd2;
0045 //   G4PolyhedronTrap(dz,theta,phi,
0046 //                    h1,bl1,tl1,alp1,
0047 //                    h2,bl2,tl2,alp2)    - create G4Polyhedron for G4 Trap;
0048 //   G4PolyhedronPara(dx,dy,dz,
0049 //                    alpha,theta,phi)    - create G4Polyhedron for G4 Para;
0050 //
0051 //   G4PolyhedronTube(rmin,rmax,dz)       - create G4Polyhedron for G4 Tube;
0052 //   G4PolyhedronTubs(rmin,rmax,dz,
0053 //                    phi1,dphi)          - create G4Polyhedron for G4 Tubs;
0054 //   G4PolyhedronCone(rmin1,rmax1,
0055 //                    rmin2,rmax2,dz)     - create G4Polyhedron for G4 Cone;
0056 //   G4PolyhedronCons(rmin1,rmax1,
0057 //                    rmin2,rmax2,dz,
0058 //                    phi1,dphi)          - create G4Polyhedron for G4 Cons;
0059 //
0060 //   G4PolyhedronPgon(phi,dphi,npdv,nz,
0061 //                    z(*),rmin(*),rmax(*)) - create G4Polyhedron for G4 Pgon;
0062 //   G4PolyhedronPcon(phi,dphi,nz,
0063 //                    z(*),rmin(*),rmax(*)) - create G4Polyhedron for G4 Pcon;
0064 //
0065 //   G4PolyhedronSphere(rmin,rmax,
0066 //                      phi,dphi,the,dthe)  - create G4Polyhedron for Sphere;
0067 //   G4PolyhedronTorus(rmin,rmax,rtor,
0068 //                     phi,dphi)            - create G4Polyhedron for Torus;
0069 //   G4PolyhedronTet(p0[3],p1[3],p2[3],p3[3]) - create polyhedron for Tet;
0070 //
0071 //   G4PolyhedronEllipsoid(dx,dy,dz,
0072 //                         zcut1,zcut2)     - create G4Polyhedron for Ellipsoid;
0073 //   G4PolyhedronEllipticalCone(dx,dy,z,
0074 //                              zcut1)      - create polyhedron for Elliptical cone;
0075 //   G4PolyhedronParaboloid(r1,r2,dz,
0076 //                          phi,dphi)       - create polyhedron for Paraboloid;
0077 //   G4PolyhedronHype(r1,r2,
0078 //                    tan1,tan2,halfz)      - create polyhedron for Hype;
0079 //   G4PolyhedronHyperbolicMirror(a,h,r)    - create polyhedron for Hyperbolic mirror;
0080 //
0081 //   G4PolyhedronTetMesh(vector<p>)         - create polyhedron for tetrahedron mesh;
0082 //
0083 //   G4PolyhedronBoxMesh(sx,sy,sz,vector<p>) - create polyhedron for box mesh;
0084 //
0085 // Public functions inherited from HepPolyhedron (this list might be
0086 // incomplete):
0087 //   GetNoVertices()  - returns number of vertices
0088 //   GetNoFacets()    - returns number of faces
0089 //   GetNextVertexIndex(index, edgeFlag) - get vertex indeces of the
0090 //                      quadrilaterals in order; returns false when
0091 //                      finished each face;
0092 //   GetVertex(index) - returns vertex by index;
0093 //   GetNextVertex(vertex, edgeFlag) - get vertices with edge visibility
0094 //                      of the quadrilaterals in order;
0095 //                      returns false when finished each face;
0096 //   GetNextVertex(vertex, edgeFlag, normal) - get vertices with edge
0097 //                      visibility and normal of the quadrilaterals
0098 //                      in order; returns false when finished each face;
0099 //   GetNextNormal(normal) - get normals of each face in order;
0100 //                      returns false when finished all faces;
0101 //   GetNextUnitNormal(normal) - get normals of unit length of each face
0102 //                      in order; returns false when finished all faces;
0103 //   GetNextEdgeIndeces(i1, i2, edgeFlag) - get indeces of the next edge;
0104 //                      returns false for the last edge;
0105 //   GetNextEdge(p1, p2, edgeFlag) - get next edge;
0106 //                      returns false for the last edge;
0107 //   SetVertex(index, v) - set vertex;
0108 //   SetFacet(index,iv1,iv2,iv3,iv4) - set facet;
0109 //   SetReferences()     - set references to neighbouring facets;
0110 //   JoinCoplanarFacets(tol) - join couples of triangles into quadrilaterals;
0111 //   InvertFacets()      - invert the order on nodes in facets;
0112 //   SetNumberOfRotationSteps(G4int n) - set number of steps for whole circle;
0113 //
0114 // History:
0115 // 21st February 2000  Evgeni Chernaev, John Allison
0116 // - Re-written to inherit HepPolyhedron.
0117 //
0118 // 11.03.05 J.Allison
0119 // - Added fNumberOfRotationStepsAtTimeOfCreation and access method.
0120 //   (NumberOfRotationSteps is also called number of sides per circle or
0121 //   line segments per circle - see
0122 //   /vis/viewer/set/lineSegmentsPerCircle.)
0123 // 20.06.05 G.Cosmo
0124 // - Added G4PolyhedronEllipsoid.
0125 // 09.03.06 J.Allison
0126 // - Added operator<<.
0127 
0128 #include "globals.hh"
0129 #include "HepPolyhedron.h"
0130 #include "G4Visible.hh"
0131 
0132 class G4Polyhedron : public HepPolyhedron, public G4Visible {
0133 public:
0134   // Default constructor
0135   G4Polyhedron ();
0136 
0137   // Constructors
0138   G4Polyhedron (G4int Nvert, G4int Nface);
0139   G4Polyhedron (const HepPolyhedron& from);
0140 
0141   // Copy and move constructors
0142   G4Polyhedron (const G4Polyhedron& from) = default;
0143   G4Polyhedron (G4Polyhedron&& from) = default;
0144 
0145   // Assignment and move assignment
0146   G4Polyhedron & operator=(const G4Polyhedron & from) = default;
0147   G4Polyhedron & operator=(G4Polyhedron && from) = default;
0148 
0149   // Destructor
0150   ~G4Polyhedron () override;
0151 
0152   G4int GetNumberOfRotationStepsAtTimeOfCreation() const {
0153     return fNumberOfRotationStepsAtTimeOfCreation;
0154   }
0155 private:
0156   G4int fNumberOfRotationStepsAtTimeOfCreation = fNumberOfRotationSteps;
0157 };
0158 
0159 class G4PolyhedronBox: public G4Polyhedron {
0160 public:
0161   G4PolyhedronBox (G4double dx, G4double dy, G4double dz);
0162   ~G4PolyhedronBox () override;
0163 };
0164 
0165 class G4PolyhedronCone: public G4Polyhedron {
0166 public:
0167   G4PolyhedronCone (G4double Rmn1, G4double Rmx1,
0168                     G4double Rmn2, G4double Rmx2, G4double Dz);
0169   ~G4PolyhedronCone () override;
0170 };
0171 
0172 class G4PolyhedronCons: public G4Polyhedron {
0173 public:
0174   G4PolyhedronCons (G4double Rmn1, G4double Rmx1,
0175                     G4double Rmn2, G4double Rmx2, G4double Dz,
0176                     G4double Phi1, G4double Dphi);
0177   ~G4PolyhedronCons () override;
0178 };
0179 
0180 class G4PolyhedronPara: public G4Polyhedron {
0181 public:
0182   G4PolyhedronPara (G4double Dx, G4double Dy, G4double Dz,
0183                     G4double Alpha, G4double Theta, G4double Phi);
0184   ~G4PolyhedronPara () override;
0185 };
0186 
0187 class G4PolyhedronPcon: public G4Polyhedron {
0188 public:
0189   G4PolyhedronPcon (G4double phi, G4double dphi, G4int nz,
0190                     const G4double *z,
0191                     const G4double *rmin,
0192                     const G4double *rmax);
0193   G4PolyhedronPcon (G4double phi, G4double dphi,
0194                     const std::vector<G4TwoVector> &rz);
0195   ~G4PolyhedronPcon () override;
0196 };
0197 
0198 class G4PolyhedronPgon: public G4Polyhedron {
0199 public:
0200   G4PolyhedronPgon (G4double phi, G4double dphi, G4int npdv, G4int nz,
0201                     const G4double *z,
0202                     const G4double *rmin,
0203                     const G4double *rmax);
0204   G4PolyhedronPgon (G4double phi, G4double dphi, G4int npdv,
0205                     const std::vector<G4TwoVector> &rz);
0206 
0207   ~G4PolyhedronPgon () override;
0208 };
0209 
0210 class G4PolyhedronSphere: public G4Polyhedron {
0211 public:
0212   G4PolyhedronSphere (G4double rmin, G4double rmax,
0213                       G4double phi, G4double dphi,
0214                       G4double the, G4double dthe);
0215   ~G4PolyhedronSphere () override;
0216 };
0217 
0218 class G4PolyhedronTet: public G4Polyhedron {
0219 public:
0220   G4PolyhedronTet (const G4double p0[3],
0221                    const G4double p1[3],
0222                    const G4double p2[3],
0223                    const G4double p3[3]);
0224   ~G4PolyhedronTet () override;
0225 };
0226 
0227 class G4PolyhedronTorus: public G4Polyhedron {
0228 public:
0229   G4PolyhedronTorus (G4double rmin, G4double rmax, G4double rtor,
0230                     G4double phi, G4double dphi);
0231   ~G4PolyhedronTorus () override;
0232 };
0233 
0234 class G4PolyhedronTrap: public G4Polyhedron {
0235 public:
0236   G4PolyhedronTrap (G4double Dz, G4double Theta, G4double Phi,
0237                     G4double Dy1,
0238                     G4double Dx1, G4double Dx2, G4double Alp1,
0239                     G4double Dy2,
0240                     G4double Dx3, G4double Dx4, G4double Alp2);
0241   ~G4PolyhedronTrap () override;
0242 };
0243 
0244 class G4PolyhedronTrd1: public G4Polyhedron {
0245 public:
0246   G4PolyhedronTrd1 (G4double Dx1, G4double Dx2,
0247                     G4double Dy, G4double Dz);
0248   ~G4PolyhedronTrd1 () override;
0249 };
0250 
0251 class G4PolyhedronTrd2: public G4Polyhedron {
0252 public:
0253   G4PolyhedronTrd2 (G4double Dx1, G4double Dx2,
0254                     G4double Dy1, G4double Dy2, G4double Dz);
0255   ~G4PolyhedronTrd2 () override;
0256 };
0257 
0258 class G4PolyhedronTube: public G4Polyhedron {
0259 public:
0260   G4PolyhedronTube (G4double Rmin, G4double Rmax, G4double Dz);
0261   ~G4PolyhedronTube () override;
0262 };
0263 
0264 class G4PolyhedronTubs: public G4Polyhedron {
0265 public:
0266   G4PolyhedronTubs (G4double Rmin, G4double Rmax, G4double Dz,
0267                     G4double Phi1, G4double Dphi);
0268   ~G4PolyhedronTubs () override;
0269 };
0270 
0271 class G4PolyhedronParaboloid: public G4Polyhedron {
0272  public:
0273   G4PolyhedronParaboloid(G4double r1, G4double r2, G4double dz,
0274                          G4double sPhi, G4double dPhi);
0275   ~G4PolyhedronParaboloid () override;
0276 };
0277 
0278 class G4PolyhedronHype: public G4Polyhedron {
0279  public:
0280   G4PolyhedronHype(G4double r1, G4double r2, G4double tan1,
0281                    G4double tan2, G4double halfZ);
0282   ~G4PolyhedronHype () override;
0283 };
0284 
0285 class G4PolyhedronEllipsoid : public G4Polyhedron {
0286  public:
0287   G4PolyhedronEllipsoid(G4double dx, G4double dy, G4double dz,
0288                         G4double zcut1, G4double zcut2);
0289   ~G4PolyhedronEllipsoid () override;
0290 };
0291 
0292 class G4PolyhedronEllipticalCone : public G4Polyhedron {
0293  public:
0294   G4PolyhedronEllipticalCone(G4double dx, G4double dy, G4double z,
0295                              G4double zcut1);
0296   ~G4PolyhedronEllipticalCone () override;
0297 };
0298 
0299 class G4PolyhedronHyperbolicMirror : public G4Polyhedron {
0300  public:
0301   G4PolyhedronHyperbolicMirror(G4double a, G4double h, G4double r);
0302   ~G4PolyhedronHyperbolicMirror () override;
0303 };
0304 
0305 class G4PolyhedronTetMesh : public G4Polyhedron {
0306  public:
0307   G4PolyhedronTetMesh(const std::vector<G4ThreeVector>& tetrahedra);
0308   ~G4PolyhedronTetMesh () override;
0309 };
0310 
0311 class G4PolyhedronBoxMesh : public G4Polyhedron {
0312  public:
0313   G4PolyhedronBoxMesh(G4double sizeX, G4double sizeY, G4double sizeZ,
0314                       const std::vector<G4ThreeVector>& positions);
0315 
0316   ~G4PolyhedronBoxMesh () override;
0317 };
0318 
0319 std::ostream& operator<<(std::ostream& os, const G4Polyhedron&);
0320 
0321 #endif /* G4POLYHEDRON_HH */