42 #if !defined(G4GEOM_USE_UGENERICPOLYCONE)
54 using namespace CLHEP;
70 Create( phiStart, phiTotal, rz );
94 std::ostringstream message;
95 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl
96 <<
" All R values must be >= 0 !";
97 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
107 std::ostringstream message;
108 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl
109 <<
" R/Z cross section is zero or near zero: " << rzArea;
110 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
117 std::ostringstream message;
118 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl
119 <<
" Too few unique R/Z values !";
120 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
126 std::ostringstream message;
127 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl
128 <<
" R/Z segments cross !";
129 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
139 if (phiTotal <= 0 || phiTotal >
twopi-1E-10)
155 endPhi = phiStart+phiTotal;
173 next->
r = iterRZ.
GetA();
174 next->
z = iterRZ.
GetB();
175 }
while( ++next, iterRZ.
Next() );
199 if (corner->
r < 1/kInfinity && next->
r < 1/kInfinity)
continue;
207 if (corner->
z > next->
z)
224 }
while( prev=corner, corner=next, corner >
corners );
253 :
G4VCSGfaceted(a), startPhi(0.), endPhi(0.), phiIsOpen(false),
254 numCorner(0), corners(0), enclosingCylinder(0)
284 if (
this == &source)
return *
this;
337 std::ostringstream message;
338 message <<
"Solid " <<
GetName() <<
" built using generic construct."
339 <<
G4endl <<
"Not applicable to the generic construct !";
340 G4Exception(
"G4GenericPolycone::Reset()",
"GeomSolids1001",
413 return G4String(
"G4GenericPolycone");
430 G4int oldprc = os.precision(16);
431 os <<
"-----------------------------------------------------------\n"
432 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
433 <<
" ===================================================\n"
434 <<
" Solid type: G4GenericPolycone\n"
437 <<
" ending phi angle : " <<
endPhi/
degree <<
" degrees \n";
440 os <<
" number of RZ points: " <<
numCorner <<
"\n"
441 <<
" RZ values (corners): \n";
447 os <<
"-----------------------------------------------------------\n";
448 os.precision(oldprc);
491 const G4int numSide =
498 typedef G4int int4[4];
505 std::vector<G4bool> chopped(
numCorner,
false);
506 std::vector<G4int*> triQuads;
509 while (remaining >= 3)
513 G4int A = -1, B = -1, C = -1;
514 G4int iStepper = iStarter;
517 if (A < 0) { A = iStepper; }
518 else if (B < 0) { B = iStepper; }
519 else if (C < 0) { C = iStepper; }
522 if (++iStepper >=
numCorner) { iStepper = 0; }
524 while (chopped[iStepper]);
526 while (C < 0 && iStepper != iStarter);
541 triQuads.push_back(tq);
549 if (++iStarter >=
numCorner) { iStarter = 0; }
551 while (chopped[iStarter]);
557 nFaces = numSide *
numCorner + 2 * triQuads.size();
558 faces_vec =
new int4[nFaces];
562 for (
G4int iEnd = 0; iEnd < 2; ++iEnd)
564 for (
size_t i = 0; i < triQuads.size(); ++i)
577 a = triQuads[i][0] + addition;
578 b = triQuads[i][2] + addition;
579 c = triQuads[i][1] + addition;
581 G4int ab = std::abs(b - a);
582 G4int bc = std::abs(c - b);
583 G4int ca = std::abs(a - c);
584 faces_vec[iface][0] = (ab == 1 || ab ==
d)? a: -a;
585 faces_vec[iface][1] = (bc == 1 || bc ==
d)? b: -b;
586 faces_vec[iface][2] = (ca == 1 || ca ==
d)? c: -c;
587 faces_vec[iface][3] = 0;
594 xyz =
new double3[nNodes];
598 for (
G4int iSide = 0; iSide < numSide; ++iSide)
602 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
603 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
607 if (iCorner < numCorner - 1)
609 faces_vec[iface][0] = ixyz + 1;
610 faces_vec[iface][1] = -(ixyz + numCorner + 1);
611 faces_vec[iface][2] = ixyz + numCorner + 2;
612 faces_vec[iface][3] = ixyz + 2;
616 faces_vec[iface][0] = ixyz + 1;
617 faces_vec[iface][1] = -(ixyz + numCorner + 1);
618 faces_vec[iface][2] = ixyz + 2;
619 faces_vec[iface][3] = ixyz - numCorner + 2;
622 else if (iSide == numSide - 1)
624 if (iCorner < numCorner - 1)
626 faces_vec[iface][0] = ixyz + 1;
627 faces_vec[iface][1] = ixyz + numCorner + 1;
628 faces_vec[iface][2] = ixyz + numCorner + 2;
629 faces_vec[iface][3] = -(ixyz + 2);
633 faces_vec[iface][0] = ixyz + 1;
634 faces_vec[iface][1] = ixyz + numCorner + 1;
635 faces_vec[iface][2] = ixyz + 2;
636 faces_vec[iface][3] = -(ixyz - numCorner + 2);
641 if (iCorner < numCorner - 1)
643 faces_vec[iface][0] = ixyz + 1;
644 faces_vec[iface][1] = -(ixyz + numCorner + 1);
645 faces_vec[iface][2] = ixyz + numCorner + 2;
646 faces_vec[iface][3] = -(ixyz + 2);
650 faces_vec[iface][0] = ixyz + 1;
651 faces_vec[iface][1] = -(ixyz + numCorner + 1);
652 faces_vec[iface][2] = ixyz + 2;
653 faces_vec[iface][3] = -(ixyz - numCorner + 2);
666 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
667 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
676 xyz =
new double3[nNodes];
677 faces_vec =
new int4[nFaces];
680 G4int ixyz = 0, iface = 0;
681 for (
G4int iSide = 0; iSide < numSide; ++iSide)
685 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
686 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
689 if (iSide < numSide - 1)
691 if (iCorner < numCorner - 1)
693 faces_vec[iface][0] = ixyz + 1;
694 faces_vec[iface][1] = -(ixyz + numCorner + 1);
695 faces_vec[iface][2] = ixyz + numCorner + 2;
696 faces_vec[iface][3] = -(ixyz + 2);
700 faces_vec[iface][0] = ixyz + 1;
701 faces_vec[iface][1] = -(ixyz + numCorner + 1);
702 faces_vec[iface][2] = ixyz + 2;
703 faces_vec[iface][3] = -(ixyz - numCorner + 2);
708 if (iCorner < numCorner - 1)
710 faces_vec[iface][0] = ixyz + 1;
711 faces_vec[iface][1] = -(ixyz + numCorner - nFaces + 1);
712 faces_vec[iface][2] = ixyz + numCorner - nFaces + 2;
713 faces_vec[iface][3] = -(ixyz + 2);
717 faces_vec[iface][0] = ixyz + 1;
718 faces_vec[iface][1] = -(ixyz - nFaces + numCorner + 1);
719 faces_vec[iface][2] = ixyz - nFaces + 2;
720 faces_vec[iface][3] = -(ixyz - numCorner + 2);
735 std::ostringstream message;
736 message <<
"Problem creating G4Polyhedron for: " <<
GetName();
737 G4Exception(
"G4GenericPolycone::CreatePolyhedron()",
"GeomSolids1002",
G4bool CrossesItself(G4double tolerance)
const G4GenericPolycone & operator=(const G4GenericPolycone &source)
G4PolyconeSideRZ * corners
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4bool MustBeOutside(const G4ThreeVector &p) const
G4GenericPolycone(const G4String &name, G4double phiStart, G4double phiTotal, G4int numRZ, const G4double r[], const G4double z[])
G4GeometryType GetEntityType() const
G4Polyhedron * CreatePolyhedron() const
G4bool RemoveDuplicateVertices(G4double tolerance)
G4ThreeVector GetPointOnSurface() const
G4EnclosingCylinder * enclosingCylinder
void Create(G4double phiStart, G4double phiTotal, G4ReduciblePolygon *rz)
G4bool RemoveRedundantVertices(G4double tolerance)
G4ThreeVector GetPointOnSurfaceGeneric() const
G4int NumVertices() const
void CopyStuff(const G4GenericPolycone &source)
std::ostream & StreamInfo(std::ostream &os) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
const G4VCSGfaceted & operator=(const G4VCSGfaceted &source)
virtual ~G4GenericPolycone()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
EInside Inside(const G4ThreeVector &p) const
static G4int GetNumberOfRotationSteps()
G4bool BisectedBy(G4double a1, G4double b1, G4double a2, G4double b2, G4double tolerance)
virtual EInside Inside(const G4ThreeVector &p) const
G4bool ShouldMiss(const G4ThreeVector &p, const G4ThreeVector &v) const