33 #if !defined(G4GEOM_USE_UGENERICPOLYCONE)
50 using namespace CLHEP;
65 Create( phiStart, phiTotal, rz );
89 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl
90 <<
" All R values must be >= 0 !";
91 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
103 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl
104 <<
" R/Z cross section is zero or near zero: " << rzArea;
105 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
113 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl
114 <<
" Too few unique R/Z values !";
115 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
122 message <<
"Illegal input parameters - " <<
GetName() <<
G4endl
123 <<
" R/Z segments cross !";
124 G4Exception(
"G4GenericPolycone::Create()",
"GeomSolids0002",
134 if (phiTotal <= 0 || phiTotal >
twopi-1
E-10)
151 endPhi = phiStart+phiTotal;
170 next->
r = iterRZ.
GetA();
171 next->
z = iterRZ.
GetB();
172 }
while( ++next, iterRZ.
Next() );
204 if (corner->
z > next->
z)
221 }
while( prev=corner, corner=next, corner >
corners );
273 if (
this == &source)
return *
this;
325 message <<
"Solid " <<
GetName() <<
" built using generic construct."
326 <<
G4endl <<
"Not applicable to the generic construct !";
327 G4Exception(
"G4GenericPolycone::Reset()",
"GeomSolids1001",
391 if (corner.
r < rmin) rmin = corner.
r;
392 if (corner.
r > rmax) rmax = corner.
r;
393 if (corner.
z < zmin) zmin = corner.
z;
394 if (corner.
z > zmax) zmax = corner.
z;
404 pMin.
set(vmin.
x(),vmin.
y(),zmin);
405 pMax.
set(vmax.
x(),vmax.
y(),zmax);
409 pMin.
set(-rmax,-rmax, zmin);
410 pMax.
set( rmax, rmax, zmax);
415 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
418 message <<
"Bad bounding box (min >= max) for solid: "
420 <<
"\npMin = " << pMin
421 <<
"\npMax = " <<
pMax;
422 G4Exception(
"GenericG4Polycone::BoundingLimits()",
"GeomMgt0001",
450 return exist = (pMin <
pMax) ?
true :
false;
469 if (area < 0.)
std::reverse(contourRZ.begin(),contourRZ.end());
475 message <<
"Triangulation of RZ contour has failed for solid: "
477 <<
"\nExtent has been calculated using boundary box";
478 G4Exception(
"G4GenericPolycone::CalculateExtent()",
484 const G4int NSTEPS = 24;
490 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
493 G4double sinHalf = std::sin(0.5*ang);
494 G4double cosHalf = std::cos(0.5*ang);
495 G4double sinStep = 2.*sinHalf*cosHalf;
496 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
504 std::vector<const G4ThreeVectorList *> polygons;
505 polygons.resize(ksteps+2);
507 for (
G4int k=0;
k<ksteps+2; ++
k) pols[
k].resize(6);
508 for (
G4int k=0;
k<ksteps+2; ++
k) polygons[
k] = &pols[
k];
515 G4int ntria = triangles.size()/3;
516 for (
G4int i=0; i<ntria; ++i)
521 G4int e0 = i3+
k,
e1 = (k<2) ? e0+1 : i3;
524 r0[k2+0] = triangles[e0].x(); z0[k2+0] = triangles[e0].y();
525 r0[k2+1] = triangles[
e1].x(); z0[k2+1] = triangles[
e1].y();
529 if (z0[k2+1] - z0[k2+0] <= 0)
continue;
535 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
536 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
537 for (
G4int j=0; j<6; ++j)
539 pols[0][j].set(r0[j]*cosStart,r0[j]*sinStart,z0[j]);
543 for (
G4int j=0; j<6; ++j)
545 pols[
k][j].set(r1[j]*cosCur,r1[j]*sinCur,z0[j]);
548 sinCur = sinCur*cosStep + cosCur*sinStep;
549 cosCur = cosCur*cosStep - sinTmp*sinStep;
551 for (
G4int j=0; j<6; ++j)
553 pols[ksteps+1][j].set(r0[j]*cosEnd,r0[j]*sinEnd,z0[j]);
559 if (!benv.
CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
560 if (emin < pMin) pMin =
emin;
561 if (emax > pMax) pMax =
emax;
562 if (eminlim > pMin && emaxlim < pMax)
return true;
564 return (pMin < pMax);
571 return G4String(
"G4GenericPolycone");
589 G4int oldprc = os.precision(16);
590 os <<
"-----------------------------------------------------------\n"
591 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
592 <<
" ===================================================\n"
593 <<
" Solid type: G4GenericPolycone\n"
596 <<
" ending phi angle : " <<
endPhi/
degree <<
" degrees \n";
599 os <<
" number of RZ points: " <<
numCorner <<
"\n"
600 <<
" RZ values (corners): \n";
606 os <<
"-----------------------------------------------------------\n";
607 os.precision(oldprc);
653 typedef G4int int4[4];
660 std::vector<G4bool> chopped(
numCorner,
false);
661 std::vector<G4int*> triQuads;
664 while (remaining >= 3)
669 G4int iStepper = iStarter;
672 if (A < 0) { A = iStepper; }
673 else if (
B < 0) {
B = iStepper; }
674 else if (
C < 0) {
C = iStepper; }
677 if (++iStepper >=
numCorner) { iStepper = 0; }
679 while (chopped[iStepper]);
681 while (
C < 0 && iStepper != iStarter);
696 triQuads.push_back(tq);
704 if (++iStarter >=
numCorner) { iStarter = 0; }
706 while (chopped[iStarter]);
712 nFaces = numSide *
numCorner + 2 * triQuads.size();
713 faces_vec =
new int4[nFaces];
717 for (
G4int iEnd = 0; iEnd < 2; ++iEnd)
719 for (
size_t i = 0; i < triQuads.size(); ++i)
732 a = triQuads[i][0] + addition;
733 b = triQuads[i][2] + addition;
734 c = triQuads[i][1] + addition;
739 faces_vec[iface][0] = (ab == 1 || ab ==
d)? a: -a;
740 faces_vec[iface][1] = (bc == 1 || bc ==
d)? b: -b;
741 faces_vec[iface][2] = (ca == 1 || ca ==
d)? c: -c;
742 faces_vec[iface][3] = 0;
749 xyz =
new double3[nNodes];
757 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
758 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
762 if (iCorner < numCorner - 1)
764 faces_vec[iface][0] = ixyz + 1;
765 faces_vec[iface][1] = -(ixyz + numCorner + 1);
766 faces_vec[iface][2] = ixyz + numCorner + 2;
767 faces_vec[iface][3] = ixyz + 2;
771 faces_vec[iface][0] = ixyz + 1;
772 faces_vec[iface][1] = -(ixyz + numCorner + 1);
773 faces_vec[iface][2] = ixyz + 2;
774 faces_vec[iface][3] = ixyz - numCorner + 2;
777 else if (iSide == numSide - 1)
779 if (iCorner < numCorner - 1)
781 faces_vec[iface][0] = ixyz + 1;
782 faces_vec[iface][1] = ixyz + numCorner + 1;
783 faces_vec[iface][2] = ixyz + numCorner + 2;
784 faces_vec[iface][3] = -(ixyz + 2);
788 faces_vec[iface][0] = ixyz + 1;
789 faces_vec[iface][1] = ixyz + numCorner + 1;
790 faces_vec[iface][2] = ixyz + 2;
791 faces_vec[iface][3] = -(ixyz - numCorner + 2);
796 if (iCorner < numCorner - 1)
798 faces_vec[iface][0] = ixyz + 1;
799 faces_vec[iface][1] = -(ixyz + numCorner + 1);
800 faces_vec[iface][2] = ixyz + numCorner + 2;
801 faces_vec[iface][3] = -(ixyz + 2);
805 faces_vec[iface][0] = ixyz + 1;
806 faces_vec[iface][1] = -(ixyz + numCorner + 1);
807 faces_vec[iface][2] = ixyz + 2;
808 faces_vec[iface][3] = -(ixyz - numCorner + 2);
821 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
822 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
831 xyz =
new double3[nNodes];
832 faces_vec =
new int4[nFaces];
835 G4int ixyz = 0, iface = 0;
840 xyz[ixyz][0] =
corners[iCorner].
r * std::cos(phi);
841 xyz[ixyz][1] =
corners[iCorner].
r * std::sin(phi);
844 if (iSide < numSide - 1)
846 if (iCorner < numCorner - 1)
848 faces_vec[iface][0] = ixyz + 1;
849 faces_vec[iface][1] = -(ixyz + numCorner + 1);
850 faces_vec[iface][2] = ixyz + numCorner + 2;
851 faces_vec[iface][3] = -(ixyz + 2);
855 faces_vec[iface][0] = ixyz + 1;
856 faces_vec[iface][1] = -(ixyz + numCorner + 1);
857 faces_vec[iface][2] = ixyz + 2;
858 faces_vec[iface][3] = -(ixyz - numCorner + 2);
863 if (iCorner < numCorner - 1)
865 faces_vec[iface][0] = ixyz + 1;
866 faces_vec[iface][1] = -(ixyz + numCorner - nFaces + 1);
867 faces_vec[iface][2] = ixyz + numCorner - nFaces + 2;
868 faces_vec[iface][3] = -(ixyz + 2);
872 faces_vec[iface][0] = ixyz + 1;
873 faces_vec[iface][1] = -(ixyz - nFaces + numCorner + 1);
874 faces_vec[iface][2] = ixyz - nFaces + 2;
875 faces_vec[iface][3] = -(ixyz - numCorner + 2);
891 message <<
"Problem creating G4Polyhedron for: " <<
GetName();
892 G4Exception(
"G4GenericPolycone::CreatePolyhedron()",
"GeomSolids1002",