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() );
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;
339 std::ostringstream message;
340 message <<
"Solid " <<
GetName() <<
" built using generic construct."
341 <<
G4endl <<
"Not applicable to the generic construct !";
342 G4Exception(
"G4GenericPolycone::Reset()",
"GeomSolids1001",
415 return G4String(
"G4GenericPolycone");
432 G4int oldprc = os.precision(16);
433 os <<
"-----------------------------------------------------------\n"
434 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
435 <<
" ===================================================\n"
436 <<
" Solid type: G4GenericPolycone\n"
439 <<
" ending phi angle : " <<
endPhi/
degree <<
" degrees \n";
442 os <<
" number of RZ points: " <<
numCorner <<
"\n"
443 <<
" RZ values (corners): \n";
449 os <<
"-----------------------------------------------------------\n";
450 os.precision(oldprc);
493 const G4int numSide =
494 G4int(G4Polyhedron::GetNumberOfRotationSteps()
500 typedef G4int int4[4];
507 std::vector<G4bool> chopped(
numCorner,
false);
508 std::vector<G4int*> triQuads;
511 while (remaining >= 3)
515 G4int A = -1, B = -1, C = -1;
516 G4int iStepper = iStarter;
519 if (A < 0) { A = iStepper; }
520 else if (B < 0) { B = iStepper; }
521 else if (C < 0) { C = iStepper; }
524 if (++iStepper >=
numCorner) { iStepper = 0; }
526 while (chopped[iStepper]);
528 while (C < 0 && iStepper != iStarter);
543 triQuads.push_back(tq);
551 if (++iStarter >=
numCorner) { iStarter = 0; }
553 while (chopped[iStarter]);
559 nFaces = numSide *
numCorner + 2 * triQuads.size();
560 faces_vec =
new int4[nFaces];
564 for (
G4int iEnd = 0; iEnd < 2; ++iEnd)
566 for (
size_t i = 0; i < triQuads.size(); ++i)
579 a = triQuads[i][0] + addition;
580 b = triQuads[i][2] + addition;
581 c = triQuads[i][1] + addition;
584 G4int bc = std::abs(c - b);
585 G4int ca = std::abs(a - c);
586 faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
587 faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
588 faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
589 faces_vec[iface][3] = 0;
596 xyz =
new double3[nNodes];
600 for (
G4int iSide = 0; iSide < numSide; ++iSide)
604 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
605 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
609 if (iCorner < numCorner - 1)
611 faces_vec[iface][0] = ixyz + 1;
612 faces_vec[iface][1] = -(ixyz + numCorner + 1);
613 faces_vec[iface][2] = ixyz + numCorner + 2;
614 faces_vec[iface][3] = ixyz + 2;
618 faces_vec[iface][0] = ixyz + 1;
619 faces_vec[iface][1] = -(ixyz + numCorner + 1);
620 faces_vec[iface][2] = ixyz + 2;
621 faces_vec[iface][3] = ixyz - numCorner + 2;
624 else if (iSide == numSide - 1)
626 if (iCorner < numCorner - 1)
628 faces_vec[iface][0] = ixyz + 1;
629 faces_vec[iface][1] = ixyz + numCorner + 1;
630 faces_vec[iface][2] = ixyz + numCorner + 2;
631 faces_vec[iface][3] = -(ixyz + 2);
635 faces_vec[iface][0] = ixyz + 1;
636 faces_vec[iface][1] = ixyz + numCorner + 1;
637 faces_vec[iface][2] = ixyz + 2;
638 faces_vec[iface][3] = -(ixyz - numCorner + 2);
643 if (iCorner < numCorner - 1)
645 faces_vec[iface][0] = ixyz + 1;
646 faces_vec[iface][1] = -(ixyz + numCorner + 1);
647 faces_vec[iface][2] = ixyz + numCorner + 2;
648 faces_vec[iface][3] = -(ixyz + 2);
652 faces_vec[iface][0] = ixyz + 1;
653 faces_vec[iface][1] = -(ixyz + numCorner + 1);
654 faces_vec[iface][2] = ixyz + 2;
655 faces_vec[iface][3] = -(ixyz - numCorner + 2);
668 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
669 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
678 xyz =
new double3[nNodes];
679 faces_vec =
new int4[nFaces];
682 G4int ixyz = 0, iface = 0;
683 for (
G4int iSide = 0; iSide < numSide; ++iSide)
687 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
688 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
691 if (iSide < numSide - 1)
693 if (iCorner < numCorner - 1)
695 faces_vec[iface][0] = ixyz + 1;
696 faces_vec[iface][1] = -(ixyz + numCorner + 1);
697 faces_vec[iface][2] = ixyz + numCorner + 2;
698 faces_vec[iface][3] = -(ixyz + 2);
702 faces_vec[iface][0] = ixyz + 1;
703 faces_vec[iface][1] = -(ixyz + numCorner + 1);
704 faces_vec[iface][2] = ixyz + 2;
705 faces_vec[iface][3] = -(ixyz - numCorner + 2);
710 if (iCorner < numCorner - 1)
712 faces_vec[iface][0] = ixyz + 1;
713 faces_vec[iface][1] = -(ixyz + numCorner - nFaces + 1);
714 faces_vec[iface][2] = ixyz + numCorner - nFaces + 2;
715 faces_vec[iface][3] = -(ixyz + 2);
719 faces_vec[iface][0] = ixyz + 1;
720 faces_vec[iface][1] = -(ixyz - nFaces + numCorner + 1);
721 faces_vec[iface][2] = ixyz - nFaces + 2;
722 faces_vec[iface][3] = -(ixyz - numCorner + 2);
732 G4int problem = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
737 std::ostringstream message;
738 message <<
"Problem creating G4Polyhedron for: " <<
GetName();
739 G4Exception(
"G4GenericPolycone::CreatePolyhedron()",
"GeomSolids1002",
G4bool CrossesItself(G4double tolerance)
G4VCSGfaceted & operator=(const G4VCSGfaceted &source)
G4Polyhedron * fpPolyhedron
static const G4double kInfinity
G4PolyconeSideRZ * corners
CLHEP::Hep3Vector G4ThreeVector
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
static const G4double A[nN]
virtual ~G4GenericPolycone()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4GenericPolycone & operator=(const G4GenericPolycone &source)
EInside Inside(const G4ThreeVector &p) const
static const double degree
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
virtual G4Polyhedron * GetPolyhedron() const