Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // >> 23 // >> 24 // $Id: HepPolyhedron.h,v 1.8.2.1 2001/06/28 19:10:10 gunter Exp $ >> 25 // GEANT4 tag $Name: $ >> 26 // >> 27 // 26 // Class Description: 28 // Class Description: 27 // HepPolyhedron is an intermediate class betw 29 // HepPolyhedron is an intermediate class between description of a shape 28 // and visualization systems. It is intended t 30 // and visualization systems. It is intended to provide some service like: 29 // - polygonization of shapes with trianguli 31 // - polygonization of shapes with triangulization (quadrilaterization) 30 // of complex polygons; 32 // of complex polygons; 31 // - calculation of normals for faces and ve 33 // - calculation of normals for faces and vertices; 32 // - finding result of boolean operation on 34 // - finding result of boolean operation on polyhedra; 33 // 35 // 34 // Public constructors: 36 // Public constructors: 35 // 37 // 36 // HepPolyhedronBox (dx,dy,dz) 38 // HepPolyhedronBox (dx,dy,dz) 37 // - cr 39 // - create polyhedron for Box; 38 // HepPolyhedronTrd1 (dx1,dx2,dy,dz) 40 // HepPolyhedronTrd1 (dx1,dx2,dy,dz) 39 // - cr << 41 // - create polyhedron for G3 Trd1; 40 // HepPolyhedronTrd2 (dx1,dx2,dy1,dy2,dz) 42 // HepPolyhedronTrd2 (dx1,dx2,dy1,dy2,dz) 41 // - cr << 43 // - create polyhedron for G3 Trd2; 42 // HepPolyhedronTrap (dz,theta,phi, h1,bl1,t 44 // HepPolyhedronTrap (dz,theta,phi, h1,bl1,tl1,alp1, h2,bl2,tl2,alp2) 43 // - cr << 45 // - create polyhedron for G3 Trap; 44 // HepPolyhedronPara (dx,dy,dz,alpha,theta,p 46 // HepPolyhedronPara (dx,dy,dz,alpha,theta,phi) 45 // - cr << 47 // - create polyhedron for G3 Para; 46 // HepPolyhedronTube (rmin,rmax,dz) 48 // HepPolyhedronTube (rmin,rmax,dz) 47 // - cr << 49 // - create polyhedron for G3 Tube; 48 // HepPolyhedronTubs (rmin,rmax,dz,phi1,dphi 50 // HepPolyhedronTubs (rmin,rmax,dz,phi1,dphi) 49 // - cr << 51 // - create polyhedron for G3 Tubs; 50 // HepPolyhedronCone (rmin1,rmax1,rmin2,rmax 52 // HepPolyhedronCone (rmin1,rmax1,rmin2,rmax2,dz) 51 // - cr << 53 // - create polyhedron for G3 Cone; 52 // HepPolyhedronCons (rmin1,rmax1,rmin2,rmax 54 // HepPolyhedronCons (rmin1,rmax1,rmin2,rmax2,dz,phi1,dphi) 53 // - cr << 55 // - create polyhedron for G3 Cons; 54 // HepPolyhedronPgon (phi,dphi,npdv,nz, z(*) 56 // HepPolyhedronPgon (phi,dphi,npdv,nz, z(*),rmin(*),rmax(*)) 55 // - cr << 57 // - create polyhedron for G3 Pgon; 56 // HepPolyhedronPcon (phi,dphi,nz, z(*),rmin 58 // HepPolyhedronPcon (phi,dphi,nz, z(*),rmin(*),rmax(*)) 57 // - cr << 59 // - create polyhedron for G3 Pcon; 58 // HepPolyhedronSphere (rmin,rmax,phi,dphi,t 60 // HepPolyhedronSphere (rmin,rmax,phi,dphi,the,dthe) 59 // - cr 61 // - create polyhedron for Sphere; 60 // HepPolyhedronTorus (rmin,rmax,rtor,phi,dp 62 // HepPolyhedronTorus (rmin,rmax,rtor,phi,dphi) 61 // - cr 63 // - create polyhedron for Torus; 62 // HepPolyhedronTet (p0[3],p1[3],p2[3],p3[3] << 63 // - cr << 64 // HepPolyhedronEllipsoid (dx,dy,dz,zcut1,zc << 65 // - cr << 66 // HepPolyhedronEllipticalCone(dx,dy,z,zcut1 << 67 // - cr << 68 // HepPolyhedronParaboloid (r1,r2,dz,phi,dph << 69 // - cr << 70 // HepPolyhedronHype (r1,r2,tan1,tan2,halfz) << 71 // - cr << 72 // HepPolyhedronHyperbolicMirror (a,h,r) << 73 // - cr << 74 // HepPolyhedronTetMesh (vector<p>) << 75 // - cr << 76 // HepPolyhedronBoxMesh (sx,sy,sz,vector<p>) << 77 // - cr << 78 // Public functions: 64 // Public functions: 79 // 65 // 80 // GetNoVertices () - returns number o 66 // GetNoVertices () - returns number of vertices; 81 // GetNoFacets () - returns number o 67 // GetNoFacets () - returns number of faces; 82 // GetNextVertexIndex (index,edgeFlag) - get << 68 // GetNextVertexIndex (index,edgeFlag) - get vertex indeces of the 83 // quadrilaterals i 69 // quadrilaterals in order; 84 // returns false wh 70 // returns false when finished each face; 85 // GetVertex (index) - returns vertex b 71 // GetVertex (index) - returns vertex by index; 86 // GetNextVertex (vertex,edgeFlag) - get ver 72 // GetNextVertex (vertex,edgeFlag) - get vertices with edge visibility 87 // of the quadrilat 73 // of the quadrilaterals in order; 88 // returns false wh 74 // returns false when finished each face; 89 // GetNextVertex (vertex,edgeFlag,normal) - 75 // GetNextVertex (vertex,edgeFlag,normal) - get vertices with edge 90 // visibility and n 76 // visibility and normal of the quadrilaterals 91 // in order; return 77 // in order; returns false when finished each face; 92 // GetNextEdgeIndices (i1,i2,edgeFlag) - get << 78 // GetNextEdgeIndeces (i1,i2,edgeFlag) - get indeces of the next edge; 93 // returns false fo 79 // returns false for the last edge; 94 // GetNextEdgeIndices (i1,i2,edgeFlag,iface1 << 80 // GetNextEdgeIndeces (i1,i2,edgeFlag,iface1,iface2) - get indeces of 95 // the next edge wi << 81 // the next edge with indeces of the faces 96 // to which the edg 82 // to which the edge belongs; 97 // returns false fo 83 // returns false for the last edge; 98 // GetNextEdge (p1,p2,edgeFlag) - get next e 84 // GetNextEdge (p1,p2,edgeFlag) - get next edge; 99 // returns false fo 85 // returns false for the last edge; 100 // GetNextEdge (p1,p2,edgeFlag,iface1,iface2 << 86 // GetNextEdge (p1,p2,edgeFlag,iface1,iface2) - get next edge with indeces 101 // of the faces to 87 // of the faces to which the edge belongs; 102 // returns false fo 88 // returns false for the last edge; 103 // GetFacet (index,n,nodes,edgeFlags=0,norma 89 // GetFacet (index,n,nodes,edgeFlags=0,normals=0) - get face by index; 104 // GetNextFacet (n,nodes,edgeFlags=0,normals 90 // GetNextFacet (n,nodes,edgeFlags=0,normals=0) - get next face with normals 105 // at the nodes; re 91 // at the nodes; returns false for the last face; 106 // GetNormal (index) - get normal of fa 92 // GetNormal (index) - get normal of face given by index; 107 // GetUnitNormal (index) - get unit normal 93 // GetUnitNormal (index) - get unit normal of face given by index; 108 // GetNextNormal (normal) - get normals of e 94 // GetNextNormal (normal) - get normals of each face in order; 109 // returns false wh 95 // returns false when finished all faces; 110 // GetNextUnitNormal (normal) - get normals 96 // GetNextUnitNormal (normal) - get normals of unit length of each face 111 // in order; return 97 // in order; returns false when finished all faces; 112 // GetSurfaceArea() - get surface area 98 // GetSurfaceArea() - get surface area of the polyhedron; 113 // GetVolume() - get volume of th 99 // GetVolume() - get volume of the polyhedron; 114 // GetNumberOfRotationSteps() - get number o << 100 // GetNumberOfRotationSteps() - get number of steps for whole circle; 115 // SetVertex(index, v) - set vertex; << 116 // SetFacet(index,iv1,iv2,iv3,iv4) - set fac << 117 // SetReferences() - set references t << 118 // JoinCoplanarFacets(tolerance) - join copl << 119 // InvertFacets() - invert the order << 120 // SetNumberOfRotationSteps (n) - set number 101 // SetNumberOfRotationSteps (n) - set number of steps for whole circle; 121 // ResetNumberOfRotationSteps() - reset numb 102 // ResetNumberOfRotationSteps() - reset number of steps for whole circle 122 // to default value 103 // to default value; 123 // History: 104 // History: 124 // 105 // 125 // 20.06.96 Evgeni Chernyaev <Evgueni.Tchernia 106 // 20.06.96 Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch> - initial version 126 // 107 // 127 // 23.07.96 John Allison 108 // 23.07.96 John Allison 128 // - added GetNoVertices, GetNoFacets, GetNext 109 // - added GetNoVertices, GetNoFacets, GetNextVertex, GetNextNormal 129 // 110 // 130 // 30.09.96 E.Chernyaev 111 // 30.09.96 E.Chernyaev 131 // - added GetNextVertexIndex, GetVertex by Ya 112 // - added GetNextVertexIndex, GetVertex by Yasuhide Sawada 132 // - added GetNextUnitNormal, GetNextEdgeIndic << 113 // - added GetNextUnitNormal, GetNextEdgeIndeces, GetNextEdge 133 // - improvements: angles now expected in radi 114 // - improvements: angles now expected in radians 134 // int -> G4int, double -> G4d << 115 // int -> G4int, double -> G4double 135 // - G4ThreeVector replaced by either G4Point3 116 // - G4ThreeVector replaced by either G4Point3D or G4Normal3D 136 // 117 // 137 // 15.12.96 E.Chernyaev 118 // 15.12.96 E.Chernyaev 138 // - private functions G4PolyhedronAlloc, G4Po 119 // - private functions G4PolyhedronAlloc, G4PolyhedronPrism renamed 139 // to AllocateMemory and CreatePrism 120 // to AllocateMemory and CreatePrism 140 // - added private functions GetNumberOfRotati 121 // - added private functions GetNumberOfRotationSteps, RotateEdge, 141 // RotateAroundZ, SetReferences 122 // RotateAroundZ, SetReferences 142 // - rewritten G4PolyhedronCons; 123 // - rewritten G4PolyhedronCons; 143 // - added G4PolyhedronPara, ...Trap, ...Pgon, 124 // - added G4PolyhedronPara, ...Trap, ...Pgon, ...Pcon, ...Sphere, ...Torus, 144 // so full List of implemented shapes now lo 125 // so full List of implemented shapes now looks like: 145 // BOX, TRD1, TRD2, TRAP, TUBE, TUBS, CONE, 126 // BOX, TRD1, TRD2, TRAP, TUBE, TUBS, CONE, CONS, PARA, PGON, PCON, 146 // SPHERE, TORUS 127 // SPHERE, TORUS 147 // 128 // 148 // 01.06.97 E.Chernyaev 129 // 01.06.97 E.Chernyaev 149 // - RotateAroundZ modified and SetSideFacets 130 // - RotateAroundZ modified and SetSideFacets added to allow Rmin=Rmax 150 // in bodies of revolution 131 // in bodies of revolution 151 // 132 // 152 // 24.06.97 J.Allison 133 // 24.06.97 J.Allison 153 // - added static private member fNumberOfRota 134 // - added static private member fNumberOfRotationSteps and static public 154 // functions void SetNumberOfRotationSteps ( 135 // functions void SetNumberOfRotationSteps (G4int n) and 155 // void ResetNumberOfRotationSteps (). Modi 136 // void ResetNumberOfRotationSteps (). Modified 156 // GetNumberOfRotationSteps() appropriately. 137 // GetNumberOfRotationSteps() appropriately. Made all three functions 157 // inline (at end of this .hh file). 138 // inline (at end of this .hh file). 158 // Usage: 139 // Usage: 159 // G4Polyhedron::SetNumberOfRotationSteps 140 // G4Polyhedron::SetNumberOfRotationSteps 160 // (fpView -> GetViewParameters ().GetNoOf 141 // (fpView -> GetViewParameters ().GetNoOfSides ()); 161 // pPolyhedron = solid.CreatePolyhedron (); 142 // pPolyhedron = solid.CreatePolyhedron (); 162 // G4Polyhedron::ResetNumberOfRotationSteps 143 // G4Polyhedron::ResetNumberOfRotationSteps (); 163 // 144 // 164 // 19.03.00 E.Chernyaev 145 // 19.03.00 E.Chernyaev 165 // - added boolean operations (add, subtract, 146 // - added boolean operations (add, subtract, intersect) on polyhedra; 166 // 147 // 167 // 25.05.01 E.Chernyaev 148 // 25.05.01 E.Chernyaev 168 // - added GetSurfaceArea() and GetVolume(); 149 // - added GetSurfaceArea() and GetVolume(); 169 // 150 // 170 // 05.11.02 E.Chernyaev << 171 // - added createTwistedTrap() and createPolyh << 172 // << 173 // 06.03.05 J.Allison << 174 // - added IsErrorBooleanProcess << 175 // << 176 // 20.06.05 G.Cosmo << 177 // - added HepPolyhedronEllipsoid << 178 // << 179 // 18.07.07 T.Nikitina << 180 // - added HepPolyhedronParaboloid; << 181 // << 182 // 21.10.09 J.Allison << 183 // - removed IsErrorBooleanProcess (now error << 184 // << 185 // 22.02.20 E.Chernyaev << 186 // - added HepPolyhedronTet, HepPolyhedronHybe << 187 // << 188 // 12.05.21 E.Chernyaev << 189 // - added TriangulatePolygon(), RotateContour << 190 // - added HepPolyhedronPgon, HepPolyhedronPco << 191 // << 192 // 26.03.22 E.Chernyaev << 193 // - added HepPolyhedronTetMesh << 194 // << 195 // 04.04.22 E.Chernyaev << 196 // - added JoinCoplanarFacets() << 197 // << 198 // 07.04.22 E.Chernyaev << 199 // - added HepPolyhedronBoxMesh << 200 151 201 #ifndef HEP_POLYHEDRON_HH 152 #ifndef HEP_POLYHEDRON_HH 202 #define HEP_POLYHEDRON_HH 153 #define HEP_POLYHEDRON_HH 203 154 204 #include <vector> << 155 #include <CLHEP/Geometry/Point3D.h> 205 #include "G4Types.hh" << 156 206 #include "G4TwoVector.hh" << 157 #ifndef HepStd 207 #include "G4ThreeVector.hh" << 158 #ifndef HEP_USE_STD 208 #include "G4Point3D.hh" << 159 #define HepStd 209 #include "G4Normal3D.hh" << 160 #else 210 #include "G4Transform3D.hh" << 161 #define HepStd std >> 162 #endif >> 163 #endif 211 164 212 #ifndef DEFAULT_NUMBER_OF_STEPS 165 #ifndef DEFAULT_NUMBER_OF_STEPS 213 #define DEFAULT_NUMBER_OF_STEPS 24 166 #define DEFAULT_NUMBER_OF_STEPS 24 214 #endif 167 #endif 215 168 216 class G4Facet { 169 class G4Facet { 217 friend class HepPolyhedron; 170 friend class HepPolyhedron; 218 friend std::ostream& operator<<(std::ostream << 171 friend HepStd::ostream& operator<<(HepStd::ostream&, const G4Facet &facet); 219 172 220 private: 173 private: 221 struct G4Edge { G4int v,f; }; << 174 struct G4Edge { int v,f; }; 222 G4Edge edge[4]; 175 G4Edge edge[4]; 223 176 224 public: 177 public: 225 G4Facet(G4int v1=0, G4int f1=0, G4int v2=0, << 178 G4Facet(int v1=0, int f1=0, int v2=0, int f2=0, 226 G4int v3=0, G4int f3=0, G4int v4=0, << 179 int v3=0, int f3=0, int v4=0, int f4=0) 227 { edge[0].v=v1; edge[0].f=f1; edge[1].v=v2; 180 { edge[0].v=v1; edge[0].f=f1; edge[1].v=v2; edge[1].f=f2; 228 edge[2].v=v3; edge[2].f=f3; edge[3].v=v4; 181 edge[2].v=v3; edge[2].f=f3; edge[3].v=v4; edge[3].f=f4; } 229 }; 182 }; 230 183 231 class HepPolyhedron { 184 class HepPolyhedron { 232 friend std::ostream& operator<<(std::ostream << 185 friend HepStd::ostream& operator<<(HepStd::ostream&, const HepPolyhedron &ph); >> 186 >> 187 private: >> 188 static int fNumberOfRotationSteps; 233 189 234 protected: 190 protected: 235 static G4ThreadLocal G4int fNumberOfRotation << 191 int nvert, nface; 236 G4int nvert, nface; << 192 HepPoint3D *pV; 237 G4Point3D *pV; << 238 G4Facet *pF; 193 G4Facet *pF; 239 194 240 // Re-allocate memory for HepPolyhedron << 195 // Allocate memory for HepPolyhedron 241 void AllocateMemory(G4int Nvert, G4int Nface << 196 void AllocateMemory(int Nvert, int Nface); 242 197 243 // Find neighbouring facet 198 // Find neighbouring facet 244 G4int FindNeighbour(G4int iFace, G4int iNode << 199 int FindNeighbour(int iFace, int iNode, int iOrder) const; 245 200 246 // Find normal at node 201 // Find normal at node 247 G4Normal3D FindNodeNormal(G4int iFace, G4int << 202 HepNormal3D FindNodeNormal(int iFace, int iNode) const; 248 203 249 // Create HepPolyhedron for prism with quadr 204 // Create HepPolyhedron for prism with quadrilateral base 250 void CreatePrism(); 205 void CreatePrism(); 251 206 252 // Generate facets by revolving an edge arou 207 // Generate facets by revolving an edge around Z-axis 253 void RotateEdge(G4int k1, G4int k2, G4double << 208 void RotateEdge(int k1, int k2, HepDouble r1, HepDouble r2, 254 G4int v1, G4int v2, G4int vE << 209 int v1, int v2, int vEdge, 255 G4bool ifWholeCircle, G4int << 210 HepBoolean ifWholeCircle, int ns, int &kface); 256 211 257 // Set side facets for the case of incomplet 212 // Set side facets for the case of incomplete rotation 258 void SetSideFacets(G4int ii[4], G4int vv[4], << 213 void SetSideFacets(int ii[4], int vv[4], 259 G4int *kk, G4double *r, << 214 int *kk, HepDouble *r, 260 G4double dphi, G4int ns, << 215 HepDouble dphi, int ns, int &kface); 261 216 262 // Create HepPolyhedron for body of revoluti 217 // Create HepPolyhedron for body of revolution around Z-axis 263 void RotateAroundZ(G4int nstep, G4double phi << 218 void RotateAroundZ(int nstep, HepDouble phi, HepDouble dphi, 264 G4int np1, G4int np2, << 219 int np1, int np2, 265 const G4double *z, G4doub << 220 const HepDouble *z, HepDouble *r, 266 G4int nodeVis, G4int edge << 221 int nodeVis, int edgeVis); 267 222 268 // Create HepPolyhedron for body of revoluti << 223 // For each edge set reference to neighbouring facet 269 void RotateContourAroundZ(G4int nstep, G4dou << 224 void SetReferences(); 270 const std::vector< << 271 G4int nodeVis, G4i << 272 << 273 // Triangulate closed polygon (contour) << 274 G4bool TriangulatePolygon(const std::vector< << 275 std::vector<G4int> << 276 << 277 // Helper function for TriangulatePolygon() << 278 G4bool CheckSnip(const std::vector<G4TwoVect << 279 G4int a, G4int b, G4int c, << 280 G4int n, const G4int* V); << 281 225 282 public: << 226 // Invert the order on nodes in facets 283 // Default constructor << 227 void InvertFacets(); 284 HepPolyhedron() : nvert(0), nface(0), pV(nul << 285 228 286 // Constructor with allocation of memory << 229 public: 287 HepPolyhedron(G4int Nvert, G4int Nface); << 230 // Constructor >> 231 HepPolyhedron(int Nvert=0, int Nface=0) >> 232 : nvert(Nvert), nface(Nface), >> 233 pV(Nvert ? new HepPoint3D[Nvert+1] : 0), >> 234 pF(Nface ? new G4Facet[Nface+1] : 0) {} 288 235 289 // Copy constructor 236 // Copy constructor 290 HepPolyhedron(const HepPolyhedron & from); 237 HepPolyhedron(const HepPolyhedron & from); 291 238 292 // Move constructor << 293 HepPolyhedron(HepPolyhedron && from); << 294 << 295 // Destructor 239 // Destructor 296 virtual ~HepPolyhedron() { delete [] pV; del 240 virtual ~HepPolyhedron() { delete [] pV; delete [] pF; } 297 241 298 // Assignment 242 // Assignment 299 HepPolyhedron & operator=(const HepPolyhedro << 243 virtual HepPolyhedron & operator=(const HepPolyhedron & from); 300 << 301 // Move assignment << 302 HepPolyhedron & operator=(HepPolyhedron && f << 303 244 304 // Get number of vertices 245 // Get number of vertices 305 G4int GetNoVertices() const { return nvert; << 246 int GetNoVertices() const { return nvert; } 306 G4int GetNoVerteces() const { return nvert; << 307 247 308 // Get number of facets 248 // Get number of facets 309 G4int GetNoFacets() const { return nface; } << 249 int GetNoFacets() const { return nface; } 310 250 311 // Transform the polyhedron 251 // Transform the polyhedron 312 HepPolyhedron & Transform(const G4Transform3 << 252 HepPolyhedron & Transform(const HepTransform3D & t); 313 253 314 // Get next vertex index of the quadrilatera 254 // Get next vertex index of the quadrilateral 315 G4bool GetNextVertexIndex(G4int & index, G4i << 255 HepBoolean GetNextVertexIndex(int & index, int & edgeFlag) const; 316 256 317 // Get vertex by index << 257 // Get vertex by index 318 G4Point3D GetVertex(G4int index) const; << 258 HepPoint3D GetVertex(int index) const; 319 259 320 // Get next vertex + edge visibility of the 260 // Get next vertex + edge visibility of the quadrilateral 321 G4bool GetNextVertex(G4Point3D & vertex, G4i << 261 HepBoolean GetNextVertex(HepPoint3D & vertex, int & edgeFlag) const; 322 262 323 // Get next vertex + edge visibility + norma 263 // Get next vertex + edge visibility + normal of the quadrilateral 324 G4bool GetNextVertex(G4Point3D & vertex, G4i << 264 HepBoolean GetNextVertex(HepPoint3D & vertex, int & edgeFlag, 325 G4Normal3D & normal) co << 265 HepNormal3D & normal) const; 326 266 327 // Get indices of the next edge with indices << 267 // Get indeces of the next edge with indeces of the faces 328 G4bool GetNextEdgeIndices(G4int & i1, G4int << 268 HepBoolean GetNextEdgeIndeces(int & i1, int & i2, int & edgeFlag, 329 G4int & iface1, G4 << 269 int & iface1, int & iface2) const; 330 G4bool GetNextEdgeIndeces(G4int & i1, G4int << 270 331 G4int & iface1, G4 << 271 // Get indeces of the next edge 332 {return GetNextEdgeIndices(i1,i2,edgeFlag,if << 272 HepBoolean GetNextEdgeIndeces(int & i1, int & i2, int & edgeFlag) const; 333 << 334 // Get indices of the next edge << 335 G4bool GetNextEdgeIndices(G4int & i1, G4int << 336 G4bool GetNextEdgeIndeces(G4int & i1, G4int << 337 {return GetNextEdgeIndices(i1,i2,edgeFlag);} << 338 273 339 // Get next edge 274 // Get next edge 340 G4bool GetNextEdge(G4Point3D &p1, G4Point3D << 275 HepBoolean GetNextEdge(HepPoint3D &p1, HepPoint3D &p2, int &edgeFlag) const; 341 276 342 // Get next edge 277 // Get next edge 343 G4bool GetNextEdge(G4Point3D &p1, G4Point3D << 278 HepBoolean GetNextEdge(HepPoint3D &p1, HepPoint3D &p2, int &edgeFlag, 344 G4int &iface1, G4int &ifa << 279 int &iface1, int &iface2) const; 345 280 346 // Get face by index 281 // Get face by index 347 void GetFacet(G4int iFace, G4int &n, G4int * << 282 void GetFacet(int iFace, int &n, int *iNodes, 348 G4int *edgeFlags = nullptr, G4 << 283 int *edgeFlags = 0, int *iFaces = 0) const; 349 284 350 // Get face by index 285 // Get face by index 351 void GetFacet(G4int iFace, G4int &n, G4Point << 286 void GetFacet(int iFace, int &n, HepPoint3D *nodes, 352 G4int *edgeFlags=nullptr, G4No << 287 int *edgeFlags = 0, HepNormal3D *normals = 0) const; 353 288 354 // Get next face with normals at the nodes 289 // Get next face with normals at the nodes 355 G4bool GetNextFacet(G4int &n, G4Point3D *nod << 290 HepBoolean GetNextFacet(int &n, HepPoint3D *nodes, 356 G4Normal3D *normals=null << 291 int *edgeFlags=0, HepNormal3D *normals=0) const; 357 292 358 // Get normal of the face given by index 293 // Get normal of the face given by index 359 G4Normal3D GetNormal(G4int iFace) const; << 294 HepNormal3D GetNormal(int iFace) const; 360 295 361 // Get unit normal of the face given by inde 296 // Get unit normal of the face given by index 362 G4Normal3D GetUnitNormal(G4int iFace) const; << 297 HepNormal3D GetUnitNormal(int iFace) const; 363 298 364 // Get normal of the next face 299 // Get normal of the next face 365 G4bool GetNextNormal(G4Normal3D &normal) con << 300 HepBoolean GetNextNormal(HepNormal3D &normal) const; 366 301 367 // Get normal of unit length of the next fac << 302 // Get normal of unit length of the next face 368 G4bool GetNextUnitNormal(G4Normal3D &normal) << 303 HepBoolean GetNextUnitNormal(HepNormal3D &normal) const; 369 304 370 // Boolean operations << 305 // Boolean operations 371 HepPolyhedron add(const HepPolyhedron &p) co 306 HepPolyhedron add(const HepPolyhedron &p) const; 372 HepPolyhedron subtract(const HepPolyhedron & 307 HepPolyhedron subtract(const HepPolyhedron &p) const; 373 HepPolyhedron intersect(const HepPolyhedron 308 HepPolyhedron intersect(const HepPolyhedron &p) const; 374 309 375 // Get area of the surface of the polyhedron 310 // Get area of the surface of the polyhedron 376 G4double GetSurfaceArea() const; << 311 double GetSurfaceArea() const; 377 312 378 // Get volume of the polyhedron 313 // Get volume of the polyhedron 379 G4double GetVolume() const; << 314 double GetVolume() const; 380 315 381 // Get number of steps for whole circle 316 // Get number of steps for whole circle 382 static G4int GetNumberOfRotationSteps(); << 317 static int GetNumberOfRotationSteps() { return fNumberOfRotationSteps; } 383 << 384 // Set vertex (1 <= index <= Nvert) << 385 void SetVertex(G4int index, const G4Point3D& << 386 << 387 // Set facet (1 <= index <= Nface) << 388 void SetFacet(G4int index, G4int iv1, G4int << 389 << 390 // For each edge set reference to neighbouri << 391 // call this after all vertices and facets h << 392 void SetReferences(); << 393 << 394 // Join couples of triangular facets to quad << 395 // where it is possible << 396 void JoinCoplanarFacets(G4double tolerance); << 397 << 398 // Invert the order on nodes in facets << 399 void InvertFacets(); << 400 318 401 // Set number of steps for whole circle 319 // Set number of steps for whole circle 402 static void SetNumberOfRotationSteps(G4int n << 320 static void SetNumberOfRotationSteps(int n); 403 321 404 // Reset number of steps for whole circle to 322 // Reset number of steps for whole circle to default value 405 static void ResetNumberOfRotationSteps(); << 323 static void ResetNumberOfRotationSteps() { 406 << 324 fNumberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS; 407 /** << 325 } 408 * Creates polyhedron for twisted trapezoid. << 326 }; 409 * The trapezoid is given by two bases perpe << 327 410 * << 328 class HepPolyhedronTrd2 : public HepPolyhedron { 411 * @param Dz half length in z << 329 public: 412 * @param xy1 1st base (at z = -Dz) << 330 HepPolyhedronTrd2(HepDouble Dx1, HepDouble Dx2, 413 * @param xy2 2nd base (at z = +Dz) << 331 HepDouble Dy1, HepDouble Dy2, HepDouble Dz); 414 * @return status of the operation - is non- << 332 virtual ~HepPolyhedronTrd2(); 415 */ << 333 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 416 G4int createTwistedTrap(G4double Dz, << 334 return HepPolyhedron::operator = (from); 417 const G4double xy1[][2 << 335 } 418 << 336 }; 419 /** << 337 420 * Creates user defined polyhedron. << 338 class HepPolyhedronTrd1 : public HepPolyhedronTrd2 { 421 * This function allows to the user to defin << 339 public: 422 * The faces of the polyhedron should be eit << 340 HepPolyhedronTrd1(HepDouble Dx1, HepDouble Dx2, 423 * quadrilateral. Nodes of a face are define << 341 HepDouble Dy, HepDouble Dz); 424 * the elements in the xyz array. Numeration << 342 virtual ~HepPolyhedronTrd1(); 425 * array starts from 1 (like in fortran). Th << 343 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 426 * or negative. Negative sign means that the << 344 return HepPolyhedron::operator = (from); 427 * invisible. The normal of the face should << 345 } 428 * of the polyhedron. << 346 }; 429 * << 347 430 * @param Nnodes number of nodes << 348 class HepPolyhedronBox : public HepPolyhedronTrd2 { 431 * @param Nfaces number of faces << 349 public: 432 * @param xyz nodes << 350 HepPolyhedronBox(HepDouble Dx, HepDouble Dy, HepDouble Dz); 433 * @param faces faces (quadrilaterals or t << 351 virtual ~HepPolyhedronBox(); 434 * @return status of the operation - is non- << 352 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 435 */ << 353 return HepPolyhedron::operator = (from); 436 G4int createPolyhedron(G4int Nnodes, G4int N << 354 } 437 const G4double xyz[][ << 355 }; 438 << 356 439 /** << 357 class HepPolyhedronTrap : public HepPolyhedron { 440 * Calculate the unweighted mean of all the << 358 public: 441 * confused with the polyhedron centre or ce << 359 HepPolyhedronTrap(HepDouble Dz, HepDouble Theta, HepDouble Phi, 442 * @return G4Point3D of the unweighted mean << 360 HepDouble Dy1, 443 */ << 361 HepDouble Dx1, HepDouble Dx2, HepDouble Alp1, 444 G4Point3D vertexUnweightedMean() const; << 362 HepDouble Dy2, 445 }; << 363 HepDouble Dx3, HepDouble Dx4, HepDouble Alp2); 446 << 364 virtual ~HepPolyhedronTrap(); 447 class HepPolyhedronTrd2 : public HepPolyhedron << 365 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 448 { << 366 return HepPolyhedron::operator = (from); 449 public: << 367 } 450 HepPolyhedronTrd2(G4double Dx1, G4double Dx2 << 368 }; 451 G4double Dy1, G4double Dy2 << 369 452 ~HepPolyhedronTrd2() override; << 370 class HepPolyhedronPara : public HepPolyhedronTrap { 453 }; << 371 public: 454 << 372 HepPolyhedronPara(HepDouble Dx, HepDouble Dy, HepDouble Dz, 455 class HepPolyhedronTrd1 : public HepPolyhedron << 373 HepDouble Alpha, HepDouble Theta, HepDouble Phi); 456 { << 374 virtual ~HepPolyhedronPara(); 457 public: << 375 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 458 HepPolyhedronTrd1(G4double Dx1, G4double Dx2 << 376 return HepPolyhedron::operator = (from); 459 G4double Dy, G4double Dz); << 377 } 460 ~HepPolyhedronTrd1() override; << 378 }; 461 }; << 379 462 << 380 class HepPolyhedronCons : public HepPolyhedron { 463 class HepPolyhedronBox : public HepPolyhedronT << 381 public: 464 { << 382 HepPolyhedronCons(HepDouble Rmn1, HepDouble Rmx1, 465 public: << 383 HepDouble Rmn2, HepDouble Rmx2, HepDouble Dz, 466 HepPolyhedronBox(G4double Dx, G4double Dy, G << 384 HepDouble Phi1, HepDouble Dphi); 467 ~HepPolyhedronBox() override; << 385 virtual ~HepPolyhedronCons(); 468 }; << 386 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 469 << 387 return HepPolyhedron::operator = (from); 470 class HepPolyhedronTrap : public HepPolyhedron << 388 } 471 { << 389 }; 472 public: << 390 473 HepPolyhedronTrap(G4double Dz, G4double Thet << 391 class HepPolyhedronCone : public HepPolyhedronCons { 474 G4double Dy1, << 392 public: 475 G4double Dx1, G4double Dx2 << 393 HepPolyhedronCone(HepDouble Rmn1, HepDouble Rmx1, 476 G4double Dy2, << 394 HepDouble Rmn2, HepDouble Rmx2, HepDouble Dz); 477 G4double Dx3, G4double Dx4 << 395 virtual ~HepPolyhedronCone(); 478 ~HepPolyhedronTrap() override; << 396 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 479 }; << 397 return HepPolyhedron::operator = (from); 480 << 398 } 481 class HepPolyhedronPara : public HepPolyhedron << 399 }; 482 { << 400 483 public: << 401 class HepPolyhedronTubs : public HepPolyhedronCons { 484 HepPolyhedronPara(G4double Dx, G4double Dy, << 402 public: 485 G4double Alpha, G4double T << 403 HepPolyhedronTubs(HepDouble Rmin, HepDouble Rmax, HepDouble Dz, 486 ~HepPolyhedronPara() override; << 404 HepDouble Phi1, HepDouble Dphi); 487 }; << 405 virtual ~HepPolyhedronTubs(); 488 << 406 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 489 class HepPolyhedronParaboloid : public HepPoly << 407 return HepPolyhedron::operator = (from); 490 { << 408 } 491 public: << 409 }; 492 HepPolyhedronParaboloid(G4double r1, << 410 493 G4double r2, << 411 class HepPolyhedronTube : public HepPolyhedronCons { 494 G4double dz, << 412 public: 495 G4double Phi1, << 413 HepPolyhedronTube (HepDouble Rmin, HepDouble Rmax, HepDouble Dz); 496 G4double Dphi); << 414 virtual ~HepPolyhedronTube(); 497 ~HepPolyhedronParaboloid() override; << 415 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 498 }; << 416 return HepPolyhedron::operator = (from); 499 << 417 } 500 class HepPolyhedronHype : public HepPolyhedron << 418 }; 501 { << 419 502 public: << 420 class HepPolyhedronPgon : public HepPolyhedron { 503 HepPolyhedronHype(G4double r1, << 421 public: 504 G4double r2, << 422 HepPolyhedronPgon(HepDouble phi, HepDouble dphi, int npdv, int nz, 505 G4double tan1, << 423 const HepDouble *z, 506 G4double tan2, << 424 const HepDouble *rmin, 507 G4double halfZ); << 425 const HepDouble *rmax); 508 ~HepPolyhedronHype() override; << 426 virtual ~HepPolyhedronPgon(); 509 }; << 427 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 510 << 428 return HepPolyhedron::operator = (from); 511 class HepPolyhedronCons : public HepPolyhedron << 429 } 512 { << 430 }; 513 public: << 431 514 HepPolyhedronCons(G4double Rmn1, G4double Rm << 432 class HepPolyhedronPcon : public HepPolyhedronPgon { 515 G4double Rmn2, G4double Rm << 433 public: 516 G4double Phi1, G4double Dp << 434 HepPolyhedronPcon(HepDouble phi, HepDouble dphi, int nz, 517 ~HepPolyhedronCons() override; << 435 const HepDouble *z, 518 }; << 436 const HepDouble *rmin, 519 << 437 const HepDouble *rmax); 520 class HepPolyhedronCone : public HepPolyhedron << 438 virtual ~HepPolyhedronPcon(); 521 { << 439 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 522 public: << 440 return HepPolyhedron::operator = (from); 523 HepPolyhedronCone(G4double Rmn1, G4double Rm << 441 } 524 G4double Rmn2, G4double Rm << 442 }; 525 ~HepPolyhedronCone() override; << 443 526 }; << 444 class HepPolyhedronSphere : public HepPolyhedron { 527 << 445 public: 528 class HepPolyhedronTubs : public HepPolyhedron << 446 HepPolyhedronSphere(HepDouble rmin, HepDouble rmax, 529 { << 447 HepDouble phi, HepDouble dphi, 530 public: << 448 HepDouble the, HepDouble dthe); 531 HepPolyhedronTubs(G4double Rmin, G4double Rm << 449 virtual ~HepPolyhedronSphere(); 532 G4double Phi1, G4double Dp << 450 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 533 ~HepPolyhedronTubs() override; << 451 return HepPolyhedron::operator = (from); 534 }; << 452 } 535 << 453 }; 536 class HepPolyhedronTube : public HepPolyhedron << 454 537 { << 455 class HepPolyhedronTorus : public HepPolyhedron { 538 public: << 456 public: 539 HepPolyhedronTube (G4double Rmin, G4double R << 457 HepPolyhedronTorus(HepDouble rmin, HepDouble rmax, HepDouble rtor, 540 ~HepPolyhedronTube() override; << 458 HepDouble phi, HepDouble dphi); 541 }; << 459 virtual ~HepPolyhedronTorus(); 542 << 460 virtual HepPolyhedron& operator = (const HepPolyhedron& from) { 543 class HepPolyhedronPgon : public HepPolyhedron << 461 return HepPolyhedron::operator = (from); 544 { << 462 } 545 public: << 546 HepPolyhedronPgon(G4double phi, G4double dph << 547 const G4double *z, << 548 const G4double *rmin, << 549 const G4double *rmax); << 550 HepPolyhedronPgon(G4double phi, G4double dph << 551 const std::vector<G4TwoVec << 552 ~HepPolyhedronPgon() override; << 553 }; << 554 << 555 class HepPolyhedronPcon : public HepPolyhedron << 556 { << 557 public: << 558 HepPolyhedronPcon(G4double phi, G4double dph << 559 const G4double *z, << 560 const G4double *rmin, << 561 const G4double *rmax); << 562 HepPolyhedronPcon(G4double phi, G4double dph << 563 const std::vector<G4TwoVec << 564 ~HepPolyhedronPcon() override; << 565 }; << 566 << 567 class HepPolyhedronSphere : public HepPolyhedr << 568 { << 569 public: << 570 HepPolyhedronSphere(G4double rmin, G4double << 571 G4double phi, G4double d << 572 G4double the, G4double d << 573 ~HepPolyhedronSphere() override; << 574 }; << 575 << 576 class HepPolyhedronTorus : public HepPolyhedro << 577 { << 578 public: << 579 HepPolyhedronTorus(G4double rmin, G4double r << 580 G4double phi, G4double dp << 581 ~HepPolyhedronTorus() override; << 582 }; << 583 << 584 class HepPolyhedronTet : public HepPolyhedron << 585 { << 586 public: << 587 HepPolyhedronTet(const G4double p0[3], << 588 const G4double p1[3], << 589 const G4double p2[3], << 590 const G4double p3[3]); << 591 ~HepPolyhedronTet() override; << 592 }; << 593 << 594 class HepPolyhedronEllipsoid : public HepPolyh << 595 { << 596 public: << 597 HepPolyhedronEllipsoid(G4double dx, G4double << 598 G4double zcut1, G4dou << 599 ~HepPolyhedronEllipsoid() override; << 600 }; << 601 << 602 class HepPolyhedronEllipticalCone : public Hep << 603 { << 604 public: << 605 HepPolyhedronEllipticalCone(G4double dx, G4d << 606 G4double zcut1); << 607 ~HepPolyhedronEllipticalCone() override; << 608 }; << 609 << 610 class HepPolyhedronHyperbolicMirror : public H << 611 { << 612 public: << 613 HepPolyhedronHyperbolicMirror(G4double a, G4 << 614 ~HepPolyhedronHyperbolicMirror() override; << 615 }; << 616 << 617 class HepPolyhedronTetMesh : public HepPolyhed << 618 { << 619 public: << 620 HepPolyhedronTetMesh(const std::vector<G4Thr << 621 ~HepPolyhedronTetMesh() override; << 622 }; << 623 << 624 class HepPolyhedronBoxMesh : public HepPolyhed << 625 { << 626 public: << 627 HepPolyhedronBoxMesh(G4double sizeX, G4doubl << 628 const std::vector<G4Thr << 629 ~HepPolyhedronBoxMesh() override; << 630 }; 463 }; 631 464 632 #endif /* HEP_POLYHEDRON_HH */ 465 #endif /* HEP_POLYHEDRON_HH */ 633 466