Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HepPolyhedron Class Reference

#include <HepPolyhedron.h>

Inheritance diagram for HepPolyhedron:
Collaboration diagram for HepPolyhedron:

Public Member Functions

 HepPolyhedron ()
 
 HepPolyhedron (const HepPolyhedron &from)
 
virtual ~HepPolyhedron ()
 
HepPolyhedronoperator= (const HepPolyhedron &from)
 
G4int GetNoVertices () const
 
G4int GetNoVerteces () const
 
G4int GetNoFacets () const
 
HepPolyhedronTransform (const G4Transform3D &t)
 
G4bool GetNextVertexIndex (G4int &index, G4int &edgeFlag) const
 
G4Point3D GetVertex (G4int index) const
 
G4bool GetNextVertex (G4Point3D &vertex, G4int &edgeFlag) const
 
G4bool GetNextVertex (G4Point3D &vertex, G4int &edgeFlag, G4Normal3D &normal) const
 
G4bool GetNextEdgeIndices (G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
 
G4bool GetNextEdgeIndeces (G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
 
G4bool GetNextEdgeIndices (G4int &i1, G4int &i2, G4int &edgeFlag) const
 
G4bool GetNextEdgeIndeces (G4int &i1, G4int &i2, G4int &edgeFlag) const
 
G4bool GetNextEdge (G4Point3D &p1, G4Point3D &p2, G4int &edgeFlag) const
 
G4bool GetNextEdge (G4Point3D &p1, G4Point3D &p2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
 
void GetFacet (G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
 
void GetFacet (G4int iFace, G4int &n, G4Point3D *nodes, G4int *edgeFlags=0, G4Normal3D *normals=0) const
 
G4bool GetNextFacet (G4int &n, G4Point3D *nodes, G4int *edgeFlags=0, G4Normal3D *normals=0) const
 
G4Normal3D GetNormal (G4int iFace) const
 
G4Normal3D GetUnitNormal (G4int iFace) const
 
G4bool GetNextNormal (G4Normal3D &normal) const
 
G4bool GetNextUnitNormal (G4Normal3D &normal) const
 
HepPolyhedron add (const HepPolyhedron &p) const
 
HepPolyhedron subtract (const HepPolyhedron &p) const
 
HepPolyhedron intersect (const HepPolyhedron &p) const
 
G4double GetSurfaceArea () const
 
G4double GetVolume () const
 
G4int createTwistedTrap (G4double Dz, const G4double xy1[][2], const G4double xy2[][2])
 
G4int createPolyhedron (G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
 

Static Public Member Functions

static G4int GetNumberOfRotationSteps ()
 
static void SetNumberOfRotationSteps (G4int n)
 
static void ResetNumberOfRotationSteps ()
 

Protected Member Functions

void AllocateMemory (G4int Nvert, G4int Nface)
 
G4int FindNeighbour (G4int iFace, G4int iNode, G4int iOrder) const
 
G4Normal3D FindNodeNormal (G4int iFace, G4int iNode) const
 
void CreatePrism ()
 
void RotateEdge (G4int k1, G4int k2, G4double r1, G4double r2, G4int v1, G4int v2, G4int vEdge, G4bool ifWholeCircle, G4int ns, G4int &kface)
 
void SetSideFacets (G4int ii[4], G4int vv[4], G4int *kk, G4double *r, G4double dphi, G4int ns, G4int &kface)
 
void RotateAroundZ (G4int nstep, G4double phi, G4double dphi, G4int np1, G4int np2, const G4double *z, G4double *r, G4int nodeVis, G4int edgeVis)
 
void SetReferences ()
 
void InvertFacets ()
 

Protected Attributes

G4int nvert
 
G4int nface
 
G4Point3DpV
 
G4FacetpF
 

Static Protected Attributes

static G4ThreadLocal G4int fNumberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS
 

Friends

std::ostream & operator<< (std::ostream &, const HepPolyhedron &ph)
 

Detailed Description

Definition at line 195 of file HepPolyhedron.h.

Constructor & Destructor Documentation

HepPolyhedron::HepPolyhedron ( )
inline

Definition at line 240 of file HepPolyhedron.h.

240 : nvert(0), nface(0), pV(0), pF(0) {}
G4Facet * pF
G4Point3D * pV
HepPolyhedron::HepPolyhedron ( const HepPolyhedron from)

Definition at line 108 of file HepPolyhedron.cc.

115 : nvert(0), nface(0), pV(0), pF(0)
116 {
117  AllocateMemory(from.nvert, from.nface);
118  for (G4int i=1; i<=nvert; i++) pV[i] = from.pV[i];
119  for (G4int k=1; k<=nface; k++) pF[k] = from.pF[k];
120 }
void AllocateMemory(G4int Nvert, G4int Nface)
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
for(G4int i1=0;i1< theStableOnes.GetNumberOfIsotopes(static_cast< G4int >(anE->GetZ()));i1++)

Here is the call graph for this function:

virtual HepPolyhedron::~HepPolyhedron ( )
inlinevirtual

Definition at line 246 of file HepPolyhedron.h.

246 { delete [] pV; delete [] pF; }
G4Facet * pF
G4Point3D * pV

Member Function Documentation

HepPolyhedron HepPolyhedron::add ( const HepPolyhedron p) const

Definition at line 2275 of file HepPolyhedron.cc.

2284 {
2285  G4int ierr;
2286  BooleanProcessor processor;
2287  return processor.execute(OP_UNION, *this, p,ierr);
2288 }
int G4int
Definition: G4Types.hh:78
#define processor
Definition: xmlparse.cc:617
void HepPolyhedron::AllocateMemory ( G4int  Nvert,
G4int  Nface 
)
protected

Definition at line 245 of file HepPolyhedron.cc.

257 {
258  if (nvert == Nvert && nface == Nface) return;
259  if (pV != 0) delete [] pV;
260  if (pF != 0) delete [] pF;
261  if (Nvert > 0 && Nface > 0) {
262  nvert = Nvert;
263  nface = Nface;
264  pV = new G4Point3D[nvert+1];
265  pF = new G4Facet[nface+1];
266  }else{
267  nvert = 0; nface = 0; pV = 0; pF = 0;
268  }
269 }
G4Facet * pF
G4Point3D * pV

Here is the caller graph for this function:

G4int HepPolyhedron::createPolyhedron ( G4int  Nnodes,
G4int  Nfaces,
const G4double  xyz[][3],
const G4int  faces[][4] 
)

Creates user defined polyhedron. This function allows to the user to define arbitrary polyhedron. The faces of the polyhedron should be either triangles or planar quadrilateral. Nodes of a face are defined by indexes pointing to the elements in the xyz array. Numeration of the elements in the array starts from 1 (like in fortran). The indexes can be positive or negative. Negative sign means that the corresponding edge is invisible. The normal of the face should be directed to exterior of the polyhedron.

Parameters
Nnodesnumber of nodes
Nfacesnumber of faces
xyznodes
facesfaces (quadrilaterals or triangles)
Returns
status of the operation - is non-zero in case of problem

Definition at line 1371 of file HepPolyhedron.cc.

1387 {
1388  AllocateMemory(Nnodes, Nfaces);
1389  if (nvert == 0) return 1;
1390 
1391  for (G4int i=0; i<Nnodes; i++) {
1392  pV[i+1] = G4Point3D(xyz[i][0], xyz[i][1], xyz[i][2]);
1393  }
1394  for (G4int k=0; k<Nfaces; k++) {
1395  pF[k+1] = G4Facet(faces[k][0],0,faces[k][1],0,faces[k][2],0,faces[k][3],0);
1396  }
1397  SetReferences();
1398  return 0;
1399 }
void AllocateMemory(G4int Nvert, G4int Nface)
G4Facet * pF
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
void SetReferences()

Here is the call graph for this function:

Here is the caller graph for this function:

void HepPolyhedron::CreatePrism ( )
protected

Definition at line 271 of file HepPolyhedron.cc.

280 {
281  enum {DUMMY, BOTTOM, LEFT, BACK, RIGHT, FRONT, TOP};
282 
283  pF[1] = G4Facet(1,LEFT, 4,BACK, 3,RIGHT, 2,FRONT);
284  pF[2] = G4Facet(5,TOP, 8,BACK, 4,BOTTOM, 1,FRONT);
285  pF[3] = G4Facet(8,TOP, 7,RIGHT, 3,BOTTOM, 4,LEFT);
286  pF[4] = G4Facet(7,TOP, 6,FRONT, 2,BOTTOM, 3,BACK);
287  pF[5] = G4Facet(6,TOP, 5,LEFT, 1,BOTTOM, 2,RIGHT);
288  pF[6] = G4Facet(5,FRONT, 6,RIGHT, 7,BACK, 8,LEFT);
289 }
G4Facet * pF

Here is the caller graph for this function:

G4int HepPolyhedron::createTwistedTrap ( G4double  Dz,
const G4double  xy1[][2],
const G4double  xy2[][2] 
)

Creates polyhedron for twisted trapezoid. The trapezoid is given by two bases perpendicular to the z-axis.

Parameters
Dzhalf length in z
xy11st base (at z = -Dz)
xy22nd base (at z = +Dz)
Returns
status of the operation - is non-zero in case of problem

Definition at line 1302 of file HepPolyhedron.cc.

1318 {
1319  AllocateMemory(12,18);
1320 
1321  pV[ 1] = G4Point3D(xy1[0][0],xy1[0][1],-Dz);
1322  pV[ 2] = G4Point3D(xy1[1][0],xy1[1][1],-Dz);
1323  pV[ 3] = G4Point3D(xy1[2][0],xy1[2][1],-Dz);
1324  pV[ 4] = G4Point3D(xy1[3][0],xy1[3][1],-Dz);
1325 
1326  pV[ 5] = G4Point3D(xy2[0][0],xy2[0][1], Dz);
1327  pV[ 6] = G4Point3D(xy2[1][0],xy2[1][1], Dz);
1328  pV[ 7] = G4Point3D(xy2[2][0],xy2[2][1], Dz);
1329  pV[ 8] = G4Point3D(xy2[3][0],xy2[3][1], Dz);
1330 
1331  pV[ 9] = (pV[1]+pV[2]+pV[5]+pV[6])/4.;
1332  pV[10] = (pV[2]+pV[3]+pV[6]+pV[7])/4.;
1333  pV[11] = (pV[3]+pV[4]+pV[7]+pV[8])/4.;
1334  pV[12] = (pV[4]+pV[1]+pV[8]+pV[5])/4.;
1335 
1336  enum {DUMMY, BOTTOM,
1337  LEFT_BOTTOM, LEFT_FRONT, LEFT_TOP, LEFT_BACK,
1338  BACK_BOTTOM, BACK_LEFT, BACK_TOP, BACK_RIGHT,
1339  RIGHT_BOTTOM, RIGHT_BACK, RIGHT_TOP, RIGHT_FRONT,
1340  FRONT_BOTTOM, FRONT_RIGHT, FRONT_TOP, FRONT_LEFT,
1341  TOP};
1342 
1343  pF[ 1]=G4Facet(1,LEFT_BOTTOM, 4,BACK_BOTTOM, 3,RIGHT_BOTTOM, 2,FRONT_BOTTOM);
1344 
1345  pF[ 2]=G4Facet(4,BOTTOM, -1,LEFT_FRONT, -12,LEFT_BACK, 0,0);
1346  pF[ 3]=G4Facet(1,FRONT_LEFT, -5,LEFT_TOP, -12,LEFT_BOTTOM, 0,0);
1347  pF[ 4]=G4Facet(5,TOP, -8,LEFT_BACK, -12,LEFT_FRONT, 0,0);
1348  pF[ 5]=G4Facet(8,BACK_LEFT, -4,LEFT_BOTTOM, -12,LEFT_TOP, 0,0);
1349 
1350  pF[ 6]=G4Facet(3,BOTTOM, -4,BACK_LEFT, -11,BACK_RIGHT, 0,0);
1351  pF[ 7]=G4Facet(4,LEFT_BACK, -8,BACK_TOP, -11,BACK_BOTTOM, 0,0);
1352  pF[ 8]=G4Facet(8,TOP, -7,BACK_RIGHT, -11,BACK_LEFT, 0,0);
1353  pF[ 9]=G4Facet(7,RIGHT_BACK, -3,BACK_BOTTOM, -11,BACK_TOP, 0,0);
1354 
1355  pF[10]=G4Facet(2,BOTTOM, -3,RIGHT_BACK, -10,RIGHT_FRONT, 0,0);
1356  pF[11]=G4Facet(3,BACK_RIGHT, -7,RIGHT_TOP, -10,RIGHT_BOTTOM, 0,0);
1357  pF[12]=G4Facet(7,TOP, -6,RIGHT_FRONT, -10,RIGHT_BACK, 0,0);
1358  pF[13]=G4Facet(6,FRONT_RIGHT,-2,RIGHT_BOTTOM,-10,RIGHT_TOP, 0,0);
1359 
1360  pF[14]=G4Facet(1,BOTTOM, -2,FRONT_RIGHT, -9,FRONT_LEFT, 0,0);
1361  pF[15]=G4Facet(2,RIGHT_FRONT,-6,FRONT_TOP, -9,FRONT_BOTTOM, 0,0);
1362  pF[16]=G4Facet(6,TOP, -5,FRONT_LEFT, -9,FRONT_RIGHT, 0,0);
1363  pF[17]=G4Facet(5,LEFT_FRONT, -1,FRONT_BOTTOM, -9,FRONT_TOP, 0,0);
1364 
1365  pF[18]=G4Facet(5,FRONT_TOP, 6,RIGHT_TOP, 7,BACK_TOP, 8,LEFT_TOP);
1366 
1367  return 0;
1368 }
void AllocateMemory(G4int Nvert, G4int Nface)
G4Facet * pF
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
G4Point3D * pV

Here is the call graph for this function:

G4int HepPolyhedron::FindNeighbour ( G4int  iFace,
G4int  iNode,
G4int  iOrder 
) const
protected

Definition at line 141 of file HepPolyhedron.cc.

150 {
151  G4int i;
152  for (i=0; i<4; i++) {
153  if (iNode == std::abs(pF[iFace].edge[i].v)) break;
154  }
155  if (i == 4) {
156  std::cerr
157  << "HepPolyhedron::FindNeighbour: face " << iFace
158  << " has no node " << iNode
159  << std::endl;
160  return 0;
161  }
162  if (iOrder < 0) {
163  if ( --i < 0) i = 3;
164  if (pF[iFace].edge[i].v == 0) i = 2;
165  }
166  return (pF[iFace].edge[i].v > 0) ? 0 : pF[iFace].edge[i].f;
167 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
tuple v
Definition: test.py:18
G4Normal3D HepPolyhedron::FindNodeNormal ( G4int  iFace,
G4int  iNode 
) const
protected

Definition at line 169 of file HepPolyhedron.cc.

178 {
180  G4int k = iFace, iOrder = 1, n = 1;
181 
182  for(;;) {
183  k = FindNeighbour(k, iNode, iOrder);
184  if (k == iFace) break;
185  if (k > 0) {
186  n++;
187  normal += GetUnitNormal(k);
188  }else{
189  if (iOrder < 0) break;
190  k = iFace;
191  iOrder = -iOrder;
192  }
193  }
194  return normal.unit();
195 }
G4Normal3D GetUnitNormal(G4int iFace) const
BasicVector3D< T > unit() const
int G4int
Definition: G4Types.hh:78
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:77
G4int FindNeighbour(G4int iFace, G4int iNode, G4int iOrder) const
const G4int n

Here is the call graph for this function:

void HepPolyhedron::GetFacet ( G4int  iFace,
G4int n,
G4int iNodes,
G4int edgeFlags = 0,
G4int iFaces = 0 
) const

Definition at line 1078 of file HepPolyhedron.cc.

1088 {
1089  if (iFace < 1 || iFace > nface) {
1090  std::cerr
1091  << "HepPolyhedron::GetFacet: irrelevant index " << iFace
1092  << std::endl;
1093  n = 0;
1094  }else{
1095  G4int i, k;
1096  for (i=0; i<4; i++) {
1097  k = pF[iFace].edge[i].v;
1098  if (k == 0) break;
1099  if (iFaces != 0) iFaces[i] = pF[iFace].edge[i].f;
1100  if (k > 0) {
1101  iNodes[i] = k;
1102  if (edgeFlags != 0) edgeFlags[i] = 1;
1103  }else{
1104  iNodes[i] = -k;
1105  if (edgeFlags != 0) edgeFlags[i] = -1;
1106  }
1107  }
1108  n = i;
1109  }
1110 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
const G4int n

Here is the caller graph for this function:

void HepPolyhedron::GetFacet ( G4int  iFace,
G4int n,
G4Point3D nodes,
G4int edgeFlags = 0,
G4Normal3D normals = 0 
) const

Definition at line 1112 of file HepPolyhedron.cc.

1122 {
1123  G4int iNodes[4];
1124  GetFacet(index, n, iNodes, edgeFlags);
1125  if (n != 0) {
1126  for (G4int i=0; i<n; i++) {
1127  nodes[i] = pV[iNodes[i]];
1128  if (normals != 0) normals[i] = FindNodeNormal(index,iNodes[i]);
1129  }
1130  }
1131 }
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
G4Normal3D FindNodeNormal(G4int iFace, G4int iNode) const
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
const G4int n
G4bool HepPolyhedron::GetNextEdge ( G4Point3D p1,
G4Point3D p2,
G4int edgeFlag 
) const

Definition at line 1037 of file HepPolyhedron.cc.

1049 {
1050  G4int i1,i2;
1051  G4bool rep = GetNextEdgeIndices(i1,i2,edgeFlag);
1052  p1 = pV[i1];
1053  p2 = pV[i2];
1054  return rep;
1055 }
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4Point3D * pV
G4bool GetNextEdgeIndices(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const

Here is the caller graph for this function:

G4bool HepPolyhedron::GetNextEdge ( G4Point3D p1,
G4Point3D p2,
G4int edgeFlag,
G4int iface1,
G4int iface2 
) const

Definition at line 1058 of file HepPolyhedron.cc.

1070 {
1071  G4int i1,i2;
1072  G4bool rep = GetNextEdgeIndices(i1,i2,edgeFlag,iface1,iface2);
1073  p1 = pV[i1];
1074  p2 = pV[i2];
1075  return rep;
1076 }
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4Point3D * pV
G4bool GetNextEdgeIndices(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
G4bool HepPolyhedron::GetNextEdgeIndeces ( G4int i1,
G4int i2,
G4int edgeFlag,
G4int iface1,
G4int iface2 
) const
inline

Definition at line 277 of file HepPolyhedron.h.

279  {return GetNextEdgeIndices(i1,i2,edgeFlag,iface1,iface2);} // Old spelling
G4bool GetNextEdgeIndices(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const

Here is the call graph for this function:

G4bool HepPolyhedron::GetNextEdgeIndeces ( G4int i1,
G4int i2,
G4int edgeFlag 
) const
inline

Definition at line 283 of file HepPolyhedron.h.

284  {return GetNextEdgeIndices(i1,i2,edgeFlag);} // Old spelling.
G4bool GetNextEdgeIndices(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const

Here is the call graph for this function:

G4bool HepPolyhedron::GetNextEdgeIndices ( G4int i1,
G4int i2,
G4int edgeFlag,
G4int iface1,
G4int iface2 
) const

Definition at line 968 of file HepPolyhedron.cc.

980 {
981  static G4ThreadLocal G4int iFace = 1;
982  static G4ThreadLocal G4int iQVertex = 0;
983  static G4ThreadLocal G4int iOrder = 1;
984  G4int k1, k2, kflag, kface1, kface2;
985 
986  if (iFace == 1 && iQVertex == 0) {
987  k2 = pF[nface].edge[0].v;
988  k1 = pF[nface].edge[3].v;
989  if (k1 == 0) k1 = pF[nface].edge[2].v;
990  if (std::abs(k1) > std::abs(k2)) iOrder = -1;
991  }
992 
993  do {
994  k1 = pF[iFace].edge[iQVertex].v;
995  kflag = k1;
996  k1 = std::abs(k1);
997  kface1 = iFace;
998  kface2 = pF[iFace].edge[iQVertex].f;
999  if (iQVertex >= 3 || pF[iFace].edge[iQVertex+1].v == 0) {
1000  iQVertex = 0;
1001  k2 = std::abs(pF[iFace].edge[iQVertex].v);
1002  iFace++;
1003  }else{
1004  iQVertex++;
1005  k2 = std::abs(pF[iFace].edge[iQVertex].v);
1006  }
1007  } while (iOrder*k1 > iOrder*k2);
1008 
1009  i1 = k1; i2 = k2; edgeFlag = (kflag > 0) ? 1 : 0;
1010  iface1 = kface1; iface2 = kface2;
1011 
1012  if (iFace > nface) {
1013  iFace = 1; iOrder = 1;
1014  return false;
1015  }else{
1016  return true;
1017  }
1018 }
G4Facet * pF
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
tuple v
Definition: test.py:18

Here is the caller graph for this function:

G4bool HepPolyhedron::GetNextEdgeIndices ( G4int i1,
G4int i2,
G4int edgeFlag 
) const

Definition at line 1021 of file HepPolyhedron.cc.

1031 {
1032  G4int kface1, kface2;
1033  return GetNextEdgeIndices(i1, i2, edgeFlag, kface1, kface2);
1034 }
int G4int
Definition: G4Types.hh:78
G4bool GetNextEdgeIndices(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
G4bool HepPolyhedron::GetNextFacet ( G4int n,
G4Point3D nodes,
G4int edgeFlags = 0,
G4Normal3D normals = 0 
) const

Definition at line 1134 of file HepPolyhedron.cc.

1145 {
1146  static G4ThreadLocal G4int iFace = 1;
1147 
1148  if (edgeFlags == 0) {
1149  GetFacet(iFace, n, nodes);
1150  }else if (normals == 0) {
1151  GetFacet(iFace, n, nodes, edgeFlags);
1152  }else{
1153  GetFacet(iFace, n, nodes, edgeFlags, normals);
1154  }
1155 
1156  if (++iFace > nface) {
1157  iFace = 1;
1158  return false;
1159  }else{
1160  return true;
1161  }
1162 }
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
const G4int n
G4bool HepPolyhedron::GetNextNormal ( G4Normal3D normal) const

Definition at line 1214 of file HepPolyhedron.cc.

1224 {
1225  static G4ThreadLocal G4int iFace = 1;
1226  normal = GetNormal(iFace);
1227  if (++iFace > nface) {
1228  iFace = 1;
1229  return false;
1230  }else{
1231  return true;
1232  }
1233 }
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
G4Normal3D GetNormal(G4int iFace) const

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool HepPolyhedron::GetNextUnitNormal ( G4Normal3D normal) const

Definition at line 1235 of file HepPolyhedron.cc.

1245 {
1246  G4bool rep = GetNextNormal(normal);
1247  normal = normal.unit();
1248  return rep;
1249 }
G4bool GetNextNormal(G4Normal3D &normal) const
BasicVector3D< T > unit() const
bool G4bool
Definition: G4Types.hh:79

Here is the call graph for this function:

G4bool HepPolyhedron::GetNextVertex ( G4Point3D vertex,
G4int edgeFlag 
) const

Definition at line 918 of file HepPolyhedron.cc.

929 {
930  G4int index;
931  G4bool rep = GetNextVertexIndex(index, edgeFlag);
932  vertex = pV[index];
933  return rep;
934 }
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4Point3D * pV
G4bool GetNextVertexIndex(G4int &index, G4int &edgeFlag) const

Here is the caller graph for this function:

G4bool HepPolyhedron::GetNextVertex ( G4Point3D vertex,
G4int edgeFlag,
G4Normal3D normal 
) const

Definition at line 936 of file HepPolyhedron.cc.

948 {
949  static G4ThreadLocal G4int iFace = 1;
950  static G4ThreadLocal G4int iNode = 0;
951 
952  if (nface == 0) return false; // empty polyhedron
953 
954  G4int k = pF[iFace].edge[iNode].v;
955  if (k > 0) { edgeFlag = 1; } else { edgeFlag = -1; k = -k; }
956  vertex = pV[k];
957  normal = FindNodeNormal(iFace,k);
958  if (iNode >= 3 || pF[iFace].edge[iNode+1].v == 0) {
959  iNode = 0;
960  if (++iFace > nface) iFace = 1;
961  return false; // last node
962  }else{
963  ++iNode;
964  return true; // not last node
965  }
966 }
G4Facet * pF
G4Normal3D FindNodeNormal(G4int iFace, G4int iNode) const
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
tuple v
Definition: test.py:18

Here is the call graph for this function:

G4bool HepPolyhedron::GetNextVertexIndex ( G4int index,
G4int edgeFlag 
) const

Definition at line 871 of file HepPolyhedron.cc.

880 {
881  static G4ThreadLocal G4int iFace = 1;
882  static G4ThreadLocal G4int iQVertex = 0;
883  G4int vIndex = pF[iFace].edge[iQVertex].v;
884 
885  edgeFlag = (vIndex > 0) ? 1 : 0;
886  index = std::abs(vIndex);
887 
888  if (iQVertex >= 3 || pF[iFace].edge[iQVertex+1].v == 0) {
889  iQVertex = 0;
890  if (++iFace > nface) iFace = 1;
891  return false; // Last Edge
892  }else{
893  ++iQVertex;
894  return true; // not Last Edge
895  }
896 }
G4Facet * pF
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
tuple v
Definition: test.py:18

Here is the caller graph for this function:

G4int HepPolyhedron::GetNoFacets ( ) const
inline

Definition at line 256 of file HepPolyhedron.h.

256 { return nface; }

Here is the caller graph for this function:

G4Normal3D HepPolyhedron::GetNormal ( G4int  iFace) const

Definition at line 1164 of file HepPolyhedron.cc.

1173 {
1174  if (iFace < 1 || iFace > nface) {
1175  std::cerr
1176  << "HepPolyhedron::GetNormal: irrelevant index " << iFace
1177  << std::endl;
1178  return G4Normal3D();
1179  }
1180 
1181  G4int i0 = std::abs(pF[iFace].edge[0].v);
1182  G4int i1 = std::abs(pF[iFace].edge[1].v);
1183  G4int i2 = std::abs(pF[iFace].edge[2].v);
1184  G4int i3 = std::abs(pF[iFace].edge[3].v);
1185  if (i3 == 0) i3 = i0;
1186  return (pV[i2] - pV[i0]).cross(pV[i3] - pV[i1]);
1187 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
tuple v
Definition: test.py:18
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:35
G4int HepPolyhedron::GetNoVerteces ( ) const
inline

Definition at line 253 of file HepPolyhedron.h.

253 { return nvert; } // Old spelling.
G4int HepPolyhedron::GetNoVertices ( ) const
inline

Definition at line 252 of file HepPolyhedron.h.

252 { return nvert; }

Here is the caller graph for this function:

G4int HepPolyhedron::GetNumberOfRotationSteps ( )
static

Definition at line 197 of file HepPolyhedron.cc.

206 {
207  return fNumberOfRotationSteps;
208 }
static G4ThreadLocal G4int fNumberOfRotationSteps

Here is the caller graph for this function:

G4double HepPolyhedron::GetSurfaceArea ( ) const

Definition at line 1251 of file HepPolyhedron.cc.

1260 {
1261  G4double srf = 0.;
1262  for (G4int iFace=1; iFace<=nface; iFace++) {
1263  G4int i0 = std::abs(pF[iFace].edge[0].v);
1264  G4int i1 = std::abs(pF[iFace].edge[1].v);
1265  G4int i2 = std::abs(pF[iFace].edge[2].v);
1266  G4int i3 = std::abs(pF[iFace].edge[3].v);
1267  if (i3 == 0) i3 = i0;
1268  srf += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).mag();
1269  }
1270  return srf/2.;
1271 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
tuple v
Definition: test.py:18
double G4double
Definition: G4Types.hh:76
G4Normal3D HepPolyhedron::GetUnitNormal ( G4int  iFace) const

Definition at line 1189 of file HepPolyhedron.cc.

1198 {
1199  if (iFace < 1 || iFace > nface) {
1200  std::cerr
1201  << "HepPolyhedron::GetUnitNormal: irrelevant index " << iFace
1202  << std::endl;
1203  return G4Normal3D();
1204  }
1205 
1206  G4int i0 = std::abs(pF[iFace].edge[0].v);
1207  G4int i1 = std::abs(pF[iFace].edge[1].v);
1208  G4int i2 = std::abs(pF[iFace].edge[2].v);
1209  G4int i3 = std::abs(pF[iFace].edge[3].v);
1210  if (i3 == 0) i3 = i0;
1211  return ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).unit();
1212 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
tuple v
Definition: test.py:18
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:35
G4Point3D HepPolyhedron::GetVertex ( G4int  index) const

Definition at line 898 of file HepPolyhedron.cc.

907 {
908  if (index <= 0 || index > nvert) {
909  std::cerr
910  << "HepPolyhedron::GetVertex: irrelevant index " << index
911  << std::endl;
912  return G4Point3D();
913  }
914  return pV[index];
915 }
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
G4Point3D * pV

Here is the caller graph for this function:

G4double HepPolyhedron::GetVolume ( ) const

Definition at line 1273 of file HepPolyhedron.cc.

1282 {
1283  G4double v = 0.;
1284  for (G4int iFace=1; iFace<=nface; iFace++) {
1285  G4int i0 = std::abs(pF[iFace].edge[0].v);
1286  G4int i1 = std::abs(pF[iFace].edge[1].v);
1287  G4int i2 = std::abs(pF[iFace].edge[2].v);
1288  G4int i3 = std::abs(pF[iFace].edge[3].v);
1289  G4Point3D pt;
1290  if (i3 == 0) {
1291  i3 = i0;
1292  pt = (pV[i0]+pV[i1]+pV[i2]) * (1./3.);
1293  }else{
1294  pt = (pV[i0]+pV[i1]+pV[i2]+pV[i3]) * 0.25;
1295  }
1296  v += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).dot(pt);
1297  }
1298  return v/6.;
1299 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
tuple v
Definition: test.py:18
double G4double
Definition: G4Types.hh:76
HepPolyhedron HepPolyhedron::intersect ( const HepPolyhedron p) const

Definition at line 2290 of file HepPolyhedron.cc.

2299 {
2300  G4int ierr;
2301  BooleanProcessor processor;
2302  return processor.execute(OP_INTERSECTION, *this, p,ierr);
2303 }
int G4int
Definition: G4Types.hh:78
#define processor
Definition: xmlparse.cc:617
void HepPolyhedron::InvertFacets ( )
protected

Definition at line 820 of file HepPolyhedron.cc.

829 {
830  if (nface <= 0) return;
831  G4int i, k, nnode, v[4],f[4];
832  for (i=1; i<=nface; i++) {
833  nnode = (pF[i].edge[3].v == 0) ? 3 : 4;
834  for (k=0; k<nnode; k++) {
835  v[k] = (k+1 == nnode) ? pF[i].edge[0].v : pF[i].edge[k+1].v;
836  if (v[k] * pF[i].edge[k].v < 0) v[k] = -v[k];
837  f[k] = pF[i].edge[k].f;
838  }
839  for (k=0; k<nnode; k++) {
840  pF[i].edge[nnode-1-k].v = v[k];
841  pF[i].edge[nnode-1-k].f = f[k];
842  }
843  }
844 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
tuple v
Definition: test.py:18

Here is the caller graph for this function:

HepPolyhedron & HepPolyhedron::operator= ( const HepPolyhedron from)

Definition at line 122 of file HepPolyhedron.cc.

131 {
132  if (this != &from) {
133  AllocateMemory(from.nvert, from.nface);
134  for (G4int i=1; i<=nvert; i++) pV[i] = from.pV[i];
135  for (G4int k=1; k<=nface; k++) pF[k] = from.pF[k];
136  }
137  return *this;
138 }
void AllocateMemory(G4int Nvert, G4int Nface)
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
for(G4int i1=0;i1< theStableOnes.GetNumberOfIsotopes(static_cast< G4int >(anE->GetZ()));i1++)

Here is the call graph for this function:

void HepPolyhedron::ResetNumberOfRotationSteps ( )
static

Definition at line 232 of file HepPolyhedron.cc.

241 {
243 }
#define DEFAULT_NUMBER_OF_STEPS
static G4ThreadLocal G4int fNumberOfRotationSteps

Here is the caller graph for this function:

void HepPolyhedron::RotateAroundZ ( G4int  nstep,
G4double  phi,
G4double  dphi,
G4int  np1,
G4int  np2,
const G4double z,
G4double r,
G4int  nodeVis,
G4int  edgeVis 
)
protected

Definition at line 424 of file HepPolyhedron.cc.

449 {
450  static const G4double wholeCircle = twopi;
451 
452  // S E T R O T A T I O N P A R A M E T E R S
453 
454  G4bool ifWholeCircle = (std::abs(dphi-wholeCircle) < perMillion) ? true : false;
455  G4double delPhi = ifWholeCircle ? wholeCircle : dphi;
456  G4int nSphi = (nstep > 0) ?
457  nstep : G4int(delPhi*GetNumberOfRotationSteps()/wholeCircle+.5);
458  if (nSphi == 0) nSphi = 1;
459  G4int nVphi = ifWholeCircle ? nSphi : nSphi+1;
460  G4bool ifClosed = np1 > 0 ? false : true;
461 
462  // C O U N T V E R T E C E S
463 
464  G4int absNp1 = std::abs(np1);
465  G4int absNp2 = std::abs(np2);
466  G4int i1beg = 0;
467  G4int i1end = absNp1-1;
468  G4int i2beg = absNp1;
469  G4int i2end = absNp1+absNp2-1;
470  G4int i, j, k;
471 
472  for(i=i1beg; i<=i2end; i++) {
473  if (std::abs(r[i]) < spatialTolerance) r[i] = 0.;
474  }
475 
476  j = 0; // external nodes
477  for (i=i1beg; i<=i1end; i++) {
478  j += (r[i] == 0.) ? 1 : nVphi;
479  }
480 
481  G4bool ifSide1 = false; // internal nodes
482  G4bool ifSide2 = false;
483 
484  if (r[i2beg] != r[i1beg] || z[i2beg] != z[i1beg]) {
485  j += (r[i2beg] == 0.) ? 1 : nVphi;
486  ifSide1 = true;
487  }
488 
489  for(i=i2beg+1; i<i2end; i++) {
490  j += (r[i] == 0.) ? 1 : nVphi;
491  }
492 
493  if (r[i2end] != r[i1end] || z[i2end] != z[i1end]) {
494  if (absNp2 > 1) j += (r[i2end] == 0.) ? 1 : nVphi;
495  ifSide2 = true;
496  }
497 
498  // C O U N T F A C E S
499 
500  k = ifClosed ? absNp1*nSphi : (absNp1-1)*nSphi; // external faces
501 
502  if (absNp2 > 1) { // internal faces
503  for(i=i2beg; i<i2end; i++) {
504  if (r[i] > 0. || r[i+1] > 0.) k += nSphi;
505  }
506 
507  if (ifClosed) {
508  if (r[i2end] > 0. || r[i2beg] > 0.) k += nSphi;
509  }
510  }
511 
512  if (!ifClosed) { // side faces
513  if (ifSide1 && (r[i1beg] > 0. || r[i2beg] > 0.)) k += nSphi;
514  if (ifSide2 && (r[i1end] > 0. || r[i2end] > 0.)) k += nSphi;
515  }
516 
517  if (!ifWholeCircle) { // phi_side faces
518  k += ifClosed ? 2*absNp1 : 2*(absNp1-1);
519  }
520 
521  // A L L O C A T E M E M O R Y
522 
523  AllocateMemory(j, k);
524 
525  // G E N E R A T E V E R T E C E S
526 
527  G4int *kk;
528  kk = new G4int[absNp1+absNp2];
529 
530  k = 1;
531  for(i=i1beg; i<=i1end; i++) {
532  kk[i] = k;
533  if (r[i] == 0.)
534  { pV[k++] = G4Point3D(0, 0, z[i]); } else { k += nVphi; }
535  }
536 
537  i = i2beg;
538  if (ifSide1) {
539  kk[i] = k;
540  if (r[i] == 0.)
541  { pV[k++] = G4Point3D(0, 0, z[i]); } else { k += nVphi; }
542  }else{
543  kk[i] = kk[i1beg];
544  }
545 
546  for(i=i2beg+1; i<i2end; i++) {
547  kk[i] = k;
548  if (r[i] == 0.)
549  { pV[k++] = G4Point3D(0, 0, z[i]); } else { k += nVphi; }
550  }
551 
552  if (absNp2 > 1) {
553  i = i2end;
554  if (ifSide2) {
555  kk[i] = k;
556  if (r[i] == 0.) pV[k] = G4Point3D(0, 0, z[i]);
557  }else{
558  kk[i] = kk[i1end];
559  }
560  }
561 
562  G4double cosPhi, sinPhi;
563 
564  for(j=0; j<nVphi; j++) {
565  cosPhi = std::cos(phi+j*delPhi/nSphi);
566  sinPhi = std::sin(phi+j*delPhi/nSphi);
567  for(i=i1beg; i<=i2end; i++) {
568  if (r[i] != 0.)
569  pV[kk[i]+j] = G4Point3D(r[i]*cosPhi,r[i]*sinPhi,z[i]);
570  }
571  }
572 
573  // G E N E R A T E E X T E R N A L F A C E S
574 
575  G4int v1,v2;
576 
577  k = 1;
578  v2 = ifClosed ? nodeVis : 1;
579  for(i=i1beg; i<i1end; i++) {
580  v1 = v2;
581  if (!ifClosed && i == i1end-1) {
582  v2 = 1;
583  }else{
584  v2 = (r[i] == r[i+1] && r[i+1] == r[i+2]) ? -1 : nodeVis;
585  }
586  RotateEdge(kk[i], kk[i+1], r[i], r[i+1], v1, v2,
587  edgeVis, ifWholeCircle, nSphi, k);
588  }
589  if (ifClosed) {
590  RotateEdge(kk[i1end], kk[i1beg], r[i1end],r[i1beg], nodeVis, nodeVis,
591  edgeVis, ifWholeCircle, nSphi, k);
592  }
593 
594  // G E N E R A T E I N T E R N A L F A C E S
595 
596  if (absNp2 > 1) {
597  v2 = ifClosed ? nodeVis : 1;
598  for(i=i2beg; i<i2end; i++) {
599  v1 = v2;
600  if (!ifClosed && i==i2end-1) {
601  v2 = 1;
602  }else{
603  v2 = (r[i] == r[i+1] && r[i+1] == r[i+2]) ? -1 : nodeVis;
604  }
605  RotateEdge(kk[i+1], kk[i], r[i+1], r[i], v2, v1,
606  edgeVis, ifWholeCircle, nSphi, k);
607  }
608  if (ifClosed) {
609  RotateEdge(kk[i2beg], kk[i2end], r[i2beg], r[i2end], nodeVis, nodeVis,
610  edgeVis, ifWholeCircle, nSphi, k);
611  }
612  }
613 
614  // G E N E R A T E S I D E F A C E S
615 
616  if (!ifClosed) {
617  if (ifSide1) {
618  RotateEdge(kk[i2beg], kk[i1beg], r[i2beg], r[i1beg], 1, 1,
619  -1, ifWholeCircle, nSphi, k);
620  }
621  if (ifSide2) {
622  RotateEdge(kk[i1end], kk[i2end], r[i1end], r[i2end], 1, 1,
623  -1, ifWholeCircle, nSphi, k);
624  }
625  }
626 
627  // G E N E R A T E S I D E F A C E S for the case of incomplete circle
628 
629  if (!ifWholeCircle) {
630 
631  G4int ii[4], vv[4];
632 
633  if (ifClosed) {
634  for (i=i1beg; i<=i1end; i++) {
635  ii[0] = i;
636  ii[3] = (i == i1end) ? i1beg : i+1;
637  ii[1] = (absNp2 == 1) ? i2beg : ii[0]+absNp1;
638  ii[2] = (absNp2 == 1) ? i2beg : ii[3]+absNp1;
639  vv[0] = -1;
640  vv[1] = 1;
641  vv[2] = -1;
642  vv[3] = 1;
643  SetSideFacets(ii, vv, kk, r, dphi, nSphi, k);
644  }
645  }else{
646  for (i=i1beg; i<i1end; i++) {
647  ii[0] = i;
648  ii[3] = i+1;
649  ii[1] = (absNp2 == 1) ? i2beg : ii[0]+absNp1;
650  ii[2] = (absNp2 == 1) ? i2beg : ii[3]+absNp1;
651  vv[0] = (i == i1beg) ? 1 : -1;
652  vv[1] = 1;
653  vv[2] = (i == i1end-1) ? 1 : -1;
654  vv[3] = 1;
655  SetSideFacets(ii, vv, kk, r, dphi, nSphi, k);
656  }
657  }
658  }
659 
660  delete [] kk;
661 
662  if (k-1 != nface) {
663  std::cerr
664  << "Polyhedron::RotateAroundZ: number of generated faces ("
665  << k-1 << ") is not equal to the number of allocated faces ("
666  << nface << ")"
667  << std::endl;
668  }
669 }
static constexpr double perMillion
Definition: G4SIunits.hh:334
void AllocateMemory(G4int Nvert, G4int Nface)
const G4double spatialTolerance
void SetSideFacets(G4int ii[4], G4int vv[4], G4int *kk, G4double *r, G4double dphi, G4int ns, G4int &kface)
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
int G4int
Definition: G4Types.hh:78
static constexpr double twopi
Definition: G4SIunits.hh:76
bool G4bool
Definition: G4Types.hh:79
G4Point3D * pV
static G4int GetNumberOfRotationSteps()
tuple z
Definition: test.py:28
void RotateEdge(G4int k1, G4int k2, G4double r1, G4double r2, G4int v1, G4int v2, G4int vEdge, G4bool ifWholeCircle, G4int ns, G4int &kface)
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

void HepPolyhedron::RotateEdge ( G4int  k1,
G4int  k2,
G4double  r1,
G4double  r2,
G4int  v1,
G4int  v2,
G4int  vEdge,
G4bool  ifWholeCircle,
G4int  ns,
G4int kface 
)
protected

Definition at line 291 of file HepPolyhedron.cc.

312 {
313  if (r1 == 0. && r2 == 0) return;
314 
315  G4int i;
316  G4int i1 = k1;
317  G4int i2 = k2;
318  G4int ii1 = ifWholeCircle ? i1 : i1+nds;
319  G4int ii2 = ifWholeCircle ? i2 : i2+nds;
320  G4int vv = ifWholeCircle ? vEdge : 1;
321 
322  if (nds == 1) {
323  if (r1 == 0.) {
324  pF[kface++] = G4Facet(i1,0, v2*i2,0, (i2+1),0);
325  }else if (r2 == 0.) {
326  pF[kface++] = G4Facet(i1,0, i2,0, v1*(i1+1),0);
327  }else{
328  pF[kface++] = G4Facet(i1,0, v2*i2,0, (i2+1),0, v1*(i1+1),0);
329  }
330  }else{
331  if (r1 == 0.) {
332  pF[kface++] = G4Facet(vv*i1,0, v2*i2,0, vEdge*(i2+1),0);
333  for (i2++,i=1; i<nds-1; i2++,i++) {
334  pF[kface++] = G4Facet(vEdge*i1,0, v2*i2,0, vEdge*(i2+1),0);
335  }
336  pF[kface++] = G4Facet(vEdge*i1,0, v2*i2,0, vv*ii2,0);
337  }else if (r2 == 0.) {
338  pF[kface++] = G4Facet(vv*i1,0, vEdge*i2,0, v1*(i1+1),0);
339  for (i1++,i=1; i<nds-1; i1++,i++) {
340  pF[kface++] = G4Facet(vEdge*i1,0, vEdge*i2,0, v1*(i1+1),0);
341  }
342  pF[kface++] = G4Facet(vEdge*i1,0, vv*i2,0, v1*ii1,0);
343  }else{
344  pF[kface++] = G4Facet(vv*i1,0, v2*i2,0, vEdge*(i2+1),0,v1*(i1+1),0);
345  for (i1++,i2++,i=1; i<nds-1; i1++,i2++,i++) {
346  pF[kface++] = G4Facet(vEdge*i1,0, v2*i2,0, vEdge*(i2+1),0,v1*(i1+1),0);
347  }
348  pF[kface++] = G4Facet(vEdge*i1,0, v2*i2,0, vv*ii2,0, v1*ii1,0);
349  }
350  }
351 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78

Here is the caller graph for this function:

void HepPolyhedron::SetNumberOfRotationSteps ( G4int  n)
static

Definition at line 210 of file HepPolyhedron.cc.

219 {
220  const G4int nMin = 3;
221  if (n < nMin) {
222  std::cerr
223  << "HepPolyhedron::SetNumberOfRotationSteps: attempt to set the\n"
224  << "number of steps per circle < " << nMin << "; forced to " << nMin
225  << std::endl;
226  fNumberOfRotationSteps = nMin;
227  }else{
229  }
230 }
int G4int
Definition: G4Types.hh:78
static G4ThreadLocal G4int fNumberOfRotationSteps
const G4int n

Here is the caller graph for this function:

void HepPolyhedron::SetReferences ( )
protected

Definition at line 671 of file HepPolyhedron.cc.

680 {
681  if (nface <= 0) return;
682 
683  struct edgeListMember {
684  edgeListMember *next;
685  G4int v2;
686  G4int iface;
687  G4int iedge;
688  } *edgeList, *freeList, **headList;
689 
690 
691  // A L L O C A T E A N D I N I T I A T E L I S T S
692 
693  edgeList = new edgeListMember[2*nface];
694  headList = new edgeListMember*[nvert];
695 
696  G4int i;
697  for (i=0; i<nvert; i++) {
698  headList[i] = 0;
699  }
700  freeList = edgeList;
701  for (i=0; i<2*nface-1; i++) {
702  edgeList[i].next = &edgeList[i+1];
703  }
704  edgeList[2*nface-1].next = 0;
705 
706  // L O O P A L O N G E D G E S
707 
708  G4int iface, iedge, nedge, i1, i2, k1, k2;
709  edgeListMember *prev, *cur;
710 
711  for(iface=1; iface<=nface; iface++) {
712  nedge = (pF[iface].edge[3].v == 0) ? 3 : 4;
713  for (iedge=0; iedge<nedge; iedge++) {
714  i1 = iedge;
715  i2 = (iedge < nedge-1) ? iedge+1 : 0;
716  i1 = std::abs(pF[iface].edge[i1].v);
717  i2 = std::abs(pF[iface].edge[i2].v);
718  k1 = (i1 < i2) ? i1 : i2; // k1 = ::min(i1,i2);
719  k2 = (i1 > i2) ? i1 : i2; // k2 = ::max(i1,i2);
720 
721  // check head of the List corresponding to k1
722  cur = headList[k1];
723  if (cur == 0) {
724  headList[k1] = freeList;
725  if (!freeList) {
726  std::cerr
727  << "Polyhedron::SetReferences: bad link "
728  << std::endl;
729  break;
730  }
731  freeList = freeList->next;
732  cur = headList[k1];
733  cur->next = 0;
734  cur->v2 = k2;
735  cur->iface = iface;
736  cur->iedge = iedge;
737  continue;
738  }
739 
740  if (cur->v2 == k2) {
741  headList[k1] = cur->next;
742  cur->next = freeList;
743  freeList = cur;
744  pF[iface].edge[iedge].f = cur->iface;
745  pF[cur->iface].edge[cur->iedge].f = iface;
746  i1 = (pF[iface].edge[iedge].v < 0) ? -1 : 1;
747  i2 = (pF[cur->iface].edge[cur->iedge].v < 0) ? -1 : 1;
748  if (i1 != i2) {
749  std::cerr
750  << "Polyhedron::SetReferences: different edge visibility "
751  << iface << "/" << iedge << "/"
752  << pF[iface].edge[iedge].v << " and "
753  << cur->iface << "/" << cur->iedge << "/"
754  << pF[cur->iface].edge[cur->iedge].v
755  << std::endl;
756  }
757  continue;
758  }
759 
760  // check List itself
761  for (;;) {
762  prev = cur;
763  cur = prev->next;
764  if (cur == 0) {
765  prev->next = freeList;
766  if (!freeList) {
767  std::cerr
768  << "Polyhedron::SetReferences: bad link "
769  << std::endl;
770  break;
771  }
772  freeList = freeList->next;
773  cur = prev->next;
774  cur->next = 0;
775  cur->v2 = k2;
776  cur->iface = iface;
777  cur->iedge = iedge;
778  break;
779  }
780 
781  if (cur->v2 == k2) {
782  prev->next = cur->next;
783  cur->next = freeList;
784  freeList = cur;
785  pF[iface].edge[iedge].f = cur->iface;
786  pF[cur->iface].edge[cur->iedge].f = iface;
787  i1 = (pF[iface].edge[iedge].v < 0) ? -1 : 1;
788  i2 = (pF[cur->iface].edge[cur->iedge].v < 0) ? -1 : 1;
789  if (i1 != i2) {
790  std::cerr
791  << "Polyhedron::SetReferences: different edge visibility "
792  << iface << "/" << iedge << "/"
793  << pF[iface].edge[iedge].v << " and "
794  << cur->iface << "/" << cur->iedge << "/"
795  << pF[cur->iface].edge[cur->iedge].v
796  << std::endl;
797  }
798  break;
799  }
800  }
801  }
802  }
803 
804  // C H E C K T H A T A L L L I S T S A R E E M P T Y
805 
806  for (i=0; i<nvert; i++) {
807  if (headList[i] != 0) {
808  std::cerr
809  << "Polyhedron::SetReferences: List " << i << " is not empty"
810  << std::endl;
811  }
812  }
813 
814  // F R E E M E M O R Y
815 
816  delete [] edgeList;
817  delete [] headList;
818 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
tuple v
Definition: test.py:18

Here is the caller graph for this function:

void HepPolyhedron::SetSideFacets ( G4int  ii[4],
G4int  vv[4],
G4int kk,
G4double r,
G4double  dphi,
G4int  ns,
G4int kface 
)
protected

Definition at line 353 of file HepPolyhedron.cc.

372 {
373  G4int k1, k2, k3, k4;
374 
375  if (std::abs((G4double)(dphi-pi)) < perMillion) { // half a circle
376  for (G4int i=0; i<4; i++) {
377  k1 = ii[i];
378  k2 = (i == 3) ? ii[0] : ii[i+1];
379  if (r[k1] == 0. && r[k2] == 0.) vv[i] = -1;
380  }
381  }
382 
383  if (ii[1] == ii[2]) {
384  k1 = kk[ii[0]];
385  k2 = kk[ii[2]];
386  k3 = kk[ii[3]];
387  pF[kface++] = G4Facet(vv[0]*k1,0, vv[2]*k2,0, vv[3]*k3,0);
388  if (r[ii[0]] != 0.) k1 += nds;
389  if (r[ii[2]] != 0.) k2 += nds;
390  if (r[ii[3]] != 0.) k3 += nds;
391  pF[kface++] = G4Facet(vv[2]*k3,0, vv[0]*k2,0, vv[3]*k1,0);
392  }else if (kk[ii[0]] == kk[ii[1]]) {
393  k1 = kk[ii[0]];
394  k2 = kk[ii[2]];
395  k3 = kk[ii[3]];
396  pF[kface++] = G4Facet(vv[1]*k1,0, vv[2]*k2,0, vv[3]*k3,0);
397  if (r[ii[0]] != 0.) k1 += nds;
398  if (r[ii[2]] != 0.) k2 += nds;
399  if (r[ii[3]] != 0.) k3 += nds;
400  pF[kface++] = G4Facet(vv[2]*k3,0, vv[1]*k2,0, vv[3]*k1,0);
401  }else if (kk[ii[2]] == kk[ii[3]]) {
402  k1 = kk[ii[0]];
403  k2 = kk[ii[1]];
404  k3 = kk[ii[2]];
405  pF[kface++] = G4Facet(vv[0]*k1,0, vv[1]*k2,0, vv[3]*k3,0);
406  if (r[ii[0]] != 0.) k1 += nds;
407  if (r[ii[1]] != 0.) k2 += nds;
408  if (r[ii[2]] != 0.) k3 += nds;
409  pF[kface++] = G4Facet(vv[1]*k3,0, vv[0]*k2,0, vv[3]*k1,0);
410  }else{
411  k1 = kk[ii[0]];
412  k2 = kk[ii[1]];
413  k3 = kk[ii[2]];
414  k4 = kk[ii[3]];
415  pF[kface++] = G4Facet(vv[0]*k1,0, vv[1]*k2,0, vv[2]*k3,0, vv[3]*k4,0);
416  if (r[ii[0]] != 0.) k1 += nds;
417  if (r[ii[1]] != 0.) k2 += nds;
418  if (r[ii[2]] != 0.) k3 += nds;
419  if (r[ii[3]] != 0.) k4 += nds;
420  pF[kface++] = G4Facet(vv[2]*k4,0, vv[1]*k3,0, vv[0]*k2,0, vv[3]*k1,0);
421  }
422 }
static constexpr double perMillion
Definition: G4SIunits.hh:334
G4Facet * pF
int G4int
Definition: G4Types.hh:78
static constexpr double pi
Definition: G4SIunits.hh:75
double G4double
Definition: G4Types.hh:76

Here is the caller graph for this function:

HepPolyhedron HepPolyhedron::subtract ( const HepPolyhedron p) const

Definition at line 2305 of file HepPolyhedron.cc.

2314 {
2315  G4int ierr;
2316  BooleanProcessor processor;
2317  return processor.execute(OP_SUBTRACTION, *this, p,ierr);
2318 }
int G4int
Definition: G4Types.hh:78
#define processor
Definition: xmlparse.cc:617
HepPolyhedron & HepPolyhedron::Transform ( const G4Transform3D t)

Definition at line 846 of file HepPolyhedron.cc.

855 {
856  if (nvert > 0) {
857  for (G4int i=1; i<=nvert; i++) { pV[i] = t * pV[i]; }
858 
859  // C H E C K D E T E R M I N A N T A N D
860  // I N V E R T F A C E T S I F I T I S N E G A T I V E
861 
862  G4Vector3D d = t * G4Vector3D(0,0,0);
863  G4Vector3D x = t * G4Vector3D(1,0,0) - d;
864  G4Vector3D y = t * G4Vector3D(0,1,0) - d;
865  G4Vector3D z = t * G4Vector3D(0,0,1) - d;
866  if ((x.cross(y))*z < 0) InvertFacets();
867  }
868  return *this;
869 }
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
tuple z
Definition: test.py:28
BasicVector3D< T > cross(const BasicVector3D< T > &v) const

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ostr,
const HepPolyhedron ph 
)
friend

Definition at line 93 of file HepPolyhedron.cc.

93  {
94  ostr << std::endl;
95  ostr << "Nvertices=" << ph.nvert << ", Nfacets=" << ph.nface << std::endl;
96  G4int i;
97  for (i=1; i<=ph.nvert; i++) {
98  ostr << "xyz(" << i << ")="
99  << ph.pV[i].x() << ' ' << ph.pV[i].y() << ' ' << ph.pV[i].z()
100  << std::endl;
101  }
102  for (i=1; i<=ph.nface; i++) {
103  ostr << "face(" << i << ")=" << ph.pF[i] << std::endl;
104  }
105  return ostr;
106 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV

Member Data Documentation

G4ThreadLocal G4int HepPolyhedron::fNumberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS
staticprotected

Definition at line 199 of file HepPolyhedron.h.

G4int HepPolyhedron::nface
protected

Definition at line 200 of file HepPolyhedron.h.

G4int HepPolyhedron::nvert
protected

Definition at line 200 of file HepPolyhedron.h.

G4Facet* HepPolyhedron::pF
protected

Definition at line 202 of file HepPolyhedron.h.

G4Point3D* HepPolyhedron::pV
protected

Definition at line 201 of file HepPolyhedron.h.


The documentation for this class was generated from the following files: