34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
41 using namespace CLHEP;
48 G4UCutTubs::G4UCutTubs(
const G4String& pName,
54 : Base_t(pName, pRMin, pRMax, pDz, pSPhi, pDPhi,
55 pLowNorm.
x(), pLowNorm.
y(), pLowNorm.
z(),
56 pHighNorm.
x(), pHighNorm.
y(), pHighNorm.
z())
65 G4UCutTubs::G4UCutTubs( __void__&
a )
74 G4UCutTubs::~G4UCutTubs()
82 G4UCutTubs::G4UCutTubs(
const G4UCutTubs& rhs)
91 G4UCutTubs& G4UCutTubs::operator = (
const G4UCutTubs& rhs)
95 if (
this == &rhs) {
return *
this; }
99 Base_t::operator=(rhs);
108 G4double G4UCutTubs::GetInnerRadius()
const
112 G4double G4UCutTubs::GetOuterRadius()
const
116 G4double G4UCutTubs::GetZHalfLength()
const
120 G4double G4UCutTubs::GetStartPhiAngle()
const
124 G4double G4UCutTubs::GetDeltaPhiAngle()
const
128 G4double G4UCutTubs::GetSinStartPhi()
const
130 return std::sin(GetStartPhiAngle());
132 G4double G4UCutTubs::GetCosStartPhi()
const
134 return std::cos(GetStartPhiAngle());
136 G4double G4UCutTubs::GetSinEndPhi()
const
138 return std::sin(GetStartPhiAngle()+GetDeltaPhiAngle());
140 G4double G4UCutTubs::GetCosEndPhi()
const
142 return std::cos(GetStartPhiAngle()+GetDeltaPhiAngle());
146 U3Vector
lc = BottomNormal();
151 U3Vector
hc = TopNormal();
155 void G4UCutTubs::SetInnerRadius(
G4double newRMin)
158 fRebuildPolyhedron =
true;
160 void G4UCutTubs::SetOuterRadius(
G4double newRMax)
163 fRebuildPolyhedron =
true;
165 void G4UCutTubs::SetZHalfLength(
G4double newDz)
168 fRebuildPolyhedron =
true;
173 fRebuildPolyhedron =
true;
175 void G4UCutTubs::SetDeltaPhiAngle(
G4double newDPhi)
178 fRebuildPolyhedron =
true;
187 return new G4UCutTubs(*
this);
196 static G4bool checkBBox =
true;
203 G4double sinSphi = GetSinStartPhi();
204 G4double cosSphi = GetCosStartPhi();
209 G4double mag, topx, topy, dists, diste;
216 mag = std::sqrt(norm.
x()*norm.
x() + norm.
y()*norm.
y());
217 topx = (mag == 0) ? 0 : -rmax*norm.
x()/mag;
218 topy = (mag == 0) ? 0 : -rmax*norm.
y()/mag;
219 dists = sinSphi*topx - cosSphi*topy;
220 diste = -sinEphi*topx + cosEphi*topy;
224 if (dists > 0 && diste > 0)iftop =
false;
229 if (dists <= 0 && diste <= 0) iftop =
true;
233 zmin = -(norm.
x()*topx + norm.
y()*topy)/norm.
z() -
dz;
237 G4double z1 = -rmin*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() -
dz;
238 G4double z2 = -rmin*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() -
dz;
239 G4double z3 = -rmax*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() -
dz;
240 G4double z4 = -rmax*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() -
dz;
247 norm = GetHighNorm();
248 mag = std::sqrt(norm.
x()*norm.
x() + norm.
y()*norm.
y());
249 topx = (mag == 0) ? 0 : -rmax*norm.
x()/mag;
250 topy = (mag == 0) ? 0 : -rmax*norm.
y()/mag;
251 dists = sinSphi*topx - cosSphi*topy;
252 diste = -sinEphi*topx + cosEphi*topy;
256 if (dists > 0 && diste > 0) iftop =
false;
261 if (dists <= 0 && diste <= 0) iftop =
true;
265 zmax = -(norm.
x()*topx + norm.
y()*topy)/norm.
z() +
dz;
269 G4double z1 = -rmin*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() +
dz;
270 G4double z2 = -rmin*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() +
dz;
271 G4double z3 = -rmax*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() +
dz;
272 G4double z4 = -rmax*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() +
dz;
278 if (GetDeltaPhiAngle() <
twopi)
282 GetSinStartPhi(),GetCosStartPhi(),
283 GetSinEndPhi(),GetCosEndPhi(),
285 pMin.
set(vmin.
x(),vmin.
y(), zmin);
286 pMax.
set(vmax.
x(),vmax.
y(), zmax);
290 pMin.
set(-rmax,-rmax, zmin);
291 pMax.
set( rmax, rmax, zmax);
296 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
299 message <<
"Bad bounding box (min >= max) for solid: "
301 <<
"\npMin = " << pMin
302 <<
"\npMax = " <<
pMax;
303 G4Exception(
"G4CUutTubs::BoundingLimits()",
"GeomMgt0001",
322 message <<
"Inconsistency in bounding boxes for solid: "
324 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
325 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
326 G4Exception(
"G4UCutTubs::BoundingLimits()",
"GeomMgt0001",
338 G4UCutTubs::CalculateExtent(
const EAxis pAxis,
347 BoundingLimits(bmin,bmax);
352 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
354 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
356 return exist = (pMin <
pMax) ?
true :
false;
368 const G4int NSTEPS = 24;
370 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
373 G4double sinHalf = std::sin(0.5*ang);
374 G4double cosHalf = std::cos(0.5*ang);
375 G4double sinStep = 2.*sinHalf*cosHalf;
376 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
381 if (rmin == 0 && dphi ==
twopi)
389 baseA[
k].set(rext*cosCur,rext*sinCur,zmin);
390 baseB[
k].set(rext*cosCur,rext*sinCur,zmax);
393 sinCur = sinCur*cosStep + cosCur*sinStep;
394 cosCur = cosCur*cosStep - sinTmp*sinStep;
396 std::vector<const G4ThreeVectorList *> polygons(2);
397 polygons[0] = &baseA;
398 polygons[1] = &baseB;
400 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
404 G4double sinStart = GetSinStartPhi();
405 G4double cosStart = GetCosStartPhi();
408 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
409 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
413 for (
G4int k=0;
k<ksteps+2; ++
k) pols[
k].resize(4);
414 pols[0][0].set(rmin*cosStart,rmin*sinStart,zmax);
415 pols[0][1].set(rmin*cosStart,rmin*sinStart,zmin);
416 pols[0][2].set(rmax*cosStart,rmax*sinStart,zmin);
417 pols[0][3].set(rmax*cosStart,rmax*sinStart,zmax);
420 pols[
k][0].set(rmin*cosCur,rmin*sinCur,zmax);
421 pols[
k][1].set(rmin*cosCur,rmin*sinCur,zmin);
422 pols[
k][2].set(rext*cosCur,rext*sinCur,zmin);
423 pols[
k][3].set(rext*cosCur,rext*sinCur,zmax);
426 sinCur = sinCur*cosStep + cosCur*sinStep;
427 cosCur = cosCur*cosStep - sinTmp*sinStep;
429 pols[ksteps+1][0].set(rmin*cosEnd,rmin*sinEnd,zmax);
430 pols[ksteps+1][1].set(rmin*cosEnd,rmin*sinEnd,zmin);
431 pols[ksteps+1][2].set(rmax*cosEnd,rmax*sinEnd,zmin);
432 pols[ksteps+1][3].set(rmax*cosEnd,rmax*sinEnd,zmax);
435 std::vector<const G4ThreeVectorList *> polygons;
436 polygons.resize(ksteps+2);
437 for (
G4int k=0;
k<ksteps+2; ++
k) polygons[
k] = &pols[
k];
439 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
458 newz = -GetZHalfLength()
459 - (p.
x()*fLowNorm.
x()+p.
y()*fLowNorm.
y())/fLowNorm.
z();
464 if(fHighNorm.
z()!=0.)
466 newz = GetZHalfLength()
467 - (p.
x()*fHighNorm.
x()+p.
y()*fHighNorm.
y())/fHighNorm.
z();
480 typedef G4int G4int4[4];
490 G4double3* xyz =
new G4double3[
nn];
491 G4int4* faces =
new G4int4[nf] ;
515 for(
G4int i=0; i<nf; ++i)
520 faces[i][
k]=iNodes[
k];
536 #endif // G4GEOM_USE_USOLIDS