42 #if !defined(G4GEOM_USE_UPOLYCONE) 53 using namespace CLHEP;
80 for (i=0; i<numZPlanes; i++)
82 if(rInner[i]>rOuter[i])
85 std::ostringstream message;
86 message <<
"Cannot create a Polycone with rInner > rOuter for the same Z" 88 <<
" rInner > rOuter for the same Z !" <<
G4endl 89 <<
" rMin[" << i <<
"] = " << rInner[i]
90 <<
" -- rMax[" << i <<
"] = " << rOuter[i];
91 G4Exception(
"G4Polycone::G4Polycone()",
"GeomSolids0002",
94 if (( i < numZPlanes-1) && ( zPlane[i] == zPlane[i+1] ))
96 if( (rInner[i] > rOuter[i+1])
97 ||(rInner[i+1] > rOuter[i]) )
100 std::ostringstream message;
101 message <<
"Cannot create a Polycone with no contiguous segments." 103 <<
" Segments are not contiguous !" <<
G4endl 104 <<
" rMin[" << i <<
"] = " << rInner[i]
105 <<
" -- rMax[" << i+1 <<
"] = " << rOuter[i+1] <<
G4endl 106 <<
" rMin[" << i+1 <<
"] = " << rInner[i+1]
107 <<
" -- rMax[" << i <<
"] = " << rOuter[i];
108 G4Exception(
"G4Polycone::G4Polycone()",
"GeomSolids0002",
126 Create( phiStart, phiTotal, rz );
146 Create( phiStart, phiTotal, rz );
155 std::ostringstream message;
156 message <<
"Polycone " <<
GetName() <<
"cannot be converted" <<
G4endl 157 <<
"to Polycone with (Rmin,Rmaz,Z) parameters!";
158 G4Exception(
"G4Polycone::G4Polycone()",
"GeomSolids0002",
164 <<
"to optimized polycone with (Rmin,Rmaz,Z) parameters !" 183 if (rz->
Amin() < 0.0)
185 std::ostringstream message;
186 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl 187 <<
" All R values must be >= 0 !";
188 G4Exception(
"G4Polycone::Create()",
"GeomSolids0002",
199 std::ostringstream message;
200 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl 201 <<
" R/Z cross section is zero or near zero: " << rzArea;
202 G4Exception(
"G4Polycone::Create()",
"GeomSolids0002",
209 std::ostringstream message;
210 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl 211 <<
" Too few unique R/Z values !";
212 G4Exception(
"G4Polycone::Create()",
"GeomSolids0002",
218 std::ostringstream message;
219 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl 220 <<
" R/Z segments cross !";
221 G4Exception(
"G4Polycone::Create()",
"GeomSolids0002",
231 if (phiTotal <= 0 || phiTotal >
twopi-1
E-10)
248 endPhi = phiStart+phiTotal;
267 next->
r = iterRZ.
GetA();
268 next->
z = iterRZ.
GetB();
269 }
while( ++next, iterRZ.
Next() );
301 if (corner->
z > next->
z)
318 }
while( prev=corner, corner=next, corner >
corners );
380 if (
this == &source)
return *
this;
549 G4int oldprc = os.precision(16);
550 os <<
"-----------------------------------------------------------\n" 551 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n" 552 <<
" ===================================================\n" 553 <<
" Solid type: G4Polycone\n" 556 <<
" ending phi angle : " <<
endPhi/
degree <<
" degrees \n";
560 os <<
" number of Z planes: " << numPlanes <<
"\n" 562 for (i=0; i<numPlanes; i++)
564 os <<
" Z plane " << i <<
": " 567 os <<
" Tangent distances to inner surface (Rmin): \n";
568 for (i=0; i<numPlanes; i++)
570 os <<
" Z plane " << i <<
": " 573 os <<
" Tangent distances to outer surface (Rmax): \n";
574 for (i=0; i<numPlanes; i++)
576 os <<
" Z plane " << i <<
": " 580 os <<
" number of RZ points: " <<
numCorner <<
"\n" 581 <<
" RZ values (corners): \n";
587 os <<
"-----------------------------------------------------------\n";
588 os.precision(oldprc);
606 G4double Aone, Atwo, Afive, phi, zRand, fDPhi, cosu, sinu;
607 G4double rRand1, rmin, rmax, chose, rone, rtwo, qone, qtwo;
608 G4double fDz=(zTwo-zOne)/2., afDz=std::fabs(fDz);
611 rone = (fRmax1-fRmax2)/(2.*fDz);
612 rtwo = (fRmin1-fRmin2)/(2.*fDz);
613 if(fRmax1==fRmax2){qone=0.;}
615 qone = fDz*(fRmax1+fRmax2)/(fRmax1-fRmax2);
617 if(fRmin1==fRmin2){qtwo=0.;}
619 qtwo = fDz*(fRmin1+fRmin2)/(fRmin1-fRmin2);
621 Aone = 0.5*fDPhi*(fRmax2 + fRmax1)*(
sqr(fRmin1-fRmin2)+
sqr(zTwo-zOne));
622 Atwo = 0.5*fDPhi*(fRmin2 + fRmin1)*(
sqr(fRmax1-fRmax2)+
sqr(zTwo-zOne));
623 Afive = fDz*(fRmax1-fRmin1+fRmax2-fRmin2);
624 totArea = Aone+Atwo+2.*Afive;
627 cosu = std::cos(phi);
628 sinu = std::sin(phi);
631 if( (startPhi == 0) && (
endPhi ==
twopi) ) { Afive = 0; }
633 if( (chose >= 0) && (chose < Aone) )
639 rone*sinu*(qone-zRand), zRand);
648 else if(chose >= Aone && chose < Aone + Atwo)
654 rtwo*sinu*(qtwo-zRand), zRand);
663 else if( (chose >= Aone + Atwo + Afive) && (chose < Aone + Atwo + 2.*Afive) )
666 rmin = fRmin2-((zRand-fDz)/(2.*fDz))*(fRmin1-fRmin2);
667 rmax = fRmax2-((zRand-fDz)/(2.*fDz))*(fRmax1-fRmax2);
670 rRand1*std::sin(startPhi), zRand);
675 rmin = fRmin2-((zRand-fDz)/(2.*fDz))*(fRmin1-fRmin2);
676 rmax = fRmax2-((zRand-fDz)/(2.*fDz))*(fRmax1-fRmax2);
679 rRand1*std::sin(
endPhi), zRand);
696 G4double xRand,yRand,zRand,phi,cosphi,sinphi,chose,
697 aOne,aTwo,aFou,rRand,fDz,fSPhi,fDPhi;
698 fDz = std::fabs(0.5*(zTwo-zOne));
702 aOne = 2.*fDz*fDPhi*fRMax;
703 aTwo = 2.*fDz*fDPhi*fRMin;
704 aFou = 2.*fDz*(fRMax-fRMin);
705 totArea = aOne+aTwo+2.*aFou;
707 cosphi = std::cos(phi);
708 sinphi = std::sin(phi);
715 if( (chose >= 0) && (chose < aOne) )
717 xRand = fRMax*cosphi;
718 yRand = fRMax*sinphi;
722 else if( (chose >= aOne) && (chose < aOne + aTwo) )
724 xRand = fRMin*cosphi;
725 yRand = fRMin*sinphi;
729 else if( (chose >= aOne+aTwo) && (chose <aOne+aTwo+aFou) )
731 xRand = rRand*std::cos(fSPhi+fDPhi);
732 yRand = rRand*std::sin(fSPhi+fDPhi);
739 xRand = rRand*std::cos(fSPhi+fDPhi);
740 yRand = rRand*std::sin(fSPhi+fDPhi);
755 G4double xRand,yRand,phi,cosphi,sinphi,rRand1,rRand2,A1,Atot,rCh;
757 cosphi = std::cos(phi);
758 sinphi = std::sin(phi);
762 rRand1 = fRMin1; A1=0.;
767 A1=std::fabs(fRMin2*fRMin2-fRMin1*fRMin1);
771 rRand2=fRMax1; Atot=A1;
776 Atot = A1+std::fabs(fRMax2*fRMax2-fRMax1*fRMax1);
780 if(rCh>A1) { rRand1=rRand2; }
782 xRand = rRand1*cosphi;
783 yRand = rRand1*sinphi;
802 if( (fRMin1 == fRMin2) && (fRMax1 == fRMax2) )
806 return GetPointOnCone(fRMin1,fRMax1,fRMin2,fRMax2,zOne,zTwo,totArea);
815 G4double Area=0,totArea=0,Achose1=0,Achose2=0,phi,cosphi,sinphi,rRand;
820 cosphi = std::cos(phi);
821 sinphi = std::sin(phi);
827 std::vector<G4double> areas;
828 std::vector<G4ThreeVector> points;
833 for(i=0; i<numPlanes-1; i++)
858 areas.push_back(Area);
865 totArea += (areas[0]+areas[numPlanes]);
868 if( (chose>=0.) && (chose<areas[0]) )
874 for (i=0; i<numPlanes-1; i++)
877 Achose2 = (Achose1+areas[i+1]);
878 if(chose>=Achose1 && chose<Achose2)
918 G4bool isConvertible=
true;
924 std::vector<G4double>
Z;
925 std::vector<G4double> Rmin;
926 std::vector<G4double> Rmax;
939 Rmax.push_back (
corners[1].r);icurr=1;
941 else if (Zprev ==
corners[numPlanes-1].z)
943 Rmin.push_back(
corners[numPlanes-1].
r);
955 G4int inextr=0, inextl=0;
956 for (
G4int i=0; i < numPlanes-2; i++)
959 inextl=(icurl <= 0)? numPlanes-1 : icurl-1;
977 Rmax.push_back(
corners[icurr].r);
991 Rmax.push_back(
corners[icurr].r);
1002 isConvertible=
false;
break;
1004 icurl=(icurl == 0)? numPlanes-1 : icurl-1;
1012 icurl=(icurl == 0)? numPlanes-1 : icurl-1;
1015 Rmax.push_back(
corners[inextr].r);
1019 Z.push_back(Zright);
1029 Rmin.push_back(
corners[icurr].r);
1035 Rmax.push_back(
corners[inextr].r);
1044 Rmin.push_back (
corners[icurr].r);
1056 isConvertible=
false;
break;
1066 inextl=(icurl <= 0)? numPlanes-1 : icurl-1;
1069 Rmin.push_back(
corners[inextl].r);
1080 for(
G4int j=0; j < countPlanes; j++)
1094 std::ostringstream message;
1096 <<
"cannot be converted to Polycone with (Rmin,Rmaz,Z) parameters!";
1097 G4Exception(
"G4Polycone::SetOriginalParameters()",
"GeomSolids0002",
1105 for(
G4int j=0; j < numPlanes; j++)
1115 return isConvertible;
G4Polyhedron * CreatePolyhedron() const
G4bool CrossesItself(G4double tolerance)
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
ThreeVector shoot(const G4int Ap, const G4int Af)
G4VCSGfaceted & operator=(const G4VCSGfaceted &source)
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4bool fRebuildPolyhedron
G4Polyhedron * fpPolyhedron
static const G4double kInfinity
CLHEP::Hep3Vector G4ThreeVector
G4bool ShouldMiss(const G4ThreeVector &p, const G4ThreeVector &v) const
G4ThreeVector GetPointOnRing(G4double fRMin, G4double fRMax, G4double fRMin2, G4double fRMax2, G4double zOne) const
G4PolyconeSideRZ * corners
G4bool RemoveDuplicateVertices(G4double tolerance)
virtual EInside Inside(const G4ThreeVector &p) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4bool RemoveRedundantVertices(G4double tolerance)
G4Polycone & operator=(const G4Polycone &source)
G4GLOB_DLL std::ostream G4cout
G4bool MustBeOutside(const G4ThreeVector &p) const
static const double twopi
void SetOriginalParameters(G4PolyconeHistorical *pars)
G4ThreeVector GetPointOnCut(G4double fRMin1, G4double fRMax1, G4double fRMin2, G4double fRMax2, G4double zOne, G4double zTwo, G4double &totArea) const
G4ThreeVector GetPointOnSurface() const
G4GeometryType GetEntityType() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
EInside Inside(const G4ThreeVector &p) const
void CopyStuff(const G4Polycone &source)
G4EnclosingCylinder * enclosingCylinder
G4int NumVertices() const
static const double degree
std::ostream & StreamInfo(std::ostream &os) const
G4bool BisectedBy(G4double a1, G4double b1, G4double a2, G4double b2, G4double tolerance)
G4ThreeVector GetPointOnTubs(G4double fRMin, G4double fRMax, G4double zOne, G4double zTwo, G4double &totArea) const
G4ThreeVector GetPointOnCone(G4double fRmin1, G4double fRmax1, G4double fRmin2, G4double fRmax2, G4double zOne, G4double zTwo, G4double &totArea) const
G4Polycone(const G4String &name, G4double phiStart, G4double phiTotal, G4int numZPlanes, const G4double zPlane[], const G4double rInner[], const G4double rOuter[])
void Create(G4double phiStart, G4double phiTotal, G4ReduciblePolygon *rz)
G4PolyconeHistorical * original_parameters
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const