Geant4-11
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes
G4PolyhedronTube Class Reference

#include <G4Polyhedron.hh>

Inheritance diagram for G4PolyhedronTube:
G4Polyhedron HepPolyhedron G4Visible

Public Member Functions

HepPolyhedron add (const HepPolyhedron &p) const
 
G4int createPolyhedron (G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
 
G4int createTwistedTrap (G4double Dz, const G4double xy1[][2], const G4double xy2[][2])
 
 G4PolyhedronTube (G4double Rmin, G4double Rmax, G4double Dz)
 
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 GetNextEdge (G4Point3D &p1, G4Point3D &p2, G4int &edgeFlag) const
 
G4bool GetNextEdge (G4Point3D &p1, G4Point3D &p2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
 
G4bool GetNextEdgeIndeces (G4int &i1, G4int &i2, G4int &edgeFlag) const
 
G4bool GetNextEdgeIndeces (G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
 
G4bool GetNextEdgeIndices (G4int &i1, G4int &i2, G4int &edgeFlag) const
 
G4bool GetNextEdgeIndices (G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const
 
G4bool GetNextFacet (G4int &n, G4Point3D *nodes, G4int *edgeFlags=0, G4Normal3D *normals=0) const
 
G4bool GetNextNormal (G4Normal3D &normal) const
 
G4bool GetNextUnitNormal (G4Normal3D &normal) const
 
G4bool GetNextVertex (G4Point3D &vertex, G4int &edgeFlag) const
 
G4bool GetNextVertex (G4Point3D &vertex, G4int &edgeFlag, G4Normal3D &normal) const
 
G4bool GetNextVertexIndex (G4int &index, G4int &edgeFlag) const
 
G4int GetNoFacets () const
 
G4Normal3D GetNormal (G4int iFace) const
 
G4int GetNoVerteces () const
 
G4int GetNoVertices () const
 
G4int GetNumberOfRotationStepsAtTimeOfCreation () const
 
G4double GetSurfaceArea () const
 
G4Normal3D GetUnitNormal (G4int iFace) const
 
G4Point3D GetVertex (G4int index) const
 
const G4VisAttributesGetVisAttributes () const
 
G4double GetVolume () const
 
HepPolyhedron intersect (const HepPolyhedron &p) const
 
G4bool operator!= (const G4Visible &right) const
 
void SetVisAttributes (const G4VisAttributes &)
 
void SetVisAttributes (const G4VisAttributes *)
 
HepPolyhedron subtract (const HepPolyhedron &p) const
 
HepPolyhedronTransform (const G4Transform3D &t)
 
virtual ~G4PolyhedronTube ()
 

Static Public Member Functions

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

Protected Member Functions

void AllocateMemory (G4int Nvert, G4int Nface)
 
G4bool CheckSnip (const std::vector< G4TwoVector > &contour, G4int a, G4int b, G4int c, G4int n, const G4int *V)
 
void CreatePrism ()
 
G4int FindNeighbour (G4int iFace, G4int iNode, G4int iOrder) const
 
G4Normal3D FindNodeNormal (G4int iFace, G4int iNode) const
 
void InvertFacets ()
 
void RotateAroundZ (G4int nstep, G4double phi, G4double dphi, G4int np1, G4int np2, const G4double *z, G4double *r, G4int nodeVis, G4int edgeVis)
 
void RotateContourAroundZ (G4int nstep, G4double phi, G4double dphi, const std::vector< G4TwoVector > &rz, G4int nodeVis, G4int edgeVis)
 
void RotateEdge (G4int k1, G4int k2, G4double r1, G4double r2, G4int v1, G4int v2, G4int vEdge, G4bool ifWholeCircle, G4int ns, G4int &kface)
 
void SetReferences ()
 
void SetSideFacets (G4int ii[4], G4int vv[4], G4int *kk, G4double *r, G4double dphi, G4int ns, G4int &kface)
 
G4bool TriangulatePolygon (const std::vector< G4TwoVector > &polygon, std::vector< G4int > &result)
 

Protected Attributes

G4bool fAllocatedVisAttributes
 
const G4VisAttributesfpVisAttributes
 
G4int nface
 
G4int nvert
 
G4FacetpF
 
G4Point3DpV
 

Static Protected Attributes

static G4ThreadLocal G4int fNumberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS
 

Private Attributes

G4int fNumberOfRotationStepsAtTimeOfCreation
 

Detailed Description

Definition at line 237 of file G4Polyhedron.hh.

Constructor & Destructor Documentation

◆ G4PolyhedronTube()

G4PolyhedronTube::G4PolyhedronTube ( G4double  Rmin,
G4double  Rmax,
G4double  Dz 
)

Definition at line 137 of file G4Polyhedron.cc.

137 :
138 G4Polyhedron (HepPolyhedronTube (Rmin, Rmax, Dz)) {}

◆ ~G4PolyhedronTube()

G4PolyhedronTube::~G4PolyhedronTube ( )
virtual

Definition at line 140 of file G4Polyhedron.cc.

140{}

Member Function Documentation

◆ add()

HepPolyhedron HepPolyhedron::add ( const HepPolyhedron p) const
inherited

Definition at line 2788 of file HepPolyhedron.cc.

2797{
2798 G4int ierr;
2799 BooleanProcessor processor;
2800 return processor.execute(OP_UNION, *this, p,ierr);
2801}
int G4int
Definition: G4Types.hh:85
#define processor
Definition: xmlparse.cc:617

References processor.

◆ AllocateMemory()

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

◆ CheckSnip()

G4bool HepPolyhedron::CheckSnip ( const std::vector< G4TwoVector > &  contour,
G4int  a,
G4int  b,
G4int  c,
G4int  n,
const G4int V 
)
protectedinherited

Definition at line 985 of file HepPolyhedron.cc.

997{
998 static const G4double kCarTolerance = 1.e-9;
999
1000 // check orientation of Triangle
1001 G4double Ax = contour[V[a]].x(), Ay = contour[V[a]].y();
1002 G4double Bx = contour[V[b]].x(), By = contour[V[b]].y();
1003 G4double Cx = contour[V[c]].x(), Cy = contour[V[c]].y();
1004 if ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax) < kCarTolerance) return false;
1005
1006 // check that there is no point inside Triangle
1007 G4double xmin = std::min(std::min(Ax,Bx),Cx);
1008 G4double xmax = std::max(std::max(Ax,Bx),Cx);
1009 G4double ymin = std::min(std::min(Ay,By),Cy);
1010 G4double ymax = std::max(std::max(Ay,By),Cy);
1011
1012 for (G4int i=0; i<n; ++i)
1013 {
1014 if((i == a) || (i == b) || (i == c)) continue;
1015 G4double Px = contour[V[i]].x();
1016 if (Px < xmin || Px > xmax) continue;
1017 G4double Py = contour[V[i]].y();
1018 if (Py < ymin || Py > ymax) continue;
1019 // if (PointInTriangle(Ax,Ay,Bx,By,Cx,Cy,Px,Py)) return false;
1020 if ((Bx-Ax)*(Cy-Ay) - (By-Ay)*(Cx-Ax) > 0.)
1021 {
1022 if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) < 0.) continue;
1023 if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) < 0.) continue;
1024 if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) < 0.) continue;
1025 }
1026 else
1027 {
1028 if ((Ax-Cx)*(Py-Cy) - (Ay-Cy)*(Px-Cx) > 0.) continue;
1029 if ((Bx-Ax)*(Py-Ay) - (By-Ay)*(Px-Ax) > 0.) continue;
1030 if ((Cx-Bx)*(Py-By) - (Cy-By)*(Px-Bx) > 0.) continue;
1031 }
1032 return false;
1033 }
1034 return true;
1035}
const G4double kCarTolerance
double G4double
Definition: G4Types.hh:83
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References kCarTolerance, G4INCL::Math::max(), G4INCL::Math::min(), and CLHEP::detail::n.

Referenced by HepPolyhedron::TriangulatePolygon().

◆ createPolyhedron()

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

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

1753{
1754 AllocateMemory(Nnodes, Nfaces);
1755 if (nvert == 0) return 1;
1756
1757 for (G4int i=0; i<Nnodes; i++) {
1758 pV[i+1] = G4Point3D(xyz[i][0], xyz[i][1], xyz[i][2]);
1759 }
1760 for (G4int k=0; k<Nfaces; k++) {
1761 pF[k+1] = G4Facet(faces[k][0],0,faces[k][1],0,faces[k][2],0,faces[k][3],0);
1762 }
1763 SetReferences();
1764 return 0;
1765}
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:34
void AllocateMemory(G4int Nvert, G4int Nface)

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

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

◆ CreatePrism()

void HepPolyhedron::CreatePrism ( )
protectedinherited

Definition at line 322 of file HepPolyhedron.cc.

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

References HepPolyhedron::pF.

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

◆ createTwistedTrap()

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

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

1684{
1685 AllocateMemory(12,18);
1686
1687 pV[ 1] = G4Point3D(xy1[0][0],xy1[0][1],-Dz);
1688 pV[ 2] = G4Point3D(xy1[1][0],xy1[1][1],-Dz);
1689 pV[ 3] = G4Point3D(xy1[2][0],xy1[2][1],-Dz);
1690 pV[ 4] = G4Point3D(xy1[3][0],xy1[3][1],-Dz);
1691
1692 pV[ 5] = G4Point3D(xy2[0][0],xy2[0][1], Dz);
1693 pV[ 6] = G4Point3D(xy2[1][0],xy2[1][1], Dz);
1694 pV[ 7] = G4Point3D(xy2[2][0],xy2[2][1], Dz);
1695 pV[ 8] = G4Point3D(xy2[3][0],xy2[3][1], Dz);
1696
1697 pV[ 9] = (pV[1]+pV[2]+pV[5]+pV[6])/4.;
1698 pV[10] = (pV[2]+pV[3]+pV[6]+pV[7])/4.;
1699 pV[11] = (pV[3]+pV[4]+pV[7]+pV[8])/4.;
1700 pV[12] = (pV[4]+pV[1]+pV[8]+pV[5])/4.;
1701
1702 enum {DUMMY, BOTTOM,
1703 LEFT_BOTTOM, LEFT_FRONT, LEFT_TOP, LEFT_BACK,
1704 BACK_BOTTOM, BACK_LEFT, BACK_TOP, BACK_RIGHT,
1705 RIGHT_BOTTOM, RIGHT_BACK, RIGHT_TOP, RIGHT_FRONT,
1706 FRONT_BOTTOM, FRONT_RIGHT, FRONT_TOP, FRONT_LEFT,
1707 TOP};
1708
1709 pF[ 1]=G4Facet(1,LEFT_BOTTOM, 4,BACK_BOTTOM, 3,RIGHT_BOTTOM, 2,FRONT_BOTTOM);
1710
1711 pF[ 2]=G4Facet(4,BOTTOM, -1,LEFT_FRONT, -12,LEFT_BACK, 0,0);
1712 pF[ 3]=G4Facet(1,FRONT_LEFT, -5,LEFT_TOP, -12,LEFT_BOTTOM, 0,0);
1713 pF[ 4]=G4Facet(5,TOP, -8,LEFT_BACK, -12,LEFT_FRONT, 0,0);
1714 pF[ 5]=G4Facet(8,BACK_LEFT, -4,LEFT_BOTTOM, -12,LEFT_TOP, 0,0);
1715
1716 pF[ 6]=G4Facet(3,BOTTOM, -4,BACK_LEFT, -11,BACK_RIGHT, 0,0);
1717 pF[ 7]=G4Facet(4,LEFT_BACK, -8,BACK_TOP, -11,BACK_BOTTOM, 0,0);
1718 pF[ 8]=G4Facet(8,TOP, -7,BACK_RIGHT, -11,BACK_LEFT, 0,0);
1719 pF[ 9]=G4Facet(7,RIGHT_BACK, -3,BACK_BOTTOM, -11,BACK_TOP, 0,0);
1720
1721 pF[10]=G4Facet(2,BOTTOM, -3,RIGHT_BACK, -10,RIGHT_FRONT, 0,0);
1722 pF[11]=G4Facet(3,BACK_RIGHT, -7,RIGHT_TOP, -10,RIGHT_BOTTOM, 0,0);
1723 pF[12]=G4Facet(7,TOP, -6,RIGHT_FRONT, -10,RIGHT_BACK, 0,0);
1724 pF[13]=G4Facet(6,FRONT_RIGHT,-2,RIGHT_BOTTOM,-10,RIGHT_TOP, 0,0);
1725
1726 pF[14]=G4Facet(1,BOTTOM, -2,FRONT_RIGHT, -9,FRONT_LEFT, 0,0);
1727 pF[15]=G4Facet(2,RIGHT_FRONT,-6,FRONT_TOP, -9,FRONT_BOTTOM, 0,0);
1728 pF[16]=G4Facet(6,TOP, -5,FRONT_LEFT, -9,FRONT_RIGHT, 0,0);
1729 pF[17]=G4Facet(5,LEFT_FRONT, -1,FRONT_BOTTOM, -9,FRONT_TOP, 0,0);
1730
1731 pF[18]=G4Facet(5,FRONT_TOP, 6,RIGHT_TOP, 7,BACK_TOP, 8,LEFT_TOP);
1732
1733 return 0;
1734}

References HepPolyhedron::AllocateMemory(), HepPolyhedron::pF, and HepPolyhedron::pV.

◆ FindNeighbour()

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

Definition at line 192 of file HepPolyhedron.cc.

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

◆ FindNodeNormal()

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

Definition at line 220 of file HepPolyhedron.cc.

229{
231 G4int k = iFace, iOrder = 1, n = 1;
232
233 for(;;) {
234 k = FindNeighbour(k, iNode, iOrder);
235 if (k == iFace) break;
236 if (k > 0) {
237 n++;
238 normal += GetUnitNormal(k);
239 }else{
240 if (iOrder < 0) break;
241 k = iFace;
242 iOrder = -iOrder;
243 }
244 }
245 return normal.unit();
246}
G4Normal3D GetUnitNormal(G4int iFace) const
G4int FindNeighbour(G4int iFace, G4int iNode, G4int iOrder) const
static double normal(HepRandomEngine *eptr)
Definition: RandPoisson.cc:79

References CLHEP::detail::n, and CLHEP::normal().

◆ GetFacet() [1/2]

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

Definition at line 1444 of file HepPolyhedron.cc.

1454{
1455 if (iFace < 1 || iFace > nface) {
1456 std::cerr
1457 << "HepPolyhedron::GetFacet: irrelevant index " << iFace
1458 << std::endl;
1459 n = 0;
1460 }else{
1461 G4int i, k;
1462 for (i=0; i<4; i++) {
1463 k = pF[iFace].edge[i].v;
1464 if (k == 0) break;
1465 if (iFaces != 0) iFaces[i] = pF[iFace].edge[i].f;
1466 if (k > 0) {
1467 iNodes[i] = k;
1468 if (edgeFlags != 0) edgeFlags[i] = 1;
1469 }else{
1470 iNodes[i] = -k;
1471 if (edgeFlags != 0) edgeFlags[i] = -1;
1472 }
1473 }
1474 n = i;
1475 }
1476}

References CLHEP::detail::n.

Referenced by G4CutTubs::CreatePolyhedron().

◆ GetFacet() [2/2]

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

Definition at line 1478 of file HepPolyhedron.cc.

1488{
1489 G4int iNodes[4];
1490 GetFacet(index, n, iNodes, edgeFlags);
1491 if (n != 0) {
1492 for (G4int i=0; i<n; i++) {
1493 nodes[i] = pV[iNodes[i]];
1494 if (normals != 0) normals[i] = FindNodeNormal(index,iNodes[i]);
1495 }
1496 }
1497}
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
G4Normal3D FindNodeNormal(G4int iFace, G4int iNode) const

References CLHEP::detail::n, and geant4_check_module_cycles::nodes.

◆ GetNextEdge() [1/2]

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

Definition at line 1403 of file HepPolyhedron.cc.

1415{
1416 G4int i1,i2;
1417 G4bool rep = GetNextEdgeIndices(i1,i2,edgeFlag);
1418 p1 = pV[i1];
1419 p2 = pV[i2];
1420 return rep;
1421}
bool G4bool
Definition: G4Types.hh:86
G4bool GetNextEdgeIndices(G4int &i1, G4int &i2, G4int &edgeFlag, G4int &iface1, G4int &iface2) const

Referenced by G4GMocrenFileSceneHandler::AddSolid(), and G4GMocrenFileSceneHandler::ExtractDetector().

◆ GetNextEdge() [2/2]

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

Definition at line 1424 of file HepPolyhedron.cc.

1436{
1437 G4int i1,i2;
1438 G4bool rep = GetNextEdgeIndices(i1,i2,edgeFlag,iface1,iface2);
1439 p1 = pV[i1];
1440 p2 = pV[i2];
1441 return rep;
1442}

◆ GetNextEdgeIndeces() [1/2]

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

Definition at line 321 of file HepPolyhedron.h.

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

References HepPolyhedron::GetNextEdgeIndices().

◆ GetNextEdgeIndeces() [2/2]

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

Definition at line 315 of file HepPolyhedron.h.

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

References HepPolyhedron::GetNextEdgeIndices().

◆ GetNextEdgeIndices() [1/2]

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

Definition at line 1387 of file HepPolyhedron.cc.

1397{
1398 G4int kface1, kface2;
1399 return GetNextEdgeIndices(i1, i2, edgeFlag, kface1, kface2);
1400}

◆ GetNextEdgeIndices() [2/2]

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

Definition at line 1334 of file HepPolyhedron.cc.

1346{
1347 static G4ThreadLocal G4int iFace = 1;
1348 static G4ThreadLocal G4int iQVertex = 0;
1349 static G4ThreadLocal G4int iOrder = 1;
1350 G4int k1, k2, kflag, kface1, kface2;
1351
1352 if (iFace == 1 && iQVertex == 0) {
1353 k2 = pF[nface].edge[0].v;
1354 k1 = pF[nface].edge[3].v;
1355 if (k1 == 0) k1 = pF[nface].edge[2].v;
1356 if (std::abs(k1) > std::abs(k2)) iOrder = -1;
1357 }
1358
1359 do {
1360 k1 = pF[iFace].edge[iQVertex].v;
1361 kflag = k1;
1362 k1 = std::abs(k1);
1363 kface1 = iFace;
1364 kface2 = pF[iFace].edge[iQVertex].f;
1365 if (iQVertex >= 3 || pF[iFace].edge[iQVertex+1].v == 0) {
1366 iQVertex = 0;
1367 k2 = std::abs(pF[iFace].edge[iQVertex].v);
1368 iFace++;
1369 }else{
1370 iQVertex++;
1371 k2 = std::abs(pF[iFace].edge[iQVertex].v);
1372 }
1373 } while (iOrder*k1 > iOrder*k2);
1374
1375 i1 = k1; i2 = k2; edgeFlag = (kflag > 0) ? 1 : 0;
1376 iface1 = kface1; iface2 = kface2;
1377
1378 if (iFace > nface) {
1379 iFace = 1; iOrder = 1;
1380 return false;
1381 }else{
1382 return true;
1383 }
1384}
#define G4ThreadLocal
Definition: tls.hh:77

References G4ThreadLocal.

Referenced by HepPolyhedron::GetNextEdgeIndeces().

◆ GetNextFacet()

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

Definition at line 1500 of file HepPolyhedron.cc.

1511{
1512 static G4ThreadLocal G4int iFace = 1;
1513
1514 if (edgeFlags == 0) {
1515 GetFacet(iFace, n, nodes);
1516 }else if (normals == 0) {
1517 GetFacet(iFace, n, nodes, edgeFlags);
1518 }else{
1519 GetFacet(iFace, n, nodes, edgeFlags, normals);
1520 }
1521
1522 if (++iFace > nface) {
1523 iFace = 1;
1524 return false;
1525 }else{
1526 return true;
1527 }
1528}

References G4ThreadLocal, CLHEP::detail::n, and geant4_check_module_cycles::nodes.

Referenced by G4OpenGLSceneHandler::AddPrimitive(), G4Qt3DSceneHandler::AddPrimitive(), G4ToolsSGSceneHandler::AddPrimitive(), G4VtkSceneHandler::AddPrimitiveTensorGlyph(), and std::hash< G4Polyhedron >::operator()().

◆ GetNextNormal()

G4bool HepPolyhedron::GetNextNormal ( G4Normal3D normal) const
inherited

Definition at line 1580 of file HepPolyhedron.cc.

1590{
1591 static G4ThreadLocal G4int iFace = 1;
1592 normal = GetNormal(iFace);
1593 if (++iFace > nface) {
1594 iFace = 1;
1595 return false;
1596 }else{
1597 return true;
1598 }
1599}
G4Normal3D GetNormal(G4int iFace) const

References G4ThreadLocal, and CLHEP::normal().

Referenced by G4HepRepFileSceneHandler::AddPrimitive().

◆ GetNextUnitNormal()

G4bool HepPolyhedron::GetNextUnitNormal ( G4Normal3D normal) const
inherited

Definition at line 1601 of file HepPolyhedron.cc.

1611{
1613 normal = normal.unit();
1614 return rep;
1615}
G4bool GetNextNormal(G4Normal3D &normal) const

References CLHEP::normal().

Referenced by Geant4_SoPolyhedron::computeBBox(), Geant4_SoPolyhedron::generateAlternateRep(), and Geant4_SoPolyhedron::generatePrimitives().

◆ GetNextVertex() [1/2]

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

Definition at line 1284 of file HepPolyhedron.cc.

1295{
1296 G4int index;
1297 G4bool rep = GetNextVertexIndex(index, edgeFlag);
1298 vertex = pV[index];
1299 return rep;
1300}
G4bool GetNextVertexIndex(G4int &index, G4int &edgeFlag) const

Referenced by G4HepRepFileSceneHandler::AddPrimitive(), Geant4_SoPolyhedron::computeBBox(), Geant4_SoPolyhedron::generateAlternateRep(), and Geant4_SoPolyhedron::generatePrimitives().

◆ GetNextVertex() [2/2]

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

Definition at line 1302 of file HepPolyhedron.cc.

1314{
1315 static G4ThreadLocal G4int iFace = 1;
1316 static G4ThreadLocal G4int iNode = 0;
1317
1318 if (nface == 0) return false; // empty polyhedron
1319
1320 G4int k = pF[iFace].edge[iNode].v;
1321 if (k > 0) { edgeFlag = 1; } else { edgeFlag = -1; k = -k; }
1322 vertex = pV[k];
1323 normal = FindNodeNormal(iFace,k);
1324 if (iNode >= 3 || pF[iFace].edge[iNode+1].v == 0) {
1325 iNode = 0;
1326 if (++iFace > nface) iFace = 1;
1327 return false; // last node
1328 }else{
1329 ++iNode;
1330 return true; // not last node
1331 }
1332}

References G4ThreadLocal, and CLHEP::normal().

◆ GetNextVertexIndex()

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

Definition at line 1237 of file HepPolyhedron.cc.

1246{
1247 static G4ThreadLocal G4int iFace = 1;
1248 static G4ThreadLocal G4int iQVertex = 0;
1249 G4int vIndex = pF[iFace].edge[iQVertex].v;
1250
1251 edgeFlag = (vIndex > 0) ? 1 : 0;
1252 index = std::abs(vIndex);
1253
1254 if (iQVertex >= 3 || pF[iFace].edge[iQVertex+1].v == 0) {
1255 iQVertex = 0;
1256 if (++iFace > nface) iFace = 1;
1257 return false; // Last Edge
1258 }else{
1259 ++iQVertex;
1260 return true; // not Last Edge
1261 }
1262}

References G4ThreadLocal.

Referenced by G4GMocrenFileSceneHandler::AddPrimitive().

◆ GetNoFacets()

G4int HepPolyhedron::GetNoFacets ( ) const
inlineinherited

◆ GetNormal()

G4Normal3D HepPolyhedron::GetNormal ( G4int  iFace) const
inherited

Definition at line 1530 of file HepPolyhedron.cc.

1539{
1540 if (iFace < 1 || iFace > nface) {
1541 std::cerr
1542 << "HepPolyhedron::GetNormal: irrelevant index " << iFace
1543 << std::endl;
1544 return G4Normal3D();
1545 }
1546
1547 G4int i0 = std::abs(pF[iFace].edge[0].v);
1548 G4int i1 = std::abs(pF[iFace].edge[1].v);
1549 G4int i2 = std::abs(pF[iFace].edge[2].v);
1550 G4int i3 = std::abs(pF[iFace].edge[3].v);
1551 if (i3 == 0) i3 = i0;
1552 return (pV[i2] - pV[i0]).cross(pV[i3] - pV[i1]);
1553}
HepGeom::Normal3D< G4double > G4Normal3D
Definition: G4Normal3D.hh:34

◆ GetNoVerteces()

G4int HepPolyhedron::GetNoVerteces ( ) const
inlineinherited

Definition at line 291 of file HepPolyhedron.h.

291{ return nvert; } // Old spelling.

References HepPolyhedron::nvert.

◆ GetNoVertices()

G4int HepPolyhedron::GetNoVertices ( ) const
inlineinherited

◆ GetNumberOfRotationSteps()

G4int HepPolyhedron::GetNumberOfRotationSteps ( )
staticinherited

◆ GetNumberOfRotationStepsAtTimeOfCreation()

G4int G4Polyhedron::GetNumberOfRotationStepsAtTimeOfCreation ( ) const
inlineinherited

◆ GetSurfaceArea()

G4double HepPolyhedron::GetSurfaceArea ( ) const
inherited

Definition at line 1617 of file HepPolyhedron.cc.

1626{
1627 G4double srf = 0.;
1628 for (G4int iFace=1; iFace<=nface; iFace++) {
1629 G4int i0 = std::abs(pF[iFace].edge[0].v);
1630 G4int i1 = std::abs(pF[iFace].edge[1].v);
1631 G4int i2 = std::abs(pF[iFace].edge[2].v);
1632 G4int i3 = std::abs(pF[iFace].edge[3].v);
1633 if (i3 == 0) i3 = i0;
1634 srf += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).mag();
1635 }
1636 return srf/2.;
1637}

References HepPolyhedron::nface, HepPolyhedron::pF, and HepPolyhedron::pV.

◆ GetUnitNormal()

G4Normal3D HepPolyhedron::GetUnitNormal ( G4int  iFace) const
inherited

Definition at line 1555 of file HepPolyhedron.cc.

1564{
1565 if (iFace < 1 || iFace > nface) {
1566 std::cerr
1567 << "HepPolyhedron::GetUnitNormal: irrelevant index " << iFace
1568 << std::endl;
1569 return G4Normal3D();
1570 }
1571
1572 G4int i0 = std::abs(pF[iFace].edge[0].v);
1573 G4int i1 = std::abs(pF[iFace].edge[1].v);
1574 G4int i2 = std::abs(pF[iFace].edge[2].v);
1575 G4int i3 = std::abs(pF[iFace].edge[3].v);
1576 if (i3 == 0) i3 = i0;
1577 return ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).unit();
1578}

◆ GetVertex()

G4Point3D HepPolyhedron::GetVertex ( G4int  index) const
inherited

Definition at line 1264 of file HepPolyhedron.cc.

1273{
1274 if (index <= 0 || index > nvert) {
1275 std::cerr
1276 << "HepPolyhedron::GetVertex: irrelevant index " << index
1277 << std::endl;
1278 return G4Point3D();
1279 }
1280 return pV[index];
1281}

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

◆ GetVisAttributes()

const G4VisAttributes * G4Visible::GetVisAttributes ( ) const
inherited

◆ GetVolume()

G4double HepPolyhedron::GetVolume ( ) const
inherited

Definition at line 1639 of file HepPolyhedron.cc.

1648{
1649 G4double v = 0.;
1650 for (G4int iFace=1; iFace<=nface; iFace++) {
1651 G4int i0 = std::abs(pF[iFace].edge[0].v);
1652 G4int i1 = std::abs(pF[iFace].edge[1].v);
1653 G4int i2 = std::abs(pF[iFace].edge[2].v);
1654 G4int i3 = std::abs(pF[iFace].edge[3].v);
1655 G4Point3D pt;
1656 if (i3 == 0) {
1657 i3 = i0;
1658 pt = (pV[i0]+pV[i1]+pV[i2]) * (1./3.);
1659 }else{
1660 pt = (pV[i0]+pV[i1]+pV[i2]+pV[i3]) * 0.25;
1661 }
1662 v += ((pV[i2] - pV[i0]).cross(pV[i3] - pV[i1])).dot(pt);
1663 }
1664 return v/6.;
1665}

References HepPolyhedron::nface, HepPolyhedron::pF, and HepPolyhedron::pV.

◆ intersect()

HepPolyhedron HepPolyhedron::intersect ( const HepPolyhedron p) const
inherited

Definition at line 2803 of file HepPolyhedron.cc.

2812{
2813 G4int ierr;
2814 BooleanProcessor processor;
2815 return processor.execute(OP_INTERSECTION, *this, p,ierr);
2816}

References processor.

◆ InvertFacets()

void HepPolyhedron::InvertFacets ( )
protectedinherited

Definition at line 1186 of file HepPolyhedron.cc.

1195{
1196 if (nface <= 0) return;
1197 G4int i, k, nnode, v[4],f[4];
1198 for (i=1; i<=nface; i++) {
1199 nnode = (pF[i].edge[3].v == 0) ? 3 : 4;
1200 for (k=0; k<nnode; k++) {
1201 v[k] = (k+1 == nnode) ? pF[i].edge[0].v : pF[i].edge[k+1].v;
1202 if (v[k] * pF[i].edge[k].v < 0) v[k] = -v[k];
1203 f[k] = pF[i].edge[k].f;
1204 }
1205 for (k=0; k<nnode; k++) {
1206 pF[i].edge[nnode-1-k].v = v[k];
1207 pF[i].edge[nnode-1-k].f = f[k];
1208 }
1209 }
1210}

References G4Facet::edge, G4Facet::G4Edge::f, HepPolyhedron::nface, HepPolyhedron::pF, and G4Facet::G4Edge::v.

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

◆ operator!=()

G4bool G4Visible::operator!= ( const G4Visible right) const
inherited

Definition at line 103 of file G4Visible.cc.

103 {
104 if (fpVisAttributes && right.fpVisAttributes)
105 return *fpVisAttributes != *right.fpVisAttributes;
106 else if (!fpVisAttributes && !right.fpVisAttributes) return false;
107 else return true;
108}
const G4VisAttributes * fpVisAttributes
Definition: G4Visible.hh:82

References G4Visible::fpVisAttributes.

◆ ResetNumberOfRotationSteps()

void HepPolyhedron::ResetNumberOfRotationSteps ( )
staticinherited

◆ RotateAroundZ()

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

Definition at line 475 of file HepPolyhedron.cc.

500{
501 static const G4double wholeCircle = twopi;
502
503 // S E T R O T A T I O N P A R A M E T E R S
504
505 G4bool ifWholeCircle = (std::abs(dphi-wholeCircle) < perMillion) ? true : false;
506 G4double delPhi = ifWholeCircle ? wholeCircle : dphi;
507 G4int nSphi = nstep;
508 if (nSphi <= 0) nSphi = GetNumberOfRotationSteps()*delPhi/wholeCircle + 0.5;
509 if (nSphi == 0) nSphi = 1;
510 G4int nVphi = ifWholeCircle ? nSphi : nSphi + 1;
511 G4bool ifClosed = np1 > 0 ? false : true; // true if external polyline is closed
512
513 // C O U N T V E R T I C E S
514
515 G4int absNp1 = std::abs(np1);
516 G4int absNp2 = std::abs(np2);
517 G4int i1beg = 0;
518 G4int i1end = absNp1-1;
519 G4int i2beg = absNp1;
520 G4int i2end = absNp1+absNp2-1;
521 G4int i, j, k;
522
523 for(i=i1beg; i<=i2end; i++) {
524 if (std::abs(r[i]) < spatialTolerance) r[i] = 0.;
525 }
526
527 // external polyline - check position of nodes relative to Z
528 //
529 G4int Nverts = 0;
530 for (i=i1beg; i<=i1end; i++) {
531 Nverts += (r[i] == 0.) ? 1 : nVphi;
532 }
533
534 // internal polyline
535 //
536 G4bool ifSide1 = false; // whether to create bottom faces
537 G4bool ifSide2 = false; // whether to create top faces
538
539 if (r[i2beg] != r[i1beg] || z[i2beg] != z[i1beg]) { // first node
540 Nverts += (r[i2beg] == 0.) ? 1 : nVphi;
541 ifSide1 = true;
542 }
543
544 for(i=i2beg+1; i<i2end; i++) { // intermediate nodes
545 Nverts += (r[i] == 0.) ? 1 : nVphi;
546 }
547
548 if (r[i2end] != r[i1end] || z[i2end] != z[i1end]) { // last node
549 if (absNp2 > 1) Nverts += (r[i2end] == 0.) ? 1 : nVphi;
550 ifSide2 = true;
551 }
552
553 // C O U N T F A C E S
554
555 // external lateral faces
556 //
557 G4int Nfaces = ifClosed ? absNp1*nSphi : (absNp1-1)*nSphi;
558
559 // internal lateral faces
560 //
561 if (absNp2 > 1) {
562 for(i=i2beg; i<i2end; i++) {
563 if (r[i] > 0. || r[i+1] > 0.) Nfaces += nSphi;
564 }
565
566 if (ifClosed) {
567 if (r[i2end] > 0. || r[i2beg] > 0.) Nfaces += nSphi;
568 }
569 }
570
571 // bottom and top faces
572 //
573 if (!ifClosed) {
574 if (ifSide1 && (r[i1beg] > 0. || r[i2beg] > 0.)) Nfaces += nSphi;
575 if (ifSide2 && (r[i1end] > 0. || r[i2end] > 0.)) Nfaces += nSphi;
576 }
577
578 // phi_wedge faces
579 //
580 if (!ifWholeCircle) {
581 Nfaces += ifClosed ? 2*absNp1 : 2*(absNp1-1);
582 }
583
584 // A L L O C A T E M E M O R Y
585
586 AllocateMemory(Nverts, Nfaces);
587 if (pV == nullptr || pF == nullptr) return;
588
589 // G E N E R A T E V E R T I C E S
590
591 G4int *kk; // array of start indices along polylines
592 kk = new G4int[absNp1+absNp2];
593
594 // external polyline
595 //
596 k = 1; // free position in array of vertices pV
597 for(i=i1beg; i<=i1end; i++) {
598 kk[i] = k;
599 if (r[i] == 0.)
600 { pV[k++] = G4Point3D(0, 0, z[i]); } else { k += nVphi; }
601 }
602
603 // first point of internal polyline
604 //
605 i = i2beg;
606 if (ifSide1) {
607 kk[i] = k;
608 if (r[i] == 0.)
609 { pV[k++] = G4Point3D(0, 0, z[i]); } else { k += nVphi; }
610 }else{
611 kk[i] = kk[i1beg];
612 }
613
614 // intermediate points of internal polyline
615 //
616 for(i=i2beg+1; i<i2end; i++) {
617 kk[i] = k;
618 if (r[i] == 0.)
619 { pV[k++] = G4Point3D(0, 0, z[i]); } else { k += nVphi; }
620 }
621
622 // last point of internal polyline
623 //
624 if (absNp2 > 1) {
625 i = i2end;
626 if (ifSide2) {
627 kk[i] = k;
628 if (r[i] == 0.) pV[k] = G4Point3D(0, 0, z[i]);
629 }else{
630 kk[i] = kk[i1end];
631 }
632 }
633
634 // set vertices
635 //
636 G4double cosPhi, sinPhi;
637
638 for(j=0; j<nVphi; j++) {
639 cosPhi = std::cos(phi+j*delPhi/nSphi);
640 sinPhi = std::sin(phi+j*delPhi/nSphi);
641 for(i=i1beg; i<=i2end; i++) {
642 if (r[i] != 0.)
643 pV[kk[i]+j] = G4Point3D(r[i]*cosPhi,r[i]*sinPhi,z[i]);
644 }
645 }
646
647 // G E N E R A T E F A C E S
648
649 // external faces
650 //
651 G4int v1,v2;
652
653 k = 1; // free position in array of faces pF
654 v2 = ifClosed ? nodeVis : 1;
655 for(i=i1beg; i<i1end; i++) {
656 v1 = v2;
657 if (!ifClosed && i == i1end-1) {
658 v2 = 1;
659 }else{
660 v2 = (r[i] == r[i+1] && r[i+1] == r[i+2]) ? -1 : nodeVis;
661 }
662 RotateEdge(kk[i], kk[i+1], r[i], r[i+1], v1, v2,
663 edgeVis, ifWholeCircle, nSphi, k);
664 }
665 if (ifClosed) {
666 RotateEdge(kk[i1end], kk[i1beg], r[i1end],r[i1beg], nodeVis, nodeVis,
667 edgeVis, ifWholeCircle, nSphi, k);
668 }
669
670 // internal faces
671 //
672 if (absNp2 > 1) {
673 v2 = ifClosed ? nodeVis : 1;
674 for(i=i2beg; i<i2end; i++) {
675 v1 = v2;
676 if (!ifClosed && i==i2end-1) {
677 v2 = 1;
678 }else{
679 v2 = (r[i] == r[i+1] && r[i+1] == r[i+2]) ? -1 : nodeVis;
680 }
681 RotateEdge(kk[i+1], kk[i], r[i+1], r[i], v2, v1,
682 edgeVis, ifWholeCircle, nSphi, k);
683 }
684 if (ifClosed) {
685 RotateEdge(kk[i2beg], kk[i2end], r[i2beg], r[i2end], nodeVis, nodeVis,
686 edgeVis, ifWholeCircle, nSphi, k);
687 }
688 }
689
690 // bottom and top faces
691 //
692 if (!ifClosed) {
693 if (ifSide1) {
694 RotateEdge(kk[i2beg], kk[i1beg], r[i2beg], r[i1beg], 1, 1,
695 -1, ifWholeCircle, nSphi, k);
696 }
697 if (ifSide2) {
698 RotateEdge(kk[i1end], kk[i2end], r[i1end], r[i2end], 1, 1,
699 -1, ifWholeCircle, nSphi, k);
700 }
701 }
702
703 // phi_wedge faces in case of incomplete circle
704 //
705 if (!ifWholeCircle) {
706
707 G4int ii[4], vv[4];
708
709 if (ifClosed) {
710 for (i=i1beg; i<=i1end; i++) {
711 ii[0] = i;
712 ii[3] = (i == i1end) ? i1beg : i+1;
713 ii[1] = (absNp2 == 1) ? i2beg : ii[0]+absNp1;
714 ii[2] = (absNp2 == 1) ? i2beg : ii[3]+absNp1;
715 vv[0] = -1;
716 vv[1] = 1;
717 vv[2] = -1;
718 vv[3] = 1;
719 SetSideFacets(ii, vv, kk, r, delPhi, nSphi, k);
720 }
721 }else{
722 for (i=i1beg; i<i1end; i++) {
723 ii[0] = i;
724 ii[3] = i+1;
725 ii[1] = (absNp2 == 1) ? i2beg : ii[0]+absNp1;
726 ii[2] = (absNp2 == 1) ? i2beg : ii[3]+absNp1;
727 vv[0] = (i == i1beg) ? 1 : -1;
728 vv[1] = 1;
729 vv[2] = (i == i1end-1) ? 1 : -1;
730 vv[3] = 1;
731 SetSideFacets(ii, vv, kk, r, delPhi, nSphi, k);
732 }
733 }
734 }
735
736 delete [] kk; // free memory
737
738 // final check
739 //
740 if (k-1 != nface) {
741 std::cerr
742 << "HepPolyhedron::RotateAroundZ: number of generated faces ("
743 << k-1 << ") is not equal to the number of allocated faces ("
744 << nface << ")"
745 << std::endl;
746 }
747}
static constexpr double perMillion
Definition: G4SIunits.hh:327
static constexpr double twopi
Definition: G4SIunits.hh:56
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)

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

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

◆ RotateContourAroundZ()

void HepPolyhedron::RotateContourAroundZ ( G4int  nstep,
G4double  phi,
G4double  dphi,
const std::vector< G4TwoVector > &  rz,
G4int  nodeVis,
G4int  edgeVis 
)
protectedinherited

Definition at line 750 of file HepPolyhedron.cc.

773{
774 // S E T R O T A T I O N P A R A M E T E R S
775
776 G4bool ifWholeCircle = (std::abs(dphi - twopi) < perMillion) ? true : false;
777 G4double delPhi = (ifWholeCircle) ? twopi : dphi;
778 G4int nSphi = nstep;
779 if (nSphi <= 0) nSphi = GetNumberOfRotationSteps()*delPhi/twopi + 0.5;
780 if (nSphi == 0) nSphi = 1;
781 G4int nVphi = (ifWholeCircle) ? nSphi : nSphi + 1;
782
783 // C A L C U L A T E A R E A
784
785 G4int Nrz = rz.size();
786 G4double area = 0;
787 for (G4int i = 0; i < Nrz; ++i)
788 {
789 G4int k = (i == 0) ? Nrz - 1 : i - 1;
790 area += rz[k].x()*rz[i].y() - rz[i].x()*rz[k].y();
791 }
792
793 // P R E P A R E P O L Y L I N E
794
795 G4double *r = new G4double[Nrz];
796 G4double *z = new G4double[Nrz];
797 for (G4int i = 0; i < Nrz; ++i)
798 {
799 r[i] = rz[i].x();
800 z[i] = rz[i].y();
801 if (std::abs(r[i]) < spatialTolerance) r[i] = 0.;
802 }
803
804 // C O U N T V E R T I C E S A N D F A C E S
805
806 G4int Nverts = 0;
807 for(G4int i = 0; i < Nrz; ++i) Nverts += (r[i] == 0.) ? 1 : nVphi;
808
809 G4int Nedges = Nrz;
810 for (G4int i = 0; i < Nrz; ++i)
811 {
812 G4int k = (i == 0) ? Nrz - 1 : i - 1;
813 Nedges -= (r[k] == 0 && r[i] == 0);
814 }
815
816 G4int Nfaces = Nedges*nSphi; // lateral faces
817 if (!ifWholeCircle) Nfaces += 2*(Nrz - 2); // phi_wedge faces
818
819 // A L L O C A T E M E M O R Y
820
821 AllocateMemory(Nverts, Nfaces);
822 if (pV == nullptr || pF == nullptr)
823 {
824 delete [] r;
825 delete [] z;
826 return;
827 }
828
829 // S E T V E R T I C E S
830
831 G4int *kk = new G4int[Nrz]; // start indices along contour
832 G4int kfree = 1; // current free position in array of vertices pV
833
834 // set start indices, set vertices for nodes with r == 0
835 for(G4int i = 0; i < Nrz; ++i)
836 {
837 kk[i] = kfree;
838 if (r[i] == 0.) pV[kfree++] = G4Point3D(0, 0, z[i]);
839 if (r[i] != 0.) kfree += nVphi;
840 }
841
842 // set vertices by rotating r
843 for(G4int j = 0; j < nVphi; ++j)
844 {
845 G4double cosPhi = std::cos(phi + j*delPhi/nSphi);
846 G4double sinPhi = std::sin(phi + j*delPhi/nSphi);
847 for(G4int i = 0; i < Nrz; ++i)
848 {
849 if (r[i] != 0.)
850 pV[kk[i] + j] = G4Point3D(r[i]*cosPhi, r[i]*sinPhi, z[i]);
851 }
852 }
853
854 // S E T F A C E S
855
856 kfree = 1; // current free position in array of faces pF
857 for(G4int i = 0; i < Nrz; ++i)
858 {
859 G4int i1 = (i < Nrz - 1) ? i + 1 : 0; // inverse order if area > 0
860 G4int i2 = i;
861 if (area < 0.) std::swap(i1, i2);
862 RotateEdge(kk[i1], kk[i2], r[i1], r[i2], nodeVis, nodeVis,
863 edgeVis, ifWholeCircle, nSphi, kfree);
864 }
865
866 // S E T P H I _ W E D G E F A C E S
867
868 if (!ifWholeCircle)
869 {
870 std::vector<G4int> triangles;
871 TriangulatePolygon(rz, triangles);
872
873 G4int ii[4], vv[4];
874 G4int ntria = triangles.size()/3;
875 for (G4int i = 0; i < ntria; ++i)
876 {
877 G4int i1 = triangles[0 + i*3];
878 G4int i2 = triangles[1 + i*3];
879 G4int i3 = triangles[2 + i*3];
880 if (area < 0.) std::swap(i1, i3);
881 G4int v1 = (std::abs(i2-i1) == 1 || std::abs(i2-i1) == Nrz-1) ? 1 : -1;
882 G4int v2 = (std::abs(i3-i2) == 1 || std::abs(i3-i2) == Nrz-1) ? 1 : -1;
883 G4int v3 = (std::abs(i1-i3) == 1 || std::abs(i1-i3) == Nrz-1) ? 1 : -1;
884 ii[0] = i1; ii[1] = i2; ii[2] = i2; ii[3] = i3;
885 vv[0] = v1; vv[1] = -1; vv[2] = v2; vv[3] = v3;
886 SetSideFacets(ii, vv, kk, r, delPhi, nSphi, kfree);
887 }
888 }
889
890 // free memory
891 delete [] r;
892 delete [] z;
893 delete [] kk;
894
895 // final check
896 if (kfree - 1 != nface)
897 {
898 std::cerr
899 << "HepPolyhedron::RotateContourAroundZ: number of generated faces ("
900 << kfree-1 << ") is not equal to the number of allocated faces ("
901 << nface << ")"
902 << std::endl;
903 }
904}
G4bool TriangulatePolygon(const std::vector< G4TwoVector > &polygon, std::vector< G4int > &result)

References HepPolyhedron::AllocateMemory(), HepPolyhedron::GetNumberOfRotationSteps(), HepPolyhedron::nface, perMillion, HepPolyhedron::pF, HepPolyhedron::pV, HepPolyhedron::RotateEdge(), HepPolyhedron::SetSideFacets(), spatialTolerance, HepPolyhedron::TriangulatePolygon(), and twopi.

Referenced by HepPolyhedronPgon::HepPolyhedronPgon().

◆ RotateEdge()

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

Definition at line 342 of file HepPolyhedron.cc.

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

References HepPolyhedron::pF.

Referenced by HepPolyhedron::RotateAroundZ(), and HepPolyhedron::RotateContourAroundZ().

◆ SetNumberOfRotationSteps()

void HepPolyhedron::SetNumberOfRotationSteps ( G4int  n)
staticinherited

Definition at line 261 of file HepPolyhedron.cc.

270{
271 const G4int nMin = 3;
272 if (n < nMin) {
273 std::cerr
274 << "HepPolyhedron::SetNumberOfRotationSteps: attempt to set the\n"
275 << "number of steps per circle < " << nMin << "; forced to " << nMin
276 << std::endl;
278 }else{
280 }
281}

References HepPolyhedron::fNumberOfRotationSteps, and CLHEP::detail::n.

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

◆ SetReferences()

void HepPolyhedron::SetReferences ( )
protectedinherited

Definition at line 1037 of file HepPolyhedron.cc.

1046{
1047 if (nface <= 0) return;
1048
1049 struct edgeListMember {
1050 edgeListMember *next;
1051 G4int v2;
1052 G4int iface;
1053 G4int iedge;
1054 } *edgeList, *freeList, **headList;
1055
1056
1057 // A L L O C A T E A N D I N I T I A T E L I S T S
1058
1059 edgeList = new edgeListMember[2*nface];
1060 headList = new edgeListMember*[nvert];
1061
1062 G4int i;
1063 for (i=0; i<nvert; i++) {
1064 headList[i] = 0;
1065 }
1066 freeList = edgeList;
1067 for (i=0; i<2*nface-1; i++) {
1068 edgeList[i].next = &edgeList[i+1];
1069 }
1070 edgeList[2*nface-1].next = 0;
1071
1072 // L O O P A L O N G E D G E S
1073
1074 G4int iface, iedge, nedge, i1, i2, k1, k2;
1075 edgeListMember *prev, *cur;
1076
1077 for(iface=1; iface<=nface; iface++) {
1078 nedge = (pF[iface].edge[3].v == 0) ? 3 : 4;
1079 for (iedge=0; iedge<nedge; iedge++) {
1080 i1 = iedge;
1081 i2 = (iedge < nedge-1) ? iedge+1 : 0;
1082 i1 = std::abs(pF[iface].edge[i1].v);
1083 i2 = std::abs(pF[iface].edge[i2].v);
1084 k1 = (i1 < i2) ? i1 : i2; // k1 = ::min(i1,i2);
1085 k2 = (i1 > i2) ? i1 : i2; // k2 = ::max(i1,i2);
1086
1087 // check head of the List corresponding to k1
1088 cur = headList[k1];
1089 if (cur == 0) {
1090 headList[k1] = freeList;
1091 if (!freeList) {
1092 std::cerr
1093 << "Polyhedron::SetReferences: bad link "
1094 << std::endl;
1095 break;
1096 }
1097 freeList = freeList->next;
1098 cur = headList[k1];
1099 cur->next = 0;
1100 cur->v2 = k2;
1101 cur->iface = iface;
1102 cur->iedge = iedge;
1103 continue;
1104 }
1105
1106 if (cur->v2 == k2) {
1107 headList[k1] = cur->next;
1108 cur->next = freeList;
1109 freeList = cur;
1110 pF[iface].edge[iedge].f = cur->iface;
1111 pF[cur->iface].edge[cur->iedge].f = iface;
1112 i1 = (pF[iface].edge[iedge].v < 0) ? -1 : 1;
1113 i2 = (pF[cur->iface].edge[cur->iedge].v < 0) ? -1 : 1;
1114 if (i1 != i2) {
1115 std::cerr
1116 << "Polyhedron::SetReferences: different edge visibility "
1117 << iface << "/" << iedge << "/"
1118 << pF[iface].edge[iedge].v << " and "
1119 << cur->iface << "/" << cur->iedge << "/"
1120 << pF[cur->iface].edge[cur->iedge].v
1121 << std::endl;
1122 }
1123 continue;
1124 }
1125
1126 // check List itself
1127 for (;;) {
1128 prev = cur;
1129 cur = prev->next;
1130 if (cur == 0) {
1131 prev->next = freeList;
1132 if (!freeList) {
1133 std::cerr
1134 << "Polyhedron::SetReferences: bad link "
1135 << std::endl;
1136 break;
1137 }
1138 freeList = freeList->next;
1139 cur = prev->next;
1140 cur->next = 0;
1141 cur->v2 = k2;
1142 cur->iface = iface;
1143 cur->iedge = iedge;
1144 break;
1145 }
1146
1147 if (cur->v2 == k2) {
1148 prev->next = cur->next;
1149 cur->next = freeList;
1150 freeList = cur;
1151 pF[iface].edge[iedge].f = cur->iface;
1152 pF[cur->iface].edge[cur->iedge].f = iface;
1153 i1 = (pF[iface].edge[iedge].v < 0) ? -1 : 1;
1154 i2 = (pF[cur->iface].edge[cur->iedge].v < 0) ? -1 : 1;
1155 if (i1 != i2) {
1156 std::cerr
1157 << "Polyhedron::SetReferences: different edge visibility "
1158 << iface << "/" << iedge << "/"
1159 << pF[iface].edge[iedge].v << " and "
1160 << cur->iface << "/" << cur->iedge << "/"
1161 << pF[cur->iface].edge[cur->iedge].v
1162 << std::endl;
1163 }
1164 break;
1165 }
1166 }
1167 }
1168 }
1169
1170 // 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
1171
1172 for (i=0; i<nvert; i++) {
1173 if (headList[i] != 0) {
1174 std::cerr
1175 << "Polyhedron::SetReferences: List " << i << " is not empty"
1176 << std::endl;
1177 }
1178 }
1179
1180 // F R E E M E M O R Y
1181
1182 delete [] edgeList;
1183 delete [] headList;
1184}

References G4Facet::edge, G4Facet::G4Edge::f, HepPolyhedron::nface, HepPolyhedron::nvert, HepPolyhedron::pF, and G4Facet::G4Edge::v.

Referenced by HepPolyhedron::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 
)
protectedinherited

Definition at line 404 of file HepPolyhedron.cc.

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

References perMillion, HepPolyhedron::pF, and pi.

Referenced by HepPolyhedron::RotateAroundZ(), and HepPolyhedron::RotateContourAroundZ().

◆ SetVisAttributes() [1/2]

void G4Visible::SetVisAttributes ( const G4VisAttributes VA)
inherited

Definition at line 85 of file G4Visible.cc.

85 {
86 // Allocate G4VisAttributes on the heap in case the user specifies a
87 // short-lived VA for a long-lived G4Visible. Flag so that it can
88 // be deleted in the destructor.
89 // First delete any G4VisAttributes already on the heap...
93}
G4bool fAllocatedVisAttributes
Definition: G4Visible.hh:83

References G4Visible::fAllocatedVisAttributes, and G4Visible::fpVisAttributes.

◆ SetVisAttributes() [2/2]

void G4Visible::SetVisAttributes ( const G4VisAttributes pVA)
inherited

Definition at line 96 of file G4Visible.cc.

96 {
97 // First delete any G4VisAttributes already on the heap...
99 fpVisAttributes = pVA;
101}

References G4Visible::fAllocatedVisAttributes, and G4Visible::fpVisAttributes.

Referenced by G4OpenGLSceneHandler::AddCompound(), G4Qt3DSceneHandler::AddCompound(), G4VisCommandSceneAddArrow2D::Arrow2D::Arrow2D(), G4DrawVoxels::ComputeVoxelPolyhedra(), G4AxesModel::Construct(), G4PhysicalVolumeModel::DescribeSolid(), G4GPSModel::DescribeYourselfTo(), G4VFieldModel::DescribeYourselfTo(), G4ScoringBox::Draw(), G4ScoringCylinder::Draw(), G4ScoreLogColorMap::DrawColorChartBar(), G4VScoreColorMap::DrawColorChartBar(), G4ScoreLogColorMap::DrawColorChartText(), G4VScoreColorMap::DrawColorChartText(), G4ScoringBox::DrawColumn(), G4ScoringCylinder::DrawColumn(), G4OpenGLStoredViewer::DrawDisplayLists(), anonymous_namespace{G4LogicalVolumeModel.cc}::DrawPoint(), G4TrajectoryDrawerUtils::DrawWithoutTime(), G4TrajectoryDrawerUtils::DrawWithTime(), G4ArrowModel::G4ArrowModel(), G4VisCommandSceneAddLogo::G4Logo::G4Logo(), G4VisCommandSceneAddLine::Line::Line(), G4VisCommandSceneAddLine2D::Line2D::Line2D(), G4VisCommandSceneAddDate::Date::operator()(), G4VisCommandSceneAddEventID::EventID::operator()(), G4VisCommandSceneAddFrame::Frame::operator()(), G4VisCommandSceneAddLogo2D::Logo2D::operator()(), G4VSceneHandler::RequestPrimitives(), G4VisCommandSceneAddScale::Scale::Scale(), G4VisCommandSceneAddText::SetNewValue(), and G4VisCommandSceneAddText2D::SetNewValue().

◆ subtract()

HepPolyhedron HepPolyhedron::subtract ( const HepPolyhedron p) const
inherited

Definition at line 2818 of file HepPolyhedron.cc.

2827{
2828 G4int ierr;
2829 BooleanProcessor processor;
2830 return processor.execute(OP_SUBTRACTION, *this, p,ierr);
2831}

References processor.

◆ Transform()

HepPolyhedron & HepPolyhedron::Transform ( const G4Transform3D t)
inherited

Definition at line 1212 of file HepPolyhedron.cc.

1221{
1222 if (nvert > 0) {
1223 for (G4int i=1; i<=nvert; i++) { pV[i] = t * pV[i]; }
1224
1225 // C H E C K D E T E R M I N A N T A N D
1226 // 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
1227
1228 G4Vector3D d = t * G4Vector3D(0,0,0);
1229 G4Vector3D x = t * G4Vector3D(1,0,0) - d;
1230 G4Vector3D y = t * G4Vector3D(0,1,0) - d;
1231 G4Vector3D z = t * G4Vector3D(0,0,1) - d;
1232 if ((x.cross(y))*z < 0) InvertFacets();
1233 }
1234 return *this;
1235}
HepGeom::Vector3D< G4double > G4Vector3D
Definition: G4Vector3D.hh:34
BasicVector3D< T > cross(const BasicVector3D< T > &v) const

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

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

◆ TriangulatePolygon()

G4bool HepPolyhedron::TriangulatePolygon ( const std::vector< G4TwoVector > &  polygon,
std::vector< G4int > &  result 
)
protectedinherited

Definition at line 907 of file HepPolyhedron.cc.

924{
925 result.resize(0);
926 G4int n = polygon.size();
927 if (n < 3) return false;
928
929 // calculate area
930 //
931 G4double area = 0.;
932 for(G4int i = 0; i < n; ++i)
933 {
934 G4int k = (i == 0) ? n - 1 : i - 1;
935 area += polygon[k].x()*polygon[i].y() - polygon[i].x()*polygon[k].y();
936 }
937
938 // allocate and initialize list of Vertices
939 // we want a counter-clockwise polygon in V
940 //
941 G4int* V = new G4int[n];
942 if (area > 0.)
943 for (G4int i = 0; i < n; ++i) V[i] = i;
944 else
945 for (G4int i = 0; i < n; ++i) V[i] = (n - 1) - i;
946
947 // Triangulation: remove nv-2 Vertices, creating 1 triangle every time
948 //
949 G4int nv = n;
950 G4int count = 2*nv; // error detection counter
951 for(G4int b = nv - 1; nv > 2; )
952 {
953 // ERROR: if we loop, it is probably a non-simple polygon
954 if ((count--) <= 0)
955 {
956 delete [] V;
957 if (area < 0.) std::reverse(result.begin(),result.end());
958 return false;
959 }
960
961 // three consecutive vertices in current polygon, <a,b,c>
962 G4int a = (b < nv) ? b : 0; // previous
963 b = (a+1 < nv) ? a+1 : 0; // current
964 G4int c = (b+1 < nv) ? b+1 : 0; // next
965
966 if (CheckSnip(polygon, a,b,c, nv,V))
967 {
968 // output Triangle
969 result.push_back(V[a]);
970 result.push_back(V[b]);
971 result.push_back(V[c]);
972
973 // remove vertex b from remaining polygon
974 nv--;
975 for(G4int i = b; i < nv; ++i) V[i] = V[i+1];
976
977 count = 2*nv; // resest error detection counter
978 }
979 }
980 delete [] V;
981 if (area < 0.) std::reverse(result.begin(),result.end());
982 return true;
983}
G4bool CheckSnip(const std::vector< G4TwoVector > &contour, G4int a, G4int b, G4int c, G4int n, const G4int *V)

References HepPolyhedron::CheckSnip(), and CLHEP::detail::n.

Referenced by HepPolyhedron::RotateContourAroundZ().

Field Documentation

◆ fAllocatedVisAttributes

G4bool G4Visible::fAllocatedVisAttributes
protectedinherited

◆ fNumberOfRotationSteps

G4ThreadLocal G4int HepPolyhedron::fNumberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS
staticprotectedinherited

◆ fNumberOfRotationStepsAtTimeOfCreation

G4int G4Polyhedron::fNumberOfRotationStepsAtTimeOfCreation
privateinherited

◆ fpVisAttributes

const G4VisAttributes* G4Visible::fpVisAttributes
protectedinherited

◆ nface

G4int HepPolyhedron::nface
protectedinherited

◆ nvert

G4int HepPolyhedron::nvert
protectedinherited

◆ pF

G4Facet* HepPolyhedron::pF
protectedinherited

◆ pV

G4Point3D* HepPolyhedron::pV
protectedinherited

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