Ignore:
Timestamp:
Jun 18, 2010, 11:42:07 AM (14 years ago)
Author:
garnier
Message:

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/geometry/solids/CSG/src/G4Box.cc

    r1228 r1315  
    2525//
    2626//
    27 // $Id: G4Box.cc,v 1.44 2006/10/19 15:33:37 gcosmo Exp $
    28 // GEANT4 tag $Name: geant4-09-03 $
     27// $Id: G4Box.cc,v 1.49 2010/05/25 10:14:41 gcosmo Exp $
     28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
    2929//
    3030//
     
    3232// Implementation for G4Box class
    3333//
    34 //  24.06.98 - V. Grichine: insideEdge in DistanceToIn(p,v)
     34//  24.06.98 - V.Grichine: insideEdge in DistanceToIn(p,v)
    3535//  20.09.98 - V.Grichine: new algorithm of DistanceToIn(p,v)
    3636//  07.05.00 - V.Grichine: d= DistanceToIn(p,v), if d<e/2, d=0
     
    6767  if ( (pX > 2*kCarTolerance)
    6868    && (pY > 2*kCarTolerance)
    69     && (pZ > 2*kCarTolerance) )
     69    && (pZ > 2*kCarTolerance) )  // limit to thickness of surfaces
    7070  {
    7171    fDx = pX ;
     
    105105void G4Box::SetXHalfLength(G4double dx)
    106106{
    107   if(dx > 2*kCarTolerance)
     107  if(dx > 2*kCarTolerance)  // limit to thickness of surfaces
     108  {
    108109    fDx = dx;
     110  }
    109111  else
    110112  {
     
    122124void G4Box::SetYHalfLength(G4double dy)
    123125{
    124   if(dy > 2*kCarTolerance)
     126  if(dy > 2*kCarTolerance)  // limit to thickness of surfaces
     127  {
    125128    fDy = dy;
     129  }
    126130  else
    127131  {
     
    139143void G4Box::SetZHalfLength(G4double dz)
    140144{
    141   if(dz > 2*kCarTolerance)
     145  if(dz > 2*kCarTolerance)  // limit to thickness of surfaces
     146  {
    142147    fDz = dz;
     148  }
    143149  else
    144150  {
     
    153159  fpPolyhedron = 0;
    154160}
    155    
    156 
    157161
    158162////////////////////////////////////////////////////////////////////////
     
    193197    if (pVoxelLimit.IsXLimited())
    194198    {
    195       if ( xMin > pVoxelLimit.GetMaxXExtent()+kCarTolerance ||
    196            xMax < pVoxelLimit.GetMinXExtent()-kCarTolerance    ) return false ;
     199      if ((xMin > pVoxelLimit.GetMaxXExtent()+kCarTolerance) ||
     200          (xMax < pVoxelLimit.GetMinXExtent()-kCarTolerance)) { return false ; }
    197201      else
    198202      {
    199         if (xMin < pVoxelLimit.GetMinXExtent())
    200         {
    201           xMin = pVoxelLimit.GetMinXExtent() ;
    202         }
    203         if (xMax > pVoxelLimit.GetMaxXExtent())
    204         {
    205           xMax = pVoxelLimit.GetMaxXExtent() ;
    206         }
     203        xMin = std::max(xMin, pVoxelLimit.GetMinXExtent());
     204        xMax = std::min(xMax, pVoxelLimit.GetMaxXExtent());
    207205      }
    208206    }
     
    213211    if (pVoxelLimit.IsYLimited())
    214212    {
    215       if ( yMin > pVoxelLimit.GetMaxYExtent()+kCarTolerance ||
    216            yMax < pVoxelLimit.GetMinYExtent()-kCarTolerance   ) return false ;
     213      if ((yMin > pVoxelLimit.GetMaxYExtent()+kCarTolerance) ||
     214          (yMax < pVoxelLimit.GetMinYExtent()-kCarTolerance)) { return false ; }
    217215      else
    218216      {
    219         if (yMin < pVoxelLimit.GetMinYExtent())
    220         {
    221           yMin = pVoxelLimit.GetMinYExtent() ;
    222         }
    223         if (yMax > pVoxelLimit.GetMaxYExtent())
    224         {
    225           yMax = pVoxelLimit.GetMaxYExtent() ;
    226         }
     217        yMin = std::max(yMin, pVoxelLimit.GetMinYExtent());
     218        yMax = std::min(yMax, pVoxelLimit.GetMaxYExtent());
    227219      }
    228220    }
     
    233225    if (pVoxelLimit.IsZLimited())
    234226    {
    235       if ( zMin > pVoxelLimit.GetMaxZExtent()+kCarTolerance ||
    236            zMax < pVoxelLimit.GetMinZExtent()-kCarTolerance   ) return false ;
     227      if ((zMin > pVoxelLimit.GetMaxZExtent()+kCarTolerance) ||
     228          (zMax < pVoxelLimit.GetMinZExtent()-kCarTolerance)) { return false ; }
    237229      else
    238230      {
    239         if (zMin < pVoxelLimit.GetMinZExtent())
    240         {
    241           zMin = pVoxelLimit.GetMinZExtent() ;
    242         }
    243         if (zMax > pVoxelLimit.GetMaxZExtent())
    244         {
    245           zMax = pVoxelLimit.GetMaxZExtent() ;
    246         }
     231        zMin = std::max(zMin, pVoxelLimit.GetMinZExtent());
     232        zMax = std::min(zMax, pVoxelLimit.GetMaxZExtent());
    247233      }
    248234    }
     
    286272    if (pVoxelLimit.IsLimited(pAxis) == false)
    287273    { 
    288       if ( pMin != kInfinity || pMax != -kInfinity )
     274      if ( (pMin != kInfinity) || (pMax != -kInfinity) )
    289275      {
    290276        existsAfterClip = true ;
     
    292278        // Add 2*tolerance to avoid precision troubles
    293279
    294         pMin           -= kCarTolerance;
    295         pMax           += kCarTolerance;
     280        pMin -= kCarTolerance;
     281        pMax += kCarTolerance;
    296282      }
    297283    }     
     
    303289       ( pVoxelLimit.GetMinZExtent()+pVoxelLimit.GetMaxZExtent())*0.5);
    304290
    305       if ( pMin != kInfinity || pMax != -kInfinity )
     291      if ( (pMin != kInfinity) || (pMax != -kInfinity) )
    306292      {
    307293        existsAfterClip = true ;
     
    356342EInside G4Box::Inside(const G4ThreeVector& p) const
    357343{
     344  static const G4double delta=0.5*kCarTolerance;
    358345  EInside in = kOutside ;
    359 
    360   if ( std::fabs(p.x()) <= fDx - kCarTolerance*0.5 )
    361   {
    362     if (std::fabs(p.y()) <= fDy - kCarTolerance*0.5 )
    363     {
    364       if      (std::fabs(p.z()) <= fDz - kCarTolerance*0.5 ) in = kInside ;
    365       else if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5 ) in = kSurface ;
    366     }
    367     else if (std::fabs(p.y()) <= fDy + kCarTolerance*0.5 )
    368     {
    369       if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5 ) in = kSurface ;
    370     }
    371   }
    372   else if (std::fabs(p.x()) <= fDx + kCarTolerance*0.5 )
    373   {
    374     if (std::fabs(p.y()) <= fDy + kCarTolerance*0.5 )
    375     {
    376       if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5) in = kSurface ;
     346  G4ThreeVector q(std::fabs(p.x()), std::fabs(p.y()), std::fabs(p.z()));
     347
     348  if ( q.x() <= (fDx - delta) )
     349  {
     350    if (q.y() <= (fDy - delta) )
     351    {
     352      if      ( q.z() <= (fDz - delta) ) { in = kInside ;  }
     353      else if ( q.z() <= (fDz + delta) ) { in = kSurface ; }
     354    }
     355    else if ( q.y() <= (fDy + delta) )
     356    {
     357      if ( q.z() <= (fDz + delta) ) { in = kSurface ; }
     358    }
     359  }
     360  else if ( q.x() <= (fDx + delta) )
     361  {
     362    if ( q.y() <= (fDy + delta) )
     363    {
     364      if ( q.z() <= (fDz + delta) ) { in = kSurface ; }
    377365    }
    378366  }
     
    389377{
    390378  G4double distx, disty, distz ;
    391   G4ThreeVector norm ;
     379  G4ThreeVector norm(0.,0.,0.);
    392380
    393381  // Calculate distances as if in 1st octant
     
    400388  // normals
    401389
    402   const G4double delta    = 0.5*kCarTolerance;
     390  static const G4double delta    = 0.5*kCarTolerance;
    403391  const G4ThreeVector nX  = G4ThreeVector( 1.0, 0,0  );
    404392  const G4ThreeVector nmX = G4ThreeVector(-1.0, 0,0  );
     
    415403  {
    416404    noSurfaces ++;
    417     if ( p.x() >= 0.){        // on +X surface
    418       normX= nX ;    // G4ThreeVector( 1.0, 0., 0. );
    419     }else{
    420       normX= nmX;    // G4ThreeVector(-1.0, 0., 0. );
    421     }
     405    if ( p.x() >= 0. )  { normX= nX ; }       // on +X surface : (1,0,0)
     406    else                { normX= nmX; }       //                 (-1,0,0)
    422407    sumnorm= normX;
    423408  }
     
    426411  {
    427412    noSurfaces ++;
    428     if ( p.y() >= 0.){        // on +Y surface
    429       normY= nY;
    430     }else{
    431       normY = nmY;
    432     }
     413    if ( p.y() >= 0. )  { normY= nY;  }       // on +Y surface
     414    else                { normY= nmY; }
    433415    sumnorm += normY;
    434416  }
     
    437419  {
    438420    noSurfaces ++;
    439     if ( p.z() >= 0.){        // on +Z surface
    440       normZ= nZ;
    441     }else{
    442       normZ = nmZ;
    443     }
    444     sumnorm += normZ;
    445   }
    446 
    447   // sumnorm= normX + normY + normZ;
    448   const G4double invSqrt2 = 1.0 / std::sqrt( 2.0);
    449   const G4double invSqrt3 = 1.0 / std::sqrt( 3.0);
    450 
    451   norm= G4ThreeVector( 0., 0., 0.);
     421    if ( p.z() >= 0. )  { normZ= nZ;  }       // on +Z surface
     422    else                { normZ= nmZ; }
     423    sumnorm += normZ;
     424  }
     425
     426  static const G4double invSqrt2 = 1.0 / std::sqrt(2.0);
     427  static const G4double invSqrt3 = 1.0 / std::sqrt(3.0);
     428
    452429  if( noSurfaces > 0 )
    453430  {
    454     if( noSurfaces == 1 ){
     431    if( noSurfaces == 1 )
     432    {
    455433      norm= sumnorm;
    456     }else{
     434    }
     435    else
     436    {
    457437      // norm = sumnorm . unit();
    458       if( noSurfaces == 2 ) {
     438      if( noSurfaces == 2 )
     439      {
    459440        // 2 surfaces -> on edge
    460441        norm = invSqrt2 * sumnorm;
    461       } else {
     442      }
     443      else
     444      {
    462445        // 3 surfaces (on corner)
    463446        norm = invSqrt3 * sumnorm;
    464447      }
    465448    }
    466   }else{
     449  }
     450  else
     451  {
    467452#ifdef G4CSGDEBUG
    468453     G4Exception("G4Box::SurfaceNormal(p)", "Notification", JustWarning,
     
    483468{
    484469  G4double distx, disty, distz ;
    485   G4ThreeVector norm ;
     470  G4ThreeVector norm(0.,0.,0.);
    486471
    487472  // Calculate distances as if in 1st octant
     
    495480    if ( distx <= distz )     // Closest to X
    496481    {
    497       if ( p.x() < 0 ) norm = G4ThreeVector(-1.0,0,0) ;
    498       else             norm = G4ThreeVector( 1.0,0,0) ;
     482      if ( p.x() < 0 ) { norm = G4ThreeVector(-1.0,0,0) ; }
     483      else             { norm = G4ThreeVector( 1.0,0,0) ; }
    499484    }
    500485    else                      // Closest to Z
    501486    {
    502       if ( p.z() < 0 ) norm = G4ThreeVector(0,0,-1.0) ;
    503       else             norm = G4ThreeVector(0,0, 1.0) ;
     487      if ( p.z() < 0 ) { norm = G4ThreeVector(0,0,-1.0) ; }
     488      else             { norm = G4ThreeVector(0,0, 1.0) ; }
    504489    }
    505490  }
     
    508493    if ( disty <= distz )      // Closest to Y
    509494    {
    510       if ( p.y() < 0 ) norm = G4ThreeVector(0,-1.0,0) ;
    511       else             norm = G4ThreeVector(0, 1.0,0) ;
     495      if ( p.y() < 0 ) { norm = G4ThreeVector(0,-1.0,0) ; }
     496      else             { norm = G4ThreeVector(0, 1.0,0) ; }
    512497    }
    513498    else                       // Closest to Z
    514499    {
    515       if ( p.z() < 0 ) norm = G4ThreeVector(0,0,-1.0) ;
    516       else             norm = G4ThreeVector(0,0, 1.0) ;
     500      if ( p.z() < 0 ) { norm = G4ThreeVector(0,0,-1.0) ; }
     501      else             { norm = G4ThreeVector(0,0, 1.0) ; }
    517502    }
    518503  }
     
    541526// shape.
    542527
    543 G4double G4Box::DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) const
     528G4double G4Box::DistanceToIn(const G4ThreeVector& p,
     529                             const G4ThreeVector& v) const
    544530{
    545531  G4double safx, safy, safz ;
     
    549535  G4double sOut=kInfinity, sOuty=kInfinity, sOutz=kInfinity ;
    550536
     537  static const G4double delta = 0.5*kCarTolerance;
     538
    551539  safx = std::fabs(p.x()) - fDx ;     // minimum distance to x surface of shape
    552540  safy = std::fabs(p.y()) - fDy ;
     
    558546  // travel is in a direction away from the shape.
    559547
    560   if (    ((p.x()*v.x() >= 0.0) && safx > -kCarTolerance*0.5)
    561        || ((p.y()*v.y() >= 0.0) && safy > -kCarTolerance*0.5)
    562        || ((p.z()*v.z() >= 0.0) && safz > -kCarTolerance*0.5)   )
     548  if (    ((p.x()*v.x() >= 0.0) && (safx > -delta))
     549       || ((p.y()*v.y() >= 0.0) && (safy > -delta))
     550       || ((p.z()*v.z() >= 0.0) && (safz > -delta))   )
    563551  {
    564552    return kInfinity ;  // travel away or parallel within tolerance
     
    568556  // X Planes
    569557
    570   if ( v.x())
     558  if ( v.x() )  // != 0
    571559  {
    572560    stmp = 1.0/std::fabs(v.x()) ;
     
    579567    else
    580568    {
    581       if (v.x() > 0)  sOut = (fDx - p.x())*stmp ;
    582       if (v.x() < 0)  sOut = (fDx + p.x())*stmp ;
     569      if (v.x() < 0)  { sOut = (fDx + p.x())*stmp ; }
     570      else            { sOut = (fDx - p.x())*stmp ; }
    583571    }
    584572  }
     
    586574  // Y Planes
    587575
    588   if ( v.y())
     576  if ( v.y() )  // != 0
    589577  {
    590578    stmp = 1.0/std::fabs(v.y()) ;
     
    595583      smaxy = (fDy+std::fabs(p.y()))*stmp ;
    596584
    597       if (sminy > smin) smin=sminy ;
    598       if (smaxy < smax) smax=smaxy ;
    599 
    600       if (smin >= smax-kCarTolerance*0.5)
     585      if (sminy > smin) { smin=sminy ; }
     586      if (smaxy < smax) { smax=smaxy ; }
     587
     588      if (smin >= (smax-delta))
    601589      {
    602590        return kInfinity ;  // touch XY corner
     
    605593    else
    606594    {
    607       if (v.y() > 0)  sOuty = (fDy - p.y())*stmp ;
    608       if (v.y() < 0)  sOuty = (fDy + p.y())*stmp ;
    609       if( sOuty < sOut ) sOut = sOuty ;
     595      if (v.y() < 0)  { sOuty = (fDy + p.y())*stmp ; }
     596      else            { sOuty = (fDy - p.y())*stmp ; }
     597      if( sOuty < sOut ) { sOut = sOuty ; }
    610598    }     
    611599  }
     
    613601  // Z planes
    614602
    615   if ( v.z() )
     603  if ( v.z() )  // != 0
    616604  {
    617605    stmp = 1.0/std::fabs(v.z()) ;
    618606
    619     if ( safz >= 0.0)
     607    if ( safz >= 0.0 )
    620608    {
    621609      sminz = safz*stmp ;
    622610      smaxz = (fDz+std::fabs(p.z()))*stmp ;
    623611
    624       if (sminz > smin) smin = sminz ;
    625       if (smaxz < smax) smax = smaxz ;
    626 
    627       if (smin >= smax-kCarTolerance*0.5)
     612      if (sminz > smin) { smin = sminz ; }
     613      if (smaxz < smax) { smax = smaxz ; }
     614
     615      if (smin >= (smax-delta))
    628616      {
    629617        return kInfinity ;    // touch ZX or ZY corners
     
    632620    else
    633621    {
    634       if (v.z() > 0)  sOutz = (fDz - p.z())*stmp ;
    635       if (v.z() < 0)  sOutz = (fDz + p.z())*stmp ;
    636       if( sOutz < sOut ) sOut = sOutz ;
    637     }
    638   }
    639 
    640   if ( sOut <= smin + 0.5*kCarTolerance) // travel over edge
     622      if (v.z() < 0)  { sOutz = (fDz + p.z())*stmp ; }
     623      else            { sOutz = (fDz - p.z())*stmp ; }
     624      if( sOutz < sOut ) { sOut = sOutz ; }
     625    }
     626  }
     627
     628  if (sOut <= (smin + delta)) // travel over edge
    641629  {
    642630    return kInfinity ;
    643631  }
    644   if (smin < 0.5*kCarTolerance)  smin = 0.0 ;
     632  if (smin < delta)  { smin = 0.0 ; }
    645633
    646634  return smin ;
     
    662650  safez = std::fabs(p.z()) - fDz ;
    663651
    664   if (safex > safe) safe = safex ;
    665   if (safey > safe) safe = safey ;
    666   if (safez > safe) safe = safez ;
     652  if (safex > safe) { safe = safex ; }
     653  if (safey > safe) { safe = safey ; }
     654  if (safez > safe) { safe = safez ; }
    667655
    668656  return safe ;
     
    671659/////////////////////////////////////////////////////////////////////////
    672660//
    673 // Calcluate distance to surface of box from inside
     661// Calculate distance to surface of box from inside
    674662// by calculating distances to box's x/y/z planes.
    675663// Smallest distance is exact distance to exiting.
     
    682670{
    683671  ESide side = kUndefined ;
    684   G4double pdist,stmp,snxt;
    685 
    686   if (calcNorm) *validNorm = true ; // All normals are valid
    687 
    688   if (v.x() > 0)   // X planes 
     672  G4double pdist,stmp,snxt=kInfinity;
     673
     674  static const G4double delta = 0.5*kCarTolerance;
     675
     676  if (calcNorm) { *validNorm = true ; }  // All normals are valid
     677
     678  if (v.x() > 0)   // X planes
    689679  {
    690680    pdist = fDx - p.x() ;
    691681
    692     if (pdist > kCarTolerance*0.5)
     682    if (pdist > delta)
    693683    {
    694684      snxt = pdist/v.x() ;
     
    697687    else
    698688    {
    699       if (calcNorm) *n    = G4ThreeVector(1,0,0) ;
    700       return         snxt = 0 ;
    701     }
    702   }
    703   else if (v.x() < 0) 
     689      if (calcNorm) { *n   = G4ThreeVector(1,0,0) ; }
     690      return        snxt = 0 ;
     691    }
     692  }
     693  else if (v.x() < 0)
    704694  {
    705695    pdist = fDx + p.x() ;
    706696
    707     if (pdist > kCarTolerance*0.5)
     697    if (pdist > delta)
    708698    {
    709699      snxt = -pdist/v.x() ;
     
    712702    else
    713703    {
    714       if (calcNorm) *n   = G4ThreeVector(-1,0,0) ;
     704      if (calcNorm) { *n   = G4ThreeVector(-1,0,0) ; }
    715705      return        snxt = 0 ;
    716706    }
    717707  }
    718   else snxt = kInfinity ;
    719 
    720   if ( v.y() > 0 )   // Y planes 
    721   {
    722     pdist=fDy-p.y();
    723 
    724     if (pdist>kCarTolerance*0.5)
    725     {
    726       stmp=pdist/v.y();
    727 
    728       if (stmp<snxt)
    729       {
    730         snxt=stmp;
    731         side=kPY;
    732       }
    733     }
    734     else
    735     {
    736       if (calcNorm) *n    = G4ThreeVector(0,1,0) ;
    737       return         snxt = 0 ;
    738     }
    739   }
    740   else if ( v.y() < 0 )
    741   {
    742     pdist = fDy + p.y() ;
    743 
    744     if (pdist > kCarTolerance*0.5)
    745     {
    746       stmp=-pdist/v.y();
    747 
    748       if (stmp<snxt)
    749       {
    750         snxt=stmp;
    751         side=kMY;
    752       }
    753     }
    754     else
    755     {
    756       if (calcNorm) *n    = G4ThreeVector(0,-1,0) ;
    757       return         snxt = 0 ;
    758     }
    759   }
    760   if (v.z()>0)        // Z planes
    761   {
    762     pdist=fDz-p.z();
    763 
    764     if (pdist > kCarTolerance*0.5)
    765     {
    766       stmp=pdist/v.z();
     708
     709  if (v.y() > 0)   // Y planes
     710  {
     711    pdist = fDy-p.y();
     712
     713    if (pdist > delta)
     714    {
     715      stmp = pdist/v.y();
    767716
    768717      if (stmp < snxt)
    769718      {
    770         snxt=stmp;
    771         side=kPZ;
     719        snxt = stmp;
     720        side = kPY;
    772721      }
    773722    }
    774723    else
    775724    {
    776       if (calcNorm) *n    = G4ThreeVector(0,0,1) ;
    777       return         snxt = 0 ;
    778     }
    779   }
    780   else if (v.z()<0)
    781   {
    782     pdist = fDz + p.z() ;
    783 
    784     if (pdist > kCarTolerance*0.5)
    785     {
    786       stmp=-pdist/v.z();
    787 
    788       if (stmp < snxt)
     725      if (calcNorm) { *n   = G4ThreeVector(0,1,0) ; }
     726      return        snxt = 0 ;
     727    }
     728  }
     729  else if (v.y() < 0)
     730  {
     731    pdist = fDy + p.y() ;
     732
     733    if (pdist > delta)
     734    {
     735      stmp = -pdist/v.y();
     736
     737      if ( stmp < snxt )
    789738      {
    790         snxt=stmp;
    791         side=kMZ;
     739        snxt = stmp;
     740        side = kMY;
    792741      }
    793742    }
    794743    else
    795744    {
    796       if (calcNorm) *n    = G4ThreeVector(0,0,-1) ;
    797       return         snxt = 0 ;
    798     }
    799   }
     745      if (calcNorm) { *n   = G4ThreeVector(0,-1,0) ; }
     746      return        snxt = 0 ;
     747    }
     748  }
     749
     750  if (v.z() > 0)        // Z planes
     751  {
     752    pdist = fDz-p.z();
     753
     754    if ( pdist > delta )
     755    {
     756      stmp = pdist/v.z();
     757
     758      if ( stmp < snxt )
     759      {
     760        snxt = stmp;
     761        side = kPZ;
     762      }
     763    }
     764    else
     765    {
     766      if (calcNorm) { *n   = G4ThreeVector(0,0,1) ; }
     767      return        snxt = 0 ;
     768    }
     769  }
     770  else if (v.z() < 0)
     771  {
     772    pdist = fDz + p.z();
     773
     774    if ( pdist > delta )
     775    {
     776      stmp = -pdist/v.z();
     777
     778      if ( stmp < snxt )
     779      {
     780        snxt = stmp;
     781        side = kMZ;
     782      }
     783    }
     784    else
     785    {
     786      if (calcNorm) { *n   = G4ThreeVector(0,0,-1) ; }
     787      return        snxt = 0 ;
     788    }
     789  }
     790
    800791  if (calcNorm)
    801792  {     
     
    875866  // shortest Dist to any boundary now MIN(safx1,safx2,safy1..)
    876867
    877   if (safx2 < safx1) safe = safx2 ;
    878   else               safe = safx1 ;
    879   if (safy1 < safe)  safe = safy1 ;
    880   if (safy2 < safe)  safe = safy2 ;
    881   if (safz1 < safe)  safe = safz1 ;
    882   if (safz2 < safe)  safe = safz2 ;
    883 
    884   if (safe < 0) safe = 0 ;
     868  if (safx2 < safx1) { safe = safx2; }
     869  else               { safe = safx1; }
     870  if (safy1 < safe)  { safe = safy1; }
     871  if (safy2 < safe)  { safe = safy2; }
     872  if (safz1 < safe)  { safe = safz1; }
     873  if (safz2 < safe)  { safe = safz2; }
     874
     875  if (safe < 0) { safe = 0 ; }
    885876  return safe ; 
    886877}
     
    979970    py = -fDy +2*fDy*G4UniformRand();
    980971
    981     if(G4UniformRand() > 0.5) pz =  fDz;
    982     else                      pz = -fDz;
     972    if(G4UniformRand() > 0.5) { pz =  fDz; }
     973    else                      { pz = -fDz; }
    983974  }
    984975  else if ( ( select - Sxy ) < Sxz )
     
    987978    pz = -fDz +2*fDz*G4UniformRand();
    988979
    989     if(G4UniformRand() > 0.5) py =  fDy;
    990     else                      py = -fDy;
     980    if(G4UniformRand() > 0.5) { py =  fDy; }
     981    else                      { py = -fDy; }
    991982  }
    992983  else 
     
    995986    pz = -fDz +2*fDz*G4UniformRand();
    996987
    997     if(G4UniformRand() > 0.5) px =  fDx;
    998     else                      px = -fDx;
     988    if(G4UniformRand() > 0.5) { px =  fDx; }
     989    else                      { px = -fDx; }
    999990  }
    1000991  return G4ThreeVector(px,py,pz);
Note: See TracChangeset for help on using the changeset viewer.