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;
340 std::ostringstream message;
341 message <<
"Solid " <<
GetName() <<
" built using generic construct."
342 <<
G4endl <<
"Not applicable to the generic construct !";
343 G4Exception(
"G4GenericPolycone::Reset()",
"GeomSolids1001",
416 return G4String(
"G4GenericPolycone");
433 G4int oldprc = os.precision(16);
434 os <<
"-----------------------------------------------------------\n"
435 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
436 <<
" ===================================================\n"
437 <<
" Solid type: G4GenericPolycone\n"
440 <<
" ending phi angle : " <<
endPhi/
degree <<
" degrees \n";
443 os <<
" number of RZ points: " <<
numCorner <<
"\n"
444 <<
" RZ values (corners): \n";
450 os <<
"-----------------------------------------------------------\n";
451 os.precision(oldprc);
494 const G4int numSide =
495 G4int(G4Polyhedron::GetNumberOfRotationSteps()
501 typedef G4int int4[4];
508 std::vector<G4bool> chopped(
numCorner,
false);
509 std::vector<G4int*> triQuads;
512 while (remaining >= 3)
516 G4int A = -1, B = -1, C = -1;
517 G4int iStepper = iStarter;
520 if (A < 0) { A = iStepper; }
521 else if (B < 0) { B = iStepper; }
522 else if (C < 0) { C = iStepper; }
525 if (++iStepper >=
numCorner) { iStepper = 0; }
527 while (chopped[iStepper]);
529 while (C < 0 && iStepper != iStarter);
544 triQuads.push_back(tq);
552 if (++iStarter >=
numCorner) { iStarter = 0; }
554 while (chopped[iStarter]);
560 nFaces = numSide *
numCorner + 2 * triQuads.size();
561 faces_vec =
new int4[nFaces];
565 for (
G4int iEnd = 0; iEnd < 2; ++iEnd)
567 for (
size_t i = 0; i < triQuads.size(); ++i)
580 a = triQuads[i][0] + addition;
581 b = triQuads[i][2] + addition;
582 c = triQuads[i][1] + addition;
585 G4int bc = std::abs(c - b);
586 G4int ca = std::abs(a - c);
587 faces_vec[iface][0] = (ab == 1 || ab == d)? a: -a;
588 faces_vec[iface][1] = (bc == 1 || bc == d)? b: -b;
589 faces_vec[iface][2] = (ca == 1 || ca == d)? c: -c;
590 faces_vec[iface][3] = 0;
597 xyz =
new double3[nNodes];
601 for (
G4int iSide = 0; iSide < numSide; ++iSide)
605 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
606 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
610 if (iCorner < numCorner - 1)
612 faces_vec[iface][0] = ixyz + 1;
613 faces_vec[iface][1] = -(ixyz + numCorner + 1);
614 faces_vec[iface][2] = ixyz + numCorner + 2;
615 faces_vec[iface][3] = ixyz + 2;
619 faces_vec[iface][0] = ixyz + 1;
620 faces_vec[iface][1] = -(ixyz + numCorner + 1);
621 faces_vec[iface][2] = ixyz + 2;
622 faces_vec[iface][3] = ixyz - numCorner + 2;
625 else if (iSide == numSide - 1)
627 if (iCorner < numCorner - 1)
629 faces_vec[iface][0] = ixyz + 1;
630 faces_vec[iface][1] = ixyz + numCorner + 1;
631 faces_vec[iface][2] = ixyz + numCorner + 2;
632 faces_vec[iface][3] = -(ixyz + 2);
636 faces_vec[iface][0] = ixyz + 1;
637 faces_vec[iface][1] = ixyz + numCorner + 1;
638 faces_vec[iface][2] = ixyz + 2;
639 faces_vec[iface][3] = -(ixyz - numCorner + 2);
644 if (iCorner < numCorner - 1)
646 faces_vec[iface][0] = ixyz + 1;
647 faces_vec[iface][1] = -(ixyz + numCorner + 1);
648 faces_vec[iface][2] = ixyz + numCorner + 2;
649 faces_vec[iface][3] = -(ixyz + 2);
653 faces_vec[iface][0] = ixyz + 1;
654 faces_vec[iface][1] = -(ixyz + numCorner + 1);
655 faces_vec[iface][2] = ixyz + 2;
656 faces_vec[iface][3] = -(ixyz - numCorner + 2);
669 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
670 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
679 xyz =
new double3[nNodes];
680 faces_vec =
new int4[nFaces];
683 G4int ixyz = 0, iface = 0;
684 for (
G4int iSide = 0; iSide < numSide; ++iSide)
688 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
689 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
692 if (iSide < numSide - 1)
694 if (iCorner < numCorner - 1)
696 faces_vec[iface][0] = ixyz + 1;
697 faces_vec[iface][1] = -(ixyz + numCorner + 1);
698 faces_vec[iface][2] = ixyz + numCorner + 2;
699 faces_vec[iface][3] = -(ixyz + 2);
703 faces_vec[iface][0] = ixyz + 1;
704 faces_vec[iface][1] = -(ixyz + numCorner + 1);
705 faces_vec[iface][2] = ixyz + 2;
706 faces_vec[iface][3] = -(ixyz - numCorner + 2);
711 if (iCorner < numCorner - 1)
713 faces_vec[iface][0] = ixyz + 1;
714 faces_vec[iface][1] = -(ixyz + numCorner - nFaces + 1);
715 faces_vec[iface][2] = ixyz + numCorner - nFaces + 2;
716 faces_vec[iface][3] = -(ixyz + 2);
720 faces_vec[iface][0] = ixyz + 1;
721 faces_vec[iface][1] = -(ixyz - nFaces + numCorner + 1);
722 faces_vec[iface][2] = ixyz - nFaces + 2;
723 faces_vec[iface][3] = -(ixyz - numCorner + 2);
733 G4int problem = polyhedron->createPolyhedron(nNodes, nFaces, xyz, faces_vec);
738 std::ostringstream message;
739 message <<
"Problem creating G4Polyhedron for: " <<
GetName();
740 G4Exception(
"G4GenericPolycone::CreatePolyhedron()",
"GeomSolids1002",
G4bool CrossesItself(G4double tolerance)
G4VCSGfaceted & operator=(const G4VCSGfaceted &source)
G4bool fRebuildPolyhedron
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