34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
41 using namespace CLHEP;
48 G4UTubs::G4UTubs(
const G4String& pName,
52 : Base_t(pName, pRMin, pRMax, pDz, pSPhi, pDPhi)
61 G4UTubs::G4UTubs( __void__&
a )
78 G4UTubs::G4UTubs(
const G4UTubs& rhs)
87 G4UTubs& G4UTubs::operator = (
const G4UTubs& rhs)
91 if (
this == &rhs) {
return *
this; }
95 Base_t::operator=(rhs);
104 G4double G4UTubs::GetInnerRadius()
const
108 G4double G4UTubs::GetOuterRadius()
const
112 G4double G4UTubs::GetZHalfLength()
const
116 G4double G4UTubs::GetStartPhiAngle()
const
120 G4double G4UTubs::GetDeltaPhiAngle()
const
124 G4double G4UTubs::GetSinStartPhi()
const
126 return std::sin(GetStartPhiAngle());
128 G4double G4UTubs::GetCosStartPhi()
const
130 return std::cos(GetStartPhiAngle());
132 G4double G4UTubs::GetSinEndPhi()
const
134 return std::sin(GetStartPhiAngle()+GetDeltaPhiAngle());
136 G4double G4UTubs::GetCosEndPhi()
const
138 return std::cos(GetStartPhiAngle()+GetDeltaPhiAngle());
141 void G4UTubs::SetInnerRadius(
G4double newRMin)
144 fRebuildPolyhedron =
true;
146 void G4UTubs::SetOuterRadius(
G4double newRMax)
149 fRebuildPolyhedron =
true;
151 void G4UTubs::SetZHalfLength(
G4double newDz)
154 fRebuildPolyhedron =
true;
159 fRebuildPolyhedron =
true;
161 void G4UTubs::SetDeltaPhiAngle(
G4double newDPhi)
164 fRebuildPolyhedron =
true;
185 return new G4UTubs(*
this);
194 static G4bool checkBBox =
true;
202 if (GetDeltaPhiAngle() <
twopi)
206 GetSinStartPhi(),GetCosStartPhi(),
207 GetSinEndPhi(),GetCosEndPhi(),
209 pMin.
set(vmin.
x(),vmin.
y(),-
dz);
210 pMax.
set(vmax.
x(),vmax.
y(),
dz);
214 pMin.
set(-rmax,-rmax,-dz);
215 pMax.
set( rmax, rmax, dz);
220 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
223 message <<
"Bad bounding box (min >= max) for solid: "
225 <<
"\npMin = " << pMin
226 <<
"\npMax = " <<
pMax;
227 G4Exception(
"G4UTubs::BoundingLimits()",
"GeomMgt0001",
246 message <<
"Inconsistency in bounding boxes for solid: "
248 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
249 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
250 G4Exception(
"G4UTubs::BoundingLimits()",
"GeomMgt0001",
262 G4UTubs::CalculateExtent(
const EAxis pAxis,
271 BoundingLimits(bmin,bmax);
276 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
278 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
280 return exist = (pMin <
pMax) ?
true :
false;
291 const G4int NSTEPS = 24;
293 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
296 G4double sinHalf = std::sin(0.5*ang);
297 G4double cosHalf = std::cos(0.5*ang);
298 G4double sinStep = 2.*sinHalf*cosHalf;
299 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
304 if (rmin == 0 && dphi ==
twopi)
312 baseA[
k].set(rext*cosCur,rext*sinCur,-dz);
313 baseB[
k].set(rext*cosCur,rext*sinCur, dz);
316 sinCur = sinCur*cosStep + cosCur*sinStep;
317 cosCur = cosCur*cosStep - sinTmp*sinStep;
319 std::vector<const G4ThreeVectorList *> polygons(2);
320 polygons[0] = &baseA;
321 polygons[1] = &baseB;
323 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
327 G4double sinStart = GetSinStartPhi();
328 G4double cosStart = GetCosStartPhi();
331 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
332 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
336 for (
G4int k=0;
k<ksteps+2; ++
k) pols[
k].resize(4);
337 pols[0][0].set(rmin*cosStart,rmin*sinStart, dz);
338 pols[0][1].set(rmin*cosStart,rmin*sinStart,-dz);
339 pols[0][2].set(rmax*cosStart,rmax*sinStart,-dz);
340 pols[0][3].set(rmax*cosStart,rmax*sinStart, dz);
343 pols[
k][0].set(rmin*cosCur,rmin*sinCur, dz);
344 pols[
k][1].set(rmin*cosCur,rmin*sinCur,-dz);
345 pols[
k][2].set(rext*cosCur,rext*sinCur,-dz);
346 pols[
k][3].set(rext*cosCur,rext*sinCur, dz);
349 sinCur = sinCur*cosStep + cosCur*sinStep;
350 cosCur = cosCur*cosStep - sinTmp*sinStep;
352 pols[ksteps+1][0].set(rmin*cosEnd,rmin*sinEnd, dz);
353 pols[ksteps+1][1].set(rmin*cosEnd,rmin*sinEnd,-dz);
354 pols[ksteps+1][2].set(rmax*cosEnd,rmax*sinEnd,-dz);
355 pols[ksteps+1][3].set(rmax*cosEnd,rmax*sinEnd, dz);
358 std::vector<const G4ThreeVectorList *> polygons;
359 polygons.resize(ksteps+2);
360 for (
G4int k=0;
k<ksteps+2; ++
k) polygons[
k] = &pols[
k];
362 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
380 #endif // G4GEOM_USE_USOLIDS