56 using namespace CLHEP;
 
   73   if ( pDx > 0 && pDy > 0 && pDz > 0 )
 
   78     fTalpha     = std::tan(pAlpha);
 
   79     fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
 
   80     fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
 
   84     std::ostringstream message;
 
   85     message << 
"Invalid Length Parameters for Solid: " << GetName() << 
G4endl 
   86             << 
"        pDx, pDy, pDz = " 
   87             << pDx << 
", " << pDy << 
", " << pDz;
 
   88     G4Exception(
"G4Para::SetAllParameters()", 
"GeomSolids0002",
 
  104   if ((pDx<=0) || (pDy<=0) || (pDz<=0))
 
  106     std::ostringstream message;
 
  107     message << 
"Invalid Length Parameters for Solid: " << 
GetName() << 
G4endl 
  108             << 
"        pDx, pDy, pDz = " 
  109             << pDx << 
", " << pDy << 
", " << pDz;
 
  126   if (!( pt[0].
z()<0 && pt[0].
z()==pt[1].
z() && pt[0].
z()==pt[2].
z() &&
 
  127          pt[0].
z()==pt[3].
z() && pt[4].
z()>0 && pt[4].
z()==pt[5].
z() &&
 
  128          pt[4].
z()==pt[6].
z() && pt[4].
z()==pt[7].
z()           &&
 
  129         (pt[0].
z()+pt[4].
z())==0                                &&
 
  130          pt[0].y()==pt[1].y() && pt[2].y()==pt[3].y()           &&
 
  131          pt[4].y()==pt[5].y() && pt[6].y()==pt[7].y()           &&
 
  132        ( pt[0].y() + pt[2].y() + pt[4].y() + pt[6].y() ) == 0   && 
 
  133        ( pt[0].x() + pt[1].x() + pt[4].x() + pt[5].x() ) == 0) )
 
  135     std::ostringstream message;
 
  136     message << 
"Invalid vertice coordinates for Solid: " << 
GetName();
 
  140   fDx = ((pt[3]).x()-(pt[2]).x())*0.5;
 
  141   fDy = ((pt[2]).y()-(pt[1]).y())*0.5;
 
  143   fTalpha = ((pt[2]).x()+(pt[3]).x()-(pt[1]).x()-(pt[0]).x())*0.25/
fDy ;
 
  158     fTalpha(0.), fTthetaCphi(0.), fTthetaSphi(0.)
 
  174   : 
G4CSGSolid(rhs), fDx(rhs.fDx), fDy(rhs.fDy), fDz(rhs.fDz),
 
  175     fTalpha(rhs.fTalpha), fTthetaCphi(rhs.fTthetaCphi),
 
  176     fTthetaSphi(rhs.fTthetaSphi)
 
  189    if (
this == &rhs)  { 
return *
this; }
 
  284     temp[0] = pt[0].y()+(pt[4].y()-pt[0].y())
 
  285                        *(zMin-pt[0].
z())/(pt[4].
z()-pt[0].z()) ;
 
  286     temp[1] = pt[0].y()+(pt[4].y()-pt[0].y())
 
  287                        *(zMax-pt[0].
z())/(pt[4].
z()-pt[0].z()) ;
 
  288     temp[2] = pt[2].y()+(pt[6].y()-pt[2].y())
 
  289                        *(zMin-pt[2].
z())/(pt[6].
z()-pt[2].z()) ;
 
  290     temp[3] = pt[2].y()+(pt[6].y()-pt[2].y())
 
  291                        *(zMax-pt[2].
z())/(pt[6].
z()-pt[2].z()) ;        
 
  296       if(temp[i] > yMax) yMax = temp[i] ;
 
  297       if(temp[i] < yMin) yMin = temp[i] ;
 
  320     temp[0] = pt[0].x()+(pt[4].x()-pt[0].x())
 
  321                        *(zMin-pt[0].
z())/(pt[4].
z()-pt[0].z()) ;
 
  322     temp[1] = pt[0].x()+(pt[4].x()-pt[0].x())
 
  323                        *(zMax-pt[0].
z())/(pt[4].
z()-pt[0].z()) ;
 
  324     temp[2] = pt[2].x()+(pt[6].x()-pt[2].x())
 
  325                        *(zMin-pt[2].
z())/(pt[6].
z()-pt[2].z()) ;
 
  326     temp[3] = pt[2].x()+(pt[6].x()-pt[2].x())
 
  327                        *(zMax-pt[2].
z())/(pt[6].
z()-pt[2].z()) ;
 
  328     temp[4] = pt[3].x()+(pt[7].x()-pt[3].x())
 
  329                        *(zMin-pt[3].
z())/(pt[7].
z()-pt[3].z()) ;
 
  330     temp[5] = pt[3].x()+(pt[7].x()-pt[3].x())
 
  331                        *(zMax-pt[3].
z())/(pt[7].
z()-pt[3].z()) ;
 
  332     temp[6] = pt[1].x()+(pt[5].x()-pt[1].x())
 
  333                        *(zMin-pt[1].
z())/(pt[5].
z()-pt[1].z()) ;
 
  334     temp[7] = pt[1].x()+(pt[5].x()-pt[1].x())
 
  335                        *(zMax-pt[1].
z())/(pt[5].
z()-pt[1].z()) ;
 
  341       if(temp[i] > xMax) xMax = temp[i] ;
 
  342       if(temp[i] < xMin) xMin = temp[i] ;
 
  391     G4bool existsAfterClip=
false;
 
  406       existsAfterClip=
true;
 
  427         existsAfterClip=
true;
 
  433     flag = existsAfterClip ;
 
  448   yt  = std::fabs(yt1) ;
 
  484   G4int noSurfaces = 0; 
 
  496   if (fTalpha) {salpha = -calpha*
fTalpha;} 
 
  500   xshift = newpx - newpy*
fTalpha;
 
  503   distx  = std::fabs(std::fabs(xshift)-
fDx);
 
  504   disty  = std::fabs(std::fabs(newpy)-
fDy);
 
  505   distz  = std::fabs(std::fabs(p.z())-
fDz);
 
  508   cosntheta = 1/std::sqrt(1+tntheta*tntheta);
 
  520     if ( xshift >= 0.) {sumnorm += nX;}
 
  521     else               {sumnorm -= nX;}
 
  526     if ( newpy >= 0.)  {sumnorm += nY;}
 
  527     else               {sumnorm -= nY;}
 
  532     if ( p.z() >= 0.)  {sumnorm += nZ;}
 
  533     else               {sumnorm -= nZ;}
 
  535   if ( noSurfaces == 0 )
 
  538     G4Exception(
"G4Para::SurfaceNormal(p)", 
"GeomSolids1002",
 
  543   else if ( noSurfaces == 1 ) {norm = sumnorm;}
 
  544   else                        {norm = sumnorm.unit();}
 
  578   xshift=newpx*calpha+newpy*salpha;
 
  580   distx=std::fabs(std::fabs(xshift)-
fDx*calpha);
 
  581   disty=std::fabs(std::fabs(newpy)-
fDy);
 
  582   distz=std::fabs(std::fabs(p.z())-
fDz);
 
  586     if (distx<distz) {side=
kNX;}
 
  591     if (disty<distz) {side=
kNY;}
 
  601         cosntheta=-1/std::sqrt(1+tntheta*tntheta);
 
  605         cosntheta=1/std::sqrt(1+tntheta*tntheta);
 
  607       norm=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
 
  667       smin=(-
fDz-p.z())/v.z();
 
  680       smin=(
fDz-p.z())/v.z();
 
  689     if (std::fabs(p.z())<=
fDz) 
 
  735     if (std::fabs(yt)<=
fDy)
 
  748   if (tmin>smin) smin=tmin;
 
  749   if (tmax<smax) smax=tmax;
 
  789       if (std::fabs(xt)<=
fDx)
 
  799     if (tmin>smin) smin=tmin;
 
  800     if (tmax<smax) smax=tmax;
 
  803   if (smax>0&&smin<smax)
 
  829   G4double distz1,distz2,disty1,disty2,distx1,distx2;
 
  850   disty1=(trany-
fDy)*cosy;
 
  851   disty2=(-
fDy-trany)*cosy;
 
  853   if (disty1>safe) safe=disty1;
 
  854   if (disty2>safe) safe=disty2;
 
  858   distx1=(tranx-
fDx)*cosx;
 
  859   distx2=(-
fDx-tranx)*cosx;
 
  861   if (distx1>safe) safe=distx1;
 
  862   if (distx2>safe) safe=distx2;
 
  882   G4double ycomp,calpha,salpha,tntheta,cosntheta;
 
 1016         cosntheta=1/std::sqrt(1+tntheta*tntheta);
 
 1017         *n=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
 
 1049         cosntheta=-1/std::sqrt(1+tntheta*tntheta);
 
 1050         *n=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
 
 1072         ycomp=1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
 
 1086         cosntheta=-1/std::sqrt(1+tntheta*tntheta);
 
 1087         *n=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
 
 1090         calpha=1/std::sqrt(1+fTalpha*fTalpha);
 
 1100         cosntheta=1/std::sqrt(1+tntheta*tntheta);
 
 1101         *n=
G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
 
 1107                     "Undefined side for valid surface normal to solid.");
 
 1122   G4double distz1,distz2,disty1,disty2,distx1,distx2;
 
 1135      G4cout.precision(oldprc) ;
 
 1136      G4Exception(
"G4Para::DistanceToOut(p)", 
"GeomSolids1002",
 
 1159   disty1=(
fDy-trany)*cosy;
 
 1160   disty2=(
fDy+trany)*cosy;
 
 1162   if (disty1<safe) safe=disty1;
 
 1163   if (disty2<safe) safe=disty2;
 
 1167   distx1=(
fDx-tranx)*cosx;
 
 1168   distx2=(
fDx+tranx)*cosx;
 
 1170   if (distx1<safe) safe=distx1;
 
 1171   if (distx2<safe) safe=distx2;
 
 1193     vertices->reserve(8);
 
 1225                 "Error in allocation of vertices. Out of memory !");
 
 1245   return new G4Para(*
this);
 
 1254   G4int oldprc = os.precision(16);
 
 1255   os << 
"-----------------------------------------------------------\n" 
 1256      << 
"    *** Dump for solid - " << 
GetName() << 
" ***\n" 
 1257      << 
"    ===================================================\n" 
 1258      << 
" Solid type: G4Para\n" 
 1259      << 
" Parameters: \n" 
 1260      << 
"    half length X: " << 
fDx/
mm << 
" mm \n" 
 1261      << 
"    half length Y: " << 
fDy/
mm << 
" mm \n" 
 1262      << 
"    half length Z: " << 
fDz/
mm << 
" mm \n" 
 1268      << 
"-----------------------------------------------------------\n";
 
 1269   os.precision(oldprc);
 
 1284   G4double lambda1, lambda2, chose, aOne, aTwo;
 
 1293                        w.z()*v.x() - w.x()*v.z(),
 
 1294                        w.x()*v.y() - w.y()*v.x());
 
 1296   aOne = 0.5*Area.mag();
 
 1299                        t.z()*u.x() - t.x()*u.z(),
 
 1300                        t.x()*u.y() - t.y()*u.x());
 
 1302   aTwo = 0.5*Area.mag();
 
 1308   if( (chose>=0.) && (chose < aOne) )
 
 1312     return (p2+lambda1*v+lambda2*w);    
 
 1319   return (p0+lambda1*t+lambda2*u);    
 
 1333   G4double chose, aOne, aTwo, aThree, aFour, aFive, aSix;
 
 1363   if( (chose>=0.) && (chose<aOne) )                    
 
 1365   else if(chose>=aOne && chose<aOne+aTwo)  
 
 1367   else if(chose>=aOne+aTwo && chose<aOne+aTwo+aThree)
 
 1369   else if(chose>=aOne+aTwo+aThree && chose<aOne+aTwo+aThree+aFour)
 
 1371   else if(chose>=aOne+aTwo+aThree+aFour && chose<aOne+aTwo+aThree+aFour+aFive)
 
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const 
 
void ClipCrossSection(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const 
 
ThreeVector shoot(const G4int Ap, const G4int Af)
 
G4ThreeVector GetPointOnSurface() const 
 
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
EInside Inside(const G4ThreeVector &p) const 
 
void SetAllParameters(G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
 
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const 
 
static const G4double kInfinity
 
G4double GetMinYExtent() const 
 
CLHEP::Hep3Vector G4ThreeVector
 
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const 
 
G4bool IsYLimited() const 
 
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const 
 
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const 
 
G4Para(const G4String &pName, G4double pDx, G4double pDy, G4double pDz, G4double pAlpha, G4double pTheta, G4double pPhi)
 
G4bool IsXLimited() const 
 
std::ostream & StreamInfo(std::ostream &os) const 
 
G4Para & operator=(const G4Para &rhs)
 
virtual void AddSolid(const G4Box &)=0
 
G4Polyhedron * CreatePolyhedron() const 
 
static double normal(HepRandomEngine *eptr)
 
G4double GetMaxXExtent() const 
 
G4double GetMinZExtent() const 
 
G4GLOB_DLL std::ostream G4cout
 
G4Polyhedron * fpPolyhedron
 
virtual G4Polyhedron * GetPolyhedron() const 
 
std::vector< G4ThreeVector > G4ThreeVectorList
 
G4GeometryType GetEntityType() const 
 
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
 
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const 
 
G4double GetMinXExtent() const 
 
void DescribeYourselfTo(G4VGraphicsScene &scene) const 
 
G4double GetMaxZExtent() const 
 
T max(const T t1, const T t2)
brief Return the largest of the two arguments 
 
G4ThreeVectorList * CreateRotatedVertices(const G4AffineTransform &pTransform) const 
 
static const double degree
 
G4double GetMaxYExtent() const 
 
G4double GetMaxExtent(const EAxis pAxis) const 
 
static const G4double alpha
 
G4CSGSolid & operator=(const G4CSGSolid &rhs)
 
G4bool IsZLimited() const 
 
void ClipBetweenSections(G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const 
 
G4double GetMinExtent(const EAxis pAxis) const 
 
G4ThreeVector GetPointOnPlane(G4ThreeVector p0, G4ThreeVector p1, G4ThreeVector p2, G4ThreeVector p3, G4double &area) const