Geant4 9.6.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)
 
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 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() [1/2]

HepPolyhedron::HepPolyhedron ( )
inline

Definition at line 240 of file HepPolyhedron.h.

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

◆ HepPolyhedron() [2/2]

HepPolyhedron::HepPolyhedron ( const HepPolyhedron from)

Definition at line 105 of file HepPolyhedron.cc.

112: nvert(0), nface(0), pV(0), pF(0)
113{
114 AllocateMemory(from.nvert, from.nface);
115 for (G4int i=1; i<=nvert; i++) pV[i] = from.pV[i];
116 for (G4int k=1; k<=nface; k++) pF[k] = from.pF[k];
117}
int G4int
Definition: G4Types.hh:66
void AllocateMemory(G4int Nvert, G4int Nface)

◆ ~HepPolyhedron()

virtual HepPolyhedron::~HepPolyhedron ( )
inlinevirtual

Definition at line 246 of file HepPolyhedron.h.

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

Member Function Documentation

◆ add()

HepPolyhedron HepPolyhedron::add ( const HepPolyhedron p) const

Definition at line 2259 of file HepPolyhedron.cc.

2268{
2269 G4int ierr;
2270 BooleanProcessor processor;
2271 return processor.execute(OP_UNION, *this, p,ierr);
2272}
#define processor
Definition: xmlparse.cc:600

◆ AllocateMemory()

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

Definition at line 242 of file HepPolyhedron.cc.

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

Referenced by createPolyhedron(), createTwistedTrap(), G4PolyhedronArbitrary::G4PolyhedronArbitrary(), HepPolyhedron(), 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 1356 of file HepPolyhedron.cc.

1372{
1373 AllocateMemory(Nnodes, Nfaces);
1374 if (nvert == 0) return 1;
1375
1376 for (G4int i=0; i<Nnodes; i++) {
1377 pV[i+1] = G4Point3D(xyz[i][0], xyz[i][1], xyz[i][2]);
1378 }
1379 for (G4int k=0; k<Nfaces; k++) {
1380 pF[k+1] = G4Facet(faces[k][0],0,faces[k][1],0,faces[k][2],0,faces[k][3],0);
1381 }
1382 SetReferences();
1383 return 0;
1384}
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
void SetReferences()

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

◆ CreatePrism()

void HepPolyhedron::CreatePrism ( )
protected

Definition at line 268 of file HepPolyhedron.cc.

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

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

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

◆ FindNeighbour()

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

Definition at line 138 of file HepPolyhedron.cc.

147{
148 G4int i;
149 for (i=0; i<4; i++) {
150 if (iNode == std::abs(pF[iFace].edge[i].v)) break;
151 }
152 if (i == 4) {
153 std::cerr
154 << "HepPolyhedron::FindNeighbour: face " << iFace
155 << " has no node " << iNode
156 << std::endl;
157 return 0;
158 }
159 if (iOrder < 0) {
160 if ( --i < 0) i = 3;
161 if (pF[iFace].edge[i].v == 0) i = 2;
162 }
163 return (pF[iFace].edge[i].v > 0) ? 0 : pF[iFace].edge[i].f;
164}

◆ FindNodeNormal()

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

Definition at line 166 of file HepPolyhedron.cc.

175{
176 G4Normal3D normal = GetUnitNormal(iFace);
177 G4int k = iFace, iOrder = 1, n = 1;
178
179 for(;;) {
180 k = FindNeighbour(k, iNode, iOrder);
181 if (k == iFace) break;
182 if (k > 0) {
183 n++;
184 normal += GetUnitNormal(k);
185 }else{
186 if (iOrder < 0) break;
187 k = iFace;
188 iOrder = -iOrder;
189 }
190 }
191 return normal.unit();
192}
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 1063 of file HepPolyhedron.cc.

1073{
1074 if (iFace < 1 || iFace > nface) {
1075 std::cerr
1076 << "HepPolyhedron::GetFacet: irrelevant index " << iFace
1077 << std::endl;
1078 n = 0;
1079 }else{
1080 G4int i, k;
1081 for (i=0; i<4; i++) {
1082 k = pF[iFace].edge[i].v;
1083 if (k == 0) break;
1084 if (iFaces != 0) iFaces[i] = pF[iFace].edge[i].f;
1085 if (k > 0) {
1086 iNodes[i] = k;
1087 if (edgeFlags != 0) edgeFlags[i] = 1;
1088 }else{
1089 iNodes[i] = -k;
1090 if (edgeFlags != 0) edgeFlags[i] = -1;
1091 }
1092 }
1093 n = i;
1094 }
1095}

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

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

1034{
1035 G4int i1,i2;
1036 G4bool rep = GetNextEdgeIndeces(i1,i2,edgeFlag);
1037 p1 = pV[i1];
1038 p2 = pV[i2];
1039 return rep;
1040}
bool G4bool
Definition: G4Types.hh:67
G4bool GetNextEdgeIndeces(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 1043 of file HepPolyhedron.cc.

1055{
1056 G4int i1,i2;
1057 G4bool rep = GetNextEdgeIndeces(i1,i2,edgeFlag,iface1,iface2);
1058 p1 = pV[i1];
1059 p2 = pV[i2];
1060 return rep;
1061}

◆ GetNextEdgeIndeces() [1/2]

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

Definition at line 1006 of file HepPolyhedron.cc.

1016{
1017 G4int kface1, kface2;
1018 return GetNextEdgeIndeces(i1, i2, edgeFlag, kface1, kface2);
1019}

◆ GetNextEdgeIndeces() [2/2]

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

Definition at line 953 of file HepPolyhedron.cc.

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

◆ GetNextFacet()

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

Definition at line 1119 of file HepPolyhedron.cc.

1130{
1131 static G4int iFace = 1;
1132
1133 if (edgeFlags == 0) {
1134 GetFacet(iFace, n, nodes);
1135 }else if (normals == 0) {
1136 GetFacet(iFace, n, nodes, edgeFlags);
1137 }else{
1138 GetFacet(iFace, n, nodes, edgeFlags, normals);
1139 }
1140
1141 if (++iFace > nface) {
1142 iFace = 1;
1143 return false;
1144 }else{
1145 return true;
1146 }
1147}

◆ GetNextNormal()

G4bool HepPolyhedron::GetNextNormal ( G4Normal3D normal) const

Definition at line 1199 of file HepPolyhedron.cc.

1209{
1210 static G4int iFace = 1;
1211 normal = GetNormal(iFace);
1212 if (++iFace > nface) {
1213 iFace = 1;
1214 return false;
1215 }else{
1216 return true;
1217 }
1218}
G4Normal3D GetNormal(G4int iFace) const

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

◆ GetNextUnitNormal()

G4bool HepPolyhedron::GetNextUnitNormal ( G4Normal3D normal) const

Definition at line 1220 of file HepPolyhedron.cc.

1230{
1231 G4bool rep = GetNextNormal(normal);
1232 normal = normal.unit();
1233 return rep;
1234}
G4bool GetNextNormal(G4Normal3D &normal) const

◆ GetNextVertex() [1/2]

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

Definition at line 903 of file HepPolyhedron.cc.

914{
915 G4int index;
916 G4bool rep = GetNextVertexIndex(index, edgeFlag);
917 vertex = pV[index];
918 return rep;
919}
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 921 of file HepPolyhedron.cc.

933{
934 static G4int iFace = 1;
935 static G4int iNode = 0;
936
937 if (nface == 0) return false; // empty polyhedron
938
939 G4int k = pF[iFace].edge[iNode].v;
940 if (k > 0) { edgeFlag = 1; } else { edgeFlag = -1; k = -k; }
941 vertex = pV[k];
942 normal = FindNodeNormal(iFace,k);
943 if (iNode >= 3 || pF[iFace].edge[iNode+1].v == 0) {
944 iNode = 0;
945 if (++iFace > nface) iFace = 1;
946 return false; // last node
947 }else{
948 ++iNode;
949 return true; // not last node
950 }
951}

◆ GetNextVertexIndex()

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

Definition at line 856 of file HepPolyhedron.cc.

865{
866 static G4int iFace = 1;
867 static G4int iQVertex = 0;
868 G4int vIndex = pF[iFace].edge[iQVertex].v;
869
870 edgeFlag = (vIndex > 0) ? 1 : 0;
871 index = std::abs(vIndex);
872
873 if (iQVertex >= 3 || pF[iFace].edge[iQVertex+1].v == 0) {
874 iQVertex = 0;
875 if (++iFace > nface) iFace = 1;
876 return false; // Last Edge
877 }else{
878 ++iQVertex;
879 return true; // not Last Edge
880 }
881}

Referenced by G4GMocrenFileSceneHandler::AddPrimitive().

◆ GetNoFacets()

◆ GetNormal()

G4Normal3D HepPolyhedron::GetNormal ( G4int  iFace) const

Definition at line 1149 of file HepPolyhedron.cc.

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

◆ GetNoVertices()

G4int HepPolyhedron::GetNoVertices ( ) const
inline

Definition at line 252 of file HepPolyhedron.h.

252{ return nvert; }

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

◆ GetNumberOfRotationSteps()

◆ GetSurfaceArea()

G4double HepPolyhedron::GetSurfaceArea ( ) const

Definition at line 1236 of file HepPolyhedron.cc.

1245{
1246 G4double srf = 0.;
1247 for (G4int iFace=1; iFace<=nface; iFace++) {
1248 G4int i0 = std::abs(pF[iFace].edge[0].v);
1249 G4int i1 = std::abs(pF[iFace].edge[1].v);
1250 G4int i2 = std::abs(pF[iFace].edge[2].v);
1251 G4int i3 = std::abs(pF[iFace].edge[3].v);
1252 if (i3 == 0) i3 = i0;
1253 srf += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).mag();
1254 }
1255 return srf/2.;
1256}
double G4double
Definition: G4Types.hh:64

◆ GetUnitNormal()

G4Normal3D HepPolyhedron::GetUnitNormal ( G4int  iFace) const

Definition at line 1174 of file HepPolyhedron.cc.

1183{
1184 if (iFace < 1 || iFace > nface) {
1185 std::cerr
1186 << "HepPolyhedron::GetUnitNormal: irrelevant index " << iFace
1187 << std::endl;
1188 return G4Normal3D();
1189 }
1190
1191 G4int i0 = std::abs(pF[iFace].edge[0].v);
1192 G4int i1 = std::abs(pF[iFace].edge[1].v);
1193 G4int i2 = std::abs(pF[iFace].edge[2].v);
1194 G4int i3 = std::abs(pF[iFace].edge[3].v);
1195 if (i3 == 0) i3 = i0;
1196 return ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).unit();
1197}

◆ GetVertex()

G4Point3D HepPolyhedron::GetVertex ( G4int  index) const

Definition at line 883 of file HepPolyhedron.cc.

892{
893 if (index <= 0 || index > nvert) {
894 std::cerr
895 << "HepPolyhedron::GetVertex: irrelevant index " << index
896 << std::endl;
897 return G4Point3D();
898 }
899 return pV[index];
900}

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

◆ GetVolume()

G4double HepPolyhedron::GetVolume ( ) const

Definition at line 1258 of file HepPolyhedron.cc.

1267{
1268 G4double v = 0.;
1269 for (G4int iFace=1; iFace<=nface; iFace++) {
1270 G4int i0 = std::abs(pF[iFace].edge[0].v);
1271 G4int i1 = std::abs(pF[iFace].edge[1].v);
1272 G4int i2 = std::abs(pF[iFace].edge[2].v);
1273 G4int i3 = std::abs(pF[iFace].edge[3].v);
1274 G4Point3D pt;
1275 if (i3 == 0) {
1276 i3 = i0;
1277 pt = (pV[i0]+pV[i1]+pV[i2]) * (1./3.);
1278 }else{
1279 pt = (pV[i0]+pV[i1]+pV[i2]+pV[i3]) * 0.25;
1280 }
1281 v += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).dot(pt);
1282 }
1283 return v/6.;
1284}

◆ intersect()

HepPolyhedron HepPolyhedron::intersect ( const HepPolyhedron p) const

Definition at line 2274 of file HepPolyhedron.cc.

2283{
2284 G4int ierr;
2285 BooleanProcessor processor;
2286 return processor.execute(OP_INTERSECTION, *this, p,ierr);
2287}

◆ InvertFacets()

void HepPolyhedron::InvertFacets ( )
protected

Definition at line 805 of file HepPolyhedron.cc.

814{
815 if (nface <= 0) return;
816 G4int i, k, nnode, v[4],f[4];
817 for (i=1; i<=nface; i++) {
818 nnode = (pF[i].edge[3].v == 0) ? 3 : 4;
819 for (k=0; k<nnode; k++) {
820 v[k] = (k+1 == nnode) ? pF[i].edge[0].v : pF[i].edge[k+1].v;
821 if (v[k] * pF[i].edge[k].v < 0) v[k] = -v[k];
822 f[k] = pF[i].edge[k].f;
823 }
824 for (k=0; k<nnode; k++) {
825 pF[i].edge[nnode-1-k].v = v[k];
826 pF[i].edge[nnode-1-k].f = f[k];
827 }
828 }
829}

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

◆ operator=()

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

Definition at line 119 of file HepPolyhedron.cc.

128{
129 if (this != &from) {
130 AllocateMemory(from.nvert, from.nface);
131 for (G4int i=1; i<=nvert; i++) pV[i] = from.pV[i];
132 for (G4int k=1; k<=nface; k++) pF[k] = from.pF[k];
133 }
134 return *this;
135}

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

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

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

Referenced by RotateAroundZ().

◆ SetNumberOfRotationSteps()

void HepPolyhedron::SetNumberOfRotationSteps ( G4int  n)
static

Definition at line 207 of file HepPolyhedron.cc.

216{
217 const G4int nMin = 3;
218 if (n < nMin) {
219 std::cerr
220 << "HepPolyhedron::SetNumberOfRotationSteps: attempt to set the\n"
221 << "number of steps per circle < " << nMin << "; forced to " << nMin
222 << std::endl;
224 }else{
226 }
227}

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

◆ SetReferences()

void HepPolyhedron::SetReferences ( )
protected

Definition at line 668 of file HepPolyhedron.cc.

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

Referenced by createPolyhedron(), HepPolyhedronCons::HepPolyhedronCons(), HepPolyhedronEllipsoid::HepPolyhedronEllipsoid(), HepPolyhedronEllipticalCone::HepPolyhedronEllipticalCone(), HepPolyhedronHype::HepPolyhedronHype(), 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 350 of file HepPolyhedron.cc.

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

Referenced by RotateAroundZ().

◆ subtract()

HepPolyhedron HepPolyhedron::subtract ( const HepPolyhedron p) const

Definition at line 2289 of file HepPolyhedron.cc.

2298{
2299 G4int ierr;
2300 BooleanProcessor processor;
2301 return processor.execute(OP_SUBTRACTION, *this, p,ierr);
2302}

◆ Transform()

HepPolyhedron & HepPolyhedron::Transform ( const G4Transform3D t)

Definition at line 831 of file HepPolyhedron.cc.

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

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

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 90 of file HepPolyhedron.cc.

90 {
91 ostr << std::endl;
92 ostr << "Nverteces=" << ph.nvert << ", Nfacets=" << ph.nface << std::endl;
93 G4int i;
94 for (i=1; i<=ph.nvert; i++) {
95 ostr << "xyz(" << i << ")="
96 << ph.pV[i].x() << ' ' << ph.pV[i].y() << ' ' << ph.pV[i].z()
97 << std::endl;
98 }
99 for (i=1; i<=ph.nface; i++) {
100 ostr << "face(" << i << ")=" << ph.pF[i] << std::endl;
101 }
102 return ostr;
103}

Member Data Documentation

◆ fNumberOfRotationSteps

G4int HepPolyhedron::fNumberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS
staticprotected

◆ nface

◆ nvert

◆ pF

◆ pV


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