34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
50G4UTorus::G4UTorus(
const G4String& pName,
53 : Base_t(pName, rmin, rmax, rtor, sphi, dphi)
61G4UTorus::G4UTorus( __void__& a )
69G4UTorus::~G4UTorus() { }
75G4UTorus::G4UTorus(
const G4UTorus& rhs)
83G4UTorus& G4UTorus::operator = (
const G4UTorus& rhs)
87 if (
this == &rhs) {
return *
this; }
91 Base_t::operator=(rhs);
125G4double G4UTorus::GetSinStartPhi()
const
127 return std::sin(sphi());
130G4double G4UTorus::GetCosStartPhi()
const
132 return std::cos(sphi());
135G4double G4UTorus::GetSinEndPhi()
const
137 return std::sin(sphi()+dphi());
140G4double G4UTorus::GetCosEndPhi()
const
142 return std::cos(sphi()+dphi());
147 Base_t::SetRMin(arg);
148 fRebuildPolyhedron =
true;
153 Base_t::SetRMax(arg);
154 fRebuildPolyhedron =
true;
159 Base_t::SetRTor(arg);
160 fRebuildPolyhedron =
true;
165 Base_t::SetSPhi(arg);
166 fRebuildPolyhedron =
true;
171 Base_t::SetDPhi(arg);
172 fRebuildPolyhedron =
true;
183 fRebuildPolyhedron =
true;
204 return new G4UTorus(*
this);
213 static G4bool checkBBox =
true;
223 if (GetDPhi() >= twopi)
225 pMin.
set(-rext,-rext,-dz);
226 pMax.
set( rext, rext, dz);
232 GetSinStartPhi(),GetCosStartPhi(),
233 GetSinEndPhi(),GetCosEndPhi(),
235 pMin.
set(vmin.
x(),vmin.
y(),-dz);
236 pMax.
set(vmax.
x(),vmax.
y(), dz);
241 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
243 std::ostringstream message;
244 message <<
"Bad bounding box (min >= max) for solid: "
246 <<
"\npMin = " << pMin
247 <<
"\npMax = " << pMax;
248 G4Exception(
"G4UTorus::BoundingLimits()",
"GeomMgt0001",
258 Base_t::Extent(vmin,vmax);
266 std::ostringstream message;
267 message <<
"Inconsistency in bounding boxes for solid: "
269 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
270 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
271 G4Exception(
"G4UTorus::BoundingLimits()",
"GeomMgt0001",
283G4UTorus::CalculateExtent(
const EAxis pAxis,
292 BoundingLimits(bmin,bmax);
297 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
299 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
301 return exist = (pMin < pMax) ?
true :
false;
309 G4double sinStart = GetSinStartPhi();
310 G4double cosStart = GetCosStartPhi();
318 static const G4int NPHI = 24;
319 static const G4int NDISK = 16;
320 static const G4double sinHalfDisk = std::sin(pi/NDISK);
321 static const G4double cosHalfDisk = std::cos(pi/NDISK);
322 static const G4double sinStepDisk = 2.*sinHalfDisk*cosHalfDisk;
323 static const G4double cosStepDisk = 1. - 2.*sinHalfDisk*sinHalfDisk;
326 G4int kphi = (dphi <= astep) ? 1 : (
G4int)((dphi-deg)/astep) + 1;
329 G4double sinHalf = std::sin(0.5*ang);
330 G4double cosHalf = std::cos(0.5*ang);
331 G4double sinStep = 2.*sinHalf*cosHalf;
332 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
336 for (
G4int k=0; k<NDISK+1; ++k) pols[k].resize(4);
338 std::vector<const G4ThreeVectorList *> polygons;
339 polygons.resize(NDISK+1);
340 for (
G4int k=0; k<NDISK+1; ++k) polygons[k] = &pols[k];
346 if ((rtor-rmin*sinHalfDisk)/cosHalf > (rtor+rmin*sinHalfDisk)) rmin = 0;
350 for (
G4int k=0; k<NDISK; ++k)
352 G4double rmincur = rtor + rmin*cosCurDisk;
353 if (cosCurDisk < 0 && rmin > 0) rmincur /= cosHalf;
354 rzmin[k].
set(rmincur,rmin*sinCurDisk);
356 G4double rmaxcur = rtor + rmax*cosCurDisk;
357 if (cosCurDisk > 0) rmaxcur /= cosHalf;
358 rzmax[k].
set(rmaxcur,rmax*sinCurDisk);
361 sinCurDisk = sinCurDisk*cosStepDisk + cosCurDisk*sinStepDisk;
362 cosCurDisk = cosCurDisk*cosStepDisk - sinTmpDisk*sinStepDisk;
371 G4double sinCur1 = 0, cosCur1 = 0, sinCur2 = 0, cosCur2 = 0;
372 for (
G4int i=0; i<kphi+1; ++i)
378 sinCur2 = sinCur1*cosHalf + cosCur1*sinHalf;
379 cosCur2 = cosCur1*cosHalf - sinCur1*sinHalf;
385 sinCur2 = (i == kphi) ? sinEnd : sinCur1*cosStep + cosCur1*sinStep;
386 cosCur2 = (i == kphi) ? cosEnd : cosCur1*cosStep - sinCur1*sinStep;
388 for (
G4int k=0; k<NDISK; ++k)
390 G4double r1 = rzmin[k].
x(), r2 = rzmax[k].
x();
391 G4double z1 = rzmin[k].
y(), z2 = rzmax[k].
y();
392 pols[k][0].set(r1*cosCur1,r1*sinCur1,z1);
393 pols[k][1].set(r2*cosCur1,r2*sinCur1,z2);
394 pols[k][2].set(r2*cosCur2,r2*sinCur2,z2);
395 pols[k][3].set(r1*cosCur2,r1*sinCur2,z1);
397 pols[NDISK] = pols[0];
402 DiskExtent(rint,rext,sinCur1,cosCur1,sinCur2,cosCur2,vmin,vmax);
409 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
410 if (emin < pMin) pMin = emin;
411 if (emax > pMax) pMax = emax;
412 if (eminlim > pMin && emaxlim < pMax)
break;
414 return (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)
void set(double x, double y, double z)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4double GetMinExtent(const EAxis pAxis) const
G4double GetMaxExtent(const EAxis pAxis) const