Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
HepPolyhedron Class Reference

#include <HepPolyhedron.h>

+ Inheritance diagram for HepPolyhedron:

Public Member Functions

 HepPolyhedron ()
 
 HepPolyhedron (const HepPolyhedron &from)
 
 HepPolyhedron (HepPolyhedron &&from)
 
virtual ~HepPolyhedron ()
 
HepPolyhedronoperator= (const HepPolyhedron &from)
 
HepPolyhedronoperator= (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 204 of file HepPolyhedron.h.

Constructor & Destructor Documentation

◆ HepPolyhedron() [1/3]

HepPolyhedron::HepPolyhedron ( )
inline

Definition at line 249 of file HepPolyhedron.h.

249: nvert(0), nface(0), pV(0), pF(0) {}
G4Point3D * pV
G4Facet * pF

◆ HepPolyhedron() [2/3]

HepPolyhedron::HepPolyhedron ( const HepPolyhedron from)

Definition at line 107 of file HepPolyhedron.cc.

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}
int G4int
Definition: G4Types.hh:85
void AllocateMemory(G4int Nvert, G4int Nface)

◆ HepPolyhedron() [3/3]

HepPolyhedron::HepPolyhedron ( HepPolyhedron &&  from)

Definition at line 121 of file HepPolyhedron.cc.

128: nvert(0), nface(0), pV(nullptr), pF(nullptr)
129{
130 nvert = from.nvert;
131 nface = from.nface;
132 pV = from.pV;
133 pF = from.pF;
134
135 // Release the data from the source object
136 from.nvert = 0;
137 from.nface = 0;
138 from.pV = nullptr;
139 from.pF = nullptr;
140}

◆ ~HepPolyhedron()

virtual HepPolyhedron::~HepPolyhedron ( )
inlinevirtual

Definition at line 258 of file HepPolyhedron.h.

258{ delete [] pV; delete [] pF; }

Member Function Documentation

◆ add()

HepPolyhedron HepPolyhedron::add ( const HepPolyhedron p) const

Definition at line 2414 of file HepPolyhedron.cc.

2423{
2424 G4int ierr;
2425 BooleanProcessor processor;
2426 return processor.execute(OP_UNION, *this, p,ierr);
2427}
#define processor
Definition: xmlparse.cc:617

◆ AllocateMemory()

void HepPolyhedron::AllocateMemory ( G4int  Nvert,
G4int  Nface 
)
protected

Definition at line 292 of file HepPolyhedron.cc.

304{
305 if (nvert == Nvert && nface == Nface) return;
306 if (pV != 0) delete [] pV;
307 if (pF != 0) delete [] pF;
308 if (Nvert > 0 && Nface > 0) {
309 nvert = Nvert;
310 nface = Nface;
311 pV = new G4Point3D[nvert+1];
312 pF = new G4Facet[nface+1];
313 }else{
314 nvert = 0; nface = 0; pV = 0; pF = 0;
315 }
316}

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

◆ createPolyhedron()

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 1418 of file HepPolyhedron.cc.

1434{
1435 AllocateMemory(Nnodes, Nfaces);
1436 if (nvert == 0) return 1;
1437
1438 for (G4int i=0; i<Nnodes; i++) {
1439 pV[i+1] = G4Point3D(xyz[i][0], xyz[i][1], xyz[i][2]);
1440 }
1441 for (G4int k=0; k<Nfaces; k++) {
1442 pF[k+1] = G4Facet(faces[k][0],0,faces[k][1],0,faces[k][2],0,faces[k][3],0);
1443 }
1444 SetReferences();
1445 return 0;
1446}
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:34
void SetReferences()

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

◆ CreatePrism()

void HepPolyhedron::CreatePrism ( )
protected

Definition at line 318 of file HepPolyhedron.cc.

327{
328 enum {DUMMY, BOTTOM, LEFT, BACK, RIGHT, FRONT, TOP};
329
330 pF[1] = G4Facet(1,LEFT, 4,BACK, 3,RIGHT, 2,FRONT);
331 pF[2] = G4Facet(5,TOP, 8,BACK, 4,BOTTOM, 1,FRONT);
332 pF[3] = G4Facet(8,TOP, 7,RIGHT, 3,BOTTOM, 4,LEFT);
333 pF[4] = G4Facet(7,TOP, 6,FRONT, 2,BOTTOM, 3,BACK);
334 pF[5] = G4Facet(6,TOP, 5,LEFT, 1,BOTTOM, 2,RIGHT);
335 pF[6] = G4Facet(5,FRONT, 6,RIGHT, 7,BACK, 8,LEFT);
336}

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

◆ createTwistedTrap()

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 1349 of file HepPolyhedron.cc.

1365{
1366 AllocateMemory(12,18);
1367
1368 pV[ 1] = G4Point3D(xy1[0][0],xy1[0][1],-Dz);
1369 pV[ 2] = G4Point3D(xy1[1][0],xy1[1][1],-Dz);
1370 pV[ 3] = G4Point3D(xy1[2][0],xy1[2][1],-Dz);
1371 pV[ 4] = G4Point3D(xy1[3][0],xy1[3][1],-Dz);
1372
1373 pV[ 5] = G4Point3D(xy2[0][0],xy2[0][1], Dz);
1374 pV[ 6] = G4Point3D(xy2[1][0],xy2[1][1], Dz);
1375 pV[ 7] = G4Point3D(xy2[2][0],xy2[2][1], Dz);
1376 pV[ 8] = G4Point3D(xy2[3][0],xy2[3][1], Dz);
1377
1378 pV[ 9] = (pV[1]+pV[2]+pV[5]+pV[6])/4.;
1379 pV[10] = (pV[2]+pV[3]+pV[6]+pV[7])/4.;
1380 pV[11] = (pV[3]+pV[4]+pV[7]+pV[8])/4.;
1381 pV[12] = (pV[4]+pV[1]+pV[8]+pV[5])/4.;
1382
1383 enum {DUMMY, BOTTOM,
1384 LEFT_BOTTOM, LEFT_FRONT, LEFT_TOP, LEFT_BACK,
1385 BACK_BOTTOM, BACK_LEFT, BACK_TOP, BACK_RIGHT,
1386 RIGHT_BOTTOM, RIGHT_BACK, RIGHT_TOP, RIGHT_FRONT,
1387 FRONT_BOTTOM, FRONT_RIGHT, FRONT_TOP, FRONT_LEFT,
1388 TOP};
1389
1390 pF[ 1]=G4Facet(1,LEFT_BOTTOM, 4,BACK_BOTTOM, 3,RIGHT_BOTTOM, 2,FRONT_BOTTOM);
1391
1392 pF[ 2]=G4Facet(4,BOTTOM, -1,LEFT_FRONT, -12,LEFT_BACK, 0,0);
1393 pF[ 3]=G4Facet(1,FRONT_LEFT, -5,LEFT_TOP, -12,LEFT_BOTTOM, 0,0);
1394 pF[ 4]=G4Facet(5,TOP, -8,LEFT_BACK, -12,LEFT_FRONT, 0,0);
1395 pF[ 5]=G4Facet(8,BACK_LEFT, -4,LEFT_BOTTOM, -12,LEFT_TOP, 0,0);
1396
1397 pF[ 6]=G4Facet(3,BOTTOM, -4,BACK_LEFT, -11,BACK_RIGHT, 0,0);
1398 pF[ 7]=G4Facet(4,LEFT_BACK, -8,BACK_TOP, -11,BACK_BOTTOM, 0,0);
1399 pF[ 8]=G4Facet(8,TOP, -7,BACK_RIGHT, -11,BACK_LEFT, 0,0);
1400 pF[ 9]=G4Facet(7,RIGHT_BACK, -3,BACK_BOTTOM, -11,BACK_TOP, 0,0);
1401
1402 pF[10]=G4Facet(2,BOTTOM, -3,RIGHT_BACK, -10,RIGHT_FRONT, 0,0);
1403 pF[11]=G4Facet(3,BACK_RIGHT, -7,RIGHT_TOP, -10,RIGHT_BOTTOM, 0,0);
1404 pF[12]=G4Facet(7,TOP, -6,RIGHT_FRONT, -10,RIGHT_BACK, 0,0);
1405 pF[13]=G4Facet(6,FRONT_RIGHT,-2,RIGHT_BOTTOM,-10,RIGHT_TOP, 0,0);
1406
1407 pF[14]=G4Facet(1,BOTTOM, -2,FRONT_RIGHT, -9,FRONT_LEFT, 0,0);
1408 pF[15]=G4Facet(2,RIGHT_FRONT,-6,FRONT_TOP, -9,FRONT_BOTTOM, 0,0);
1409 pF[16]=G4Facet(6,TOP, -5,FRONT_LEFT, -9,FRONT_RIGHT, 0,0);
1410 pF[17]=G4Facet(5,LEFT_FRONT, -1,FRONT_BOTTOM, -9,FRONT_TOP, 0,0);
1411
1412 pF[18]=G4Facet(5,FRONT_TOP, 6,RIGHT_TOP, 7,BACK_TOP, 8,LEFT_TOP);
1413
1414 return 0;
1415}

◆ FindNeighbour()

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

Definition at line 188 of file HepPolyhedron.cc.

197{
198 G4int i;
199 for (i=0; i<4; i++) {
200 if (iNode == std::abs(pF[iFace].edge[i].v)) break;
201 }
202 if (i == 4) {
203 std::cerr
204 << "HepPolyhedron::FindNeighbour: face " << iFace
205 << " has no node " << iNode
206 << std::endl;
207 return 0;
208 }
209 if (iOrder < 0) {
210 if ( --i < 0) i = 3;
211 if (pF[iFace].edge[i].v == 0) i = 2;
212 }
213 return (pF[iFace].edge[i].v > 0) ? 0 : pF[iFace].edge[i].f;
214}

◆ FindNodeNormal()

G4Normal3D HepPolyhedron::FindNodeNormal ( G4int  iFace,
G4int  iNode 
) const
protected

Definition at line 216 of file HepPolyhedron.cc.

225{
226 G4Normal3D normal = GetUnitNormal(iFace);
227 G4int k = iFace, iOrder = 1, n = 1;
228
229 for(;;) {
230 k = FindNeighbour(k, iNode, iOrder);
231 if (k == iFace) break;
232 if (k > 0) {
233 n++;
234 normal += GetUnitNormal(k);
235 }else{
236 if (iOrder < 0) break;
237 k = iFace;
238 iOrder = -iOrder;
239 }
240 }
241 return normal.unit();
242}
BasicVector3D< T > unit() const
G4Normal3D GetUnitNormal(G4int iFace) const
G4int FindNeighbour(G4int iFace, G4int iNode, G4int iOrder) const

◆ GetFacet() [1/2]

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

Definition at line 1125 of file HepPolyhedron.cc.

1135{
1136 if (iFace < 1 || iFace > nface) {
1137 std::cerr
1138 << "HepPolyhedron::GetFacet: irrelevant index " << iFace
1139 << std::endl;
1140 n = 0;
1141 }else{
1142 G4int i, k;
1143 for (i=0; i<4; i++) {
1144 k = pF[iFace].edge[i].v;
1145 if (k == 0) break;
1146 if (iFaces != 0) iFaces[i] = pF[iFace].edge[i].f;
1147 if (k > 0) {
1148 iNodes[i] = k;
1149 if (edgeFlags != 0) edgeFlags[i] = 1;
1150 }else{
1151 iNodes[i] = -k;
1152 if (edgeFlags != 0) edgeFlags[i] = -1;
1153 }
1154 }
1155 n = i;
1156 }
1157}

Referenced by G4CutTubs::CreatePolyhedron().

◆ GetFacet() [2/2]

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

Definition at line 1159 of file HepPolyhedron.cc.

1169{
1170 G4int iNodes[4];
1171 GetFacet(index, n, iNodes, edgeFlags);
1172 if (n != 0) {
1173 for (G4int i=0; i<n; i++) {
1174 nodes[i] = pV[iNodes[i]];
1175 if (normals != 0) normals[i] = FindNodeNormal(index,iNodes[i]);
1176 }
1177 }
1178}
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
G4Normal3D FindNodeNormal(G4int iFace, G4int iNode) const

◆ GetNextEdge() [1/2]

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

Definition at line 1084 of file HepPolyhedron.cc.

1096{
1097 G4int i1,i2;
1098 G4bool rep = GetNextEdgeIndices(i1,i2,edgeFlag);
1099 p1 = pV[i1];
1100 p2 = pV[i2];
1101 return rep;
1102}
bool G4bool
Definition: G4Types.hh:86
G4bool GetNextEdgeIndices(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const

Referenced by G4GMocrenFileSceneHandler::AddSolid().

◆ GetNextEdge() [2/2]

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

Definition at line 1105 of file HepPolyhedron.cc.

1117{
1118 G4int i1,i2;
1119 G4bool rep = GetNextEdgeIndices(i1,i2,edgeFlag,iface1,iface2);
1120 p1 = pV[i1];
1121 p2 = pV[i2];
1122 return rep;
1123}

◆ GetNextEdgeIndeces() [1/2]

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

Definition at line 298 of file HepPolyhedron.h.

299 {return GetNextEdgeIndices(i1,i2,edgeFlag);} // Old spelling.

◆ GetNextEdgeIndeces() [2/2]

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

Definition at line 292 of file HepPolyhedron.h.

294 {return GetNextEdgeIndices(i1,i2,edgeFlag,iface1,iface2);} // Old spelling

◆ GetNextEdgeIndices() [1/2]

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

Definition at line 1068 of file HepPolyhedron.cc.

1078{
1079 G4int kface1, kface2;
1080 return GetNextEdgeIndices(i1, i2, edgeFlag, kface1, kface2);
1081}

◆ GetNextEdgeIndices() [2/2]

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

Definition at line 1015 of file HepPolyhedron.cc.

1027{
1028 static G4ThreadLocal G4int iFace = 1;
1029 static G4ThreadLocal G4int iQVertex = 0;
1030 static G4ThreadLocal G4int iOrder = 1;
1031 G4int k1, k2, kflag, kface1, kface2;
1032
1033 if (iFace == 1 && iQVertex == 0) {
1034 k2 = pF[nface].edge[0].v;
1035 k1 = pF[nface].edge[3].v;
1036 if (k1 == 0) k1 = pF[nface].edge[2].v;
1037 if (std::abs(k1) > std::abs(k2)) iOrder = -1;
1038 }
1039
1040 do {
1041 k1 = pF[iFace].edge[iQVertex].v;
1042 kflag = k1;
1043 k1 = std::abs(k1);
1044 kface1 = iFace;
1045 kface2 = pF[iFace].edge[iQVertex].f;
1046 if (iQVertex >= 3 || pF[iFace].edge[iQVertex+1].v == 0) {
1047 iQVertex = 0;
1048 k2 = std::abs(pF[iFace].edge[iQVertex].v);
1049 iFace++;
1050 }else{
1051 iQVertex++;
1052 k2 = std::abs(pF[iFace].edge[iQVertex].v);
1053 }
1054 } while (iOrder*k1 > iOrder*k2);
1055
1056 i1 = k1; i2 = k2; edgeFlag = (kflag > 0) ? 1 : 0;
1057 iface1 = kface1; iface2 = kface2;
1058
1059 if (iFace > nface) {
1060 iFace = 1; iOrder = 1;
1061 return false;
1062 }else{
1063 return true;
1064 }
1065}
#define G4ThreadLocal
Definition: tls.hh:77

Referenced by GetNextEdgeIndeces().

◆ GetNextFacet()

G4bool HepPolyhedron::GetNextFacet ( G4int n,
G4Point3D nodes,
G4int edgeFlags = 0,
G4Normal3D normals = 0 
) const

Definition at line 1181 of file HepPolyhedron.cc.

1192{
1193 static G4ThreadLocal G4int iFace = 1;
1194
1195 if (edgeFlags == 0) {
1196 GetFacet(iFace, n, nodes);
1197 }else if (normals == 0) {
1198 GetFacet(iFace, n, nodes, edgeFlags);
1199 }else{
1200 GetFacet(iFace, n, nodes, edgeFlags, normals);
1201 }
1202
1203 if (++iFace > nface) {
1204 iFace = 1;
1205 return false;
1206 }else{
1207 return true;
1208 }
1209}

◆ GetNextNormal()

G4bool HepPolyhedron::GetNextNormal ( G4Normal3D normal) const

Definition at line 1261 of file HepPolyhedron.cc.

1271{
1272 static G4ThreadLocal G4int iFace = 1;
1273 normal = GetNormal(iFace);
1274 if (++iFace > nface) {
1275 iFace = 1;
1276 return false;
1277 }else{
1278 return true;
1279 }
1280}
G4Normal3D GetNormal(G4int iFace) const

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

◆ GetNextUnitNormal()

G4bool HepPolyhedron::GetNextUnitNormal ( G4Normal3D normal) const

Definition at line 1282 of file HepPolyhedron.cc.

1292{
1293 G4bool rep = GetNextNormal(normal);
1294 normal = normal.unit();
1295 return rep;
1296}
G4bool GetNextNormal(G4Normal3D &normal) const

◆ GetNextVertex() [1/2]

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

Definition at line 965 of file HepPolyhedron.cc.

976{
977 G4int index;
978 G4bool rep = GetNextVertexIndex(index, edgeFlag);
979 vertex = pV[index];
980 return rep;
981}
G4bool GetNextVertexIndex(G4int &index, G4int &edgeFlag) const

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

◆ GetNextVertex() [2/2]

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

Definition at line 983 of file HepPolyhedron.cc.

995{
996 static G4ThreadLocal G4int iFace = 1;
997 static G4ThreadLocal G4int iNode = 0;
998
999 if (nface == 0) return false; // empty polyhedron
1000
1001 G4int k = pF[iFace].edge[iNode].v;
1002 if (k > 0) { edgeFlag = 1; } else { edgeFlag = -1; k = -k; }
1003 vertex = pV[k];
1004 normal = FindNodeNormal(iFace,k);
1005 if (iNode >= 3 || pF[iFace].edge[iNode+1].v == 0) {
1006 iNode = 0;
1007 if (++iFace > nface) iFace = 1;
1008 return false; // last node
1009 }else{
1010 ++iNode;
1011 return true; // not last node
1012 }
1013}

◆ GetNextVertexIndex()

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

Definition at line 918 of file HepPolyhedron.cc.

927{
928 static G4ThreadLocal G4int iFace = 1;
929 static G4ThreadLocal G4int iQVertex = 0;
930 G4int vIndex = pF[iFace].edge[iQVertex].v;
931
932 edgeFlag = (vIndex > 0) ? 1 : 0;
933 index = std::abs(vIndex);
934
935 if (iQVertex >= 3 || pF[iFace].edge[iQVertex+1].v == 0) {
936 iQVertex = 0;
937 if (++iFace > nface) iFace = 1;
938 return false; // Last Edge
939 }else{
940 ++iQVertex;
941 return true; // not Last Edge
942 }
943}

Referenced by G4GMocrenFileSceneHandler::AddPrimitive().

◆ GetNoFacets()

◆ GetNormal()

G4Normal3D HepPolyhedron::GetNormal ( G4int  iFace) const

Definition at line 1211 of file HepPolyhedron.cc.

1220{
1221 if (iFace < 1 || iFace > nface) {
1222 std::cerr
1223 << "HepPolyhedron::GetNormal: irrelevant index " << iFace
1224 << std::endl;
1225 return G4Normal3D();
1226 }
1227
1228 G4int i0 = std::abs(pF[iFace].edge[0].v);
1229 G4int i1 = std::abs(pF[iFace].edge[1].v);
1230 G4int i2 = std::abs(pF[iFace].edge[2].v);
1231 G4int i3 = std::abs(pF[iFace].edge[3].v);
1232 if (i3 == 0) i3 = i0;
1233 return (pV[i2] - pV[i0]).cross(pV[i3] - pV[i1]);
1234}
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:34

◆ GetNoVerteces()

G4int HepPolyhedron::GetNoVerteces ( ) const
inline

Definition at line 268 of file HepPolyhedron.h.

268{ return nvert; } // Old spelling.

◆ GetNoVertices()

G4int HepPolyhedron::GetNoVertices ( ) const
inline

Definition at line 267 of file HepPolyhedron.h.

267{ return nvert; }

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

◆ GetNumberOfRotationSteps()

◆ GetSurfaceArea()

G4double HepPolyhedron::GetSurfaceArea ( ) const

Definition at line 1298 of file HepPolyhedron.cc.

1307{
1308 G4double srf = 0.;
1309 for (G4int iFace=1; iFace<=nface; iFace++) {
1310 G4int i0 = std::abs(pF[iFace].edge[0].v);
1311 G4int i1 = std::abs(pF[iFace].edge[1].v);
1312 G4int i2 = std::abs(pF[iFace].edge[2].v);
1313 G4int i3 = std::abs(pF[iFace].edge[3].v);
1314 if (i3 == 0) i3 = i0;
1315 srf += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).mag();
1316 }
1317 return srf/2.;
1318}
double G4double
Definition: G4Types.hh:83

◆ GetUnitNormal()

G4Normal3D HepPolyhedron::GetUnitNormal ( G4int  iFace) const

Definition at line 1236 of file HepPolyhedron.cc.

1245{
1246 if (iFace < 1 || iFace > nface) {
1247 std::cerr
1248 << "HepPolyhedron::GetUnitNormal: irrelevant index " << iFace
1249 << std::endl;
1250 return G4Normal3D();
1251 }
1252
1253 G4int i0 = std::abs(pF[iFace].edge[0].v);
1254 G4int i1 = std::abs(pF[iFace].edge[1].v);
1255 G4int i2 = std::abs(pF[iFace].edge[2].v);
1256 G4int i3 = std::abs(pF[iFace].edge[3].v);
1257 if (i3 == 0) i3 = i0;
1258 return ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).unit();
1259}

◆ GetVertex()

G4Point3D HepPolyhedron::GetVertex ( G4int  index) const

Definition at line 945 of file HepPolyhedron.cc.

954{
955 if (index <= 0 || index > nvert) {
956 std::cerr
957 << "HepPolyhedron::GetVertex: irrelevant index " << index
958 << std::endl;
959 return G4Point3D();
960 }
961 return pV[index];
962}

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

◆ GetVolume()

G4double HepPolyhedron::GetVolume ( ) const

Definition at line 1320 of file HepPolyhedron.cc.

1329{
1330 G4double v = 0.;
1331 for (G4int iFace=1; iFace<=nface; iFace++) {
1332 G4int i0 = std::abs(pF[iFace].edge[0].v);
1333 G4int i1 = std::abs(pF[iFace].edge[1].v);
1334 G4int i2 = std::abs(pF[iFace].edge[2].v);
1335 G4int i3 = std::abs(pF[iFace].edge[3].v);
1336 G4Point3D pt;
1337 if (i3 == 0) {
1338 i3 = i0;
1339 pt = (pV[i0]+pV[i1]+pV[i2]) * (1./3.);
1340 }else{
1341 pt = (pV[i0]+pV[i1]+pV[i2]+pV[i3]) * 0.25;
1342 }
1343 v += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).dot(pt);
1344 }
1345 return v/6.;
1346}

◆ intersect()

HepPolyhedron HepPolyhedron::intersect ( const HepPolyhedron p) const

Definition at line 2429 of file HepPolyhedron.cc.

2438{
2439 G4int ierr;
2440 BooleanProcessor processor;
2441 return processor.execute(OP_INTERSECTION, *this, p,ierr);
2442}

◆ InvertFacets()

void HepPolyhedron::InvertFacets ( )
protected

Definition at line 867 of file HepPolyhedron.cc.

876{
877 if (nface <= 0) return;
878 G4int i, k, nnode, v[4],f[4];
879 for (i=1; i<=nface; i++) {
880 nnode = (pF[i].edge[3].v == 0) ? 3 : 4;
881 for (k=0; k<nnode; k++) {
882 v[k] = (k+1 == nnode) ? pF[i].edge[0].v : pF[i].edge[k+1].v;
883 if (v[k] * pF[i].edge[k].v < 0) v[k] = -v[k];
884 f[k] = pF[i].edge[k].f;
885 }
886 for (k=0; k<nnode; k++) {
887 pF[i].edge[nnode-1-k].v = v[k];
888 pF[i].edge[nnode-1-k].f = f[k];
889 }
890 }
891}

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

◆ operator=() [1/2]

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

Definition at line 142 of file HepPolyhedron.cc.

151{
152 if (this != &from) {
153 AllocateMemory(from.nvert, from.nface);
154 for (G4int i=1; i<=nvert; i++) pV[i] = from.pV[i];
155 for (G4int k=1; k<=nface; k++) pF[k] = from.pF[k];
156 }
157 return *this;
158}

◆ operator=() [2/2]

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

Definition at line 160 of file HepPolyhedron.cc.

169{
170 if (this != &from) {
171 delete [] pV;
172 delete [] pF;
173 nvert = from.nvert;
174 nface = from.nface;
175 pV = from.pV;
176 pF = from.pF;
177
178 // Release the data from the source object
179 from.nvert = 0;
180 from.nface = 0;
181 from.pV = nullptr;
182 from.pF = nullptr;
183 }
184 return *this;
185}

◆ ResetNumberOfRotationSteps()

void HepPolyhedron::ResetNumberOfRotationSteps ( )
static

◆ RotateAroundZ()

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 471 of file HepPolyhedron.cc.

496{
497 static const G4double wholeCircle = twopi;
498
499 // S E T R O T A T I O N P A R A M E T E R S
500
501 G4bool ifWholeCircle = (std::abs(dphi-wholeCircle) < perMillion) ? true : false;
502 G4double delPhi = ifWholeCircle ? wholeCircle : dphi;
503 G4int nSphi = (nstep > 0) ?
504 nstep : G4int(delPhi*GetNumberOfRotationSteps()/wholeCircle+.5);
505 if (nSphi == 0) nSphi = 1;
506 G4int nVphi = ifWholeCircle ? nSphi : nSphi+1;
507 G4bool ifClosed = np1 > 0 ? false : true;
508
509 // C O U N T V E R T E C E S
510
511 G4int absNp1 = std::abs(np1);
512 G4int absNp2 = std::abs(np2);
513 G4int i1beg = 0;
514 G4int i1end = absNp1-1;
515 G4int i2beg = absNp1;
516 G4int i2end = absNp1+absNp2-1;
517 G4int i, j, k;
518
519 for(i=i1beg; i<=i2end; i++) {
520 if (std::abs(r[i]) < spatialTolerance) r[i] = 0.;
521 }
522
523 j = 0; // external nodes
524 for (i=i1beg; i<=i1end; i++) {
525 j += (r[i] == 0.) ? 1 : nVphi;
526 }
527
528 G4bool ifSide1 = false; // internal nodes
529 G4bool ifSide2 = false;
530
531 if (r[i2beg] != r[i1beg] || z[i2beg] != z[i1beg]) {
532 j += (r[i2beg] == 0.) ? 1 : nVphi;
533 ifSide1 = true;
534 }
535
536 for(i=i2beg+1; i<i2end; i++) {
537 j += (r[i] == 0.) ? 1 : nVphi;
538 }
539
540 if (r[i2end] != r[i1end] || z[i2end] != z[i1end]) {
541 if (absNp2 > 1) j += (r[i2end] == 0.) ? 1 : nVphi;
542 ifSide2 = true;
543 }
544
545 // C O U N T F A C E S
546
547 k = ifClosed ? absNp1*nSphi : (absNp1-1)*nSphi; // external faces
548
549 if (absNp2 > 1) { // internal faces
550 for(i=i2beg; i<i2end; i++) {
551 if (r[i] > 0. || r[i+1] > 0.) k += nSphi;
552 }
553
554 if (ifClosed) {
555 if (r[i2end] > 0. || r[i2beg] > 0.) k += nSphi;
556 }
557 }
558
559 if (!ifClosed) { // side faces
560 if (ifSide1 && (r[i1beg] > 0. || r[i2beg] > 0.)) k += nSphi;
561 if (ifSide2 && (r[i1end] > 0. || r[i2end] > 0.)) k += nSphi;
562 }
563
564 if (!ifWholeCircle) { // phi_side faces
565 k += ifClosed ? 2*absNp1 : 2*(absNp1-1);
566 }
567
568 // A L L O C A T E M E M O R Y
569
570 AllocateMemory(j, k);
571
572 // G E N E R A T E V E R T E C E S
573
574 G4int *kk;
575 kk = new G4int[absNp1+absNp2];
576
577 k = 1;
578 for(i=i1beg; i<=i1end; i++) {
579 kk[i] = k;
580 if (r[i] == 0.)
581 { pV[k++] = G4Point3D(0, 0, z[i]); } else { k += nVphi; }
582 }
583
584 i = i2beg;
585 if (ifSide1) {
586 kk[i] = k;
587 if (r[i] == 0.)
588 { pV[k++] = G4Point3D(0, 0, z[i]); } else { k += nVphi; }
589 }else{
590 kk[i] = kk[i1beg];
591 }
592
593 for(i=i2beg+1; i<i2end; i++) {
594 kk[i] = k;
595 if (r[i] == 0.)
596 { pV[k++] = G4Point3D(0, 0, z[i]); } else { k += nVphi; }
597 }
598
599 if (absNp2 > 1) {
600 i = i2end;
601 if (ifSide2) {
602 kk[i] = k;
603 if (r[i] == 0.) pV[k] = G4Point3D(0, 0, z[i]);
604 }else{
605 kk[i] = kk[i1end];
606 }
607 }
608
609 G4double cosPhi, sinPhi;
610
611 for(j=0; j<nVphi; j++) {
612 cosPhi = std::cos(phi+j*delPhi/nSphi);
613 sinPhi = std::sin(phi+j*delPhi/nSphi);
614 for(i=i1beg; i<=i2end; i++) {
615 if (r[i] != 0.)
616 pV[kk[i]+j] = G4Point3D(r[i]*cosPhi,r[i]*sinPhi,z[i]);
617 }
618 }
619
620 // G E N E R A T E E X T E R N A L F A C E S
621
622 G4int v1,v2;
623
624 k = 1;
625 v2 = ifClosed ? nodeVis : 1;
626 for(i=i1beg; i<i1end; i++) {
627 v1 = v2;
628 if (!ifClosed && i == i1end-1) {
629 v2 = 1;
630 }else{
631 v2 = (r[i] == r[i+1] && r[i+1] == r[i+2]) ? -1 : nodeVis;
632 }
633 RotateEdge(kk[i], kk[i+1], r[i], r[i+1], v1, v2,
634 edgeVis, ifWholeCircle, nSphi, k);
635 }
636 if (ifClosed) {
637 RotateEdge(kk[i1end], kk[i1beg], r[i1end],r[i1beg], nodeVis, nodeVis,
638 edgeVis, ifWholeCircle, nSphi, k);
639 }
640
641 // G E N E R A T E I N T E R N A L F A C E S
642
643 if (absNp2 > 1) {
644 v2 = ifClosed ? nodeVis : 1;
645 for(i=i2beg; i<i2end; i++) {
646 v1 = v2;
647 if (!ifClosed && i==i2end-1) {
648 v2 = 1;
649 }else{
650 v2 = (r[i] == r[i+1] && r[i+1] == r[i+2]) ? -1 : nodeVis;
651 }
652 RotateEdge(kk[i+1], kk[i], r[i+1], r[i], v2, v1,
653 edgeVis, ifWholeCircle, nSphi, k);
654 }
655 if (ifClosed) {
656 RotateEdge(kk[i2beg], kk[i2end], r[i2beg], r[i2end], nodeVis, nodeVis,
657 edgeVis, ifWholeCircle, nSphi, k);
658 }
659 }
660
661 // G E N E R A T E S I D E F A C E S
662
663 if (!ifClosed) {
664 if (ifSide1) {
665 RotateEdge(kk[i2beg], kk[i1beg], r[i2beg], r[i1beg], 1, 1,
666 -1, ifWholeCircle, nSphi, k);
667 }
668 if (ifSide2) {
669 RotateEdge(kk[i1end], kk[i2end], r[i1end], r[i2end], 1, 1,
670 -1, ifWholeCircle, nSphi, k);
671 }
672 }
673
674 // G E N E R A T E S I D E F A C E S for the case of incomplete circle
675
676 if (!ifWholeCircle) {
677
678 G4int ii[4], vv[4];
679
680 if (ifClosed) {
681 for (i=i1beg; i<=i1end; i++) {
682 ii[0] = i;
683 ii[3] = (i == i1end) ? i1beg : i+1;
684 ii[1] = (absNp2 == 1) ? i2beg : ii[0]+absNp1;
685 ii[2] = (absNp2 == 1) ? i2beg : ii[3]+absNp1;
686 vv[0] = -1;
687 vv[1] = 1;
688 vv[2] = -1;
689 vv[3] = 1;
690 SetSideFacets(ii, vv, kk, r, dphi, nSphi, k);
691 }
692 }else{
693 for (i=i1beg; i<i1end; i++) {
694 ii[0] = i;
695 ii[3] = i+1;
696 ii[1] = (absNp2 == 1) ? i2beg : ii[0]+absNp1;
697 ii[2] = (absNp2 == 1) ? i2beg : ii[3]+absNp1;
698 vv[0] = (i == i1beg) ? 1 : -1;
699 vv[1] = 1;
700 vv[2] = (i == i1end-1) ? 1 : -1;
701 vv[3] = 1;
702 SetSideFacets(ii, vv, kk, r, dphi, nSphi, k);
703 }
704 }
705 }
706
707 delete [] kk;
708
709 if (k-1 != nface) {
710 std::cerr
711 << "Polyhedron::RotateAroundZ: number of generated faces ("
712 << k-1 << ") is not equal to the number of allocated faces ("
713 << nface << ")"
714 << std::endl;
715 }
716}
const G4double spatialTolerance
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)
void SetSideFacets(G4int ii[4], G4int vv[4], G4int *kk, G4double *r, G4double dphi, G4int ns, G4int &kface)

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

◆ RotateEdge()

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 338 of file HepPolyhedron.cc.

359{
360 if (r1 == 0. && r2 == 0) return;
361
362 G4int i;
363 G4int i1 = k1;
364 G4int i2 = k2;
365 G4int ii1 = ifWholeCircle ? i1 : i1+nds;
366 G4int ii2 = ifWholeCircle ? i2 : i2+nds;
367 G4int vv = ifWholeCircle ? vEdge : 1;
368
369 if (nds == 1) {
370 if (r1 == 0.) {
371 pF[kface++] = G4Facet(i1,0, v2*i2,0, (i2+1),0);
372 }else if (r2 == 0.) {
373 pF[kface++] = G4Facet(i1,0, i2,0, v1*(i1+1),0);
374 }else{
375 pF[kface++] = G4Facet(i1,0, v2*i2,0, (i2+1),0, v1*(i1+1),0);
376 }
377 }else{
378 if (r1 == 0.) {
379 pF[kface++] = G4Facet(vv*i1,0, v2*i2,0, vEdge*(i2+1),0);
380 for (i2++,i=1; i<nds-1; i2++,i++) {
381 pF[kface++] = G4Facet(vEdge*i1,0, v2*i2,0, vEdge*(i2+1),0);
382 }
383 pF[kface++] = G4Facet(vEdge*i1,0, v2*i2,0, vv*ii2,0);
384 }else if (r2 == 0.) {
385 pF[kface++] = G4Facet(vv*i1,0, vEdge*i2,0, v1*(i1+1),0);
386 for (i1++,i=1; i<nds-1; i1++,i++) {
387 pF[kface++] = G4Facet(vEdge*i1,0, vEdge*i2,0, v1*(i1+1),0);
388 }
389 pF[kface++] = G4Facet(vEdge*i1,0, vv*i2,0, v1*ii1,0);
390 }else{
391 pF[kface++] = G4Facet(vv*i1,0, v2*i2,0, vEdge*(i2+1),0,v1*(i1+1),0);
392 for (i1++,i2++,i=1; i<nds-1; i1++,i2++,i++) {
393 pF[kface++] = G4Facet(vEdge*i1,0, v2*i2,0, vEdge*(i2+1),0,v1*(i1+1),0);
394 }
395 pF[kface++] = G4Facet(vEdge*i1,0, v2*i2,0, vv*ii2,0, v1*ii1,0);
396 }
397 }
398}

Referenced by RotateAroundZ().

◆ SetNumberOfRotationSteps()

void HepPolyhedron::SetNumberOfRotationSteps ( G4int  n)
static

Definition at line 257 of file HepPolyhedron.cc.

266{
267 const G4int nMin = 3;
268 if (n < nMin) {
269 std::cerr
270 << "HepPolyhedron::SetNumberOfRotationSteps: attempt to set the\n"
271 << "number of steps per circle < " << nMin << "; forced to " << nMin
272 << std::endl;
274 }else{
276 }
277}

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

◆ SetReferences()

void HepPolyhedron::SetReferences ( )
protected

Definition at line 718 of file HepPolyhedron.cc.

727{
728 if (nface <= 0) return;
729
730 struct edgeListMember {
731 edgeListMember *next;
732 G4int v2;
733 G4int iface;
734 G4int iedge;
735 } *edgeList, *freeList, **headList;
736
737
738 // A L L O C A T E A N D I N I T I A T E L I S T S
739
740 edgeList = new edgeListMember[2*nface];
741 headList = new edgeListMember*[nvert];
742
743 G4int i;
744 for (i=0; i<nvert; i++) {
745 headList[i] = 0;
746 }
747 freeList = edgeList;
748 for (i=0; i<2*nface-1; i++) {
749 edgeList[i].next = &edgeList[i+1];
750 }
751 edgeList[2*nface-1].next = 0;
752
753 // L O O P A L O N G E D G E S
754
755 G4int iface, iedge, nedge, i1, i2, k1, k2;
756 edgeListMember *prev, *cur;
757
758 for(iface=1; iface<=nface; iface++) {
759 nedge = (pF[iface].edge[3].v == 0) ? 3 : 4;
760 for (iedge=0; iedge<nedge; iedge++) {
761 i1 = iedge;
762 i2 = (iedge < nedge-1) ? iedge+1 : 0;
763 i1 = std::abs(pF[iface].edge[i1].v);
764 i2 = std::abs(pF[iface].edge[i2].v);
765 k1 = (i1 < i2) ? i1 : i2; // k1 = ::min(i1,i2);
766 k2 = (i1 > i2) ? i1 : i2; // k2 = ::max(i1,i2);
767
768 // check head of the List corresponding to k1
769 cur = headList[k1];
770 if (cur == 0) {
771 headList[k1] = freeList;
772 if (!freeList) {
773 std::cerr
774 << "Polyhedron::SetReferences: bad link "
775 << std::endl;
776 break;
777 }
778 freeList = freeList->next;
779 cur = headList[k1];
780 cur->next = 0;
781 cur->v2 = k2;
782 cur->iface = iface;
783 cur->iedge = iedge;
784 continue;
785 }
786
787 if (cur->v2 == k2) {
788 headList[k1] = cur->next;
789 cur->next = freeList;
790 freeList = cur;
791 pF[iface].edge[iedge].f = cur->iface;
792 pF[cur->iface].edge[cur->iedge].f = iface;
793 i1 = (pF[iface].edge[iedge].v < 0) ? -1 : 1;
794 i2 = (pF[cur->iface].edge[cur->iedge].v < 0) ? -1 : 1;
795 if (i1 != i2) {
796 std::cerr
797 << "Polyhedron::SetReferences: different edge visibility "
798 << iface << "/" << iedge << "/"
799 << pF[iface].edge[iedge].v << " and "
800 << cur->iface << "/" << cur->iedge << "/"
801 << pF[cur->iface].edge[cur->iedge].v
802 << std::endl;
803 }
804 continue;
805 }
806
807 // check List itself
808 for (;;) {
809 prev = cur;
810 cur = prev->next;
811 if (cur == 0) {
812 prev->next = freeList;
813 if (!freeList) {
814 std::cerr
815 << "Polyhedron::SetReferences: bad link "
816 << std::endl;
817 break;
818 }
819 freeList = freeList->next;
820 cur = prev->next;
821 cur->next = 0;
822 cur->v2 = k2;
823 cur->iface = iface;
824 cur->iedge = iedge;
825 break;
826 }
827
828 if (cur->v2 == k2) {
829 prev->next = cur->next;
830 cur->next = freeList;
831 freeList = cur;
832 pF[iface].edge[iedge].f = cur->iface;
833 pF[cur->iface].edge[cur->iedge].f = iface;
834 i1 = (pF[iface].edge[iedge].v < 0) ? -1 : 1;
835 i2 = (pF[cur->iface].edge[cur->iedge].v < 0) ? -1 : 1;
836 if (i1 != i2) {
837 std::cerr
838 << "Polyhedron::SetReferences: different edge visibility "
839 << iface << "/" << iedge << "/"
840 << pF[iface].edge[iedge].v << " and "
841 << cur->iface << "/" << cur->iedge << "/"
842 << pF[cur->iface].edge[cur->iedge].v
843 << std::endl;
844 }
845 break;
846 }
847 }
848 }
849 }
850
851 // 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
852
853 for (i=0; i<nvert; i++) {
854 if (headList[i] != 0) {
855 std::cerr
856 << "Polyhedron::SetReferences: List " << i << " is not empty"
857 << std::endl;
858 }
859 }
860
861 // F R E E M E M O R Y
862
863 delete [] edgeList;
864 delete [] headList;
865}

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

◆ SetSideFacets()

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

Definition at line 400 of file HepPolyhedron.cc.

419{
420 G4int k1, k2, k3, k4;
421
422 if (std::abs((G4double)(dphi-pi)) < perMillion) { // half a circle
423 for (G4int i=0; i<4; i++) {
424 k1 = ii[i];
425 k2 = ii[(i+1)%4];
426 if (r[k1] == 0. && r[k2] == 0.) vv[i] = -1;
427 }
428 }
429
430 if (ii[1] == ii[2]) {
431 k1 = kk[ii[0]];
432 k2 = kk[ii[2]];
433 k3 = kk[ii[3]];
434 pF[kface++] = G4Facet(vv[0]*k1,0, vv[2]*k2,0, vv[3]*k3,0);
435 if (r[ii[0]] != 0.) k1 += nds;
436 if (r[ii[2]] != 0.) k2 += nds;
437 if (r[ii[3]] != 0.) k3 += nds;
438 pF[kface++] = G4Facet(vv[2]*k3,0, vv[0]*k2,0, vv[3]*k1,0);
439 }else if (kk[ii[0]] == kk[ii[1]]) {
440 k1 = kk[ii[0]];
441 k2 = kk[ii[2]];
442 k3 = kk[ii[3]];
443 pF[kface++] = G4Facet(vv[1]*k1,0, vv[2]*k2,0, vv[3]*k3,0);
444 if (r[ii[0]] != 0.) k1 += nds;
445 if (r[ii[2]] != 0.) k2 += nds;
446 if (r[ii[3]] != 0.) k3 += nds;
447 pF[kface++] = G4Facet(vv[2]*k3,0, vv[1]*k2,0, vv[3]*k1,0);
448 }else if (kk[ii[2]] == kk[ii[3]]) {
449 k1 = kk[ii[0]];
450 k2 = kk[ii[1]];
451 k3 = kk[ii[2]];
452 pF[kface++] = G4Facet(vv[0]*k1,0, vv[1]*k2,0, vv[3]*k3,0);
453 if (r[ii[0]] != 0.) k1 += nds;
454 if (r[ii[1]] != 0.) k2 += nds;
455 if (r[ii[2]] != 0.) k3 += nds;
456 pF[kface++] = G4Facet(vv[1]*k3,0, vv[0]*k2,0, vv[3]*k1,0);
457 }else{
458 k1 = kk[ii[0]];
459 k2 = kk[ii[1]];
460 k3 = kk[ii[2]];
461 k4 = kk[ii[3]];
462 pF[kface++] = G4Facet(vv[0]*k1,0, vv[1]*k2,0, vv[2]*k3,0, vv[3]*k4,0);
463 if (r[ii[0]] != 0.) k1 += nds;
464 if (r[ii[1]] != 0.) k2 += nds;
465 if (r[ii[2]] != 0.) k3 += nds;
466 if (r[ii[3]] != 0.) k4 += nds;
467 pF[kface++] = G4Facet(vv[2]*k4,0, vv[1]*k3,0, vv[0]*k2,0, vv[3]*k1,0);
468 }
469}

Referenced by RotateAroundZ().

◆ subtract()

HepPolyhedron HepPolyhedron::subtract ( const HepPolyhedron p) const

Definition at line 2444 of file HepPolyhedron.cc.

2453{
2454 G4int ierr;
2455 BooleanProcessor processor;
2456 return processor.execute(OP_SUBTRACTION, *this, p,ierr);
2457}

◆ Transform()

HepPolyhedron & HepPolyhedron::Transform ( const G4Transform3D t)

Definition at line 893 of file HepPolyhedron.cc.

902{
903 if (nvert > 0) {
904 for (G4int i=1; i<=nvert; i++) { pV[i] = t * pV[i]; }
905
906 // C H E C K D E T E R M I N A N T A N D
907 // 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
908
909 G4Vector3D d = t * G4Vector3D(0,0,0);
910 G4Vector3D x = t * G4Vector3D(1,0,0) - d;
911 G4Vector3D y = t * G4Vector3D(0,1,0) - d;
912 G4Vector3D z = t * G4Vector3D(0,0,1) - d;
913 if ((x.cross(y))*z < 0) InvertFacets();
914 }
915 return *this;
916}
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:34
BasicVector3D< T > cross(const BasicVector3D< T > &v) const

Referenced by G4GMocrenFileSceneHandler::AddSolid(), G4ReflectedSolid::CreatePolyhedron(), G4DisplacedSolid::CreatePolyhedron(), G4ScaledSolid::CreatePolyhedron(), G4EllipticalTube::CreatePolyhedron(), G4ScoringBox::Draw(), G4ScoringCylinder::Draw(), G4ScoringBox::DrawColumn(), G4ScoringCylinder::DrawColumn(), G4ArrowModel::G4ArrowModel(), G4ASCIITreeSceneHandler::RequestPrimitives(), and G4VisCommandsTouchable::SetNewValue().

Friends And Related Function Documentation

◆ operator<<

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 << "Nvertices=" << 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}

Member Data Documentation

◆ fNumberOfRotationSteps

G4ThreadLocal G4int HepPolyhedron::fNumberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS
staticprotected

◆ nface

◆ nvert

◆ pF

◆ pV


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