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