36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
43 using namespace CLHEP;
50 G4UTubs::G4UTubs(
const G4String& pName,
54 : G4USolid(pName, new UTubs(pName, pRMin, pRMax, pDz, pSPhi, pDPhi))
63 G4UTubs::G4UTubs( __void__&
a )
80 G4UTubs::G4UTubs(
const G4UTubs& rhs)
89 G4UTubs& G4UTubs::operator = (
const G4UTubs& rhs)
93 if (
this == &rhs) {
return *
this; }
97 G4USolid::operator=(rhs);
106 G4double G4UTubs::GetInnerRadius()
const
108 return GetShape()->GetInnerRadius();
110 G4double G4UTubs::GetOuterRadius()
const
112 return GetShape()->GetOuterRadius();
114 G4double G4UTubs::GetZHalfLength()
const
116 return GetShape()->GetZHalfLength();
118 G4double G4UTubs::GetStartPhiAngle()
const
120 return GetShape()->GetStartPhiAngle();
122 G4double G4UTubs::GetDeltaPhiAngle()
const
124 return GetShape()->GetDeltaPhiAngle();
126 G4double G4UTubs::GetSinStartPhi()
const
128 G4double phi = GetShape()->GetStartPhiAngle();
129 return std::sin(phi);
131 G4double G4UTubs::GetCosStartPhi()
const
133 G4double phi = GetShape()->GetStartPhiAngle();
134 return std::cos(phi);
136 G4double G4UTubs::GetSinEndPhi()
const
138 G4double phi = GetShape()->GetStartPhiAngle() +
139 GetShape()->GetDeltaPhiAngle();
140 return std::sin(phi);
142 G4double G4UTubs::GetCosEndPhi()
const
144 G4double phi = GetShape()->GetStartPhiAngle() +
145 GetShape()->GetDeltaPhiAngle();
146 return std::cos(phi);
149 void G4UTubs::SetInnerRadius(
G4double newRMin)
151 GetShape()->SetInnerRadius(newRMin);
152 fRebuildPolyhedron =
true;
154 void G4UTubs::SetOuterRadius(
G4double newRMax)
156 GetShape()->SetOuterRadius(newRMax);
157 fRebuildPolyhedron =
true;
159 void G4UTubs::SetZHalfLength(
G4double newDz)
161 GetShape()->SetZHalfLength(newDz);
162 fRebuildPolyhedron =
true;
166 GetShape()->SetStartPhiAngle(newSPhi, trig);
167 fRebuildPolyhedron =
true;
169 void G4UTubs::SetDeltaPhiAngle(
G4double newDPhi)
171 GetShape()->SetDeltaPhiAngle(newDPhi);
172 fRebuildPolyhedron =
true;
193 return new G4UTubs(*
this);
202 static G4bool checkBBox =
true;
210 if (GetDeltaPhiAngle() <
twopi)
214 GetSinStartPhi(),GetCosStartPhi(),
215 GetSinEndPhi(),GetCosEndPhi(),
217 pMin.set(vmin.x(),vmin.y(),-dz);
218 pMax.set(vmax.x(),vmax.y(), dz);
222 pMin.set(-rmax,-rmax,-dz);
223 pMax.set( rmax, rmax, dz);
228 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
230 std::ostringstream message;
231 message <<
"Bad bounding box (min >= max) for solid: "
233 <<
"\npMin = " << pMin
234 <<
"\npMax = " << pMax;
244 GetShape()->Extent(vmin,vmax);
252 std::ostringstream message;
253 message <<
"Inconsistency in bounding boxes for solid: "
255 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
256 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
268 G4UTubs::CalculateExtent(
const EAxis pAxis,
282 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
284 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
286 return exist = (pMin < pMax) ?
true :
false;
297 const G4int NSTEPS = 24;
299 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
302 G4double sinHalf = std::sin(0.5*ang);
303 G4double cosHalf = std::cos(0.5*ang);
304 G4double sinStep = 2.*sinHalf*cosHalf;
305 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
310 if (rmin == 0 && dphi ==
twopi)
316 for (
G4int k=0; k<NSTEPS; ++k)
318 baseA[k].set(rext*cosCur,rext*sinCur,-dz);
319 baseB[k].set(rext*cosCur,rext*sinCur, dz);
322 sinCur = sinCur*cosStep + cosCur*sinStep;
323 cosCur = cosCur*cosStep - sinTmp*sinStep;
325 std::vector<const G4ThreeVectorList *> polygons(2);
326 polygons[0] = &baseA;
327 polygons[1] = &baseB;
329 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
333 G4double sinStart = GetSinStartPhi();
334 G4double cosStart = GetCosStartPhi();
337 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
338 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
342 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
343 pols[0][0].set(rmin*cosStart,rmin*sinStart, dz);
344 pols[0][1].set(rmin*cosStart,rmin*sinStart,-dz);
345 pols[0][2].set(rmax*cosStart,rmax*sinStart,-dz);
346 pols[0][3].set(rmax*cosStart,rmax*sinStart, dz);
347 for (
G4int k=1; k<ksteps+1; ++k)
349 pols[k][0].set(rmin*cosCur,rmin*sinCur, dz);
350 pols[k][1].set(rmin*cosCur,rmin*sinCur,-dz);
351 pols[k][2].set(rext*cosCur,rext*sinCur,-dz);
352 pols[k][3].set(rext*cosCur,rext*sinCur, dz);
355 sinCur = sinCur*cosStep + cosCur*sinStep;
356 cosCur = cosCur*cosStep - sinTmp*sinStep;
358 pols[ksteps+1][0].set(rmin*cosEnd,rmin*sinEnd, dz);
359 pols[ksteps+1][1].set(rmin*cosEnd,rmin*sinEnd,-dz);
360 pols[ksteps+1][2].set(rmax*cosEnd,rmax*sinEnd,-dz);
361 pols[ksteps+1][3].set(rmax*cosEnd,rmax*sinEnd, dz);
364 std::vector<const G4ThreeVectorList *> polygons;
365 polygons.resize(ksteps+2);
366 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
368 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
386 #endif // G4GEOM_USE_USOLIDS
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
static constexpr double twopi
G4GLOB_DLL std::ostream G4cout
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
CLHEP::Hep2Vector G4TwoVector
static constexpr double deg