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)
61G4UTubs::G4UTubs( __void__& a )
70G4UTubs::~G4UTubs() =
default;
76G4UTubs::G4UTubs(
const G4UTubs& rhs)
85G4UTubs& G4UTubs::operator = (
const G4UTubs& rhs)
89 if (
this == &rhs) {
return *
this; }
93 Base_t::operator=(rhs);
102G4double G4UTubs::GetInnerRadius()
const
106G4double G4UTubs::GetOuterRadius()
const
110G4double G4UTubs::GetZHalfLength()
const
114G4double G4UTubs::GetStartPhiAngle()
const
118G4double G4UTubs::GetDeltaPhiAngle()
const
122G4double G4UTubs::GetSinStartPhi()
const
124 return std::sin(GetStartPhiAngle());
126G4double G4UTubs::GetCosStartPhi()
const
128 return std::cos(GetStartPhiAngle());
130G4double G4UTubs::GetSinEndPhi()
const
132 return std::sin(GetStartPhiAngle()+GetDeltaPhiAngle());
134G4double G4UTubs::GetCosEndPhi()
const
136 return std::cos(GetStartPhiAngle()+GetDeltaPhiAngle());
139void G4UTubs::SetInnerRadius(
G4double newRMin)
142 fRebuildPolyhedron =
true;
144void G4UTubs::SetOuterRadius(
G4double newRMax)
147 fRebuildPolyhedron =
true;
149void G4UTubs::SetZHalfLength(
G4double newDz)
152 fRebuildPolyhedron =
true;
157 fRebuildPolyhedron =
true;
159void G4UTubs::SetDeltaPhiAngle(
G4double newDPhi)
162 fRebuildPolyhedron =
true;
183 return new G4UTubs(*
this);
192 static G4bool checkBBox =
true;
200 if (GetDeltaPhiAngle() < twopi)
204 GetSinStartPhi(),GetCosStartPhi(),
205 GetSinEndPhi(),GetCosEndPhi(),
207 pMin.
set(vmin.
x(),vmin.
y(),-dz);
208 pMax.
set(vmax.
x(),vmax.
y(), dz);
212 pMin.
set(-rmax,-rmax,-dz);
213 pMax.
set( rmax, rmax, dz);
218 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
220 std::ostringstream message;
221 message <<
"Bad bounding box (min >= max) for solid: "
223 <<
"\npMin = " << pMin
224 <<
"\npMax = " << pMax;
225 G4Exception(
"G4UTubs::BoundingLimits()",
"GeomMgt0001",
243 std::ostringstream message;
244 message <<
"Inconsistency in bounding boxes for solid: "
246 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
247 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
248 G4Exception(
"G4UTubs::BoundingLimits()",
"GeomMgt0001",
260G4UTubs::CalculateExtent(
const EAxis pAxis,
269 BoundingLimits(bmin,bmax);
274 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
276 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
278 return exist = pMin < pMax;
289 const G4int NSTEPS = 24;
291 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-deg)/astep) + 1;
294 G4double sinHalf = std::sin(0.5*ang);
295 G4double cosHalf = std::cos(0.5*ang);
296 G4double sinStep = 2.*sinHalf*cosHalf;
297 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
302 if (rmin == 0 && dphi == twopi)
308 for (
G4int k=0; k<NSTEPS; ++k)
310 baseA[k].set(rext*cosCur,rext*sinCur,-dz);
311 baseB[k].set(rext*cosCur,rext*sinCur, dz);
314 sinCur = sinCur*cosStep + cosCur*sinStep;
315 cosCur = cosCur*cosStep - sinTmp*sinStep;
317 std::vector<const G4ThreeVectorList *> polygons(2);
318 polygons[0] = &baseA;
319 polygons[1] = &baseB;
321 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
325 G4double sinStart = GetSinStartPhi();
326 G4double cosStart = GetCosStartPhi();
329 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
330 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
334 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
335 pols[0][0].set(rmin*cosStart,rmin*sinStart, dz);
336 pols[0][1].set(rmin*cosStart,rmin*sinStart,-dz);
337 pols[0][2].set(rmax*cosStart,rmax*sinStart,-dz);
338 pols[0][3].set(rmax*cosStart,rmax*sinStart, dz);
339 for (
G4int k=1; k<ksteps+1; ++k)
341 pols[k][0].set(rmin*cosCur,rmin*sinCur, dz);
342 pols[k][1].set(rmin*cosCur,rmin*sinCur,-dz);
343 pols[k][2].set(rext*cosCur,rext*sinCur,-dz);
344 pols[k][3].set(rext*cosCur,rext*sinCur, dz);
347 sinCur = sinCur*cosStep + cosCur*sinStep;
348 cosCur = cosCur*cosStep - sinTmp*sinStep;
350 pols[ksteps+1][0].set(rmin*cosEnd,rmin*sinEnd, dz);
351 pols[ksteps+1][1].set(rmin*cosEnd,rmin*sinEnd,-dz);
352 pols[ksteps+1][2].set(rmax*cosEnd,rmax*sinEnd,-dz);
353 pols[ksteps+1][3].set(rmax*cosEnd,rmax*sinEnd, dz);
356 std::vector<const G4ThreeVectorList *> polygons;
357 polygons.resize(ksteps+2);
358 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
360 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)
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const