34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
48G4UTubs::G4UTubs(
const G4String& pName,
52 : Base_t(pName, pRMin, pRMax, pDz, pSPhi, pDPhi)
60G4UTubs::G4UTubs(
const G4UTubs& rhs)
69G4UTubs& G4UTubs::operator = (
const G4UTubs& rhs)
73 if (
this == &rhs) {
return *
this; }
77 Base_t::operator=(rhs);
86G4double G4UTubs::GetInnerRadius()
const
90G4double G4UTubs::GetOuterRadius()
const
94G4double G4UTubs::GetZHalfLength()
const
98G4double G4UTubs::GetStartPhiAngle()
const
102G4double G4UTubs::GetDeltaPhiAngle()
const
106G4double G4UTubs::GetSinStartPhi()
const
108 return std::sin(GetStartPhiAngle());
110G4double G4UTubs::GetCosStartPhi()
const
112 return std::cos(GetStartPhiAngle());
114G4double G4UTubs::GetSinEndPhi()
const
116 return std::sin(GetStartPhiAngle()+GetDeltaPhiAngle());
118G4double G4UTubs::GetCosEndPhi()
const
120 return std::cos(GetStartPhiAngle()+GetDeltaPhiAngle());
123void G4UTubs::SetInnerRadius(
G4double newRMin)
126 fRebuildPolyhedron =
true;
128void G4UTubs::SetOuterRadius(
G4double newRMax)
131 fRebuildPolyhedron =
true;
133void G4UTubs::SetZHalfLength(
G4double newDz)
136 fRebuildPolyhedron =
true;
141 fRebuildPolyhedron =
true;
143void G4UTubs::SetDeltaPhiAngle(
G4double newDPhi)
146 fRebuildPolyhedron =
true;
167 return new G4UTubs(*
this);
176 static G4bool checkBBox =
true;
184 if (GetDeltaPhiAngle() < twopi)
188 GetSinStartPhi(),GetCosStartPhi(),
189 GetSinEndPhi(),GetCosEndPhi(),
191 pMin.
set(vmin.
x(),vmin.
y(),-dz);
192 pMax.
set(vmax.
x(),vmax.
y(), dz);
196 pMin.
set(-rmax,-rmax,-dz);
197 pMax.
set( rmax, rmax, dz);
202 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
204 std::ostringstream message;
205 message <<
"Bad bounding box (min >= max) for solid: "
207 <<
"\npMin = " << pMin
208 <<
"\npMax = " << pMax;
209 G4Exception(
"G4UTubs::BoundingLimits()",
"GeomMgt0001",
227 std::ostringstream message;
228 message <<
"Inconsistency in bounding boxes for solid: "
230 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
231 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
232 G4Exception(
"G4UTubs::BoundingLimits()",
"GeomMgt0001",
244G4UTubs::CalculateExtent(
const EAxis pAxis,
253 BoundingLimits(bmin,bmax);
258 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
260 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
262 return exist = pMin < pMax;
273 const G4int NSTEPS = 24;
275 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-deg)/astep) + 1;
278 G4double sinHalf = std::sin(0.5*ang);
279 G4double cosHalf = std::cos(0.5*ang);
280 G4double sinStep = 2.*sinHalf*cosHalf;
281 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
286 if (rmin == 0 && dphi == twopi)
292 for (
G4int k=0; k<NSTEPS; ++k)
294 baseA[k].set(rext*cosCur,rext*sinCur,-dz);
295 baseB[k].set(rext*cosCur,rext*sinCur, dz);
298 sinCur = sinCur*cosStep + cosCur*sinStep;
299 cosCur = cosCur*cosStep - sinTmp*sinStep;
301 std::vector<const G4ThreeVectorList *> polygons(2);
302 polygons[0] = &baseA;
303 polygons[1] = &baseB;
305 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
309 G4double sinStart = GetSinStartPhi();
310 G4double cosStart = GetCosStartPhi();
313 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
314 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
318 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
319 pols[0][0].set(rmin*cosStart,rmin*sinStart, dz);
320 pols[0][1].set(rmin*cosStart,rmin*sinStart,-dz);
321 pols[0][2].set(rmax*cosStart,rmax*sinStart,-dz);
322 pols[0][3].set(rmax*cosStart,rmax*sinStart, dz);
323 for (
G4int k=1; k<ksteps+1; ++k)
325 pols[k][0].set(rmin*cosCur,rmin*sinCur, dz);
326 pols[k][1].set(rmin*cosCur,rmin*sinCur,-dz);
327 pols[k][2].set(rext*cosCur,rext*sinCur,-dz);
328 pols[k][3].set(rext*cosCur,rext*sinCur, dz);
331 sinCur = sinCur*cosStep + cosCur*sinStep;
332 cosCur = cosCur*cosStep - sinTmp*sinStep;
334 pols[ksteps+1][0].set(rmin*cosEnd,rmin*sinEnd, dz);
335 pols[ksteps+1][1].set(rmin*cosEnd,rmin*sinEnd,-dz);
336 pols[ksteps+1][2].set(rmax*cosEnd,rmax*sinEnd,-dz);
337 pols[ksteps+1][3].set(rmax*cosEnd,rmax*sinEnd, dz);
340 std::vector<const G4ThreeVectorList *> polygons;
341 polygons.resize(ksteps+2);
342 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
344 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
CLHEP::Hep2Vector G4TwoVector
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4BoundingEnvelope is a helper class to facilitate calculation of the extent of a solid within the li...
G4Tubs is a tube or tube segment with curved sides parallel to the Z-axis. The tube has a specified h...
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...