38 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
47 using namespace CLHEP;
54 G4UTorus::G4UTorus(
const G4String& pName,
57 : Base_t(pName, rmin, rmax, rtor, sphi, dphi)
65 G4UTorus::G4UTorus( __void__&
a )
73 G4UTorus::~G4UTorus() { }
79 G4UTorus::G4UTorus(
const G4UTorus& rhs)
87 G4UTorus& G4UTorus::operator = (
const G4UTorus& rhs)
91 if (
this == &rhs) {
return *
this; }
95 Base_t::operator=(rhs);
129 G4double G4UTorus::GetSinStartPhi()
const
131 return std::sin(sphi());
134 G4double G4UTorus::GetCosStartPhi()
const
136 return std::cos(sphi());
139 G4double G4UTorus::GetSinEndPhi()
const
141 return std::sin(sphi()+dphi());
144 G4double G4UTorus::GetCosEndPhi()
const
146 return std::cos(sphi()+dphi());
149 void G4UTorus::SetRmin(
G4double arg)
151 Base_t::SetRMin(arg);
152 fRebuildPolyhedron =
true;
155 void G4UTorus::SetRmax(
G4double arg)
157 Base_t::SetRMax(arg);
158 fRebuildPolyhedron =
true;
161 void G4UTorus::SetRtor(
G4double arg)
163 Base_t::SetRTor(arg);
164 fRebuildPolyhedron =
true;
167 void G4UTorus::SetSPhi(
G4double arg)
169 Base_t::SetSPhi(arg);
170 fRebuildPolyhedron =
true;
173 void G4UTorus::SetDPhi(
G4double arg)
175 Base_t::SetDPhi(arg);
176 fRebuildPolyhedron =
true;
187 fRebuildPolyhedron =
true;
208 return new G4UTorus(*
this);
217 static G4bool checkBBox =
true;
227 if (GetDPhi() >=
twopi)
229 pMin.
set(-rext,-rext,-dz);
230 pMax.
set( rext, rext, dz);
236 GetSinStartPhi(),GetCosStartPhi(),
237 GetSinEndPhi(),GetCosEndPhi(),
239 pMin.
set(vmin.
x(),vmin.
y(),-dz);
240 pMax.
set(vmax.
x(),vmax.
y(), dz);
245 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
248 message <<
"Bad bounding box (min >= max) for solid: "
250 <<
"\npMin = " << pMin
251 <<
"\npMax = " << pMax;
252 G4Exception(
"G4UTorus::BoundingLimits()",
"GeomMgt0001",
262 Base_t::Extent(vmin,vmax);
271 message <<
"Inconsistency in bounding boxes for solid: "
273 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
274 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
275 G4Exception(
"G4UTorus::BoundingLimits()",
"GeomMgt0001",
287 G4UTorus::CalculateExtent(
const EAxis pAxis,
296 BoundingLimits(bmin,bmax);
301 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
303 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
305 return exist = (pMin < pMax) ?
true :
false;
313 G4double sinStart = GetSinStartPhi();
314 G4double cosStart = GetCosStartPhi();
322 static const G4int NPHI = 24;
323 static const G4int NDISK = 16;
324 static const G4double sinHalfDisk = std::sin(
pi/NDISK);
325 static const G4double cosHalfDisk = std::cos(
pi/NDISK);
326 static const G4double sinStepDisk = 2.*sinHalfDisk*cosHalfDisk;
327 static const G4double cosStepDisk = 1. - 2.*sinHalfDisk*sinHalfDisk;
330 G4int kphi = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
333 G4double sinHalf = std::sin(0.5*ang);
334 G4double cosHalf = std::cos(0.5*ang);
335 G4double sinStep = 2.*sinHalf*cosHalf;
336 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
340 for (
G4int k=0; k<NDISK+1; ++k) pols[k].resize(4);
342 std::vector<const G4ThreeVectorList *> polygons;
343 polygons.resize(NDISK+1);
344 for (
G4int k=0; k<NDISK+1; ++k) polygons[k] = &pols[k];
350 if ((rtor-rmin*sinHalfDisk)/cosHalf > (rtor+rmin*sinHalfDisk)) rmin = 0;
354 for (
G4int k=0; k<NDISK; ++k)
356 G4double rmincur = rtor + rmin*cosCurDisk;
357 if (cosCurDisk < 0 && rmin > 0) rmincur /= cosHalf;
358 rzmin[k].
set(rmincur,rmin*sinCurDisk);
360 G4double rmaxcur = rtor + rmax*cosCurDisk;
361 if (cosCurDisk > 0) rmaxcur /= cosHalf;
362 rzmax[k].
set(rmaxcur,rmax*sinCurDisk);
365 sinCurDisk = sinCurDisk*cosStepDisk + cosCurDisk*sinStepDisk;
366 cosCurDisk = cosCurDisk*cosStepDisk - sinTmpDisk*sinStepDisk;
375 G4double sinCur1 = 0, cosCur1 = 0, sinCur2 = 0, cosCur2 = 0;
376 for (
G4int i=0; i<kphi+1; ++i)
382 sinCur2 = sinCur1*cosHalf + cosCur1*sinHalf;
383 cosCur2 = cosCur1*cosHalf - sinCur1*sinHalf;
389 sinCur2 = (i == kphi) ? sinEnd : sinCur1*cosStep + cosCur1*sinStep;
390 cosCur2 = (i == kphi) ? cosEnd : cosCur1*cosStep - sinCur1*sinStep;
392 for (
G4int k=0; k<NDISK; ++k)
394 G4double r1 = rzmin[k].
x(), r2 = rzmax[k].
x();
395 G4double z1 = rzmin[k].
y(), z2 = rzmax[k].
y();
396 pols[k][0].set(r1*cosCur1,r1*sinCur1,z1);
397 pols[k][1].set(r2*cosCur1,r2*sinCur1,z2);
398 pols[k][2].set(r2*cosCur2,r2*sinCur2,z2);
399 pols[k][3].set(r1*cosCur2,r1*sinCur2,z1);
401 pols[NDISK] = pols[0];
406 DiskExtent(rint,rext,sinCur1,cosCur1,sinCur2,cosCur2,vmin,vmax);
413 if (!benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,emin,emax))
continue;
414 if (emin < pMin) pMin = emin;
415 if (emax > pMax) pMax =
emax;
416 if (eminlim > pMin && emaxlim < pMax)
break;
418 return (pMin < pMax);
434 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
G4double GetMaxExtent(const EAxis pAxis) const
std::vector< ExP01TrackerHit * > a
static const G4double kInfinity
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
void message(RunManager *runmanager)
static const G4double emax
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
G4double GetMinExtent(const EAxis pAxis) const
static constexpr double deg
static constexpr double twopi
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void set(double x, double y)
G4GLOB_DLL std::ostream G4cout
static constexpr double pi