Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
HepPolyhedron Class Reference

#include <HepPolyhedron.h>

Inheritance diagram for HepPolyhedron:
G4Polyhedron HepPolyhedronCons HepPolyhedronEllipsoid HepPolyhedronEllipticalCone HepPolyhedronHype HepPolyhedronParaboloid HepPolyhedronPgon HepPolyhedronSphere HepPolyhedronTorus HepPolyhedronTrap HepPolyhedronTrd2

Public Member Functions

 HepPolyhedron ()
 
 HepPolyhedron (const HepPolyhedron &from)
 
virtual ~HepPolyhedron ()
 
HepPolyhedronoperator= (const HepPolyhedron &from)
 
G4int GetNoVertices () 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 GetNextEdgeIndeces (G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) 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 107 of file HepPolyhedron.cc.

References AllocateMemory(), nface, nvert, pF, and pV.

114 : nvert(0), nface(0), pV(0), pF(0)
115 {
116  AllocateMemory(from.nvert, from.nface);
117  for (G4int i=1; i<=nvert; i++) pV[i] = from.pV[i];
118  for (G4int k=1; k<=nface; k++) pF[k] = from.pF[k];
119 }
void AllocateMemory(G4int Nvert, G4int Nface)
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
virtual HepPolyhedron::~HepPolyhedron ( )
inlinevirtual

Definition at line 246 of file HepPolyhedron.h.

References pF, and pV.

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

Member Function Documentation

HepPolyhedron HepPolyhedron::add ( const HepPolyhedron p) const

Definition at line 2261 of file HepPolyhedron.cc.

References processor.

2270 {
2271  G4int ierr;
2272  BooleanProcessor processor;
2273  return processor.execute(OP_UNION, *this, p,ierr);
2274 }
int G4int
Definition: G4Types.hh:78
#define processor
Definition: xmlparse.cc:600
void HepPolyhedron::AllocateMemory ( G4int  Nvert,
G4int  Nface 
)
protected

Definition at line 244 of file HepPolyhedron.cc.

References nface, nvert, pF, and pV.

Referenced by createPolyhedron(), createTwistedTrap(), G4PolyhedronArbitrary::G4PolyhedronArbitrary(), HepPolyhedron(), HepPolyhedronTrap::HepPolyhedronTrap(), HepPolyhedronTrd2::HepPolyhedronTrd2(), operator=(), and RotateAroundZ().

256 {
257  if (nvert == Nvert && nface == Nface) return;
258  if (pV != 0) delete [] pV;
259  if (pF != 0) delete [] pF;
260  if (Nvert > 0 && Nface > 0) {
261  nvert = Nvert;
262  nface = Nface;
263  pV = new G4Point3D[nvert+1];
264  pF = new G4Facet[nface+1];
265  }else{
266  nvert = 0; nface = 0; pV = 0; pF = 0;
267  }
268 }
G4Facet * pF
G4Point3D * pV
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 1358 of file HepPolyhedron.cc.

References AllocateMemory(), nvert, pF, pV, and SetReferences().

Referenced by G4UGenericPolycone::CreatePolyhedron(), G4GenericPolycone::CreatePolyhedron(), G4CutTubs::CreatePolyhedron(), G4UPolyhedra::CreatePolyhedron(), G4VTwistedFaceted::CreatePolyhedron(), G4Tet::CreatePolyhedron(), G4Polyhedra::CreatePolyhedron(), G4TwistedTubs::CreatePolyhedron(), and G4USolid::CreatePolyhedron().

1374 {
1375  AllocateMemory(Nnodes, Nfaces);
1376  if (nvert == 0) return 1;
1377 
1378  for (G4int i=0; i<Nnodes; i++) {
1379  pV[i+1] = G4Point3D(xyz[i][0], xyz[i][1], xyz[i][2]);
1380  }
1381  for (G4int k=0; k<Nfaces; k++) {
1382  pF[k+1] = G4Facet(faces[k][0],0,faces[k][1],0,faces[k][2],0,faces[k][3],0);
1383  }
1384  SetReferences();
1385  return 0;
1386 }
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()
void HepPolyhedron::CreatePrism ( )
protected

Definition at line 270 of file HepPolyhedron.cc.

References pF.

Referenced by HepPolyhedronTrap::HepPolyhedronTrap(), and HepPolyhedronTrd2::HepPolyhedronTrd2().

279 {
280  enum {DUMMY, BOTTOM, LEFT, BACK, RIGHT, FRONT, TOP};
281 
282  pF[1] = G4Facet(1,LEFT, 4,BACK, 3,RIGHT, 2,FRONT);
283  pF[2] = G4Facet(5,TOP, 8,BACK, 4,BOTTOM, 1,FRONT);
284  pF[3] = G4Facet(8,TOP, 7,RIGHT, 3,BOTTOM, 4,LEFT);
285  pF[4] = G4Facet(7,TOP, 6,FRONT, 2,BOTTOM, 3,BACK);
286  pF[5] = G4Facet(6,TOP, 5,LEFT, 1,BOTTOM, 2,RIGHT);
287  pF[6] = G4Facet(5,FRONT, 6,RIGHT, 7,BACK, 8,LEFT);
288 }
G4Facet * pF
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 1289 of file HepPolyhedron.cc.

References AllocateMemory(), pF, and pV.

1305 {
1306  AllocateMemory(12,18);
1307 
1308  pV[ 1] = G4Point3D(xy1[0][0],xy1[0][1],-Dz);
1309  pV[ 2] = G4Point3D(xy1[1][0],xy1[1][1],-Dz);
1310  pV[ 3] = G4Point3D(xy1[2][0],xy1[2][1],-Dz);
1311  pV[ 4] = G4Point3D(xy1[3][0],xy1[3][1],-Dz);
1312 
1313  pV[ 5] = G4Point3D(xy2[0][0],xy2[0][1], Dz);
1314  pV[ 6] = G4Point3D(xy2[1][0],xy2[1][1], Dz);
1315  pV[ 7] = G4Point3D(xy2[2][0],xy2[2][1], Dz);
1316  pV[ 8] = G4Point3D(xy2[3][0],xy2[3][1], Dz);
1317 
1318  pV[ 9] = (pV[1]+pV[2]+pV[5]+pV[6])/4.;
1319  pV[10] = (pV[2]+pV[3]+pV[6]+pV[7])/4.;
1320  pV[11] = (pV[3]+pV[4]+pV[7]+pV[8])/4.;
1321  pV[12] = (pV[4]+pV[1]+pV[8]+pV[5])/4.;
1322 
1323  enum {DUMMY, BOTTOM,
1324  LEFT_BOTTOM, LEFT_FRONT, LEFT_TOP, LEFT_BACK,
1325  BACK_BOTTOM, BACK_LEFT, BACK_TOP, BACK_RIGHT,
1326  RIGHT_BOTTOM, RIGHT_BACK, RIGHT_TOP, RIGHT_FRONT,
1327  FRONT_BOTTOM, FRONT_RIGHT, FRONT_TOP, FRONT_LEFT,
1328  TOP};
1329 
1330  pF[ 1]=G4Facet(1,LEFT_BOTTOM, 4,BACK_BOTTOM, 3,RIGHT_BOTTOM, 2,FRONT_BOTTOM);
1331 
1332  pF[ 2]=G4Facet(4,BOTTOM, -1,LEFT_FRONT, -12,LEFT_BACK, 0,0);
1333  pF[ 3]=G4Facet(1,FRONT_LEFT, -5,LEFT_TOP, -12,LEFT_BOTTOM, 0,0);
1334  pF[ 4]=G4Facet(5,TOP, -8,LEFT_BACK, -12,LEFT_FRONT, 0,0);
1335  pF[ 5]=G4Facet(8,BACK_LEFT, -4,LEFT_BOTTOM, -12,LEFT_TOP, 0,0);
1336 
1337  pF[ 6]=G4Facet(3,BOTTOM, -4,BACK_LEFT, -11,BACK_RIGHT, 0,0);
1338  pF[ 7]=G4Facet(4,LEFT_BACK, -8,BACK_TOP, -11,BACK_BOTTOM, 0,0);
1339  pF[ 8]=G4Facet(8,TOP, -7,BACK_RIGHT, -11,BACK_LEFT, 0,0);
1340  pF[ 9]=G4Facet(7,RIGHT_BACK, -3,BACK_BOTTOM, -11,BACK_TOP, 0,0);
1341 
1342  pF[10]=G4Facet(2,BOTTOM, -3,RIGHT_BACK, -10,RIGHT_FRONT, 0,0);
1343  pF[11]=G4Facet(3,BACK_RIGHT, -7,RIGHT_TOP, -10,RIGHT_BOTTOM, 0,0);
1344  pF[12]=G4Facet(7,TOP, -6,RIGHT_FRONT, -10,RIGHT_BACK, 0,0);
1345  pF[13]=G4Facet(6,FRONT_RIGHT,-2,RIGHT_BOTTOM,-10,RIGHT_TOP, 0,0);
1346 
1347  pF[14]=G4Facet(1,BOTTOM, -2,FRONT_RIGHT, -9,FRONT_LEFT, 0,0);
1348  pF[15]=G4Facet(2,RIGHT_FRONT,-6,FRONT_TOP, -9,FRONT_BOTTOM, 0,0);
1349  pF[16]=G4Facet(6,TOP, -5,FRONT_LEFT, -9,FRONT_RIGHT, 0,0);
1350  pF[17]=G4Facet(5,LEFT_FRONT, -1,FRONT_BOTTOM, -9,FRONT_TOP, 0,0);
1351 
1352  pF[18]=G4Facet(5,FRONT_TOP, 6,RIGHT_TOP, 7,BACK_TOP, 8,LEFT_TOP);
1353 
1354  return 0;
1355 }
void AllocateMemory(G4int Nvert, G4int Nface)
G4Facet * pF
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
G4Point3D * pV
G4int HepPolyhedron::FindNeighbour ( G4int  iFace,
G4int  iNode,
G4int  iOrder 
) const
protected

Definition at line 140 of file HepPolyhedron.cc.

References test::v.

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

Definition at line 168 of file HepPolyhedron.cc.

References n, and HepGeom::BasicVector3D< T >::unit().

177 {
178  G4Normal3D normal = GetUnitNormal(iFace);
179  G4int k = iFace, iOrder = 1, n = 1;
180 
181  for(;;) {
182  k = FindNeighbour(k, iNode, iOrder);
183  if (k == iFace) break;
184  if (k > 0) {
185  n++;
186  normal += GetUnitNormal(k);
187  }else{
188  if (iOrder < 0) break;
189  k = iFace;
190  iOrder = -iOrder;
191  }
192  }
193  return normal.unit();
194 }
G4Normal3D GetUnitNormal(G4int iFace) const
BasicVector3D< T > unit() const
int G4int
Definition: G4Types.hh:78
G4int FindNeighbour(G4int iFace, G4int iNode, G4int iOrder) const
const G4int n
void HepPolyhedron::GetFacet ( G4int  iFace,
G4int n,
G4int iNodes,
G4int edgeFlags = 0,
G4int iFaces = 0 
) const

Definition at line 1065 of file HepPolyhedron.cc.

References n.

Referenced by G4CutTubs::CreatePolyhedron().

1075 {
1076  if (iFace < 1 || iFace > nface) {
1077  std::cerr
1078  << "HepPolyhedron::GetFacet: irrelevant index " << iFace
1079  << std::endl;
1080  n = 0;
1081  }else{
1082  G4int i, k;
1083  for (i=0; i<4; i++) {
1084  k = pF[iFace].edge[i].v;
1085  if (k == 0) break;
1086  if (iFaces != 0) iFaces[i] = pF[iFace].edge[i].f;
1087  if (k > 0) {
1088  iNodes[i] = k;
1089  if (edgeFlags != 0) edgeFlags[i] = 1;
1090  }else{
1091  iNodes[i] = -k;
1092  if (edgeFlags != 0) edgeFlags[i] = -1;
1093  }
1094  }
1095  n = i;
1096  }
1097 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
const G4int n
void HepPolyhedron::GetFacet ( G4int  iFace,
G4int n,
G4Point3D nodes,
G4int edgeFlags = 0,
G4Normal3D normals = 0 
) const

Definition at line 1099 of file HepPolyhedron.cc.

References n.

1109 {
1110  G4int iNodes[4];
1111  GetFacet(index, n, iNodes, edgeFlags);
1112  if (n != 0) {
1113  for (G4int i=0; i<n; i++) {
1114  nodes[i] = pV[iNodes[i]];
1115  if (normals != 0) normals[i] = FindNodeNormal(index,iNodes[i]);
1116  }
1117  }
1118 }
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 1024 of file HepPolyhedron.cc.

Referenced by G4GMocrenFileSceneHandler::AddSolid().

1036 {
1037  G4int i1,i2;
1038  G4bool rep = GetNextEdgeIndeces(i1,i2,edgeFlag);
1039  p1 = pV[i1];
1040  p2 = pV[i2];
1041  return rep;
1042 }
G4bool GetNextEdgeIndeces(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4Point3D * pV
G4bool HepPolyhedron::GetNextEdge ( G4Point3D p1,
G4Point3D p2,
G4int edgeFlag,
G4int iface1,
G4int iface2 
) const

Definition at line 1045 of file HepPolyhedron.cc.

1057 {
1058  G4int i1,i2;
1059  G4bool rep = GetNextEdgeIndeces(i1,i2,edgeFlag,iface1,iface2);
1060  p1 = pV[i1];
1061  p2 = pV[i2];
1062  return rep;
1063 }
G4bool GetNextEdgeIndeces(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4Point3D * pV
G4bool HepPolyhedron::GetNextEdgeIndeces ( G4int i1,
G4int i2,
G4int edgeFlag,
G4int iface1,
G4int iface2 
) const

Definition at line 955 of file HepPolyhedron.cc.

References G4ThreadLocal, and test::v.

967 {
968  static G4ThreadLocal G4int iFace = 1;
969  static G4ThreadLocal G4int iQVertex = 0;
970  static G4ThreadLocal G4int iOrder = 1;
971  G4int k1, k2, kflag, kface1, kface2;
972 
973  if (iFace == 1 && iQVertex == 0) {
974  k2 = pF[nface].edge[0].v;
975  k1 = pF[nface].edge[3].v;
976  if (k1 == 0) k1 = pF[nface].edge[2].v;
977  if (std::abs(k1) > std::abs(k2)) iOrder = -1;
978  }
979 
980  do {
981  k1 = pF[iFace].edge[iQVertex].v;
982  kflag = k1;
983  k1 = std::abs(k1);
984  kface1 = iFace;
985  kface2 = pF[iFace].edge[iQVertex].f;
986  if (iQVertex >= 3 || pF[iFace].edge[iQVertex+1].v == 0) {
987  iQVertex = 0;
988  k2 = std::abs(pF[iFace].edge[iQVertex].v);
989  iFace++;
990  }else{
991  iQVertex++;
992  k2 = std::abs(pF[iFace].edge[iQVertex].v);
993  }
994  } while (iOrder*k1 > iOrder*k2);
995 
996  i1 = k1; i2 = k2; edgeFlag = (kflag > 0) ? 1 : 0;
997  iface1 = kface1; iface2 = kface2;
998 
999  if (iFace > nface) {
1000  iFace = 1; iOrder = 1;
1001  return false;
1002  }else{
1003  return true;
1004  }
1005 }
G4Facet * pF
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
G4bool HepPolyhedron::GetNextEdgeIndeces ( G4int i1,
G4int i2,
G4int edgeFlag 
) const

Definition at line 1008 of file HepPolyhedron.cc.

1018 {
1019  G4int kface1, kface2;
1020  return GetNextEdgeIndeces(i1, i2, edgeFlag, kface1, kface2);
1021 }
G4bool GetNextEdgeIndeces(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
int G4int
Definition: G4Types.hh:78
G4bool HepPolyhedron::GetNextFacet ( G4int n,
G4Point3D nodes,
G4int edgeFlags = 0,
G4Normal3D normals = 0 
) const

Definition at line 1121 of file HepPolyhedron.cc.

References G4ThreadLocal, and n.

1132 {
1133  static G4ThreadLocal G4int iFace = 1;
1134 
1135  if (edgeFlags == 0) {
1136  GetFacet(iFace, n, nodes);
1137  }else if (normals == 0) {
1138  GetFacet(iFace, n, nodes, edgeFlags);
1139  }else{
1140  GetFacet(iFace, n, nodes, edgeFlags, normals);
1141  }
1142 
1143  if (++iFace > nface) {
1144  iFace = 1;
1145  return false;
1146  }else{
1147  return true;
1148  }
1149 }
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
const G4int n
G4bool HepPolyhedron::GetNextNormal ( G4Normal3D normal) const

Definition at line 1201 of file HepPolyhedron.cc.

References G4ThreadLocal.

Referenced by G4HepRepSceneHandler::AddPrimitive(), and G4HepRepFileSceneHandler::AddPrimitive().

1211 {
1212  static G4ThreadLocal G4int iFace = 1;
1213  normal = GetNormal(iFace);
1214  if (++iFace > nface) {
1215  iFace = 1;
1216  return false;
1217  }else{
1218  return true;
1219  }
1220 }
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
G4Normal3D GetNormal(G4int iFace) const
G4bool HepPolyhedron::GetNextUnitNormal ( G4Normal3D normal) const

Definition at line 1222 of file HepPolyhedron.cc.

1232 {
1233  G4bool rep = GetNextNormal(normal);
1234  normal = normal.unit();
1235  return rep;
1236 }
G4bool GetNextNormal(G4Normal3D &normal) const
BasicVector3D< T > unit() const
bool G4bool
Definition: G4Types.hh:79
G4bool HepPolyhedron::GetNextVertex ( G4Point3D vertex,
G4int edgeFlag 
) const

Definition at line 905 of file HepPolyhedron.cc.

Referenced by G4HepRepSceneHandler::AddPrimitive(), and G4HepRepFileSceneHandler::AddPrimitive().

916 {
917  G4int index;
918  G4bool rep = GetNextVertexIndex(index, edgeFlag);
919  vertex = pV[index];
920  return rep;
921 }
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
G4Point3D * pV
G4bool GetNextVertexIndex(G4int &index, G4int &edgeFlag) const
G4bool HepPolyhedron::GetNextVertex ( G4Point3D vertex,
G4int edgeFlag,
G4Normal3D normal 
) const

Definition at line 923 of file HepPolyhedron.cc.

References G4ThreadLocal, and test::v.

935 {
936  static G4ThreadLocal G4int iFace = 1;
937  static G4ThreadLocal G4int iNode = 0;
938 
939  if (nface == 0) return false; // empty polyhedron
940 
941  G4int k = pF[iFace].edge[iNode].v;
942  if (k > 0) { edgeFlag = 1; } else { edgeFlag = -1; k = -k; }
943  vertex = pV[k];
944  normal = FindNodeNormal(iFace,k);
945  if (iNode >= 3 || pF[iFace].edge[iNode+1].v == 0) {
946  iNode = 0;
947  if (++iFace > nface) iFace = 1;
948  return false; // last node
949  }else{
950  ++iNode;
951  return true; // not last node
952  }
953 }
G4Facet * pF
G4Normal3D FindNodeNormal(G4int iFace, G4int iNode) const
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
G4bool HepPolyhedron::GetNextVertexIndex ( G4int index,
G4int edgeFlag 
) const

Definition at line 858 of file HepPolyhedron.cc.

References G4ThreadLocal, and test::v.

Referenced by G4GMocrenFileSceneHandler::AddPrimitive().

867 {
868  static G4ThreadLocal G4int iFace = 1;
869  static G4ThreadLocal G4int iQVertex = 0;
870  G4int vIndex = pF[iFace].edge[iQVertex].v;
871 
872  edgeFlag = (vIndex > 0) ? 1 : 0;
873  index = std::abs(vIndex);
874 
875  if (iQVertex >= 3 || pF[iFace].edge[iQVertex+1].v == 0) {
876  iQVertex = 0;
877  if (++iFace > nface) iFace = 1;
878  return false; // Last Edge
879  }else{
880  ++iQVertex;
881  return true; // not Last Edge
882  }
883 }
G4Facet * pF
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
G4int HepPolyhedron::GetNoFacets ( ) const
inline
G4Normal3D HepPolyhedron::GetNormal ( G4int  iFace) const

Definition at line 1151 of file HepPolyhedron.cc.

References test::v.

1160 {
1161  if (iFace < 1 || iFace > nface) {
1162  std::cerr
1163  << "HepPolyhedron::GetNormal: irrelevant index " << iFace
1164  << std::endl;
1165  return G4Normal3D();
1166  }
1167 
1168  G4int i0 = std::abs(pF[iFace].edge[0].v);
1169  G4int i1 = std::abs(pF[iFace].edge[1].v);
1170  G4int i2 = std::abs(pF[iFace].edge[2].v);
1171  G4int i3 = std::abs(pF[iFace].edge[3].v);
1172  if (i3 == 0) i3 = i0;
1173  return (pV[i2] - pV[i0]).cross(pV[i3] - pV[i1]);
1174 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:35
G4int HepPolyhedron::GetNoVertices ( ) const
inline

Definition at line 252 of file HepPolyhedron.h.

References nvert.

Referenced by G4GMocrenFileSceneHandler::AddSolid(), and G4CutTubs::CreatePolyhedron().

252 { return nvert; }
G4int HepPolyhedron::GetNumberOfRotationSteps ( )
static
G4double HepPolyhedron::GetSurfaceArea ( ) const

Definition at line 1238 of file HepPolyhedron.cc.

References nface, pF, pV, and test::v.

1247 {
1248  G4double srf = 0.;
1249  for (G4int iFace=1; iFace<=nface; iFace++) {
1250  G4int i0 = std::abs(pF[iFace].edge[0].v);
1251  G4int i1 = std::abs(pF[iFace].edge[1].v);
1252  G4int i2 = std::abs(pF[iFace].edge[2].v);
1253  G4int i3 = std::abs(pF[iFace].edge[3].v);
1254  if (i3 == 0) i3 = i0;
1255  srf += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).mag();
1256  }
1257  return srf/2.;
1258 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
double G4double
Definition: G4Types.hh:76
G4Normal3D HepPolyhedron::GetUnitNormal ( G4int  iFace) const

Definition at line 1176 of file HepPolyhedron.cc.

References test::v.

1185 {
1186  if (iFace < 1 || iFace > nface) {
1187  std::cerr
1188  << "HepPolyhedron::GetUnitNormal: irrelevant index " << iFace
1189  << std::endl;
1190  return G4Normal3D();
1191  }
1192 
1193  G4int i0 = std::abs(pF[iFace].edge[0].v);
1194  G4int i1 = std::abs(pF[iFace].edge[1].v);
1195  G4int i2 = std::abs(pF[iFace].edge[2].v);
1196  G4int i3 = std::abs(pF[iFace].edge[3].v);
1197  if (i3 == 0) i3 = i0;
1198  return ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).unit();
1199 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:35
G4Point3D HepPolyhedron::GetVertex ( G4int  index) const

Definition at line 885 of file HepPolyhedron.cc.

Referenced by G4GMocrenFileSceneHandler::AddSolid(), and G4CutTubs::CreatePolyhedron().

894 {
895  if (index <= 0 || index > nvert) {
896  std::cerr
897  << "HepPolyhedron::GetVertex: irrelevant index " << index
898  << std::endl;
899  return G4Point3D();
900  }
901  return pV[index];
902 }
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
G4Point3D * pV
G4double HepPolyhedron::GetVolume ( ) const

Definition at line 1260 of file HepPolyhedron.cc.

References nface, pF, pV, and test::v.

1269 {
1270  G4double v = 0.;
1271  for (G4int iFace=1; iFace<=nface; iFace++) {
1272  G4int i0 = std::abs(pF[iFace].edge[0].v);
1273  G4int i1 = std::abs(pF[iFace].edge[1].v);
1274  G4int i2 = std::abs(pF[iFace].edge[2].v);
1275  G4int i3 = std::abs(pF[iFace].edge[3].v);
1276  G4Point3D pt;
1277  if (i3 == 0) {
1278  i3 = i0;
1279  pt = (pV[i0]+pV[i1]+pV[i2]) * (1./3.);
1280  }else{
1281  pt = (pV[i0]+pV[i1]+pV[i2]+pV[i3]) * 0.25;
1282  }
1283  v += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).dot(pt);
1284  }
1285  return v/6.;
1286 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
double G4double
Definition: G4Types.hh:76
HepPolyhedron HepPolyhedron::intersect ( const HepPolyhedron p) const

Definition at line 2276 of file HepPolyhedron.cc.

References processor.

2285 {
2286  G4int ierr;
2287  BooleanProcessor processor;
2288  return processor.execute(OP_INTERSECTION, *this, p,ierr);
2289 }
int G4int
Definition: G4Types.hh:78
#define processor
Definition: xmlparse.cc:600
void HepPolyhedron::InvertFacets ( )
protected

Definition at line 807 of file HepPolyhedron.cc.

References nface, pF, and test::v.

Referenced by G4PolyhedronArbitrary::InvertFacets(), and Transform().

816 {
817  if (nface <= 0) return;
818  G4int i, k, nnode, v[4],f[4];
819  for (i=1; i<=nface; i++) {
820  nnode = (pF[i].edge[3].v == 0) ? 3 : 4;
821  for (k=0; k<nnode; k++) {
822  v[k] = (k+1 == nnode) ? pF[i].edge[0].v : pF[i].edge[k+1].v;
823  if (v[k] * pF[i].edge[k].v < 0) v[k] = -v[k];
824  f[k] = pF[i].edge[k].f;
825  }
826  for (k=0; k<nnode; k++) {
827  pF[i].edge[nnode-1-k].v = v[k];
828  pF[i].edge[nnode-1-k].f = f[k];
829  }
830  }
831 }
G4Facet * pF
int G4int
Definition: G4Types.hh:78
HepPolyhedron & HepPolyhedron::operator= ( const HepPolyhedron from)

Definition at line 121 of file HepPolyhedron.cc.

References AllocateMemory(), nface, nvert, pF, and pV.

130 {
131  if (this != &from) {
132  AllocateMemory(from.nvert, from.nface);
133  for (G4int i=1; i<=nvert; i++) pV[i] = from.pV[i];
134  for (G4int k=1; k<=nface; k++) pF[k] = from.pF[k];
135  }
136  return *this;
137 }
void AllocateMemory(G4int Nvert, G4int Nface)
G4Facet * pF
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
void HepPolyhedron::ResetNumberOfRotationSteps ( )
static

Definition at line 231 of file HepPolyhedron.cc.

References DEFAULT_NUMBER_OF_STEPS, and fNumberOfRotationSteps.

Referenced by G4PhysicalVolumeModel::DescribeSolid(), and G4VSceneHandler::RequestPrimitives().

240 {
242 }
#define DEFAULT_NUMBER_OF_STEPS
static G4ThreadLocal G4int fNumberOfRotationSteps
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 423 of file HepPolyhedron.cc.

References AllocateMemory(), GetNumberOfRotationSteps(), nface, python.hepunit::perMillion, pV, RotateEdge(), SetSideFacets(), spatialTolerance, and python.hepunit::twopi.

Referenced by HepPolyhedronCons::HepPolyhedronCons(), HepPolyhedronEllipsoid::HepPolyhedronEllipsoid(), HepPolyhedronEllipticalCone::HepPolyhedronEllipticalCone(), HepPolyhedronHype::HepPolyhedronHype(), HepPolyhedronParaboloid::HepPolyhedronParaboloid(), HepPolyhedronPgon::HepPolyhedronPgon(), HepPolyhedronSphere::HepPolyhedronSphere(), and HepPolyhedronTorus::HepPolyhedronTorus().

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

References pF.

Referenced by RotateAroundZ().

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

Definition at line 209 of file HepPolyhedron.cc.

References fNumberOfRotationSteps, and n.

Referenced by G4PhysicalVolumeModel::DescribeSolid(), and G4VSceneHandler::RequestPrimitives().

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

Definition at line 670 of file HepPolyhedron.cc.

References nface, nvert, pF, and test::v.

Referenced by createPolyhedron(), HepPolyhedronCons::HepPolyhedronCons(), HepPolyhedronEllipsoid::HepPolyhedronEllipsoid(), HepPolyhedronEllipticalCone::HepPolyhedronEllipticalCone(), HepPolyhedronHype::HepPolyhedronHype(), HepPolyhedronParaboloid::HepPolyhedronParaboloid(), HepPolyhedronPgon::HepPolyhedronPgon(), HepPolyhedronSphere::HepPolyhedronSphere(), HepPolyhedronTorus::HepPolyhedronTorus(), and G4PolyhedronArbitrary::SetReferences().

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

Definition at line 352 of file HepPolyhedron.cc.

References python.hepunit::perMillion, pF, and python.hepunit::pi.

Referenced by RotateAroundZ().

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

Definition at line 2291 of file HepPolyhedron.cc.

References processor.

2300 {
2301  G4int ierr;
2302  BooleanProcessor processor;
2303  return processor.execute(OP_SUBTRACTION, *this, p,ierr);
2304 }
int G4int
Definition: G4Types.hh:78
#define processor
Definition: xmlparse.cc:600
HepPolyhedron & HepPolyhedron::Transform ( const G4Transform3D t)

Definition at line 833 of file HepPolyhedron.cc.

References HepGeom::BasicVector3D< T >::cross(), InvertFacets(), nvert, pV, test::x, and z.

Referenced by G4GMocrenFileSceneHandler::AddSolid(), G4EllipticalTube::CreatePolyhedron(), G4ReflectedSolid::CreatePolyhedron(), G4DisplacedSolid::CreatePolyhedron(), and G4ArrowModel::G4ArrowModel().

842 {
843  if (nvert > 0) {
844  for (G4int i=1; i<=nvert; i++) { pV[i] = t * pV[i]; }
845 
846  // C H E C K D E T E R M I N A N T A N D
847  // 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
848 
849  G4Vector3D d = t * G4Vector3D(0,0,0);
850  G4Vector3D x = t * G4Vector3D(1,0,0) - d;
851  G4Vector3D y = t * G4Vector3D(0,1,0) - d;
852  G4Vector3D z = t * G4Vector3D(0,0,1) - d;
853  if ((x.cross(y))*z < 0) InvertFacets();
854  }
855  return *this;
856 }
G4double z
Definition: TRTMaterials.hh:39
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:35
int G4int
Definition: G4Types.hh:78
G4Point3D * pV
BasicVector3D< T > cross(const BasicVector3D< T > &v) const

Friends And Related Function Documentation

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

Definition at line 92 of file HepPolyhedron.cc.

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

Field Documentation

G4ThreadLocal G4int HepPolyhedron::fNumberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS
staticprotected
G4int HepPolyhedron::nface
protected
G4int HepPolyhedron::nvert
protected
G4Facet* HepPolyhedron::pF
protected
G4Point3D* HepPolyhedron::pV
protected

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