34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
43 using namespace CLHEP;
50 G4UTorus::G4UTorus(
const G4String& pName,
53 : Base_t(pName, rmin, rmax, rtor, sphi, dphi)
61 G4UTorus::G4UTorus( __void__&
a )
69 G4UTorus::~G4UTorus() { }
75 G4UTorus::G4UTorus(
const G4UTorus& rhs)
83 G4UTorus& G4UTorus::operator = (
const G4UTorus& rhs)
87 if (
this == &rhs) {
return *
this; }
91 Base_t::operator=(rhs);
125 G4double G4UTorus::GetSinStartPhi()
const
127 return std::sin(sphi());
130 G4double G4UTorus::GetCosStartPhi()
const
132 return std::cos(sphi());
135 G4double G4UTorus::GetSinEndPhi()
const
137 return std::sin(sphi()+dphi());
140 G4double G4UTorus::GetCosEndPhi()
const
142 return std::cos(sphi()+dphi());
145 void G4UTorus::SetRmin(
G4double arg)
147 Base_t::SetRMin(arg);
148 fRebuildPolyhedron =
true;
151 void G4UTorus::SetRmax(
G4double arg)
153 Base_t::SetRMax(arg);
154 fRebuildPolyhedron =
true;
157 void G4UTorus::SetRtor(
G4double arg)
159 Base_t::SetRTor(arg);
160 fRebuildPolyhedron =
true;
163 void G4UTorus::SetSPhi(
G4double arg)
165 Base_t::SetSPhi(arg);
166 fRebuildPolyhedron =
true;
169 void G4UTorus::SetDPhi(
G4double arg)
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())
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);
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",
283 G4UTorus::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;
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;
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);
430 #endif // G4GEOM_USE_USOLIDS