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",
108 std::ostringstream message;
109 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl 110 <<
" R/Z cross section is zero or near zero: " << rzArea;
111 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
118 std::ostringstream message;
119 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl 120 <<
" Too few unique R/Z values !";
121 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
127 std::ostringstream message;
128 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl 129 <<
" R/Z segments cross !";
130 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
140 if (phiTotal <= 0 || phiTotal >
twopi-1
E-10)
157 endPhi = phiStart+phiTotal;
176 next->
r = iterRZ.
GetA();
177 next->
z = iterRZ.
GetB();
178 }
while( ++next, iterRZ.
Next() );
210 if (corner->
z > next->
z)
227 }
while( prev=corner, corner=next, corner >
corners );
287 if (
this == &source)
return *
this;
343 std::ostringstream message;
344 message <<
"Solid " <<
GetName() <<
" built using generic construct." 345 <<
G4endl <<
"Not applicable to the generic construct !";
346 G4Exception(
"G4GenericPolycone::Reset()",
"GeomSolids1001",
419 return G4String(
"G4GenericPolycone");
436 G4int oldprc = os.precision(16);
437 os <<
"-----------------------------------------------------------\n" 438 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n" 439 <<
" ===================================================\n" 440 <<
" Solid type: G4GenericPolycone\n" 443 <<
" ending phi angle : " <<
endPhi/
degree <<
" degrees \n";
446 os <<
" number of RZ points: " <<
numCorner <<
"\n" 447 <<
" RZ values (corners): \n";
453 os <<
"-----------------------------------------------------------\n";
454 os.precision(oldprc);
497 const G4int numSide =
504 typedef G4int int4[4];
511 std::vector<G4bool> chopped(
numCorner,
false);
512 std::vector<G4int*> triQuads;
515 while (remaining >= 3)
520 G4int iStepper = iStarter;
523 if (A < 0) { A = iStepper; }
524 else if (
B < 0) {
B = iStepper; }
525 else if (
C < 0) {
C = iStepper; }
528 if (++iStepper >=
numCorner) { iStepper = 0; }
530 while (chopped[iStepper]);
532 while (
C < 0 && iStepper != iStarter);
547 triQuads.push_back(tq);
555 if (++iStarter >=
numCorner) { iStarter = 0; }
557 while (chopped[iStarter]);
563 nFaces = numSide *
numCorner + 2 * triQuads.size();
564 faces_vec =
new int4[nFaces];
568 for (
G4int iEnd = 0; iEnd < 2; ++iEnd)
570 for (
size_t i = 0; i < triQuads.size(); ++i)
583 a = triQuads[i][0] + addition;
584 b = triQuads[i][2] + addition;
585 c = triQuads[i][1] + addition;
588 G4int bc = std::abs(c - b);
589 G4int ca = std::abs(a - c);
590 faces_vec[iface][0] = (ab == 1 || ab ==
d)? a: -a;
591 faces_vec[iface][1] = (bc == 1 || bc ==
d)? b: -b;
592 faces_vec[iface][2] = (ca == 1 || ca ==
d)? c: -c;
593 faces_vec[iface][3] = 0;
600 xyz =
new double3[nNodes];
604 for (
G4int iSide = 0; iSide < numSide; ++iSide)
608 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
609 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
613 if (iCorner < numCorner - 1)
615 faces_vec[iface][0] = ixyz + 1;
616 faces_vec[iface][1] = -(ixyz + numCorner + 1);
617 faces_vec[iface][2] = ixyz + numCorner + 2;
618 faces_vec[iface][3] = ixyz + 2;
622 faces_vec[iface][0] = ixyz + 1;
623 faces_vec[iface][1] = -(ixyz + numCorner + 1);
624 faces_vec[iface][2] = ixyz + 2;
625 faces_vec[iface][3] = ixyz - numCorner + 2;
628 else if (iSide == numSide - 1)
630 if (iCorner < numCorner - 1)
632 faces_vec[iface][0] = ixyz + 1;
633 faces_vec[iface][1] = ixyz + numCorner + 1;
634 faces_vec[iface][2] = ixyz + numCorner + 2;
635 faces_vec[iface][3] = -(ixyz + 2);
639 faces_vec[iface][0] = ixyz + 1;
640 faces_vec[iface][1] = ixyz + numCorner + 1;
641 faces_vec[iface][2] = ixyz + 2;
642 faces_vec[iface][3] = -(ixyz - numCorner + 2);
647 if (iCorner < numCorner - 1)
649 faces_vec[iface][0] = ixyz + 1;
650 faces_vec[iface][1] = -(ixyz + numCorner + 1);
651 faces_vec[iface][2] = ixyz + numCorner + 2;
652 faces_vec[iface][3] = -(ixyz + 2);
656 faces_vec[iface][0] = ixyz + 1;
657 faces_vec[iface][1] = -(ixyz + numCorner + 1);
658 faces_vec[iface][2] = ixyz + 2;
659 faces_vec[iface][3] = -(ixyz - numCorner + 2);
672 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
673 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
682 xyz =
new double3[nNodes];
683 faces_vec =
new int4[nFaces];
686 G4int ixyz = 0, iface = 0;
687 for (
G4int iSide = 0; iSide < numSide; ++iSide)
691 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
692 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
695 if (iSide < numSide - 1)
697 if (iCorner < numCorner - 1)
699 faces_vec[iface][0] = ixyz + 1;
700 faces_vec[iface][1] = -(ixyz + numCorner + 1);
701 faces_vec[iface][2] = ixyz + numCorner + 2;
702 faces_vec[iface][3] = -(ixyz + 2);
706 faces_vec[iface][0] = ixyz + 1;
707 faces_vec[iface][1] = -(ixyz + numCorner + 1);
708 faces_vec[iface][2] = ixyz + 2;
709 faces_vec[iface][3] = -(ixyz - numCorner + 2);
714 if (iCorner < numCorner - 1)
716 faces_vec[iface][0] = ixyz + 1;
717 faces_vec[iface][1] = -(ixyz + numCorner - nFaces + 1);
718 faces_vec[iface][2] = ixyz + numCorner - nFaces + 2;
719 faces_vec[iface][3] = -(ixyz + 2);
723 faces_vec[iface][0] = ixyz + 1;
724 faces_vec[iface][1] = -(ixyz - nFaces + numCorner + 1);
725 faces_vec[iface][2] = ixyz - nFaces + 2;
726 faces_vec[iface][3] = -(ixyz - numCorner + 2);
741 std::ostringstream message;
742 message <<
"Problem creating G4Polyhedron for: " <<
GetName();
743 G4Exception(
"G4GenericPolycone::CreatePolyhedron()",
"GeomSolids1002",
G4bool CrossesItself(G4double tolerance)
G4VCSGfaceted & operator=(const G4VCSGfaceted &source)
G4bool fRebuildPolyhedron
G4Polyhedron * fpPolyhedron
static const G4double kInfinity
G4PolyconeSideRZ * corners
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
G4bool ShouldMiss(const G4ThreeVector &p, const G4ThreeVector &v) const
std::ostream & StreamInfo(std::ostream &os) const
G4GenericPolycone(const G4String &name, G4double phiStart, G4double phiTotal, G4int numRZ, const G4double r[], const G4double z[])
G4bool RemoveDuplicateVertices(G4double tolerance)
virtual EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4EnclosingCylinder * enclosingCylinder
void Create(G4double phiStart, G4double phiTotal, G4ReduciblePolygon *rz)
G4bool RemoveRedundantVertices(G4double tolerance)
G4Polyhedron * CreatePolyhedron() const
double A(double temperature)
G4bool MustBeOutside(const G4ThreeVector &p) const
void CopyStuff(const G4GenericPolycone &source)
G4GeometryType GetEntityType() const
static const double twopi
virtual ~G4GenericPolycone()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4GenericPolycone & operator=(const G4GenericPolycone &source)
G4ThreeVector GetPointOnSurfaceGeneric() const
EInside Inside(const G4ThreeVector &p) const
static G4int GetNumberOfRotationSteps()
G4int NumVertices() const
static const double degree
G4bool BisectedBy(G4double a1, G4double b1, G4double a2, G4double b2, G4double tolerance)
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4ThreeVector GetPointOnSurface() const