Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4CutTubs Class Reference

#include <G4CutTubs.hh>

Inheritance diagram for G4CutTubs:
G4CSGSolid G4VSolid

Public Member Functions

void BoundingLimits (G4ThreeVector &pMin, G4ThreeVector &pMax) const
 
G4bool CalculateExtent (const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
 
G4VSolidClone () const
 
virtual void ComputeDimensions (G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
 
G4PolyhedronCreatePolyhedron () const
 
void DescribeYourselfTo (G4VGraphicsScene &scene) const
 
G4double DistanceToIn (const G4ThreeVector &p) const
 
G4double DistanceToIn (const G4ThreeVector &p, const G4ThreeVector &v) const
 
G4double DistanceToOut (const G4ThreeVector &p) const
 
G4double DistanceToOut (const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
 
void DumpInfo () const
 
G4double EstimateCubicVolume (G4int nStat, G4double epsilon) const
 
G4double EstimateSurfaceArea (G4int nStat, G4double ell) const
 
 G4CutTubs (__void__ &)
 
 G4CutTubs (const G4CutTubs &rhs)
 
 G4CutTubs (const G4String &pName, G4double pRMin, G4double pRMax, G4double pDz, G4double pSPhi, G4double pDPhi, G4ThreeVector pLowNorm, G4ThreeVector pHighNorm)
 
virtual G4VSolidGetConstituentSolid (G4int no)
 
virtual const G4VSolidGetConstituentSolid (G4int no) const
 
G4double GetCosEndPhi () const
 
G4double GetCosStartPhi () const
 
G4double GetCubicVolume ()
 
G4double GetDeltaPhiAngle () const
 
virtual G4DisplacedSolidGetDisplacedSolidPtr ()
 
virtual const G4DisplacedSolidGetDisplacedSolidPtr () const
 
G4GeometryType GetEntityType () const
 
virtual G4VisExtent GetExtent () const
 
G4ThreeVector GetHighNorm () const
 
G4double GetInnerRadius () const
 
G4ThreeVector GetLowNorm () const
 
G4String GetName () const
 
G4double GetOuterRadius () const
 
G4ThreeVector GetPointOnSurface () const
 
virtual G4PolyhedronGetPolyhedron () const
 
G4double GetSinEndPhi () const
 
G4double GetSinStartPhi () const
 
G4double GetStartPhiAngle () const
 
G4double GetSurfaceArea ()
 
G4double GetTolerance () const
 
G4double GetZHalfLength () const
 
EInside Inside (const G4ThreeVector &p) const
 
G4CutTubsoperator= (const G4CutTubs &rhs)
 
G4bool operator== (const G4VSolid &s) const
 
void SetDeltaPhiAngle (G4double newDPhi)
 
void SetInnerRadius (G4double newRMin)
 
void SetName (const G4String &name)
 
void SetOuterRadius (G4double newRMax)
 
void SetStartPhiAngle (G4double newSPhi, G4bool trig=true)
 
void SetZHalfLength (G4double newDz)
 
std::ostream & StreamInfo (std::ostream &os) const
 
G4ThreeVector SurfaceNormal (const G4ThreeVector &p) const
 
 ~G4CutTubs ()
 

Protected Member Functions

G4ThreeVector ApproxSurfaceNormal (const G4ThreeVector &p) const
 
void CalculateClippedPolygonExtent (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void CheckDPhiAngle (G4double dPhi)
 
void CheckPhiAngles (G4double sPhi, G4double dPhi)
 
void CheckSPhiAngle (G4double sPhi)
 
void ClipBetweenSections (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipCrossSection (G4ThreeVectorList *pVertices, const G4int pSectionIndex, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
 
void ClipPolygon (G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
 
G4double GetCutZ (const G4ThreeVector &p) const
 
G4double GetRadiusInRing (G4double rmin, G4double rmax) const
 
void Initialize ()
 
void InitializeTrigonometry ()
 
G4bool IsCrossingCutPlanes () const
 

Protected Attributes

G4double fCubicVolume = 0.0
 
G4PolyhedronfpPolyhedron = nullptr
 
G4bool fRebuildPolyhedron = false
 
G4double fSurfaceArea = 0.0
 
G4double kCarTolerance
 

Private Member Functions

void ClipPolygonToSimpleLimits (G4ThreeVectorList &pPolygon, G4ThreeVectorList &outputPolygon, const G4VoxelLimits &pVoxelLimit) const
 

Private Attributes

G4double cosCPhi
 
G4double cosEPhi
 
G4double cosHDPhi
 
G4double cosHDPhiIT
 
G4double cosHDPhiOT
 
G4double cosSPhi
 
G4double fDPhi
 
G4double fDz
 
G4ThreeVector fHighNorm
 
G4ThreeVector fLowNorm
 
G4bool fPhiFullCutTube = false
 
G4double fRMax
 
G4double fRMin
 
G4String fshapeName
 
G4double fSPhi
 
G4double fZMax
 
G4double fZMin
 
G4double halfAngTolerance
 
G4double halfCarTolerance
 
G4double halfRadTolerance
 
G4double kAngTolerance
 
G4double kRadTolerance
 
G4double sinCPhi
 
G4double sinEPhi
 
G4double sinSPhi
 

Detailed Description

Definition at line 59 of file G4CutTubs.hh.

Constructor & Destructor Documentation

◆ G4CutTubs() [1/3]

G4CutTubs::G4CutTubs ( const G4String pName,
G4double  pRMin,
G4double  pRMax,
G4double  pDz,
G4double  pSPhi,
G4double  pDPhi,
G4ThreeVector  pLowNorm,
G4ThreeVector  pHighNorm 
)

Definition at line 63 of file G4CutTubs.cc.

68 : G4CSGSolid(pName), fRMin(pRMin), fRMax(pRMax), fDz(pDz),
69 fSPhi(0.), fDPhi(0.), fZMin(0.), fZMax(0.)
70{
73
77
78 if (pDz<=0) // Check z-len
79 {
80 std::ostringstream message;
81 message << "Negative Z half-length (" << pDz << ") in solid: " << GetName();
82 G4Exception("G4CutTubs::G4CutTubs()", "GeomSolids0002", FatalException, message);
83 }
84 if ( (pRMin >= pRMax) || (pRMin < 0) ) // Check radii
85 {
86 std::ostringstream message;
87 message << "Invalid values for radii in solid: " << GetName()
88 << G4endl
89 << " pRMin = " << pRMin << ", pRMax = " << pRMax;
90 G4Exception("G4CutTubs::G4CutTubs()", "GeomSolids0002", FatalException, message);
91 }
92
93 // Check angles
94 //
95 CheckPhiAngles(pSPhi, pDPhi);
96
97 // Check on Cutted Planes Normals
98 // If there is NO CUT, propose to use G4Tubs instead
99 //
100 if ( ( !pLowNorm.x()) && ( !pLowNorm.y())
101 && ( !pHighNorm.x()) && (!pHighNorm.y()) )
102 {
103 std::ostringstream message;
104 message << "Inexisting Low/High Normal to Z plane or Parallel to Z."
105 << G4endl
106 << "Normals to Z plane are " << pLowNorm << " and "
107 << pHighNorm << " in solid: " << GetName() << " \n";
108 G4Exception("G4CutTubs::G4CutTubs()", "GeomSolids1001",
109 JustWarning, message, "Should use G4Tubs!");
110 }
111
112 // If Normal is (0,0,0),means parallel to R, give it value of (0,0,+/-1)
113 //
114 if (pLowNorm.mag2() == 0.) { pLowNorm.setZ(-1.); }
115 if (pHighNorm.mag2()== 0.) { pHighNorm.setZ(1.); }
116
117 // Given Normals to Cut Planes have to be an unit vectors.
118 // Normalize if it is needed.
119 //
120 if (pLowNorm.mag2() != 1.) { pLowNorm = pLowNorm.unit(); }
121 if (pHighNorm.mag2()!= 1.) { pHighNorm = pHighNorm.unit(); }
122
123 // Normals to cutted planes have to point outside Solid
124 //
125 if( (pLowNorm.mag2() != 0.) && (pHighNorm.mag2()!= 0. ) )
126 {
127 if( ( pLowNorm.z()>= 0. ) || ( pHighNorm.z() <= 0.))
128 {
129 std::ostringstream message;
130 message << "Invalid Low or High Normal to Z plane; "
131 "has to point outside Solid." << G4endl
132 << "Invalid Norm to Z plane (" << pLowNorm << " or "
133 << pHighNorm << ") in solid: " << GetName();
134 G4Exception("G4CutTubs::G4CutTubs()", "GeomSolids0002",
135 FatalException, message);
136 }
137 }
138 fLowNorm = pLowNorm;
139 fHighNorm = pHighNorm;
140
141 // Check intersection of cut planes, they MUST NOT intersect
142 // each other inside the lateral surface
143 //
145 {
146 std::ostringstream message;
147 message << "Invalid normals to Z plane in solid : " << GetName() << G4endl
148 << "Cut planes are crossing inside lateral surface !!!\n"
149 << " Solid type: G4CutTubs\n"
150 << " Parameters: \n"
151 << " inner radius : " << fRMin/mm << " mm \n"
152 << " outer radius : " << fRMax/mm << " mm \n"
153 << " half length Z: " << fDz/mm << " mm \n"
154 << " starting phi : " << fSPhi/degree << " degrees \n"
155 << " delta phi : " << fDPhi/degree << " degrees \n"
156 << " low Norm : " << fLowNorm << " \n"
157 << " high Norm : " << fHighNorm;
158 G4Exception("G4CutTubs::G4CutTubs()", "GeomSolids0002",
159 FatalException, message);
160 }
161}
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
static constexpr double mm
Definition: G4SIunits.hh:95
static constexpr double degree
Definition: G4SIunits.hh:124
#define G4endl
Definition: G4ios.hh:57
double z() const
Hep3Vector unit() const
double x() const
double mag2() const
double y() const
void setZ(double)
G4CSGSolid(const G4String &pName)
Definition: G4CSGSolid.cc:49
G4double halfRadTolerance
Definition: G4CutTubs.hh:197
G4double fDPhi
Definition: G4CutTubs.hh:183
G4double fSPhi
Definition: G4CutTubs.hh:183
G4double fDz
Definition: G4CutTubs.hh:183
G4double fRMax
Definition: G4CutTubs.hh:183
G4double halfAngTolerance
Definition: G4CutTubs.hh:197
G4bool IsCrossingCutPlanes() const
Definition: G4CutTubs.cc:2128
void CheckPhiAngles(G4double sPhi, G4double dPhi)
G4double fZMax
Definition: G4CutTubs.hh:184
G4ThreeVector fHighNorm
Definition: G4CutTubs.hh:201
G4ThreeVector fLowNorm
Definition: G4CutTubs.hh:201
G4double halfCarTolerance
Definition: G4CutTubs.hh:197
G4double kRadTolerance
Definition: G4CutTubs.hh:179
G4double fZMin
Definition: G4CutTubs.hh:184
G4double kAngTolerance
Definition: G4CutTubs.hh:179
G4double fRMin
Definition: G4CutTubs.hh:183
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
G4double GetAngularTolerance() const
G4String GetName() const
G4double kCarTolerance
Definition: G4VSolid.hh:299

References CheckPhiAngles(), degree, FatalException, fDPhi, fDz, fHighNorm, fLowNorm, fRMax, fRMin, fSPhi, G4endl, G4Exception(), G4GeometryTolerance::GetAngularTolerance(), G4GeometryTolerance::GetInstance(), G4VSolid::GetName(), G4GeometryTolerance::GetRadialTolerance(), halfAngTolerance, halfCarTolerance, halfRadTolerance, IsCrossingCutPlanes(), JustWarning, kAngTolerance, G4VSolid::kCarTolerance, kRadTolerance, CLHEP::Hep3Vector::mag2(), mm, CLHEP::Hep3Vector::setZ(), CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by Clone().

◆ ~G4CutTubs()

G4CutTubs::~G4CutTubs ( )

Definition at line 182 of file G4CutTubs.cc.

183{
184}

◆ G4CutTubs() [2/3]

G4CutTubs::G4CutTubs ( __void__ &  a)

Definition at line 168 of file G4CutTubs.cc.

170 fRMin(0.), fRMax(0.), fDz(0.), fSPhi(0.), fDPhi(0.), fZMin(0.), fZMax(0.),
171 sinCPhi(0.), cosCPhi(0.), cosHDPhi(0.), cosHDPhiOT(0.), cosHDPhiIT(0.),
172 sinSPhi(0.), cosSPhi(0.), sinEPhi(0.), cosEPhi(0.),
175{
176}
CLHEP::Hep3Vector G4ThreeVector
G4double cosSPhi
Definition: G4CutTubs.hh:189
G4double cosCPhi
Definition: G4CutTubs.hh:188
G4double sinEPhi
Definition: G4CutTubs.hh:189
G4double cosEPhi
Definition: G4CutTubs.hh:189
G4double sinSPhi
Definition: G4CutTubs.hh:189
G4double cosHDPhiOT
Definition: G4CutTubs.hh:188
G4double cosHDPhi
Definition: G4CutTubs.hh:188
G4double sinCPhi
Definition: G4CutTubs.hh:188
G4double cosHDPhiIT
Definition: G4CutTubs.hh:188

◆ G4CutTubs() [3/3]

G4CutTubs::G4CutTubs ( const G4CutTubs rhs)

Definition at line 190 of file G4CutTubs.cc.

Member Function Documentation

◆ ApproxSurfaceNormal()

G4ThreeVector G4CutTubs::ApproxSurfaceNormal ( const G4ThreeVector p) const
protected

Definition at line 763 of file G4CutTubs.cc.

764{
766
767 ENorm side ;
768 G4ThreeVector norm ;
769 G4double rho, phi ;
770 G4double distZLow,distZHigh,distZ;
771 G4double distRMin, distRMax, distSPhi, distEPhi, distMin ;
773
774 rho = std::sqrt(p.x()*p.x() + p.y()*p.y()) ;
775
776 distRMin = std::fabs(rho - fRMin) ;
777 distRMax = std::fabs(rho - fRMax) ;
778
779 //dist to Low Cut
780 //
781 distZLow =std::fabs((p+vZ).dot(fLowNorm));
782
783 //dist to High Cut
784 //
785 distZHigh = std::fabs((p-vZ).dot(fHighNorm));
786 distZ=std::min(distZLow,distZHigh);
787
788 if (distRMin < distRMax) // First minimum
789 {
790 if ( distZ < distRMin )
791 {
792 distMin = distZ ;
793 side = kNZ ;
794 }
795 else
796 {
797 distMin = distRMin ;
798 side = kNRMin ;
799 }
800 }
801 else
802 {
803 if ( distZ < distRMax )
804 {
805 distMin = distZ ;
806 side = kNZ ;
807 }
808 else
809 {
810 distMin = distRMax ;
811 side = kNRMax ;
812 }
813 }
814 if (!fPhiFullCutTube && rho ) // Protected against (0,0,z)
815 {
816 phi = std::atan2(p.y(),p.x()) ;
817
818 if ( phi < 0 ) { phi += twopi; }
819
820 if ( fSPhi < 0 )
821 {
822 distSPhi = std::fabs(phi - (fSPhi + twopi))*rho ;
823 }
824 else
825 {
826 distSPhi = std::fabs(phi - fSPhi)*rho ;
827 }
828 distEPhi = std::fabs(phi - fSPhi - fDPhi)*rho ;
829
830 if (distSPhi < distEPhi) // Find new minimum
831 {
832 if ( distSPhi < distMin )
833 {
834 side = kNSPhi ;
835 }
836 }
837 else
838 {
839 if ( distEPhi < distMin )
840 {
841 side = kNEPhi ;
842 }
843 }
844 }
845 switch ( side )
846 {
847 case kNRMin : // Inner radius
848 {
849 norm = G4ThreeVector(-p.x()/rho, -p.y()/rho, 0) ;
850 break ;
851 }
852 case kNRMax : // Outer radius
853 {
854 norm = G4ThreeVector(p.x()/rho, p.y()/rho, 0) ;
855 break ;
856 }
857 case kNZ : // + or - dz
858 {
859 if ( distZHigh > distZLow ) { norm = fHighNorm ; }
860 else { norm = fLowNorm; }
861 break ;
862 }
863 case kNSPhi:
864 {
865 norm = G4ThreeVector(sinSPhi, -cosSPhi, 0) ;
866 break ;
867 }
868 case kNEPhi:
869 {
870 norm = G4ThreeVector(-sinEPhi, cosEPhi, 0) ;
871 break;
872 }
873 default: // Should never reach this case ...
874 {
875 DumpInfo();
876 G4Exception("G4CutTubs::ApproxSurfaceNormal()",
877 "GeomSolids1002", JustWarning,
878 "Undefined side for valid surface normal to solid.");
879 break ;
880 }
881 }
882 return norm;
883}
ENorm
Definition: G4Cons.cc:65
@ kNRMax
Definition: G4Cons.cc:65
@ kNEPhi
Definition: G4Cons.cc:65
@ kNSPhi
Definition: G4Cons.cc:65
@ kNRMin
Definition: G4Cons.cc:65
@ kNZ
Definition: G4Cons.cc:65
static constexpr double twopi
Definition: G4SIunits.hh:56
double G4double
Definition: G4Types.hh:83
void DumpInfo() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References cosEPhi, cosSPhi, G4VSolid::DumpInfo(), fDPhi, fDz, fHighNorm, fLowNorm, fPhiFullCutTube, fRMax, fRMin, fSPhi, G4Exception(), JustWarning, kNEPhi, kNRMax, kNRMin, kNSPhi, kNZ, G4INCL::Math::min(), sinEPhi, sinSPhi, twopi, CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::y().

Referenced by SurfaceNormal().

◆ BoundingLimits()

void G4CutTubs::BoundingLimits ( G4ThreeVector pMin,
G4ThreeVector pMax 
) const
virtual

Reimplemented from G4VSolid.

Definition at line 350 of file G4CutTubs.cc.

351{
352 G4double rmin = GetInnerRadius();
353 G4double rmax = GetOuterRadius();
355 G4double dphi = GetDeltaPhiAngle();
356
357 G4double sinSphi = GetSinStartPhi();
358 G4double cosSphi = GetCosStartPhi();
359 G4double sinEphi = GetSinEndPhi();
360 G4double cosEphi = GetCosEndPhi();
361
362 G4ThreeVector norm;
363 G4double mag, topx, topy, dists, diste;
364 G4bool iftop;
365
366 // Find Zmin
367 //
368 G4double zmin;
369 norm = GetLowNorm();
370 mag = std::sqrt(norm.x()*norm.x() + norm.y()*norm.y());
371 topx = (mag == 0) ? 0 : -rmax*norm.x()/mag;
372 topy = (mag == 0) ? 0 : -rmax*norm.y()/mag;
373 dists = sinSphi*topx - cosSphi*topy;
374 diste = -sinEphi*topx + cosEphi*topy;
375 if (dphi > pi)
376 {
377 iftop = true;
378 if (dists > 0 && diste > 0)iftop = false;
379 }
380 else
381 {
382 iftop = false;
383 if (dists <= 0 && diste <= 0) iftop = true;
384 }
385 if (iftop)
386 {
387 zmin = -(norm.x()*topx + norm.y()*topy)/norm.z() - dz;
388 }
389 else
390 {
391 G4double z1 = -rmin*(norm.x()*cosSphi + norm.y()*sinSphi)/norm.z() - dz;
392 G4double z2 = -rmin*(norm.x()*cosEphi + norm.y()*sinEphi)/norm.z() - dz;
393 G4double z3 = -rmax*(norm.x()*cosSphi + norm.y()*sinSphi)/norm.z() - dz;
394 G4double z4 = -rmax*(norm.x()*cosEphi + norm.y()*sinEphi)/norm.z() - dz;
395 zmin = std::min(std::min(std::min(z1,z2),z3),z4);
396 }
397
398 // Find Zmax
399 //
400 G4double zmax;
401 norm = GetHighNorm();
402 mag = std::sqrt(norm.x()*norm.x() + norm.y()*norm.y());
403 topx = (mag == 0) ? 0 : -rmax*norm.x()/mag;
404 topy = (mag == 0) ? 0 : -rmax*norm.y()/mag;
405 dists = sinSphi*topx - cosSphi*topy;
406 diste = -sinEphi*topx + cosEphi*topy;
407 if (dphi > pi)
408 {
409 iftop = true;
410 if (dists > 0 && diste > 0) iftop = false;
411 }
412 else
413 {
414 iftop = false;
415 if (dists <= 0 && diste <= 0) iftop = true;
416 }
417 if (iftop)
418 {
419 zmax = -(norm.x()*topx + norm.y()*topy)/norm.z() + dz;
420 }
421 else
422 {
423 G4double z1 = -rmin*(norm.x()*cosSphi + norm.y()*sinSphi)/norm.z() + dz;
424 G4double z2 = -rmin*(norm.x()*cosEphi + norm.y()*sinEphi)/norm.z() + dz;
425 G4double z3 = -rmax*(norm.x()*cosSphi + norm.y()*sinSphi)/norm.z() + dz;
426 G4double z4 = -rmax*(norm.x()*cosEphi + norm.y()*sinEphi)/norm.z() + dz;
427 zmax = std::max(std::max(std::max(z1,z2),z3),z4);
428 }
429
430 // Find bounding box
431 //
432 if (dphi < twopi)
433 {
434 G4TwoVector vmin,vmax;
435 G4GeomTools::DiskExtent(rmin,rmax,
438 vmin,vmax);
439 pMin.set(vmin.x(),vmin.y(), zmin);
440 pMax.set(vmax.x(),vmax.y(), zmax);
441 }
442 else
443 {
444 pMin.set(-rmax,-rmax, zmin);
445 pMax.set( rmax, rmax, zmax);
446 }
447
448 // Check correctness of the bounding box
449 //
450 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
451 {
452 std::ostringstream message;
453 message << "Bad bounding box (min >= max) for solid: "
454 << GetName() << " !"
455 << "\npMin = " << pMin
456 << "\npMax = " << pMax;
457 G4Exception("G4CutTubs::BoundingLimits()", "GeomMgt0001",
458 JustWarning, message);
459 DumpInfo();
460 }
461}
static const G4double pMax
static const G4double pMin
static constexpr double pi
Definition: G4SIunits.hh:55
bool G4bool
Definition: G4Types.hh:86
double x() const
double y() const
G4ThreeVector GetHighNorm() const
G4double GetZHalfLength() const
G4double GetInnerRadius() const
G4ThreeVector GetLowNorm() const
G4double GetDeltaPhiAngle() const
G4double GetOuterRadius() const
G4double GetSinStartPhi() const
G4double GetSinEndPhi() const
G4double GetCosStartPhi() const
G4double GetCosEndPhi() const
static G4bool DiskExtent(G4double rmin, G4double rmax, G4double startPhi, G4double delPhi, G4TwoVector &pmin, G4TwoVector &pmax)
Definition: G4GeomTools.cc:390
T max(const T t1, const T t2)
brief Return the largest of the two arguments

References G4GeomTools::DiskExtent(), G4VSolid::DumpInfo(), G4Exception(), GetCosEndPhi(), GetCosStartPhi(), GetDeltaPhiAngle(), GetHighNorm(), GetInnerRadius(), GetLowNorm(), G4VSolid::GetName(), GetOuterRadius(), GetSinEndPhi(), GetSinStartPhi(), GetZHalfLength(), JustWarning, G4INCL::Math::max(), G4INCL::Math::min(), pi, pMax, pMin, twopi, CLHEP::Hep3Vector::x(), CLHEP::Hep2Vector::x(), CLHEP::Hep3Vector::y(), CLHEP::Hep2Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by CalculateExtent(), and GetPointOnSurface().

◆ CalculateClippedPolygonExtent()

void G4VSolid::CalculateClippedPolygonExtent ( G4ThreeVectorList pPolygon,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis,
G4double pMin,
G4double pMax 
) const
protectedinherited

Definition at line 489 of file G4VSolid.cc.

494{
495 G4int noLeft,i;
496 G4double component;
497
498 ClipPolygon(pPolygon,pVoxelLimit,pAxis);
499 noLeft = pPolygon.size();
500
501 if ( noLeft )
502 {
503 for (i=0; i<noLeft; ++i)
504 {
505 component = pPolygon[i].operator()(pAxis);
506
507 if (component < pMin)
508 {
509 pMin = component;
510 }
511 if (component > pMax)
512 {
513 pMax = component;
514 }
515 }
516 }
517}
int G4int
Definition: G4Types.hh:85
void ClipPolygon(G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis) const
Definition: G4VSolid.cc:539

References G4VSolid::ClipPolygon(), pMax, and pMin.

Referenced by G4VSolid::ClipBetweenSections(), and G4VSolid::ClipCrossSection().

◆ CalculateExtent()

G4bool G4CutTubs::CalculateExtent ( const EAxis  pAxis,
const G4VoxelLimits pVoxelLimit,
const G4AffineTransform pTransform,
G4double pmin,
G4double pmax 
) const
virtual

Implements G4VSolid.

Definition at line 467 of file G4CutTubs.cc.

472{
473 G4ThreeVector bmin, bmax;
474 G4bool exist;
475
476 // Get bounding box
477 BoundingLimits(bmin,bmax);
478
479 // Check bounding box
480 G4BoundingEnvelope bbox(bmin,bmax);
481#ifdef G4BBOX_EXTENT
482 return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
483#endif
484 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
485 {
486 return exist = (pMin < pMax) ? true : false;
487 }
488
489 // Get parameters of the solid
490 G4double rmin = GetInnerRadius();
491 G4double rmax = GetOuterRadius();
492 G4double dphi = GetDeltaPhiAngle();
493 G4double zmin = bmin.z();
494 G4double zmax = bmax.z();
495
496 // Find bounding envelope and calculate extent
497 //
498 const G4int NSTEPS = 24; // number of steps for whole circle
499 G4double astep = twopi/NSTEPS; // max angle for one step
500 G4int ksteps = (dphi <= astep) ? 1 : (G4int)((dphi-deg)/astep) + 1;
501 G4double ang = dphi/ksteps;
502
503 G4double sinHalf = std::sin(0.5*ang);
504 G4double cosHalf = std::cos(0.5*ang);
505 G4double sinStep = 2.*sinHalf*cosHalf;
506 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
507 G4double rext = rmax/cosHalf;
508
509 // bounding envelope for full cylinder consists of two polygons,
510 // in other cases it is a sequence of quadrilaterals
511 if (rmin == 0 && dphi == twopi)
512 {
513 G4double sinCur = sinHalf;
514 G4double cosCur = cosHalf;
515
516 G4ThreeVectorList baseA(NSTEPS),baseB(NSTEPS);
517 for (G4int k=0; k<NSTEPS; ++k)
518 {
519 baseA[k].set(rext*cosCur,rext*sinCur,zmin);
520 baseB[k].set(rext*cosCur,rext*sinCur,zmax);
521
522 G4double sinTmp = sinCur;
523 sinCur = sinCur*cosStep + cosCur*sinStep;
524 cosCur = cosCur*cosStep - sinTmp*sinStep;
525 }
526 std::vector<const G4ThreeVectorList *> polygons(2);
527 polygons[0] = &baseA;
528 polygons[1] = &baseB;
529 G4BoundingEnvelope benv(bmin,bmax,polygons);
530 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
531 }
532 else
533 {
534 G4double sinStart = GetSinStartPhi();
535 G4double cosStart = GetCosStartPhi();
536 G4double sinEnd = GetSinEndPhi();
537 G4double cosEnd = GetCosEndPhi();
538 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
539 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
540
541 // set quadrilaterals
542 G4ThreeVectorList pols[NSTEPS+2];
543 for (G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
544 pols[0][0].set(rmin*cosStart,rmin*sinStart,zmax);
545 pols[0][1].set(rmin*cosStart,rmin*sinStart,zmin);
546 pols[0][2].set(rmax*cosStart,rmax*sinStart,zmin);
547 pols[0][3].set(rmax*cosStart,rmax*sinStart,zmax);
548 for (G4int k=1; k<ksteps+1; ++k)
549 {
550 pols[k][0].set(rmin*cosCur,rmin*sinCur,zmax);
551 pols[k][1].set(rmin*cosCur,rmin*sinCur,zmin);
552 pols[k][2].set(rext*cosCur,rext*sinCur,zmin);
553 pols[k][3].set(rext*cosCur,rext*sinCur,zmax);
554
555 G4double sinTmp = sinCur;
556 sinCur = sinCur*cosStep + cosCur*sinStep;
557 cosCur = cosCur*cosStep - sinTmp*sinStep;
558 }
559 pols[ksteps+1][0].set(rmin*cosEnd,rmin*sinEnd,zmax);
560 pols[ksteps+1][1].set(rmin*cosEnd,rmin*sinEnd,zmin);
561 pols[ksteps+1][2].set(rmax*cosEnd,rmax*sinEnd,zmin);
562 pols[ksteps+1][3].set(rmax*cosEnd,rmax*sinEnd,zmax);
563
564 // set envelope and calculate extent
565 std::vector<const G4ThreeVectorList *> polygons;
566 polygons.resize(ksteps+2);
567 for (G4int k=0; k<ksteps+2; ++k) { polygons[k] = &pols[k]; }
568 G4BoundingEnvelope benv(bmin,bmax,polygons);
569 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
570 }
571 return exist;
572}
std::vector< G4ThreeVector > G4ThreeVectorList
static constexpr double deg
Definition: G4SIunits.hh:132
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4CutTubs.cc:350

References G4BoundingEnvelope::BoundingBoxVsVoxelLimits(), BoundingLimits(), G4BoundingEnvelope::CalculateExtent(), deg, GetCosEndPhi(), GetCosStartPhi(), GetDeltaPhiAngle(), GetInnerRadius(), GetOuterRadius(), GetSinEndPhi(), GetSinStartPhi(), pMax, pMin, twopi, and CLHEP::Hep3Vector::z().

◆ CheckDPhiAngle()

void G4CutTubs::CheckDPhiAngle ( G4double  dPhi)
inlineprotected

◆ CheckPhiAngles()

void G4CutTubs::CheckPhiAngles ( G4double  sPhi,
G4double  dPhi 
)
inlineprotected

Referenced by G4CutTubs().

◆ CheckSPhiAngle()

void G4CutTubs::CheckSPhiAngle ( G4double  sPhi)
inlineprotected

◆ ClipBetweenSections()

void G4VSolid::ClipBetweenSections ( G4ThreeVectorList pVertices,
const G4int  pSectionIndex,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis,
G4double pMin,
G4double pMax 
) const
protectedinherited

Definition at line 444 of file G4VSolid.cc.

449{
450 G4ThreeVectorList polygon;
451 polygon.reserve(4);
452 polygon.push_back((*pVertices)[pSectionIndex]);
453 polygon.push_back((*pVertices)[pSectionIndex+4]);
454 polygon.push_back((*pVertices)[pSectionIndex+5]);
455 polygon.push_back((*pVertices)[pSectionIndex+1]);
456 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
457 polygon.clear();
458
459 polygon.push_back((*pVertices)[pSectionIndex+1]);
460 polygon.push_back((*pVertices)[pSectionIndex+5]);
461 polygon.push_back((*pVertices)[pSectionIndex+6]);
462 polygon.push_back((*pVertices)[pSectionIndex+2]);
463 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
464 polygon.clear();
465
466 polygon.push_back((*pVertices)[pSectionIndex+2]);
467 polygon.push_back((*pVertices)[pSectionIndex+6]);
468 polygon.push_back((*pVertices)[pSectionIndex+7]);
469 polygon.push_back((*pVertices)[pSectionIndex+3]);
470 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
471 polygon.clear();
472
473 polygon.push_back((*pVertices)[pSectionIndex+3]);
474 polygon.push_back((*pVertices)[pSectionIndex+7]);
475 polygon.push_back((*pVertices)[pSectionIndex+4]);
476 polygon.push_back((*pVertices)[pSectionIndex]);
477 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
478 return;
479}
void CalculateClippedPolygonExtent(G4ThreeVectorList &pPolygon, const G4VoxelLimits &pVoxelLimit, const EAxis pAxis, G4double &pMin, G4double &pMax) const
Definition: G4VSolid.cc:489

References G4VSolid::CalculateClippedPolygonExtent(), pMax, and pMin.

◆ ClipCrossSection()

void G4VSolid::ClipCrossSection ( G4ThreeVectorList pVertices,
const G4int  pSectionIndex,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis,
G4double pMin,
G4double pMax 
) const
protectedinherited

Definition at line 414 of file G4VSolid.cc.

419{
420
421 G4ThreeVectorList polygon;
422 polygon.reserve(4);
423 polygon.push_back((*pVertices)[pSectionIndex]);
424 polygon.push_back((*pVertices)[pSectionIndex+1]);
425 polygon.push_back((*pVertices)[pSectionIndex+2]);
426 polygon.push_back((*pVertices)[pSectionIndex+3]);
427 CalculateClippedPolygonExtent(polygon,pVoxelLimit,pAxis,pMin,pMax);
428 return;
429}

References G4VSolid::CalculateClippedPolygonExtent(), pMax, and pMin.

◆ ClipPolygon()

void G4VSolid::ClipPolygon ( G4ThreeVectorList pPolygon,
const G4VoxelLimits pVoxelLimit,
const EAxis  pAxis 
) const
protectedinherited

Definition at line 539 of file G4VSolid.cc.

542{
543 G4ThreeVectorList outputPolygon;
544
545 if ( pVoxelLimit.IsLimited() )
546 {
547 if (pVoxelLimit.IsXLimited() ) // && pAxis != kXAxis)
548 {
549 G4VoxelLimits simpleLimit1;
550 simpleLimit1.AddLimit(kXAxis,pVoxelLimit.GetMinXExtent(),kInfinity);
551 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
552
553 pPolygon.clear();
554
555 if ( !outputPolygon.size() ) return;
556
557 G4VoxelLimits simpleLimit2;
558 simpleLimit2.AddLimit(kXAxis,-kInfinity,pVoxelLimit.GetMaxXExtent());
559 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
560
561 if ( !pPolygon.size() ) return;
562 else outputPolygon.clear();
563 }
564 if ( pVoxelLimit.IsYLimited() ) // && pAxis != kYAxis)
565 {
566 G4VoxelLimits simpleLimit1;
567 simpleLimit1.AddLimit(kYAxis,pVoxelLimit.GetMinYExtent(),kInfinity);
568 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
569
570 // Must always clear pPolygon - for clip to simpleLimit2 and in case of
571 // early exit
572
573 pPolygon.clear();
574
575 if ( !outputPolygon.size() ) return;
576
577 G4VoxelLimits simpleLimit2;
578 simpleLimit2.AddLimit(kYAxis,-kInfinity,pVoxelLimit.GetMaxYExtent());
579 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
580
581 if ( !pPolygon.size() ) return;
582 else outputPolygon.clear();
583 }
584 if ( pVoxelLimit.IsZLimited() ) // && pAxis != kZAxis)
585 {
586 G4VoxelLimits simpleLimit1;
587 simpleLimit1.AddLimit(kZAxis,pVoxelLimit.GetMinZExtent(),kInfinity);
588 ClipPolygonToSimpleLimits(pPolygon,outputPolygon,simpleLimit1);
589
590 // Must always clear pPolygon - for clip to simpleLimit2 and in case of
591 // early exit
592
593 pPolygon.clear();
594
595 if ( !outputPolygon.size() ) return;
596
597 G4VoxelLimits simpleLimit2;
598 simpleLimit2.AddLimit(kZAxis,-kInfinity,pVoxelLimit.GetMaxZExtent());
599 ClipPolygonToSimpleLimits(outputPolygon,pPolygon,simpleLimit2);
600
601 // Return after final clip - no cleanup
602 }
603 }
604}
void ClipPolygonToSimpleLimits(G4ThreeVectorList &pPolygon, G4ThreeVectorList &outputPolygon, const G4VoxelLimits &pVoxelLimit) const
Definition: G4VSolid.cc:612
G4bool IsYLimited() const
G4double GetMinZExtent() const
void AddLimit(const EAxis pAxis, const G4double pMin, const G4double pMax)
G4bool IsXLimited() const
G4double GetMaxYExtent() const
G4double GetMaxZExtent() const
G4double GetMinYExtent() const
G4double GetMinXExtent() const
G4bool IsZLimited() const
G4bool IsLimited() const
G4double GetMaxXExtent() const
@ kYAxis
Definition: geomdefs.hh:56
@ kXAxis
Definition: geomdefs.hh:55
@ kZAxis
Definition: geomdefs.hh:57
static const G4double kInfinity
Definition: geomdefs.hh:41

References G4VoxelLimits::AddLimit(), G4VSolid::ClipPolygonToSimpleLimits(), G4VoxelLimits::GetMaxXExtent(), G4VoxelLimits::GetMaxYExtent(), G4VoxelLimits::GetMaxZExtent(), G4VoxelLimits::GetMinXExtent(), G4VoxelLimits::GetMinYExtent(), G4VoxelLimits::GetMinZExtent(), G4VoxelLimits::IsLimited(), G4VoxelLimits::IsXLimited(), G4VoxelLimits::IsYLimited(), G4VoxelLimits::IsZLimited(), kInfinity, kXAxis, kYAxis, and kZAxis.

Referenced by G4VSolid::CalculateClippedPolygonExtent().

◆ ClipPolygonToSimpleLimits()

void G4VSolid::ClipPolygonToSimpleLimits ( G4ThreeVectorList pPolygon,
G4ThreeVectorList outputPolygon,
const G4VoxelLimits pVoxelLimit 
) const
privateinherited

Definition at line 612 of file G4VSolid.cc.

615{
616 G4int i;
617 G4int noVertices=pPolygon.size();
618 G4ThreeVector vEnd,vStart;
619
620 for (i = 0 ; i < noVertices ; ++i )
621 {
622 vStart = pPolygon[i];
623 if ( i == noVertices-1 ) vEnd = pPolygon[0];
624 else vEnd = pPolygon[i+1];
625
626 if ( pVoxelLimit.Inside(vStart) )
627 {
628 if (pVoxelLimit.Inside(vEnd))
629 {
630 // vStart and vEnd inside -> output end point
631 //
632 outputPolygon.push_back(vEnd);
633 }
634 else
635 {
636 // vStart inside, vEnd outside -> output crossing point
637 //
638 pVoxelLimit.ClipToLimits(vStart,vEnd);
639 outputPolygon.push_back(vEnd);
640 }
641 }
642 else
643 {
644 if (pVoxelLimit.Inside(vEnd))
645 {
646 // vStart outside, vEnd inside -> output inside section
647 //
648 pVoxelLimit.ClipToLimits(vStart,vEnd);
649 outputPolygon.push_back(vStart);
650 outputPolygon.push_back(vEnd);
651 }
652 else // Both point outside -> no output
653 {
654 // outputPolygon.push_back(vStart);
655 // outputPolygon.push_back(vEnd);
656 }
657 }
658 }
659}
G4bool ClipToLimits(G4ThreeVector &pStart, G4ThreeVector &pEnd) const
G4bool Inside(const G4ThreeVector &pVec) const

References G4VoxelLimits::ClipToLimits(), and G4VoxelLimits::Inside().

Referenced by G4VSolid::ClipPolygon().

◆ Clone()

G4VSolid * G4CutTubs::Clone ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1909 of file G4CutTubs.cc.

1910{
1911 return new G4CutTubs(*this);
1912}
G4CutTubs(const G4String &pName, G4double pRMin, G4double pRMax, G4double pDz, G4double pSPhi, G4double pDPhi, G4ThreeVector pLowNorm, G4ThreeVector pHighNorm)
Definition: G4CutTubs.cc:63

References G4CutTubs().

◆ ComputeDimensions()

void G4VSolid::ComputeDimensions ( G4VPVParameterisation p,
const G4int  n,
const G4VPhysicalVolume pRep 
)
virtualinherited

◆ CreatePolyhedron()

G4Polyhedron * G4CutTubs::CreatePolyhedron ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 2066 of file G4CutTubs.cc.

2067{
2068 typedef G4double G4double3[3];
2069 typedef G4int G4int4[4];
2070
2071 G4Polyhedron *ph = new G4Polyhedron;
2073 G4int nn=ph1->GetNoVertices();
2074 G4int nf=ph1->GetNoFacets();
2075 G4double3* xyz = new G4double3[nn]; // number of nodes
2076 G4int4* faces = new G4int4[nf] ; // number of faces
2077
2078 for(G4int i=0; i<nn; ++i)
2079 {
2080 xyz[i][0]=ph1->GetVertex(i+1).x();
2081 xyz[i][1]=ph1->GetVertex(i+1).y();
2082 G4double tmpZ=ph1->GetVertex(i+1).z();
2083 if(tmpZ>=fDz-kCarTolerance)
2084 {
2085 xyz[i][2]=GetCutZ(G4ThreeVector(xyz[i][0],xyz[i][1],fDz));
2086 }
2087 else if(tmpZ<=-fDz+kCarTolerance)
2088 {
2089 xyz[i][2]=GetCutZ(G4ThreeVector(xyz[i][0],xyz[i][1],-fDz));
2090 }
2091 else
2092 {
2093 xyz[i][2]=tmpZ;
2094 }
2095 }
2096 G4int iNodes[4];
2097 G4int *iEdge=0;
2098 G4int n;
2099 for(G4int i=0; i<nf ; ++i)
2100 {
2101 ph1->GetFacet(i+1,n,iNodes,iEdge);
2102 for(G4int k=0; k<n; ++k)
2103 {
2104 faces[i][k]=iNodes[k];
2105 }
2106 for(G4int k=n; k<4; ++k)
2107 {
2108 faces[i][k]=0;
2109 }
2110 }
2111 ph->createPolyhedron(nn,nf,xyz,faces);
2112
2113 delete [] xyz;
2114 delete [] faces;
2115 delete ph1;
2116
2117 return ph;
2118}
G4double GetCutZ(const G4ThreeVector &p) const
Definition: G4CutTubs.cc:2163
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
G4Point3D GetVertex(G4int index) const
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
G4int GetNoFacets() const
G4int GetNoVertices() const

References HepPolyhedron::createPolyhedron(), fDPhi, fDz, fRMax, fRMin, fSPhi, GetCutZ(), HepPolyhedron::GetFacet(), HepPolyhedron::GetNoFacets(), HepPolyhedron::GetNoVertices(), HepPolyhedron::GetVertex(), G4VSolid::kCarTolerance, CLHEP::detail::n, G4InuclParticleNames::nn, HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

◆ DescribeYourselfTo()

void G4CutTubs::DescribeYourselfTo ( G4VGraphicsScene scene) const
virtual

Implements G4VSolid.

Definition at line 2061 of file G4CutTubs.cc.

2062{
2063 scene.AddSolid (*this) ;
2064}
virtual void AddSolid(const G4Box &)=0

References G4VGraphicsScene::AddSolid().

◆ DistanceToIn() [1/2]

G4double G4CutTubs::DistanceToIn ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 1360 of file G4CutTubs.cc.

1361{
1362 G4double safRMin,safRMax,safZLow,safZHigh,safePhi,safe,rho,cosPsi;
1364
1365 // Distance to R
1366 //
1367 rho = std::sqrt(p.x()*p.x() + p.y()*p.y()) ;
1368
1369 safRMin = fRMin- rho ;
1370 safRMax = rho - fRMax ;
1371
1372 // Distances to ZCut(Low/High)
1373
1374 // Dist to Low Cut
1375 //
1376 safZLow = (p+vZ).dot(fLowNorm);
1377
1378 // Dist to High Cut
1379 //
1380 safZHigh = (p-vZ).dot(fHighNorm);
1381
1382 safe = std::max(safZLow,safZHigh);
1383
1384 if ( safRMin > safe ) { safe = safRMin; }
1385 if ( safRMax> safe ) { safe = safRMax; }
1386
1387 // Distance to Phi
1388 //
1389 if ( (!fPhiFullCutTube) && (rho) )
1390 {
1391 // Psi=angle from central phi to point
1392 //
1393 cosPsi = (p.x()*cosCPhi + p.y()*sinCPhi)/rho ;
1394
1395 if ( cosPsi < cosHDPhi )
1396 {
1397 // Point lies outside phi range
1398
1399 if ( (p.y()*cosCPhi - p.x()*sinCPhi) <= 0 )
1400 {
1401 safePhi = std::fabs(p.x()*sinSPhi - p.y()*cosSPhi) ;
1402 }
1403 else
1404 {
1405 safePhi = std::fabs(p.x()*sinEPhi - p.y()*cosEPhi) ;
1406 }
1407 if ( safePhi > safe ) { safe = safePhi; }
1408 }
1409 }
1410 if ( safe < 0 ) { safe = 0; }
1411
1412 return safe ;
1413}

References cosCPhi, cosEPhi, cosHDPhi, cosSPhi, fDz, fHighNorm, fLowNorm, fPhiFullCutTube, fRMax, fRMin, G4INCL::Math::max(), sinCPhi, sinEPhi, sinSPhi, CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::y().

◆ DistanceToIn() [2/2]

G4double G4CutTubs::DistanceToIn ( const G4ThreeVector p,
const G4ThreeVector v 
) const
virtual

Implements G4VSolid.

Definition at line 907 of file G4CutTubs.cc.

909{
910 G4double snxt = kInfinity ; // snxt = default return value
911 G4double tolORMin2, tolIRMax2 ; // 'generous' radii squared
912 G4double tolORMax2, tolIRMin2;
913 const G4double dRmax = 100.*fRMax;
915
916 // Intersection point variables
917 //
918 G4double Dist, sd=0, xi, yi, zi, rho2, inum, iden, cosPsi, Comp,calf ;
919 G4double t1, t2, t3, b, c, d ; // Quadratic solver variables
920 G4double distZLow,distZHigh;
921 // Calculate tolerant rmin and rmax
922
923 if (fRMin > kRadTolerance)
924 {
925 tolORMin2 = (fRMin - halfRadTolerance)*(fRMin - halfRadTolerance) ;
926 tolIRMin2 = (fRMin + halfRadTolerance)*(fRMin + halfRadTolerance) ;
927 }
928 else
929 {
930 tolORMin2 = 0.0 ;
931 tolIRMin2 = 0.0 ;
932 }
933 tolORMax2 = (fRMax + halfRadTolerance)*(fRMax + halfRadTolerance) ;
934 tolIRMax2 = (fRMax - halfRadTolerance)*(fRMax - halfRadTolerance) ;
935
936 // Intersection with ZCut surfaces
937
938 // dist to Low Cut
939 //
940 distZLow =(p+vZ).dot(fLowNorm);
941
942 // dist to High Cut
943 //
944 distZHigh = (p-vZ).dot(fHighNorm);
945
946 if ( distZLow >= -halfCarTolerance )
947 {
948 calf = v.dot(fLowNorm);
949 if (calf<0)
950 {
951 sd = -distZLow/calf;
952 if(sd < 0.0) { sd = 0.0; }
953
954 xi = p.x() + sd*v.x() ; // Intersection coords
955 yi = p.y() + sd*v.y() ;
956 rho2 = xi*xi + yi*yi ;
957
958 // Check validity of intersection
959
960 if ((tolIRMin2 <= rho2) && (rho2 <= tolIRMax2))
961 {
962 if (!fPhiFullCutTube && rho2)
963 {
964 // Psi = angle made with central (average) phi of shape
965 //
966 inum = xi*cosCPhi + yi*sinCPhi ;
967 iden = std::sqrt(rho2) ;
968 cosPsi = inum/iden ;
969 if (cosPsi >= cosHDPhiIT) { return sd ; }
970 }
971 else
972 {
973 return sd ;
974 }
975 }
976 }
977 else
978 {
979 if ( sd<halfCarTolerance )
980 {
981 if(calf>=0) { sd=kInfinity; }
982 return sd ; // On/outside extent, and heading away
983 } // -> cannot intersect
984 }
985 }
986
987 if(distZHigh >= -halfCarTolerance )
988 {
989 calf = v.dot(fHighNorm);
990 if (calf<0)
991 {
992 sd = -distZHigh/calf;
993
994 if(sd < 0.0) { sd = 0.0; }
995
996 xi = p.x() + sd*v.x() ; // Intersection coords
997 yi = p.y() + sd*v.y() ;
998 rho2 = xi*xi + yi*yi ;
999
1000 // Check validity of intersection
1001
1002 if ((tolIRMin2 <= rho2) && (rho2 <= tolIRMax2))
1003 {
1004 if (!fPhiFullCutTube && rho2)
1005 {
1006 // Psi = angle made with central (average) phi of shape
1007 //
1008 inum = xi*cosCPhi + yi*sinCPhi ;
1009 iden = std::sqrt(rho2) ;
1010 cosPsi = inum/iden ;
1011 if (cosPsi >= cosHDPhiIT) { return sd ; }
1012 }
1013 else
1014 {
1015 return sd ;
1016 }
1017 }
1018 }
1019 else
1020 {
1021 if ( sd<halfCarTolerance )
1022 {
1023 if(calf>=0) { sd=kInfinity; }
1024 return sd ; // On/outside extent, and heading away
1025 } // -> cannot intersect
1026 }
1027 }
1028
1029 // -> Can not intersect z surfaces
1030 //
1031 // Intersection with rmax (possible return) and rmin (must also check phi)
1032 //
1033 // Intersection point (xi,yi,zi) on line x=p.x+t*v.x etc.
1034 //
1035 // Intersects with x^2+y^2=R^2
1036 //
1037 // Hence (v.x^2+v.y^2)t^2+ 2t(p.x*v.x+p.y*v.y)+p.x^2+p.y^2-R^2=0
1038 // t1 t2 t3
1039
1040 t1 = 1.0 - v.z()*v.z() ;
1041 t2 = p.x()*v.x() + p.y()*v.y() ;
1042 t3 = p.x()*p.x() + p.y()*p.y() ;
1043 if ( t1 > 0 ) // Check not || to z axis
1044 {
1045 b = t2/t1 ;
1046 c = t3 - fRMax*fRMax ;
1047
1048 if ((t3 >= tolORMax2) && (t2<0)) // This also handles the tangent case
1049 {
1050 // Try outer cylinder intersection, c=(t3-fRMax*fRMax)/t1;
1051
1052 c /= t1 ;
1053 d = b*b - c ;
1054
1055 if (d >= 0) // If real root
1056 {
1057 sd = c/(-b+std::sqrt(d));
1058 if (sd >= 0) // If 'forwards'
1059 {
1060 if ( sd>dRmax ) // Avoid rounding errors due to precision issues on
1061 { // 64 bits systems. Split long distances and recompute
1062 G4double fTerm = sd-std::fmod(sd,dRmax);
1063 sd = fTerm + DistanceToIn(p+fTerm*v,v);
1064 }
1065 // Check z intersection
1066 //
1067 zi = p.z() + sd*v.z() ;
1068 xi = p.x() + sd*v.x() ;
1069 yi = p.y() + sd*v.y() ;
1070 if ((-xi*fLowNorm.x()-yi*fLowNorm.y()
1071 -(zi+fDz)*fLowNorm.z())>-halfCarTolerance)
1072 {
1073 if ((-xi*fHighNorm.x()-yi*fHighNorm.y()
1074 +(fDz-zi)*fHighNorm.z())>-halfCarTolerance)
1075 {
1076 // Z ok. Check phi intersection if reqd
1077 //
1078 if (fPhiFullCutTube)
1079 {
1080 return sd ;
1081 }
1082 else
1083 {
1084 xi = p.x() + sd*v.x() ;
1085 yi = p.y() + sd*v.y() ;
1086 cosPsi = (xi*cosCPhi + yi*sinCPhi)/fRMax ;
1087 if (cosPsi >= cosHDPhiIT) { return sd ; }
1088 }
1089 } // end if std::fabs(zi)
1090 }
1091 } // end if (sd>=0)
1092 } // end if (d>=0)
1093 } // end if (r>=fRMax)
1094 else
1095 {
1096 // Inside outer radius :
1097 // check not inside, and heading through tubs (-> 0 to in)
1098 if ((t3 > tolIRMin2) && (t2 < 0)
1099 && (std::fabs(p.z()) <= std::fabs(GetCutZ(p))-halfCarTolerance ))
1100 {
1101 // Inside both radii, delta r -ve, inside z extent
1102
1103 if (!fPhiFullCutTube)
1104 {
1105 inum = p.x()*cosCPhi + p.y()*sinCPhi ;
1106 iden = std::sqrt(t3) ;
1107 cosPsi = inum/iden ;
1108 if (cosPsi >= cosHDPhiIT)
1109 {
1110 // In the old version, the small negative tangent for the point
1111 // on surface was not taken in account, and returning 0.0 ...
1112 // New version: check the tangent for the point on surface and
1113 // if no intersection, return kInfinity, if intersection instead
1114 // return sd.
1115 //
1116 c = t3-fRMax*fRMax;
1117 if ( c<=0.0 )
1118 {
1119 return 0.0;
1120 }
1121 else
1122 {
1123 c = c/t1 ;
1124 d = b*b-c;
1125 if ( d>=0.0 )
1126 {
1127 snxt = c/(-b+std::sqrt(d)); // using safe solution
1128 // for quadratic equation
1129 if ( snxt < halfCarTolerance ) { snxt=0; }
1130 return snxt ;
1131 }
1132 else
1133 {
1134 return kInfinity;
1135 }
1136 }
1137 }
1138 }
1139 else
1140 {
1141 // In the old version, the small negative tangent for the point
1142 // on surface was not taken in account, and returning 0.0 ...
1143 // New version: check the tangent for the point on surface and
1144 // if no intersection, return kInfinity, if intersection instead
1145 // return sd.
1146 //
1147 c = t3 - fRMax*fRMax;
1148 if ( c<=0.0 )
1149 {
1150 return 0.0;
1151 }
1152 else
1153 {
1154 c = c/t1 ;
1155 d = b*b-c;
1156 if ( d>=0.0 )
1157 {
1158 snxt= c/(-b+std::sqrt(d)); // using safe solution
1159 // for quadratic equation
1160 if ( snxt < halfCarTolerance ) { snxt=0; }
1161 return snxt ;
1162 }
1163 else
1164 {
1165 return kInfinity;
1166 }
1167 }
1168 } // end if (!fPhiFullCutTube)
1169 } // end if (t3>tolIRMin2)
1170 } // end if (Inside Outer Radius)
1171
1172 if ( fRMin ) // Try inner cylinder intersection
1173 {
1174 c = (t3 - fRMin*fRMin)/t1 ;
1175 d = b*b - c ;
1176 if ( d >= 0.0 ) // If real root
1177 {
1178 // Always want 2nd root - we are outside and know rmax Hit was bad
1179 // - If on surface of rmin also need farthest root
1180
1181 sd =( b > 0. )? c/(-b - std::sqrt(d)) : (-b + std::sqrt(d));
1182 if (sd >= -10*halfCarTolerance) // check forwards
1183 {
1184 // Check z intersection
1185 //
1186 if (sd < 0.0) { sd = 0.0; }
1187 if (sd>dRmax) // Avoid rounding errors due to precision issues seen
1188 { // 64 bits systems. Split long distances and recompute
1189 G4double fTerm = sd-std::fmod(sd,dRmax);
1190 sd = fTerm + DistanceToIn(p+fTerm*v,v);
1191 }
1192 zi = p.z() + sd*v.z() ;
1193 xi = p.x() + sd*v.x() ;
1194 yi = p.y() + sd*v.y() ;
1195 if ((-xi*fLowNorm.x()-yi*fLowNorm.y()
1196 -(zi+fDz)*fLowNorm.z())>-halfCarTolerance)
1197 {
1198 if ((-xi*fHighNorm.x()-yi*fHighNorm.y()
1199 +(fDz-zi)*fHighNorm.z())>-halfCarTolerance)
1200 {
1201 // Z ok. Check phi
1202 //
1203 if ( fPhiFullCutTube )
1204 {
1205 return sd ;
1206 }
1207 else
1208 {
1209 cosPsi = (xi*cosCPhi + yi*sinCPhi)/fRMin ;
1210 if (cosPsi >= cosHDPhiIT)
1211 {
1212 // Good inner radius isect
1213 // - but earlier phi isect still possible
1214 //
1215 snxt = sd ;
1216 }
1217 }
1218 } // end if std::fabs(zi)
1219 }
1220 } // end if (sd>=0)
1221 } // end if (d>=0)
1222 } // end if (fRMin)
1223 }
1224
1225 // Phi segment intersection
1226 //
1227 // o Tolerant of points inside phi planes by up to kCarTolerance*0.5
1228 //
1229 // o NOTE: Large duplication of code between sphi & ephi checks
1230 // -> only diffs: sphi -> ephi, Comp -> -Comp and half-plane
1231 // intersection check <=0 -> >=0
1232 // -> use some form of loop Construct ?
1233 //
1234 if ( !fPhiFullCutTube )
1235 {
1236 // First phi surface (Starting phi)
1237 //
1238 Comp = v.x()*sinSPhi - v.y()*cosSPhi ;
1239
1240 if ( Comp < 0 ) // Component in outwards normal dirn
1241 {
1242 Dist = (p.y()*cosSPhi - p.x()*sinSPhi) ;
1243
1244 if ( Dist < halfCarTolerance )
1245 {
1246 sd = Dist/Comp ;
1247
1248 if (sd < snxt)
1249 {
1250 if ( sd < 0 ) { sd = 0.0; }
1251 zi = p.z() + sd*v.z() ;
1252 xi = p.x() + sd*v.x() ;
1253 yi = p.y() + sd*v.y() ;
1254 if ((-xi*fLowNorm.x()-yi*fLowNorm.y()
1255 -(zi+fDz)*fLowNorm.z())>-halfCarTolerance)
1256 {
1257 if ((-xi*fHighNorm.x()-yi*fHighNorm.y()
1258 +(fDz-zi)*fHighNorm.z())>-halfCarTolerance)
1259 {
1260 rho2 = xi*xi + yi*yi ;
1261 if ( ( (rho2 >= tolIRMin2) && (rho2 <= tolIRMax2) )
1262 || ( (rho2 > tolORMin2) && (rho2 < tolIRMin2)
1263 && ( v.y()*cosSPhi - v.x()*sinSPhi > 0 )
1264 && ( v.x()*cosSPhi + v.y()*sinSPhi >= 0 ) )
1265 || ( (rho2 > tolIRMax2) && (rho2 < tolORMax2)
1266 && (v.y()*cosSPhi - v.x()*sinSPhi > 0)
1267 && (v.x()*cosSPhi + v.y()*sinSPhi < 0) ) )
1268 {
1269 // z and r intersections good
1270 // - check intersecting with correct half-plane
1271 //
1272 if ((yi*cosCPhi-xi*sinCPhi) <= halfCarTolerance) { snxt = sd; }
1273 }
1274 } //two Z conditions
1275 }
1276 }
1277 }
1278 }
1279
1280 // Second phi surface (Ending phi)
1281 //
1282 Comp = -(v.x()*sinEPhi - v.y()*cosEPhi) ;
1283
1284 if (Comp < 0 ) // Component in outwards normal dirn
1285 {
1286 Dist = -(p.y()*cosEPhi - p.x()*sinEPhi) ;
1287
1288 if ( Dist < halfCarTolerance )
1289 {
1290 sd = Dist/Comp ;
1291
1292 if (sd < snxt)
1293 {
1294 if ( sd < 0 ) { sd = 0; }
1295 zi = p.z() + sd*v.z() ;
1296 xi = p.x() + sd*v.x() ;
1297 yi = p.y() + sd*v.y() ;
1298 if ((-xi*fLowNorm.x()-yi*fLowNorm.y()
1299 -(zi+fDz)*fLowNorm.z())>-halfCarTolerance)
1300 {
1301 if ((-xi*fHighNorm.x()-yi*fHighNorm.y()
1302 +(fDz-zi)*fHighNorm.z())>-halfCarTolerance)
1303 {
1304 xi = p.x() + sd*v.x() ;
1305 yi = p.y() + sd*v.y() ;
1306 rho2 = xi*xi + yi*yi ;
1307 if ( ( (rho2 >= tolIRMin2) && (rho2 <= tolIRMax2) )
1308 || ( (rho2 > tolORMin2) && (rho2 < tolIRMin2)
1309 && (v.x()*sinEPhi - v.y()*cosEPhi > 0)
1310 && (v.x()*cosEPhi + v.y()*sinEPhi >= 0) )
1311 || ( (rho2 > tolIRMax2) && (rho2 < tolORMax2)
1312 && (v.x()*sinEPhi - v.y()*cosEPhi > 0)
1313 && (v.x()*cosEPhi + v.y()*sinEPhi < 0) ) )
1314 {
1315 // z and r intersections good
1316 // - check intersecting with correct half-plane
1317 //
1318 if ( (yi*cosCPhi-xi*sinCPhi) >= -halfCarTolerance )
1319 {
1320 snxt = sd;
1321 }
1322 } //?? >=-halfCarTolerance
1323 }
1324 } // two Z conditions
1325 }
1326 }
1327 } // Comp < 0
1328 } // !fPhiFullTube
1329 if ( snxt<halfCarTolerance ) { snxt=0; }
1330
1331 return snxt ;
1332}
double dot(const Hep3Vector &) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Definition: G4CutTubs.cc:907

References cosCPhi, cosEPhi, cosHDPhiIT, cosSPhi, DistanceToIn(), CLHEP::Hep3Vector::dot(), fDz, fHighNorm, fLowNorm, fPhiFullCutTube, fRMax, fRMin, GetCutZ(), halfCarTolerance, halfRadTolerance, kInfinity, kRadTolerance, sinCPhi, sinEPhi, sinSPhi, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by DistanceToIn().

◆ DistanceToOut() [1/2]

G4double G4CutTubs::DistanceToOut ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 1853 of file G4CutTubs.cc.

1854{
1855 G4double safRMin,safRMax,safZLow,safZHigh,safePhi,safe,rho;
1857
1858 rho = std::sqrt(p.x()*p.x() + p.y()*p.y()) ; // Distance to R
1859
1860 safRMin = rho - fRMin ;
1861 safRMax = fRMax - rho ;
1862
1863 // Distances to ZCut(Low/High)
1864
1865 // Dist to Low Cut
1866 //
1867 safZLow = std::fabs((p+vZ).dot(fLowNorm));
1868
1869 // Dist to High Cut
1870 //
1871 safZHigh = std::fabs((p-vZ).dot(fHighNorm));
1872 safe = std::min(safZLow,safZHigh);
1873
1874 if ( safRMin < safe ) { safe = safRMin; }
1875 if ( safRMax< safe ) { safe = safRMax; }
1876
1877 // Check if phi divided, Calc distances closest phi plane
1878 //
1879 if ( !fPhiFullCutTube )
1880 {
1881 if ( p.y()*cosCPhi-p.x()*sinCPhi <= 0 )
1882 {
1883 safePhi = -(p.x()*sinSPhi - p.y()*cosSPhi) ;
1884 }
1885 else
1886 {
1887 safePhi = (p.x()*sinEPhi - p.y()*cosEPhi) ;
1888 }
1889 if (safePhi < safe) { safe = safePhi ; }
1890 }
1891 if ( safe < 0 ) { safe = 0; }
1892
1893 return safe ;
1894}

References cosCPhi, cosEPhi, cosSPhi, fDz, fHighNorm, fLowNorm, fPhiFullCutTube, fRMax, fRMin, G4INCL::Math::min(), sinCPhi, sinEPhi, sinSPhi, CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::y().

◆ DistanceToOut() [2/2]

G4double G4CutTubs::DistanceToOut ( const G4ThreeVector p,
const G4ThreeVector v,
const G4bool  calcNorm = false,
G4bool validNorm = nullptr,
G4ThreeVector n = nullptr 
) const
virtual

Implements G4VSolid.

Definition at line 1420 of file G4CutTubs.cc.

1425{
1427
1428 ESide side=kNull , sider=kNull, sidephi=kNull ;
1429 G4double snxt=kInfinity, srd=kInfinity,sz=kInfinity, sphi=kInfinity ;
1430 G4double deltaR, t1, t2, t3, b, c, d2, roMin2 ;
1431 G4double distZLow,distZHigh,calfH,calfL;
1433
1434 // Vars for phi intersection:
1435 //
1436 G4double pDistS, compS, pDistE, compE, sphi2, xi, yi, vphi, roi2 ;
1437
1438 // Z plane intersection
1439 // Distances to ZCut(Low/High)
1440
1441 // dist to Low Cut
1442 //
1443 distZLow =(p+vZ).dot(fLowNorm);
1444
1445 // dist to High Cut
1446 //
1447 distZHigh = (p-vZ).dot(fHighNorm);
1448
1449 calfH = v.dot(fHighNorm);
1450 calfL = v.dot(fLowNorm);
1451
1452 if (calfH > 0 )
1453 {
1454 if ( distZHigh < halfCarTolerance )
1455 {
1456 snxt = -distZHigh/calfH ;
1457 side = kPZ ;
1458 }
1459 else
1460 {
1461 if (calcNorm)
1462 {
1463 *n = G4ThreeVector(0,0,1) ;
1464 *validNorm = true ;
1465 }
1466 return snxt = 0 ;
1467 }
1468 }
1469 if ( calfL>0)
1470 {
1471
1472 if ( distZLow < halfCarTolerance )
1473 {
1474 sz = -distZLow/calfL ;
1475 if(sz<snxt){
1476 snxt=sz;
1477 side = kMZ ;
1478 }
1479
1480 }
1481 else
1482 {
1483 if (calcNorm)
1484 {
1485 *n = G4ThreeVector(0,0,-1) ;
1486 *validNorm = true ;
1487 }
1488 return snxt = 0.0 ;
1489 }
1490 }
1491 if((calfH<=0)&&(calfL<=0))
1492 {
1493 snxt = kInfinity ; // Travel perpendicular to z axis
1494 side = kNull;
1495 }
1496 // Radial Intersections
1497 //
1498 // Find intersection with cylinders at rmax/rmin
1499 // Intersection point (xi,yi,zi) on line x=p.x+t*v.x etc.
1500 //
1501 // Intersects with x^2+y^2=R^2
1502 //
1503 // Hence (v.x^2+v.y^2)t^2+ 2t(p.x*v.x+p.y*v.y)+p.x^2+p.y^2-R^2=0
1504 //
1505 // t1 t2 t3
1506
1507 t1 = 1.0 - v.z()*v.z() ; // since v normalised
1508 t2 = p.x()*v.x() + p.y()*v.y() ;
1509 t3 = p.x()*p.x() + p.y()*p.y() ;
1510
1511 if ( snxt > 10*(fDz+fRMax) ) { roi2 = 2*fRMax*fRMax; }
1512 else { roi2 = snxt*snxt*t1 + 2*snxt*t2 + t3; } // radius^2 on +-fDz
1513
1514 if ( t1 > 0 ) // Check not parallel
1515 {
1516 // Calculate srd, r exit distance
1517
1518 if ( (t2 >= 0.0) && (roi2 > fRMax*(fRMax + kRadTolerance)) )
1519 {
1520 // Delta r not negative => leaving via rmax
1521
1522 deltaR = t3 - fRMax*fRMax ;
1523
1524 // NOTE: Should use rho-fRMax<-kRadTolerance*0.5
1525 // - avoid sqrt for efficiency
1526
1527 if ( deltaR < -kRadTolerance*fRMax )
1528 {
1529 b = t2/t1 ;
1530 c = deltaR/t1 ;
1531 d2 = b*b-c;
1532 if( d2 >= 0 ) { srd = c/( -b - std::sqrt(d2)); }
1533 else { srd = 0.; }
1534 sider = kRMax ;
1535 }
1536 else
1537 {
1538 // On tolerant boundary & heading outwards (or perpendicular to)
1539 // outer radial surface -> leaving immediately
1540
1541 if ( calcNorm )
1542 {
1543 *n = G4ThreeVector(p.x()/fRMax,p.y()/fRMax,0) ;
1544 *validNorm = true ;
1545 }
1546 return snxt = 0 ; // Leaving by rmax immediately
1547 }
1548 }
1549 else if ( t2 < 0. ) // i.e. t2 < 0; Possible rmin intersection
1550 {
1551 roMin2 = t3 - t2*t2/t1 ; // min ro2 of the plane of movement
1552
1553 if ( fRMin && (roMin2 < fRMin*(fRMin - kRadTolerance)) )
1554 {
1555 deltaR = t3 - fRMin*fRMin ;
1556 b = t2/t1 ;
1557 c = deltaR/t1 ;
1558 d2 = b*b - c ;
1559
1560 if ( d2 >= 0 ) // Leaving via rmin
1561 {
1562 // NOTE: SHould use rho-rmin>kRadTolerance*0.5
1563 // - avoid sqrt for efficiency
1564
1565 if (deltaR > kRadTolerance*fRMin)
1566 {
1567 srd = c/(-b+std::sqrt(d2));
1568 sider = kRMin ;
1569 }
1570 else
1571 {
1572 if ( calcNorm ) { *validNorm = false; } // Concave side
1573 return snxt = 0.0;
1574 }
1575 }
1576 else // No rmin intersect -> must be rmax intersect
1577 {
1578 deltaR = t3 - fRMax*fRMax ;
1579 c = deltaR/t1 ;
1580 d2 = b*b-c;
1581 if( d2 >=0. )
1582 {
1583 srd = -b + std::sqrt(d2) ;
1584 sider = kRMax ;
1585 }
1586 else // Case: On the border+t2<kRadTolerance
1587 // (v is perpendicular to the surface)
1588 {
1589 if (calcNorm)
1590 {
1591 *n = G4ThreeVector(p.x()/fRMax,p.y()/fRMax,0) ;
1592 *validNorm = true ;
1593 }
1594 return snxt = 0.0;
1595 }
1596 }
1597 }
1598 else if ( roi2 > fRMax*(fRMax + kRadTolerance) )
1599 // No rmin intersect -> must be rmax intersect
1600 {
1601 deltaR = t3 - fRMax*fRMax ;
1602 b = t2/t1 ;
1603 c = deltaR/t1;
1604 d2 = b*b-c;
1605 if( d2 >= 0 )
1606 {
1607 srd = -b + std::sqrt(d2) ;
1608 sider = kRMax ;
1609 }
1610 else // Case: On the border+t2<kRadTolerance
1611 // (v is perpendicular to the surface)
1612 {
1613 if (calcNorm)
1614 {
1615 *n = G4ThreeVector(p.x()/fRMax,p.y()/fRMax,0) ;
1616 *validNorm = true ;
1617 }
1618 return snxt = 0.0;
1619 }
1620 }
1621 }
1622 // Phi Intersection
1623
1624 if ( !fPhiFullCutTube )
1625 {
1626 // add angle calculation with correction
1627 // of the difference in domain of atan2 and Sphi
1628 //
1629 vphi = std::atan2(v.y(),v.x()) ;
1630
1631 if ( vphi < fSPhi - halfAngTolerance ) { vphi += twopi; }
1632 else if ( vphi > fSPhi + fDPhi + halfAngTolerance ) { vphi -= twopi; }
1633
1634
1635 if ( p.x() || p.y() ) // Check if on z axis (rho not needed later)
1636 {
1637 // pDist -ve when inside
1638
1639 pDistS = p.x()*sinSPhi - p.y()*cosSPhi ;
1640 pDistE = -p.x()*sinEPhi + p.y()*cosEPhi ;
1641
1642 // Comp -ve when in direction of outwards normal
1643
1644 compS = -sinSPhi*v.x() + cosSPhi*v.y() ;
1645 compE = sinEPhi*v.x() - cosEPhi*v.y() ;
1646
1647 sidephi = kNull;
1648
1649 if( ( (fDPhi <= pi) && ( (pDistS <= halfCarTolerance)
1650 && (pDistE <= halfCarTolerance) ) )
1651 || ( (fDPhi > pi) && !((pDistS > halfCarTolerance)
1652 && (pDistE > halfCarTolerance) ) ) )
1653 {
1654 // Inside both phi *full* planes
1655
1656 if ( compS < 0 )
1657 {
1658 sphi = pDistS/compS ;
1659
1660 if (sphi >= -halfCarTolerance)
1661 {
1662 xi = p.x() + sphi*v.x() ;
1663 yi = p.y() + sphi*v.y() ;
1664
1665 // Check intersecting with correct half-plane
1666 // (if not -> no intersect)
1667 //
1668 if( (std::fabs(xi)<=kCarTolerance)
1669 && (std::fabs(yi)<=kCarTolerance) )
1670 {
1671 sidephi = kSPhi;
1672 if (((fSPhi-halfAngTolerance)<=vphi)
1673 &&((fSPhi+fDPhi+halfAngTolerance)>=vphi))
1674 {
1675 sphi = kInfinity;
1676 }
1677 }
1678 else if ( yi*cosCPhi-xi*sinCPhi >=0 )
1679 {
1680 sphi = kInfinity ;
1681 }
1682 else
1683 {
1684 sidephi = kSPhi ;
1685 if ( pDistS > -halfCarTolerance )
1686 {
1687 sphi = 0.0 ; // Leave by sphi immediately
1688 }
1689 }
1690 }
1691 else
1692 {
1693 sphi = kInfinity ;
1694 }
1695 }
1696 else
1697 {
1698 sphi = kInfinity ;
1699 }
1700
1701 if ( compE < 0 )
1702 {
1703 sphi2 = pDistE/compE ;
1704
1705 // Only check further if < starting phi intersection
1706 //
1707 if ( (sphi2 > -halfCarTolerance) && (sphi2 < sphi) )
1708 {
1709 xi = p.x() + sphi2*v.x() ;
1710 yi = p.y() + sphi2*v.y() ;
1711
1712 if ((std::fabs(xi)<=kCarTolerance)&&(std::fabs(yi)<=kCarTolerance))
1713 {
1714 // Leaving via ending phi
1715 //
1716 if( !((fSPhi-halfAngTolerance <= vphi)
1717 &&(fSPhi+fDPhi+halfAngTolerance >= vphi)) )
1718 {
1719 sidephi = kEPhi ;
1720 if ( pDistE <= -halfCarTolerance ) { sphi = sphi2 ; }
1721 else { sphi = 0.0 ; }
1722 }
1723 }
1724 else // Check intersecting with correct half-plane
1725
1726 if ( (yi*cosCPhi-xi*sinCPhi) >= 0)
1727 {
1728 // Leaving via ending phi
1729 //
1730 sidephi = kEPhi ;
1731 if ( pDistE <= -halfCarTolerance ) { sphi = sphi2 ; }
1732 else { sphi = 0.0 ; }
1733 }
1734 }
1735 }
1736 }
1737 else
1738 {
1739 sphi = kInfinity ;
1740 }
1741 }
1742 else
1743 {
1744 // On z axis + travel not || to z axis -> if phi of vector direction
1745 // within phi of shape, Step limited by rmax, else Step =0
1746
1747 if ( (fSPhi - halfAngTolerance <= vphi)
1748 && (vphi <= fSPhi + fDPhi + halfAngTolerance ) )
1749 {
1750 sphi = kInfinity ;
1751 }
1752 else
1753 {
1754 sidephi = kSPhi ; // arbitrary
1755 sphi = 0.0 ;
1756 }
1757 }
1758 if (sphi < snxt) // Order intersecttions
1759 {
1760 snxt = sphi ;
1761 side = sidephi ;
1762 }
1763 }
1764 if (srd < snxt) // Order intersections
1765 {
1766 snxt = srd ;
1767 side = sider ;
1768 }
1769 }
1770 if (calcNorm)
1771 {
1772 switch(side)
1773 {
1774 case kRMax:
1775 // Note: returned vector not normalised
1776 // (divide by fRMax for unit vector)
1777 //
1778 xi = p.x() + snxt*v.x() ;
1779 yi = p.y() + snxt*v.y() ;
1780 *n = G4ThreeVector(xi/fRMax,yi/fRMax,0) ;
1781 *validNorm = true ;
1782 break ;
1783
1784 case kRMin:
1785 *validNorm = false ; // Rmin is inconvex
1786 break ;
1787
1788 case kSPhi:
1789 if ( fDPhi <= pi )
1790 {
1792 *validNorm = true ;
1793 }
1794 else
1795 {
1796 *validNorm = false ;
1797 }
1798 break ;
1799
1800 case kEPhi:
1801 if (fDPhi <= pi)
1802 {
1804 *validNorm = true ;
1805 }
1806 else
1807 {
1808 *validNorm = false ;
1809 }
1810 break ;
1811
1812 case kPZ:
1813 *n = fHighNorm ;
1814 *validNorm = true ;
1815 break ;
1816
1817 case kMZ:
1818 *n = fLowNorm ;
1819 *validNorm = true ;
1820 break ;
1821
1822 default:
1823 G4cout << G4endl ;
1824 DumpInfo();
1825 std::ostringstream message;
1826 G4int oldprc = message.precision(16);
1827 message << "Undefined side for valid surface normal to solid."
1828 << G4endl
1829 << "Position:" << G4endl << G4endl
1830 << "p.x() = " << p.x()/mm << " mm" << G4endl
1831 << "p.y() = " << p.y()/mm << " mm" << G4endl
1832 << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl
1833 << "Direction:" << G4endl << G4endl
1834 << "v.x() = " << v.x() << G4endl
1835 << "v.y() = " << v.y() << G4endl
1836 << "v.z() = " << v.z() << G4endl << G4endl
1837 << "Proposed distance :" << G4endl << G4endl
1838 << "snxt = " << snxt/mm << " mm" << G4endl ;
1839 message.precision(oldprc) ;
1840 G4Exception("G4CutTubs::DistanceToOut(p,v,..)", "GeomSolids1002",
1841 JustWarning, message);
1842 break ;
1843 }
1844 }
1845 if ( snxt<halfCarTolerance ) { snxt=0 ; }
1846 return snxt ;
1847}
ESide
Definition: G4Cons.cc:61
@ kPZ
Definition: G4Cons.cc:61
@ kRMax
Definition: G4Cons.cc:61
@ kNull
Definition: G4Cons.cc:61
@ kSPhi
Definition: G4Cons.cc:61
@ kRMin
Definition: G4Cons.cc:61
@ kEPhi
Definition: G4Cons.cc:61
@ kMZ
Definition: G4Cons.cc:61
static const G4double d2
G4GLOB_DLL std::ostream G4cout

References cosCPhi, cosEPhi, cosSPhi, d2, CLHEP::Hep3Vector::dot(), G4VSolid::DumpInfo(), fDPhi, fDz, fHighNorm, fLowNorm, fPhiFullCutTube, fRMax, fRMin, fSPhi, G4cout, G4endl, G4Exception(), halfAngTolerance, halfCarTolerance, JustWarning, G4VSolid::kCarTolerance, kEPhi, kInfinity, kMZ, kNull, kPZ, kRadTolerance, kRMax, kRMin, kSPhi, mm, CLHEP::detail::n, pi, sinCPhi, sinEPhi, sinSPhi, twopi, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ DumpInfo()

void G4VSolid::DumpInfo ( ) const
inlineinherited

Referenced by G4Cons::ApproxSurfaceNormal(), ApproxSurfaceNormal(), G4Sphere::ApproxSurfaceNormal(), G4Torus::ApproxSurfaceNormal(), G4Tubs::ApproxSurfaceNormal(), G4ReflectedSolid::BoundingLimits(), G4DisplacedSolid::BoundingLimits(), G4IntersectionSolid::BoundingLimits(), G4ScaledSolid::BoundingLimits(), G4SubtractionSolid::BoundingLimits(), G4UnionSolid::BoundingLimits(), G4Box::BoundingLimits(), G4Cons::BoundingLimits(), BoundingLimits(), G4Orb::BoundingLimits(), G4Para::BoundingLimits(), G4Sphere::BoundingLimits(), G4Torus::BoundingLimits(), G4Trap::BoundingLimits(), G4Trd::BoundingLimits(), G4Tubs::BoundingLimits(), G4EllipticalCone::BoundingLimits(), G4ExtrudedSolid::BoundingLimits(), G4GenericPolycone::BoundingLimits(), G4GenericTrap::BoundingLimits(), G4Hype::BoundingLimits(), G4Paraboloid::BoundingLimits(), G4Polycone::BoundingLimits(), G4Polyhedra::BoundingLimits(), G4TessellatedSolid::BoundingLimits(), G4TwistedTubs::BoundingLimits(), G4ParameterisationBoxX::ComputeDimensions(), G4ParameterisationBoxY::ComputeDimensions(), G4ParameterisationBoxZ::ComputeDimensions(), G4ParameterisationConsRho::ComputeDimensions(), G4ParameterisationConsPhi::ComputeDimensions(), G4ParameterisationConsZ::ComputeDimensions(), G4ParameterisationParaX::ComputeDimensions(), G4ParameterisationParaY::ComputeDimensions(), G4ParameterisationParaZ::ComputeDimensions(), G4ParameterisationPolyconeRho::ComputeDimensions(), G4ParameterisationPolyconePhi::ComputeDimensions(), G4ParameterisationPolyconeZ::ComputeDimensions(), G4ParameterisationPolyhedraRho::ComputeDimensions(), G4ParameterisationPolyhedraPhi::ComputeDimensions(), G4ParameterisationPolyhedraZ::ComputeDimensions(), G4ParameterisationTrdX::ComputeDimensions(), G4ParameterisationTrdY::ComputeDimensions(), G4ParameterisationTrdZ::ComputeDimensions(), G4ParameterisationTubsRho::ComputeDimensions(), G4ParameterisationTubsPhi::ComputeDimensions(), G4ParameterisationTubsZ::ComputeDimensions(), G4ReflectedSolid::ComputeDimensions(), G4DisplacedSolid::ComputeDimensions(), G4ScaledSolid::ComputeDimensions(), G4ParameterisedNavigation::ComputeStep(), G4ReplicaNavigation::ComputeStep(), G4DisplacedSolid::CreatePolyhedron(), G4ScaledSolid::CreatePolyhedron(), G4SubtractionSolid::DistanceToIn(), G4Box::DistanceToOut(), G4Orb::DistanceToOut(), G4Para::DistanceToOut(), G4Trap::DistanceToOut(), G4Trd::DistanceToOut(), G4Paraboloid::DistanceToOut(), G4VTwistedFaceted::DistanceToOut(), G4Cons::DistanceToOut(), DistanceToOut(), G4Sphere::DistanceToOut(), G4Torus::DistanceToOut(), G4Tubs::DistanceToOut(), G4Ellipsoid::DistanceToOut(), G4EllipticalCone::DistanceToOut(), G4EllipticalTube::DistanceToOut(), G4GenericTrap::DistanceToOut(), export_G4VSolid(), G4Polycone::G4Polycone(), G4Polyhedra::G4Polyhedra(), G4BooleanSolid::GetConstituentSolid(), G4NavigationLogger::PostComputeStepLog(), G4Box::SurfaceNormal(), G4Para::SurfaceNormal(), G4Trap::SurfaceNormal(), G4Trd::SurfaceNormal(), G4Ellipsoid::SurfaceNormal(), G4EllipticalCone::SurfaceNormal(), G4EllipticalTube::SurfaceNormal(), G4ExtrudedSolid::SurfaceNormal(), and G4Tet::SurfaceNormal().

◆ EstimateCubicVolume()

G4double G4VSolid::EstimateCubicVolume ( G4int  nStat,
G4double  epsilon 
) const
inherited

Definition at line 203 of file G4VSolid.cc.

204{
205 G4int iInside=0;
206 G4double px,py,pz,minX,maxX,minY,maxY,minZ,maxZ,volume,halfepsilon;
208 EInside in;
209
210 // values needed for CalculateExtent signature
211
212 G4VoxelLimits limit; // Unlimited
213 G4AffineTransform origin;
214
215 // min max extents of pSolid along X,Y,Z
216
217 CalculateExtent(kXAxis,limit,origin,minX,maxX);
218 CalculateExtent(kYAxis,limit,origin,minY,maxY);
219 CalculateExtent(kZAxis,limit,origin,minZ,maxZ);
220
221 // limits
222
223 if(nStat < 100) nStat = 100;
224 if(epsilon > 0.01) epsilon = 0.01;
225 halfepsilon = 0.5*epsilon;
226
227 for(auto i = 0; i < nStat; ++i )
228 {
229 px = minX-halfepsilon+(maxX-minX+epsilon)*G4QuickRand();
230 py = minY-halfepsilon+(maxY-minY+epsilon)*G4QuickRand();
231 pz = minZ-halfepsilon+(maxZ-minZ+epsilon)*G4QuickRand();
232 p = G4ThreeVector(px,py,pz);
233 in = Inside(p);
234 if(in != kOutside) ++iInside;
235 }
236 volume = (maxX-minX+epsilon)*(maxY-minY+epsilon)
237 * (maxZ-minZ+epsilon)*iInside/nStat;
238 return volume;
239}
G4double epsilon(G4double density, G4double temperature)
static const G4int maxZ
G4double G4QuickRand()
Definition: G4QuickRand.hh:34
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const =0
virtual EInside Inside(const G4ThreeVector &p) const =0
EInside
Definition: geomdefs.hh:67
@ kOutside
Definition: geomdefs.hh:68

References G4VSolid::CalculateExtent(), epsilon(), G4QuickRand(), G4VSolid::Inside(), kOutside, kXAxis, kYAxis, kZAxis, and maxZ.

Referenced by G4VSolid::GetCubicVolume(), G4BooleanSolid::GetCubicVolume(), and G4VCSGfaceted::GetCubicVolume().

◆ EstimateSurfaceArea()

G4double G4VSolid::EstimateSurfaceArea ( G4int  nStat,
G4double  ell 
) const
inherited

Definition at line 265 of file G4VSolid.cc.

266{
267 static const G4double s2 = 1./std::sqrt(2.);
268 static const G4double s3 = 1./std::sqrt(3.);
269 static const G4ThreeVector directions[64] =
270 {
271 G4ThreeVector( 0, 0, 0), G4ThreeVector( -1, 0, 0), // ( , , ) ( -, , )
272 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +, , ) (-+, , )
273 G4ThreeVector( 0, -1, 0), G4ThreeVector(-s2,-s2, 0), // ( , -, ) ( -, -, )
274 G4ThreeVector( s2, -s2, 0), G4ThreeVector( 0, -1, 0), // ( +, -, ) (-+, -, )
275
276 G4ThreeVector( 0, 1, 0), G4ThreeVector( -s2, s2, 0), // ( , +, ) ( -, +, )
277 G4ThreeVector( s2, s2, 0), G4ThreeVector( 0, 1, 0), // ( +, +, ) (-+, +, )
278 G4ThreeVector( 0, -1, 0), G4ThreeVector( -1, 0, 0), // ( ,-+, ) ( -,-+, )
279 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +,-+, ) (-+,-+, )
280
281 G4ThreeVector( 0, 0, -1), G4ThreeVector(-s2, 0,-s2), // ( , , -) ( -, , -)
282 G4ThreeVector( s2, 0,-s2), G4ThreeVector( 0, 0, -1), // ( +, , -) (-+, , -)
283 G4ThreeVector( 0,-s2,-s2), G4ThreeVector(-s3,-s3,-s3), // ( , -, -) ( -, -, -)
284 G4ThreeVector( s3,-s3,-s3), G4ThreeVector( 0,-s2,-s2), // ( +, -, -) (-+, -, -)
285
286 G4ThreeVector( 0, s2,-s2), G4ThreeVector(-s3, s3,-s3), // ( , +, -) ( -, +, -)
287 G4ThreeVector( s3, s3,-s3), G4ThreeVector( 0, s2,-s2), // ( +, +, -) (-+, +, -)
288 G4ThreeVector( 0, 0, -1), G4ThreeVector(-s2, 0,-s2), // ( ,-+, -) ( -,-+, -)
289 G4ThreeVector( s2, 0,-s2), G4ThreeVector( 0, 0, -1), // ( +,-+, -) (-+,-+, -)
290
291 G4ThreeVector( 0, 0, 1), G4ThreeVector(-s2, 0, s2), // ( , , +) ( -, , +)
292 G4ThreeVector( s2, 0, s2), G4ThreeVector( 0, 0, 1), // ( +, , +) (-+, , +)
293 G4ThreeVector( 0,-s2, s2), G4ThreeVector(-s3,-s3, s3), // ( , -, +) ( -, -, +)
294 G4ThreeVector( s3,-s3, s3), G4ThreeVector( 0,-s2, s2), // ( +, -, +) (-+, -, +)
295
296 G4ThreeVector( 0, s2, s2), G4ThreeVector(-s3, s3, s3), // ( , +, +) ( -, +, +)
297 G4ThreeVector( s3, s3, s3), G4ThreeVector( 0, s2, s2), // ( +, +, +) (-+, +, +)
298 G4ThreeVector( 0, 0, 1), G4ThreeVector(-s2, 0, s2), // ( ,-+, +) ( -,-+, +)
299 G4ThreeVector( s2, 0, s2), G4ThreeVector( 0, 0, 1), // ( +,-+, +) (-+,-+, +)
300
301 G4ThreeVector( 0, 0, -1), G4ThreeVector( -1, 0, 0), // ( , ,-+) ( -, ,-+)
302 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +, ,-+) (-+, ,-+)
303 G4ThreeVector( 0, -1, 0), G4ThreeVector(-s2,-s2, 0), // ( , -,-+) ( -, -,-+)
304 G4ThreeVector( s2, -s2, 0), G4ThreeVector( 0, -1, 0), // ( +, -,-+) (-+, -,-+)
305
306 G4ThreeVector( 0, 1, 0), G4ThreeVector( -s2, s2, 0), // ( , +,-+) ( -, +,-+)
307 G4ThreeVector( s2, s2, 0), G4ThreeVector( 0, 1, 0), // ( +, +,-+) (-+, +,-+)
308 G4ThreeVector( 0, -1, 0), G4ThreeVector( -1, 0, 0), // ( ,-+,-+) ( -,-+,-+)
309 G4ThreeVector( 1, 0, 0), G4ThreeVector( -1, 0, 0), // ( +,-+,-+) (-+,-+,-+)
310 };
311
312 G4ThreeVector bmin, bmax;
313 BoundingLimits(bmin, bmax);
314
315 G4double dX = bmax.x() - bmin.x();
316 G4double dY = bmax.y() - bmin.y();
317 G4double dZ = bmax.z() - bmin.z();
318
319 // Define statistics and shell thickness
320 //
321 G4int npoints = (nstat < 1000) ? 1000 : nstat;
322 G4double coeff = 0.5 / std::cbrt(G4double(npoints));
323 G4double eps = (ell > 0) ? ell : coeff * std::min(std::min(dX, dY), dZ);
324 G4double del = 1.8 * eps; // shold be more than sqrt(3.)
325
326 G4double minX = bmin.x() - eps;
327 G4double minY = bmin.y() - eps;
328 G4double minZ = bmin.z() - eps;
329
330 G4double dd = 2. * eps;
331 dX += dd;
332 dY += dd;
333 dZ += dd;
334
335 // Calculate surface area
336 //
337 G4int icount = 0;
338 for(auto i = 0; i < npoints; ++i)
339 {
340 G4double px = minX + dX*G4QuickRand();
341 G4double py = minY + dY*G4QuickRand();
342 G4double pz = minZ + dZ*G4QuickRand();
343 G4ThreeVector p = G4ThreeVector(px, py, pz);
344 EInside in = Inside(p);
345 G4double dist = 0;
346 if (in == kInside)
347 {
348 if (DistanceToOut(p) >= eps) continue;
349 G4int icase = 0;
350 if (Inside(G4ThreeVector(px-del, py, pz)) != kInside) icase += 1;
351 if (Inside(G4ThreeVector(px+del, py, pz)) != kInside) icase += 2;
352 if (Inside(G4ThreeVector(px, py-del, pz)) != kInside) icase += 4;
353 if (Inside(G4ThreeVector(px, py+del, pz)) != kInside) icase += 8;
354 if (Inside(G4ThreeVector(px, py, pz-del)) != kInside) icase += 16;
355 if (Inside(G4ThreeVector(px, py, pz+del)) != kInside) icase += 32;
356 if (icase == 0) continue;
357 G4ThreeVector v = directions[icase];
358 dist = DistanceToOut(p, v);
359 G4ThreeVector n = SurfaceNormal(p + v*dist);
360 dist *= v.dot(n);
361 }
362 else if (in == kOutside)
363 {
364 if (DistanceToIn(p) >= eps) continue;
365 G4int icase = 0;
366 if (Inside(G4ThreeVector(px-del, py, pz)) != kOutside) icase += 1;
367 if (Inside(G4ThreeVector(px+del, py, pz)) != kOutside) icase += 2;
368 if (Inside(G4ThreeVector(px, py-del, pz)) != kOutside) icase += 4;
369 if (Inside(G4ThreeVector(px, py+del, pz)) != kOutside) icase += 8;
370 if (Inside(G4ThreeVector(px, py, pz-del)) != kOutside) icase += 16;
371 if (Inside(G4ThreeVector(px, py, pz+del)) != kOutside) icase += 32;
372 if (icase == 0) continue;
373 G4ThreeVector v = directions[icase];
374 dist = DistanceToIn(p, v);
375 if (dist == kInfinity) continue;
376 G4ThreeVector n = SurfaceNormal(p + v*dist);
377 dist *= -(v.dot(n));
378 }
379 if (dist < eps) ++icount;
380 }
381 return dX*dY*dZ*icount/npoints/dd;
382}
static const G4double eps
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Definition: G4VSolid.cc:665
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
@ kInside
Definition: geomdefs.hh:70

References G4VSolid::BoundingLimits(), G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), CLHEP::Hep3Vector::dot(), eps, G4QuickRand(), G4VSolid::Inside(), kInfinity, kInside, kOutside, G4INCL::Math::min(), CLHEP::detail::n, G4VSolid::SurfaceNormal(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by G4VSolid::GetSurfaceArea(), G4MultiUnion::GetSurfaceArea(), and G4VCSGfaceted::GetSurfaceArea().

◆ GetConstituentSolid() [1/2]

G4VSolid * G4VSolid::GetConstituentSolid ( G4int  no)
virtualinherited

Reimplemented in G4BooleanSolid.

Definition at line 170 of file G4VSolid.cc.

171{ return nullptr; }

◆ GetConstituentSolid() [2/2]

const G4VSolid * G4VSolid::GetConstituentSolid ( G4int  no) const
virtualinherited

Reimplemented in G4BooleanSolid.

Definition at line 167 of file G4VSolid.cc.

168{ return nullptr; }

Referenced by G4BooleanSolid::StackPolyhedron().

◆ GetCosEndPhi()

G4double G4CutTubs::GetCosEndPhi ( ) const
inline

Referenced by BoundingLimits(), and CalculateExtent().

◆ GetCosStartPhi()

G4double G4CutTubs::GetCosStartPhi ( ) const
inline

◆ GetCubicVolume()

G4double G4CutTubs::GetCubicVolume ( )
virtual

Reimplemented from G4VSolid.

Definition at line 245 of file G4CutTubs.cc.

246{
247 constexpr G4int nphi = 200, nrho = 100;
248
249 if (fCubicVolume == 0.)
250 {
251 // get parameters
252 G4double rmin = GetInnerRadius();
253 G4double rmax = GetOuterRadius();
255 G4double sphi = GetStartPhiAngle();
256 G4double dphi = GetDeltaPhiAngle();
257
258 // calculate volume
259 G4double volume = dz*dphi*(rmax*rmax - rmin*rmin);
260 if (dphi < twopi) // make recalculation
261 {
262 // set values for calculation of h - distance between
263 // opposite points on bases
264 G4ThreeVector nbot = GetLowNorm();
265 G4ThreeVector ntop = GetHighNorm();
266 G4double nx = nbot.x()/nbot.z() - ntop.x()/ntop.z();
267 G4double ny = nbot.y()/nbot.z() - ntop.y()/ntop.z();
268
269 // compute volume by integration
270 G4double delrho = (rmax - rmin)/nrho;
271 G4double delphi = dphi/nphi;
272 volume = 0.;
273 for (G4int irho=0; irho<nrho; ++irho)
274 {
275 G4double r1 = rmin + delrho*irho;
276 G4double r2 = rmin + delrho*(irho + 1);
277 G4double rho = 0.5*(r1 + r2);
278 G4double sector = 0.5*delphi*(r2*r2 - r1*r1);
279 for (G4int iphi=0; iphi<nphi; ++iphi)
280 {
281 G4double phi = sphi + delphi*(iphi + 0.5);
282 G4double h = nx*rho*std::cos(phi) + ny*rho*std::sin(phi) + 2.*dz;
283 volume += sector*h;
284 }
285 }
286 }
287 fCubicVolume = volume;
288 }
289 return fCubicVolume;
290}
G4double fCubicVolume
Definition: G4CSGSolid.hh:70
G4double GetStartPhiAngle() const

References G4CSGSolid::fCubicVolume, GetDeltaPhiAngle(), GetHighNorm(), GetInnerRadius(), GetLowNorm(), GetOuterRadius(), GetStartPhiAngle(), GetZHalfLength(), twopi, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ GetCutZ()

G4double G4CutTubs::GetCutZ ( const G4ThreeVector p) const
protected

Definition at line 2163 of file G4CutTubs.cc.

2164{
2165 G4double newz = p.z(); // p.z() should be either +fDz or -fDz
2166 if (p.z()<0)
2167 {
2168 if(fLowNorm.z()!=0.)
2169 {
2170 newz = -fDz-(p.x()*fLowNorm.x()+p.y()*fLowNorm.y())/fLowNorm.z();
2171 }
2172 }
2173 else
2174 {
2175 if(fHighNorm.z()!=0.)
2176 {
2177 newz = fDz-(p.x()*fHighNorm.x()+p.y()*fHighNorm.y())/fHighNorm.z();
2178 }
2179 }
2180 return newz;
2181}

References fDz, fHighNorm, fLowNorm, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by CreatePolyhedron(), and DistanceToIn().

◆ GetDeltaPhiAngle()

G4double G4CutTubs::GetDeltaPhiAngle ( ) const
inline

◆ GetDisplacedSolidPtr() [1/2]

G4DisplacedSolid * G4VSolid::GetDisplacedSolidPtr ( )
virtualinherited

Reimplemented in G4DisplacedSolid.

Definition at line 176 of file G4VSolid.cc.

177{ return nullptr; }

◆ GetDisplacedSolidPtr() [2/2]

const G4DisplacedSolid * G4VSolid::GetDisplacedSolidPtr ( ) const
virtualinherited

Reimplemented in G4DisplacedSolid.

Definition at line 173 of file G4VSolid.cc.

174{ return nullptr; }

◆ GetEntityType()

G4GeometryType G4CutTubs::GetEntityType ( ) const
virtual

Implements G4VSolid.

Definition at line 1900 of file G4CutTubs.cc.

1901{
1902 return G4String("G4CutTubs");
1903}

◆ GetExtent()

G4VisExtent G4VSolid::GetExtent ( ) const
virtualinherited

Reimplemented in G4Box, G4Orb, G4Sphere, G4Ellipsoid, G4EllipticalCone, G4EllipticalTube, G4GenericTrap, G4Hype, G4TessellatedSolid, G4Tet, G4TwistedTubs, G4VCSGfaceted, and G4VTwistedFaceted.

Definition at line 682 of file G4VSolid.cc.

683{
684 G4VisExtent extent;
685 G4VoxelLimits voxelLimits; // Defaults to "infinite" limits.
686 G4AffineTransform affineTransform;
687 G4double vmin, vmax;
688 CalculateExtent(kXAxis,voxelLimits,affineTransform,vmin,vmax);
689 extent.SetXmin (vmin);
690 extent.SetXmax (vmax);
691 CalculateExtent(kYAxis,voxelLimits,affineTransform,vmin,vmax);
692 extent.SetYmin (vmin);
693 extent.SetYmax (vmax);
694 CalculateExtent(kZAxis,voxelLimits,affineTransform,vmin,vmax);
695 extent.SetZmin (vmin);
696 extent.SetZmax (vmax);
697 return extent;
698}
void SetYmin(G4double ymin)
Definition: G4VisExtent.hh:114
void SetYmax(G4double ymax)
Definition: G4VisExtent.hh:116
void SetXmax(G4double xmax)
Definition: G4VisExtent.hh:112
void SetXmin(G4double xmin)
Definition: G4VisExtent.hh:110
void SetZmax(G4double zmax)
Definition: G4VisExtent.hh:120
void SetZmin(G4double zmin)
Definition: G4VisExtent.hh:118

References G4VSolid::CalculateExtent(), kXAxis, kYAxis, kZAxis, G4VisExtent::SetXmax(), G4VisExtent::SetXmin(), G4VisExtent::SetYmax(), G4VisExtent::SetYmin(), G4VisExtent::SetZmax(), and G4VisExtent::SetZmin().

Referenced by G4tgbVolume::BuildSolidForDivision(), G4BoundingExtentScene::ProcessVolume(), G4BoundingSphereScene::ProcessVolume(), and G4VisCommandsTouchable::SetNewValue().

◆ GetHighNorm()

G4ThreeVector G4CutTubs::GetHighNorm ( ) const
inline

◆ GetInnerRadius()

G4double G4CutTubs::GetInnerRadius ( ) const
inline

◆ GetLowNorm()

G4ThreeVector G4CutTubs::GetLowNorm ( ) const
inline

◆ GetName()

G4String G4VSolid::GetName ( ) const
inlineinherited

Referenced by G4GMocrenFileSceneHandler::AddDetector(), G4HepRepFileSceneHandler::AddHepRepInstance(), G4GMocrenFileSceneHandler::AddPrimitive(), G4HepRepFileSceneHandler::AddSolid(), G4GMocrenFileSceneHandler::AddSolid(), G4VtkSceneHandler::AddSolid(), G4GDMLWriteSolids::AddSolid(), G4NavigationLogger::AlongComputeStepLog(), G4GDMLWriteSolids::BooleanWrite(), G4ReflectedSolid::BoundingLimits(), G4DisplacedSolid::BoundingLimits(), G4IntersectionSolid::BoundingLimits(), G4ScaledSolid::BoundingLimits(), G4SubtractionSolid::BoundingLimits(), G4UnionSolid::BoundingLimits(), G4Box::BoundingLimits(), G4Cons::BoundingLimits(), BoundingLimits(), G4Orb::BoundingLimits(), G4Para::BoundingLimits(), G4Sphere::BoundingLimits(), G4Torus::BoundingLimits(), G4Trap::BoundingLimits(), G4Trd::BoundingLimits(), G4Tubs::BoundingLimits(), G4EllipticalCone::BoundingLimits(), G4ExtrudedSolid::BoundingLimits(), G4GenericPolycone::BoundingLimits(), G4GenericTrap::BoundingLimits(), G4Hype::BoundingLimits(), G4Paraboloid::BoundingLimits(), G4Polycone::BoundingLimits(), G4Polyhedra::BoundingLimits(), G4TessellatedSolid::BoundingLimits(), G4TwistedTubs::BoundingLimits(), G4GDMLWriteSolids::BoxWrite(), G4ExtrudedSolid::CalculateExtent(), G4GenericPolycone::CalculateExtent(), G4Polycone::CalculateExtent(), G4Polyhedra::CalculateExtent(), G4NavigationLogger::CheckDaughterEntryPoint(), G4VDivisionParameterisation::CheckNDivAndWidth(), G4VDivisionParameterisation::CheckOffset(), G4GenericTrap::CheckOrder(), G4Para::CheckParameters(), G4Trap::CheckParameters(), G4Trd::CheckParameters(), G4Ellipsoid::CheckParameters(), G4EllipticalTube::CheckParameters(), G4ParameterisationPolyconeRho::CheckParametersValidity(), G4ParameterisationPolyconeZ::CheckParametersValidity(), G4ParameterisationPolyhedraRho::CheckParametersValidity(), G4ParameterisationPolyhedraPhi::CheckParametersValidity(), G4ParameterisationPolyhedraZ::CheckParametersValidity(), G4PhantomParameterisation::CheckVoxelsFillContainer(), G4GenericTrap::ComputeIsTwisted(), G4VoxelNavigation::ComputeSafety(), G4VoxelSafety::ComputeSafety(), G4NavigationLogger::ComputeSafetyLog(), G4ParameterisedNavigation::ComputeStep(), G4ReplicaNavigation::ComputeStep(), G4GDMLWriteSolids::ConeWrite(), G4Polyhedra::Create(), G4GenericPolycone::Create(), G4Polycone::Create(), G4PhysicalVolumeModel::CreateCurrentAttValues(), G4ReflectedSolid::CreatePolyhedron(), G4ReflectionFactory::CreateReflectedLV(), G4GenericTrap::CreateTessellatedSolid(), G4GDMLWriteSolids::CutTubeWrite(), G4SolidStore::DeRegister(), G4PhysicalVolumeModel::DescribeSolid(), G4SubtractionSolid::DistanceToIn(), G4Paraboloid::DistanceToIn(), G4TessellatedSolid::DistanceToIn(), G4Box::DistanceToOut(), G4Orb::DistanceToOut(), G4Para::DistanceToOut(), G4Trap::DistanceToOut(), G4Trd::DistanceToOut(), G4EllipticalCone::DistanceToOut(), G4TessellatedSolid::DistanceToOut(), G4Ellipsoid::DistanceToOut(), G4EllipticalTube::DistanceToOut(), G4tgbGeometryDumper::DumpMultiUnionVolume(), G4tgbGeometryDumper::DumpScaledVolume(), G4tgbGeometryDumper::DumpSolid(), G4GDMLWriteSolids::ElconeWrite(), G4GDMLWriteSolids::EllipsoidWrite(), G4GDMLWriteSolids::EltubeWrite(), G4PVDivision::ErrorInAxis(), G4ReplicatedSlice::ErrorInAxis(), export_G4VSolid(), G4Box::G4Box(), G4Cons::G4Cons(), G4CutTubs(), G4EllipticalCone::G4EllipticalCone(), G4Hype::G4Hype(), G4Para::G4Para(), G4Paraboloid::G4Paraboloid(), G4Polycone::G4Polycone(), G4Polyhedra::G4Polyhedra(), G4Sphere::G4Sphere(), G4Tet::G4Tet(), G4Trap::G4Trap(), G4Tubs::G4Tubs(), G4VParameterisationCons::G4VParameterisationCons(), G4VParameterisationPara::G4VParameterisationPara(), G4VParameterisationPolycone::G4VParameterisationPolycone(), G4VParameterisationPolyhedra::G4VParameterisationPolyhedra(), G4VParameterisationTrd::G4VParameterisationTrd(), G4VTwistedFaceted::G4VTwistedFaceted(), G4GDMLWriteSolids::GenericPolyconeWrite(), G4GDMLWriteSolids::GenTrapWrite(), G4Navigator::GetGlobalExitNormal(), G4Navigator::GetLocalExitNormal(), G4ITNavigator1::GetLocalExitNormal(), G4ITNavigator2::GetLocalExitNormal(), G4BooleanSolid::GetPointOnSurface(), G4PhantomParameterisation::GetReplicaNo(), G4GDMLWriteSolids::HypeWrite(), G4TessellatedSolid::InsideNoVoxels(), G4TessellatedSolid::InsideVoxels(), G4ITNavigator1::LocateGlobalPointAndSetup(), G4ITNavigator2::LocateGlobalPointAndSetup(), G4Navigator::LocateGlobalPointAndSetup(), G4GenericTrap::MakeDownFacet(), G4Trap::MakePlanes(), G4GenericTrap::MakeUpFacet(), G4GDMLWriteSolids::MultiUnionWrite(), G4GDMLWriteSolids::OrbWrite(), G4GDMLWriteSolids::ParaboloidWrite(), G4GDMLWriteParamvol::ParametersWrite(), G4GDMLWriteSolids::ParaWrite(), G4GDMLWriteSolids::PolyconeWrite(), G4GDMLWriteSolids::PolyhedraWrite(), G4NavigationLogger::PostComputeStepLog(), G4NavigationLogger::PreComputeStepLog(), G4NavigationLogger::PrintDaughterLog(), G4PseudoScene::ProcessVolume(), G4SolidStore::Register(), G4tgbVolumeMgr::RegisterMe(), G4NavigationLogger::ReportOutsideMother(), G4ASCIITreeSceneHandler::RequestPrimitives(), G4VSceneHandler::RequestPrimitives(), G4GenericPolycone::Reset(), G4Polyhedra::Reset(), G4VoxelSafety::SafetyForVoxelNode(), G4GDMLWriteSolids::ScaledWrite(), G4Torus::SetAllParameters(), G4Tet::SetBoundingLimits(), G4Polycone::SetOriginalParameters(), G4Polyhedra::SetOriginalParameters(), G4TessellatedSolid::SetSolidClosed(), G4Tet::SetVertices(), G4Box::SetXHalfLength(), G4Box::SetYHalfLength(), G4Box::SetZHalfLength(), G4GDMLWriteSolids::SphereWrite(), G4BooleanSolid::StackPolyhedron(), G4ReflectedSolid::StreamInfo(), G4BooleanSolid::StreamInfo(), G4DisplacedSolid::StreamInfo(), G4MultiUnion::StreamInfo(), G4ScaledSolid::StreamInfo(), G4Box::StreamInfo(), G4Cons::StreamInfo(), G4CSGSolid::StreamInfo(), StreamInfo(), G4Orb::StreamInfo(), G4Para::StreamInfo(), G4Sphere::StreamInfo(), G4Torus::StreamInfo(), G4Trap::StreamInfo(), G4Trd::StreamInfo(), G4Tubs::StreamInfo(), G4Ellipsoid::StreamInfo(), G4EllipticalCone::StreamInfo(), G4EllipticalTube::StreamInfo(), G4ExtrudedSolid::StreamInfo(), G4GenericPolycone::StreamInfo(), G4GenericTrap::StreamInfo(), G4Hype::StreamInfo(), G4Paraboloid::StreamInfo(), G4Polycone::StreamInfo(), G4Polyhedra::StreamInfo(), G4TessellatedSolid::StreamInfo(), G4Tet::StreamInfo(), G4TwistedBox::StreamInfo(), G4TwistedTrap::StreamInfo(), G4TwistedTrd::StreamInfo(), G4TwistedTubs::StreamInfo(), G4VCSGfaceted::StreamInfo(), G4VTwistedFaceted::StreamInfo(), G4GDMLRead::StripNames(), SubstractSolids(), G4UnionSolid::SurfaceNormal(), G4Box::SurfaceNormal(), G4Para::SurfaceNormal(), G4Trap::SurfaceNormal(), G4Trd::SurfaceNormal(), G4Ellipsoid::SurfaceNormal(), G4EllipticalCone::SurfaceNormal(), G4EllipticalTube::SurfaceNormal(), G4ExtrudedSolid::SurfaceNormal(), G4Tet::SurfaceNormal(), G4GDMLWriteSolids::TessellatedWrite(), G4GDMLWriteSolids::TetWrite(), G4GDMLWriteSolids::TorusWrite(), G4GDMLWriteSolids::TrapWrite(), G4GDMLWriteStructure::TraverseVolumeTree(), G4GDMLWriteSolids::TrdWrite(), G4GDMLWriteSolids::TubeWrite(), G4GDMLWriteSolids::TwistedboxWrite(), G4GDMLWriteSolids::TwistedtrapWrite(), G4GDMLWriteSolids::TwistedtrdWrite(), G4GDMLWriteSolids::TwistedtubsWrite(), G4PhysicalVolumeModel::VisitGeometryAndGetVisReps(), and G4GDMLWriteSolids::XtruWrite().

◆ GetOuterRadius()

G4double G4CutTubs::GetOuterRadius ( ) const
inline

◆ GetPointOnSurface()

G4ThreeVector G4CutTubs::GetPointOnSurface ( ) const
virtual

Reimplemented from G4VSolid.

Definition at line 1943 of file G4CutTubs.cc.

1944{
1945 // Set min and max z
1946 if (fZMin == 0. && fZMax == 0.)
1947 {
1949 G4ThreeVector bmin, bmax;
1950 BoundingLimits(bmin,bmax);
1951 fZMin = bmin.z();
1952 fZMax = bmax.z();
1953 l.unlock();
1954 }
1955
1956 // Set parameters
1957 G4double hmax = fZMax - fZMin;
1958 G4double sphi = fSPhi;
1959 G4double dphi = fDPhi;
1960 G4double rmin = fRMin;
1961 G4double rmax = fRMax;
1962 G4double rrmax = rmax*rmax;
1963 G4double rrmin = rmin*rmin;
1964
1965 G4ThreeVector nbot = GetLowNorm();
1966 G4ThreeVector ntop = GetHighNorm();
1967
1968 // Set array of surface areas
1969 G4double sbase = 0.5*dphi*(rrmax - rrmin);
1970 G4double sbot = sbase/std::abs(nbot.z());
1971 G4double stop = sbase/std::abs(ntop.z());
1972 G4double scut = (dphi == twopi) ? 0. : hmax*(rmax - rmin);
1973 G4double ssurf[6] = { scut, scut, sbot, stop, dphi*rmax*hmax, dphi*rmin*hmax };
1974 ssurf[1] += ssurf[0];
1975 ssurf[2] += ssurf[1];
1976 ssurf[3] += ssurf[2];
1977 ssurf[4] += ssurf[3];
1978 ssurf[5] += ssurf[4];
1979
1980 constexpr G4int ntry = 100000;
1981 for (G4int i=0; i<ntry; ++i)
1982 {
1983 // Select surface
1984 G4double select = ssurf[5]*G4QuickRand();
1985 G4int k = 5;
1986 k -= (select <= ssurf[4]);
1987 k -= (select <= ssurf[3]);
1988 k -= (select <= ssurf[2]);
1989 k -= (select <= ssurf[1]);
1990 k -= (select <= ssurf[0]);
1991
1992 // Generate point on selected surface (rejection sampling)
1993 G4ThreeVector p(0,0,0);
1994 switch(k)
1995 {
1996 case 0: // cut at start phi
1997 {
1998 G4double r = rmin + (rmax - rmin)*G4QuickRand();
1999 p.set(r*cosSPhi, r*sinSPhi, fZMin + hmax*G4QuickRand());
2000 break;
2001 }
2002 case 1: // cut at end phi
2003 {
2004 G4double r = rmin + (rmax - rmin)*G4QuickRand();
2005 p.set(r*cosEPhi, r*sinEPhi, fZMin + hmax*G4QuickRand());
2006 break;
2007 }
2008 case 2: // base at low z
2009 {
2010 G4double r = std::sqrt(rrmin + (rrmax - rrmin)*G4QuickRand());
2011 G4double phi = sphi + dphi*G4QuickRand();
2012 G4double x = r*std::cos(phi);
2013 G4double y = r*std::sin(phi);
2014 G4double z = -fDz - (x*nbot.x() + y*nbot.y())/nbot.z();
2015 return G4ThreeVector(x, y, z);
2016 }
2017 case 3: // base at high z
2018 {
2019 G4double r = std::sqrt(rrmin + (rrmax - rrmin)*G4QuickRand());
2020 G4double phi = sphi + dphi*G4QuickRand();
2021 G4double x = r*std::cos(phi);
2022 G4double y = r*std::sin(phi);
2023 G4double z = fDz - (x*ntop.x() + y*ntop.y())/ntop.z();
2024 return G4ThreeVector(x, y, z);
2025 }
2026 case 4: // external lateral surface
2027 {
2028 G4double phi = sphi + dphi*G4QuickRand();
2029 G4double z = fZMin + hmax*G4QuickRand();
2030 G4double x = rmax*std::cos(phi);
2031 G4double y = rmax*std::sin(phi);
2032 p.set(x, y, z);
2033 break;
2034 }
2035 case 5: // internal lateral surface
2036 {
2037 G4double phi = sphi + dphi*G4QuickRand();
2038 G4double z = fZMin + hmax*G4QuickRand();
2039 G4double x = rmin*std::cos(phi);
2040 G4double y = rmin*std::sin(phi);
2041 p.set(x, y, z);
2042 break;
2043 }
2044 }
2045 if ((ntop.dot(p) - fDz*ntop.z()) > 0.) continue;
2046 if ((nbot.dot(p) + fDz*nbot.z()) > 0.) continue;
2047 return p;
2048 }
2049 // Just in case, if all attempts to generate a point have failed
2050 // Normally should never happen
2051 G4double x = rmax*std::cos(sphi + 0.5*dphi);
2052 G4double y = rmax*std::sin(sphi + 0.5*dphi);
2053 G4double z = fDz - (x*ntop.x() + y*ntop.y())/ntop.z();
2054 return G4ThreeVector(x, y, z);
2055}

References BoundingLimits(), cosEPhi, cosSPhi, CLHEP::Hep3Vector::dot(), fDPhi, fDz, fRMax, fRMin, fSPhi, fZMax, fZMin, G4QuickRand(), GetHighNorm(), GetLowNorm(), CLHEP::Hep3Vector::set(), sinEPhi, sinSPhi, twopi, G4TemplateAutoLock< _Mutex_t >::unlock(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), CLHEP::Hep3Vector::z(), and anonymous_namespace{G4CutTubs.cc}::zminmaxMutex.

◆ GetPolyhedron()

G4Polyhedron * G4CSGSolid::GetPolyhedron ( ) const
virtualinherited

◆ GetRadiusInRing()

G4double G4CSGSolid::GetRadiusInRing ( G4double  rmin,
G4double  rmax 
) const
protectedinherited

Definition at line 109 of file G4CSGSolid.cc.

110{
111 G4double k = G4QuickRand();
112 return (rmin <= 0) ? rmax*std::sqrt(k)
113 : std::sqrt(k*rmax*rmax + (1. - k)*rmin*rmin);
114}

References G4QuickRand().

Referenced by G4Cons::GetPointOnSurface(), and G4Torus::GetPointOnSurface().

◆ GetSinEndPhi()

G4double G4CutTubs::GetSinEndPhi ( ) const
inline

Referenced by BoundingLimits(), and CalculateExtent().

◆ GetSinStartPhi()

G4double G4CutTubs::GetSinStartPhi ( ) const
inline

◆ GetStartPhiAngle()

G4double G4CutTubs::GetStartPhiAngle ( ) const
inline

◆ GetSurfaceArea()

G4double G4CutTubs::GetSurfaceArea ( )
virtual

Reimplemented from G4VSolid.

Definition at line 296 of file G4CutTubs.cc.

297{
298 constexpr G4int nphi = 400;
299
300 if (fSurfaceArea == 0.)
301 {
302 // get parameters
303 G4double rmin = GetInnerRadius();
304 G4double rmax = GetOuterRadius();
306 G4double sphi = GetStartPhiAngle();
307 G4double dphi = GetDeltaPhiAngle();
308 G4ThreeVector nbot = GetLowNorm();
309 G4ThreeVector ntop = GetHighNorm();
310
311 // calculate lateral surface area
312 G4double sinner = 2.*dz*dphi*rmin;
313 G4double souter = 2.*dz*dphi*rmax;
314 if (dphi < twopi) // make recalculation
315 {
316 // set values for calculation of h - distance between
317 // opposite points on bases
318 G4double nx = nbot.x()/nbot.z() - ntop.x()/ntop.z();
319 G4double ny = nbot.y()/nbot.z() - ntop.y()/ntop.z();
320
321 // compute lateral surface area by integration
322 G4double delphi = dphi/nphi;
323 sinner = 0.;
324 souter = 0.;
325 for (G4int iphi=0; iphi<nphi; ++iphi)
326 {
327 G4double phi = sphi + delphi*(iphi + 0.5);
328 G4double cosphi = std::cos(phi);
329 G4double sinphi = std::sin(phi);
330 sinner += rmin*(nx*cosphi + ny*sinphi) + 2.*dz;
331 souter += rmax*(nx*cosphi + ny*sinphi) + 2.*dz;
332 }
333 sinner *= delphi*rmin;
334 souter *= delphi*rmax;
335 }
336 // set surface area
337 G4double scut = (dphi == twopi) ? 0. : 2.*dz*(rmax - rmin);
338 G4double szero = 0.5*dphi*(rmax*rmax - rmin*rmin);
339 G4double slow = szero/std::abs(nbot.z());
340 G4double shigh = szero/std::abs(ntop.z());
341 fSurfaceArea = sinner + souter + 2.*scut + slow + shigh;
342 }
343 return fSurfaceArea;
344}
G4double fSurfaceArea
Definition: G4CSGSolid.hh:71

References G4CSGSolid::fSurfaceArea, GetDeltaPhiAngle(), GetHighNorm(), GetInnerRadius(), GetLowNorm(), GetOuterRadius(), GetStartPhiAngle(), GetZHalfLength(), twopi, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

◆ GetTolerance()

G4double G4VSolid::GetTolerance ( ) const
inlineinherited

◆ GetZHalfLength()

G4double G4CutTubs::GetZHalfLength ( ) const
inline

◆ Initialize()

void G4CutTubs::Initialize ( )
inlineprotected

◆ InitializeTrigonometry()

void G4CutTubs::InitializeTrigonometry ( )
inlineprotected

◆ Inside()

EInside G4CutTubs::Inside ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 578 of file G4CutTubs.cc.

579{
581 EInside in = kInside;
582
583 // Check the lower cut plane
584 //
585 G4double zinLow =(p+vZ).dot(fLowNorm);
586 if (zinLow > halfCarTolerance) { return kOutside; }
587
588 // Check the higher cut plane
589 //
590 G4double zinHigh = (p-vZ).dot(fHighNorm);
591 if (zinHigh > halfCarTolerance) { return kOutside; }
592
593 // Check radius
594 //
595 G4double r2 = p.x()*p.x() + p.y()*p.y() ;
596
597 G4double tolRMin = fRMin - halfRadTolerance;
598 G4double tolRMax = fRMax + halfRadTolerance;
599 if ( tolRMin < 0 ) { tolRMin = 0; }
600
601 if (r2 < tolRMin*tolRMin || r2 > tolRMax*tolRMax) { return kOutside; }
602
603 // Check Phi cut
604 //
605 if(!fPhiFullCutTube)
606 {
607 if ((tolRMin == 0) && (std::fabs(p.x()) <= halfCarTolerance)
608 && (std::fabs(p.y()) <= halfCarTolerance))
609 {
610 return kSurface;
611 }
612
613 G4double phi0 = std::atan2(p.y(),p.x());
614 G4double phi1 = phi0 - twopi;
615 G4double phi2 = phi0 + twopi;
616
617 in = kOutside;
619 G4double ephi = sphi + fDPhi + kAngTolerance;
620 if ((phi0 >= sphi && phi0 <= ephi) ||
621 (phi1 >= sphi && phi1 <= ephi) ||
622 (phi2 >= sphi && phi2 <= ephi)) in = kSurface;
623 if (in == kOutside) { return kOutside; }
624
625 sphi += kAngTolerance;
626 ephi -= kAngTolerance;
627 if ((phi0 >= sphi && phi0 <= ephi) ||
628 (phi1 >= sphi && phi1 <= ephi) ||
629 (phi2 >= sphi && phi2 <= ephi)) in = kInside;
630 if (in == kSurface) { return kSurface; }
631 }
632
633 // Check on the Surface for Z
634 //
635 if ((zinLow >= -halfCarTolerance) || (zinHigh >= -halfCarTolerance))
636 {
637 return kSurface;
638 }
639
640 // Check on the Surface for R
641 //
642 if (fRMin) { tolRMin = fRMin + halfRadTolerance; }
643 else { tolRMin = 0; }
644 tolRMax = fRMax - halfRadTolerance;
645 if (((r2 <= tolRMin*tolRMin) || (r2 >= tolRMax*tolRMax)) &&
647 {
648 return kSurface;
649 }
650
651 return in;
652}
@ kSurface
Definition: geomdefs.hh:69

References fDPhi, fDz, fHighNorm, fLowNorm, fPhiFullCutTube, fRMax, fRMin, fSPhi, halfAngTolerance, halfCarTolerance, halfRadTolerance, kAngTolerance, kInside, kOutside, kSurface, twopi, CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::y().

◆ IsCrossingCutPlanes()

G4bool G4CutTubs::IsCrossingCutPlanes ( ) const
protected

Definition at line 2128 of file G4CutTubs.cc.

2129{
2130 constexpr G4int npoints = 30;
2131
2132 // set values for calculation of h - distance between
2133 // opposite points on bases
2134 G4ThreeVector nbot = GetLowNorm();
2135 G4ThreeVector ntop = GetHighNorm();
2136 if (std::abs(nbot.z()) < kCarTolerance) return true;
2137 if (std::abs(ntop.z()) < kCarTolerance) return true;
2138 G4double nx = nbot.x()/nbot.z() - ntop.x()/ntop.z();
2139 G4double ny = nbot.y()/nbot.z() - ntop.y()/ntop.z();
2140
2141 // check points
2142 G4double cosphi = GetCosStartPhi();
2143 G4double sinphi = GetSinStartPhi();
2144 G4double delphi = GetDeltaPhiAngle()/npoints;
2145 G4double cosdel = std::cos(delphi);
2146 G4double sindel = std::sin(delphi);
2147 G4double hzero = 2.*GetZHalfLength()/GetOuterRadius();
2148 for (G4int i=0; i<npoints+1; ++i)
2149 {
2150 G4double h = nx*cosphi + ny*sinphi + hzero;
2151 if (h < 0.) return true;
2152 G4double sintmp = sinphi;
2153 sinphi = sintmp*cosdel + cosphi*sindel;
2154 cosphi = cosphi*cosdel - sintmp*sindel;
2155 }
2156 return false;
2157}

References GetCosStartPhi(), GetDeltaPhiAngle(), GetHighNorm(), GetLowNorm(), GetOuterRadius(), GetSinStartPhi(), GetZHalfLength(), G4VSolid::kCarTolerance, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by G4CutTubs().

◆ operator=()

G4CutTubs & G4CutTubs::operator= ( const G4CutTubs rhs)

Definition at line 212 of file G4CutTubs.cc.

213{
214 // Check assignment to self
215 //
216 if (this == &rhs) { return *this; }
217
218 // Copy base class data
219 //
221
222 // Copy data
223 //
225 fRMin = rhs.fRMin; fRMax = rhs.fRMax; fDz = rhs.fDz;
226 fSPhi = rhs.fSPhi; fDPhi = rhs.fDPhi;
227 fZMin = rhs.fZMin; fZMax = rhs.fZMax;
228 sinCPhi = rhs.sinCPhi; cosCPhi = rhs.cosCPhi;
230 sinSPhi = rhs.sinSPhi; cosSPhi = rhs.cosSPhi;
231 sinEPhi = rhs.sinEPhi; cosEPhi = rhs.cosEPhi;
237
238 return *this;
239}
G4CSGSolid & operator=(const G4CSGSolid &rhs)
Definition: G4CSGSolid.cc:89

References cosCPhi, cosEPhi, cosHDPhiIT, cosHDPhiOT, cosSPhi, fDPhi, fDz, fHighNorm, fLowNorm, fPhiFullCutTube, fRMax, fRMin, fSPhi, fZMax, fZMin, halfAngTolerance, halfCarTolerance, halfRadTolerance, kAngTolerance, kRadTolerance, G4CSGSolid::operator=(), sinCPhi, sinEPhi, and sinSPhi.

◆ operator==()

G4bool G4VSolid::operator== ( const G4VSolid s) const
inlineinherited

◆ SetDeltaPhiAngle()

void G4CutTubs::SetDeltaPhiAngle ( G4double  newDPhi)
inline

◆ SetInnerRadius()

void G4CutTubs::SetInnerRadius ( G4double  newRMin)
inline

◆ SetName()

void G4VSolid::SetName ( const G4String name)
inherited

Definition at line 127 of file G4VSolid.cc.

128{
131}
void SetMapValid(G4bool val)
Definition: G4SolidStore.hh:76
static G4SolidStore * GetInstance()
G4String fshapeName
Definition: G4VSolid.hh:312
const char * name(G4int ptype)

References G4VSolid::fshapeName, G4SolidStore::GetInstance(), G4InuclParticleNames::name(), and G4SolidStore::SetMapValid().

Referenced by export_G4VSolid(), G4MultiUnion::G4MultiUnion(), and G4GDMLRead::StripNames().

◆ SetOuterRadius()

void G4CutTubs::SetOuterRadius ( G4double  newRMax)
inline

◆ SetStartPhiAngle()

void G4CutTubs::SetStartPhiAngle ( G4double  newSPhi,
G4bool  trig = true 
)
inline

◆ SetZHalfLength()

void G4CutTubs::SetZHalfLength ( G4double  newDz)
inline

◆ StreamInfo()

std::ostream & G4CutTubs::StreamInfo ( std::ostream &  os) const
virtual

Reimplemented from G4CSGSolid.

Definition at line 1918 of file G4CutTubs.cc.

1919{
1920 G4int oldprc = os.precision(16);
1921 os << "-----------------------------------------------------------\n"
1922 << " *** Dump for solid - " << GetName() << " ***\n"
1923 << " ===================================================\n"
1924 << " Solid type: G4CutTubs\n"
1925 << " Parameters: \n"
1926 << " inner radius : " << fRMin/mm << " mm \n"
1927 << " outer radius : " << fRMax/mm << " mm \n"
1928 << " half length Z: " << fDz/mm << " mm \n"
1929 << " starting phi : " << fSPhi/degree << " degrees \n"
1930 << " delta phi : " << fDPhi/degree << " degrees \n"
1931 << " low Norm : " << fLowNorm << " \n"
1932 << " high Norm : " <<fHighNorm << " \n"
1933 << "-----------------------------------------------------------\n";
1934 os.precision(oldprc);
1935
1936 return os;
1937}

References degree, fDPhi, fDz, fHighNorm, fLowNorm, fRMax, fRMin, fSPhi, G4VSolid::GetName(), and mm.

◆ SurfaceNormal()

G4ThreeVector G4CutTubs::SurfaceNormal ( const G4ThreeVector p) const
virtual

Implements G4VSolid.

Definition at line 660 of file G4CutTubs.cc.

661{
662 G4int noSurfaces = 0;
663 G4double rho, pPhi;
664 G4double distZLow,distZHigh, distRMin, distRMax;
665 G4double distSPhi = kInfinity, distEPhi = kInfinity;
667
668 G4ThreeVector norm, sumnorm(0.,0.,0.);
669 G4ThreeVector nZ = G4ThreeVector(0, 0, 1.0);
670 G4ThreeVector nR, nPs, nPe;
671
672 rho = std::sqrt(p.x()*p.x() + p.y()*p.y());
673
674 distRMin = std::fabs(rho - fRMin);
675 distRMax = std::fabs(rho - fRMax);
676
677 // dist to Low Cut
678 //
679 distZLow =std::fabs((p+vZ).dot(fLowNorm));
680
681 // dist to High Cut
682 //
683 distZHigh = std::fabs((p-vZ).dot(fHighNorm));
684
685 if (!fPhiFullCutTube) // Protected against (0,0,z)
686 {
687 if ( rho > halfCarTolerance )
688 {
689 pPhi = std::atan2(p.y(),p.x());
690
691 if(pPhi < fSPhi- halfCarTolerance) { pPhi += twopi; }
692 else if(pPhi > fSPhi+fDPhi+ halfCarTolerance) { pPhi -= twopi; }
693
694 distSPhi = std::fabs(pPhi - fSPhi);
695 distEPhi = std::fabs(pPhi - fSPhi - fDPhi);
696 }
697 else if( !fRMin )
698 {
699 distSPhi = 0.;
700 distEPhi = 0.;
701 }
702 nPs = G4ThreeVector( sinSPhi, -cosSPhi, 0 );
703 nPe = G4ThreeVector( -sinEPhi, cosEPhi, 0 );
704 }
705 if ( rho > halfCarTolerance ) { nR = G4ThreeVector(p.x()/rho,p.y()/rho,0); }
706
707 if( distRMax <= halfCarTolerance )
708 {
709 ++noSurfaces;
710 sumnorm += nR;
711 }
712 if( fRMin && (distRMin <= halfCarTolerance) )
713 {
714 ++noSurfaces;
715 sumnorm -= nR;
716 }
717 if( fDPhi < twopi )
718 {
719 if (distSPhi <= halfAngTolerance)
720 {
721 ++noSurfaces;
722 sumnorm += nPs;
723 }
724 if (distEPhi <= halfAngTolerance)
725 {
726 ++noSurfaces;
727 sumnorm += nPe;
728 }
729 }
730 if (distZLow <= halfCarTolerance)
731 {
732 ++noSurfaces;
733 sumnorm += fLowNorm;
734 }
735 if (distZHigh <= halfCarTolerance)
736 {
737 ++noSurfaces;
738 sumnorm += fHighNorm;
739 }
740 if ( noSurfaces == 0 )
741 {
742#ifdef G4CSGDEBUG
743 G4Exception("G4CutTubs::SurfaceNormal(p)", "GeomSolids1002",
744 JustWarning, "Point p is not on surface !?" );
745 G4int oldprc = G4cout.precision(20);
746 G4cout<< "G4CutTubs::SN ( "<<p.x()<<", "<<p.y()<<", "<<p.z()<<" ); "
747 << G4endl << G4endl;
748 G4cout.precision(oldprc) ;
749#endif
750 norm = ApproxSurfaceNormal(p);
751 }
752 else if ( noSurfaces == 1 ) { norm = sumnorm; }
753 else { norm = sumnorm.unit(); }
754
755 return norm;
756}
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
Definition: G4CutTubs.cc:763

References ApproxSurfaceNormal(), cosEPhi, cosSPhi, fDPhi, fDz, fHighNorm, fLowNorm, fPhiFullCutTube, fRMax, fRMin, fSPhi, G4cout, G4endl, G4Exception(), halfAngTolerance, halfCarTolerance, JustWarning, kInfinity, sinEPhi, sinSPhi, twopi, CLHEP::Hep3Vector::unit(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Field Documentation

◆ cosCPhi

G4double G4CutTubs::cosCPhi
private

Definition at line 188 of file G4CutTubs.hh.

Referenced by DistanceToIn(), DistanceToOut(), and operator=().

◆ cosEPhi

G4double G4CutTubs::cosEPhi
private

◆ cosHDPhi

G4double G4CutTubs::cosHDPhi
private

Definition at line 188 of file G4CutTubs.hh.

Referenced by DistanceToIn().

◆ cosHDPhiIT

G4double G4CutTubs::cosHDPhiIT
private

Definition at line 188 of file G4CutTubs.hh.

Referenced by DistanceToIn(), and operator=().

◆ cosHDPhiOT

G4double G4CutTubs::cosHDPhiOT
private

Definition at line 188 of file G4CutTubs.hh.

Referenced by operator=().

◆ cosSPhi

G4double G4CutTubs::cosSPhi
private

◆ fCubicVolume

G4double G4CSGSolid::fCubicVolume = 0.0
protectedinherited

◆ fDPhi

G4double G4CutTubs::fDPhi
private

◆ fDz

G4double G4CutTubs::fDz
private

◆ fHighNorm

G4ThreeVector G4CutTubs::fHighNorm
private

◆ fLowNorm

G4ThreeVector G4CutTubs::fLowNorm
private

◆ fPhiFullCutTube

G4bool G4CutTubs::fPhiFullCutTube = false
private

◆ fpPolyhedron

G4Polyhedron* G4CSGSolid::fpPolyhedron = nullptr
mutableprotectedinherited

◆ fRebuildPolyhedron

G4bool G4CSGSolid::fRebuildPolyhedron = false
mutableprotectedinherited

◆ fRMax

G4double G4CutTubs::fRMax
private

◆ fRMin

G4double G4CutTubs::fRMin
private

◆ fshapeName

G4String G4VSolid::fshapeName
privateinherited

Definition at line 312 of file G4VSolid.hh.

Referenced by G4VSolid::operator=(), and G4VSolid::SetName().

◆ fSPhi

G4double G4CutTubs::fSPhi
private

◆ fSurfaceArea

G4double G4CSGSolid::fSurfaceArea = 0.0
protectedinherited

◆ fZMax

G4double G4CutTubs::fZMax
private

Definition at line 184 of file G4CutTubs.hh.

Referenced by GetPointOnSurface(), and operator=().

◆ fZMin

G4double G4CutTubs::fZMin
mutableprivate

Definition at line 184 of file G4CutTubs.hh.

Referenced by GetPointOnSurface(), and operator=().

◆ halfAngTolerance

G4double G4CutTubs::halfAngTolerance
private

Definition at line 197 of file G4CutTubs.hh.

Referenced by DistanceToOut(), G4CutTubs(), Inside(), operator=(), and SurfaceNormal().

◆ halfCarTolerance

G4double G4CutTubs::halfCarTolerance
private

Definition at line 197 of file G4CutTubs.hh.

Referenced by DistanceToIn(), DistanceToOut(), G4CutTubs(), Inside(), operator=(), and SurfaceNormal().

◆ halfRadTolerance

G4double G4CutTubs::halfRadTolerance
private

Definition at line 197 of file G4CutTubs.hh.

Referenced by DistanceToIn(), G4CutTubs(), Inside(), and operator=().

◆ kAngTolerance

G4double G4CutTubs::kAngTolerance
private

Definition at line 179 of file G4CutTubs.hh.

Referenced by G4CutTubs(), Inside(), and operator=().

◆ kCarTolerance

G4double G4VSolid::kCarTolerance
protectedinherited

Definition at line 299 of file G4VSolid.hh.

Referenced by G4TessellatedSolid::AddFacet(), G4Polycone::CalculateExtent(), G4Polyhedra::CalculateExtent(), G4Tet::CheckDegeneracy(), G4Para::CheckParameters(), G4Trd::CheckParameters(), G4Ellipsoid::CheckParameters(), G4EllipticalTube::CheckParameters(), G4GenericTrap::ComputeIsTwisted(), G4Polyhedra::Create(), G4GenericPolycone::Create(), G4Polycone::Create(), CreatePolyhedron(), G4TessellatedSolid::CreateVertexList(), G4VCSGfaceted::DistanceTo(), G4Sphere::DistanceToIn(), G4Ellipsoid::DistanceToIn(), G4Hype::DistanceToIn(), G4Paraboloid::DistanceToIn(), G4VCSGfaceted::DistanceToIn(), G4TessellatedSolid::DistanceToInCore(), G4Cons::DistanceToOut(), DistanceToOut(), G4Sphere::DistanceToOut(), G4Torus::DistanceToOut(), G4Tubs::DistanceToOut(), G4GenericTrap::DistanceToOut(), G4Hype::DistanceToOut(), G4Paraboloid::DistanceToOut(), G4VCSGfaceted::DistanceToOut(), G4TessellatedSolid::DistanceToOutCandidates(), G4TessellatedSolid::DistanceToOutCore(), G4TessellatedSolid::DistanceToOutNoVoxels(), G4GenericTrap::DistToPlane(), G4GenericTrap::DistToTriangle(), G4Box::G4Box(), G4Cons::G4Cons(), G4CutTubs(), G4EllipticalCone::G4EllipticalCone(), G4ExtrudedSolid::G4ExtrudedSolid(), G4GenericTrap::G4GenericTrap(), G4Hype::G4Hype(), G4Para::G4Para(), G4Sphere::G4Sphere(), G4Tet::G4Tet(), G4Trap::G4Trap(), G4Tubs::G4Tubs(), G4UnionSolid::G4UnionSolid(), G4VSolid::G4VSolid(), G4VTwistedFaceted::G4VTwistedFaceted(), G4GenericPolycone::GetPointOnSurface(), G4Polycone::GetPointOnSurface(), G4UnionSolid::Init(), G4Orb::Initialize(), G4TessellatedSolid::Initialize(), G4SubtractionSolid::Inside(), G4Hype::Inside(), G4Paraboloid::Inside(), G4VCSGfaceted::Inside(), G4VTwistedFaceted::Inside(), G4TessellatedSolid::InsideNoVoxels(), G4GenericTrap::InsidePolygone(), G4TessellatedSolid::InsideVoxels(), IsCrossingCutPlanes(), G4GenericTrap::IsSegCrossingZ(), G4Trap::MakePlane(), G4GenericTrap::NormalToPlane(), G4VSolid::operator=(), G4TessellatedSolid::SafetyFromInside(), G4TessellatedSolid::SafetyFromOutside(), G4Torus::SetAllParameters(), G4Polycone::SetOriginalParameters(), G4Polyhedra::SetOriginalParameters(), G4Box::SetXHalfLength(), G4Box::SetYHalfLength(), G4Box::SetZHalfLength(), G4Torus::SurfaceNormal(), G4GenericTrap::SurfaceNormal(), and G4Paraboloid::SurfaceNormal().

◆ kRadTolerance

G4double G4CutTubs::kRadTolerance
private

Definition at line 179 of file G4CutTubs.hh.

Referenced by DistanceToIn(), DistanceToOut(), G4CutTubs(), and operator=().

◆ sinCPhi

G4double G4CutTubs::sinCPhi
private

Definition at line 188 of file G4CutTubs.hh.

Referenced by DistanceToIn(), DistanceToOut(), and operator=().

◆ sinEPhi

G4double G4CutTubs::sinEPhi
private

◆ sinSPhi

G4double G4CutTubs::sinSPhi
private

The documentation for this class was generated from the following files: