34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
48G4UCutTubs::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())
65G4UCutTubs::G4UCutTubs( __void__& a )
74G4UCutTubs::~G4UCutTubs() =
default;
80G4UCutTubs::G4UCutTubs(
const G4UCutTubs& rhs)
89G4UCutTubs& G4UCutTubs::operator = (
const G4UCutTubs& rhs)
93 if (
this == &rhs) {
return *
this; }
97 Base_t::operator=(rhs);
106G4double G4UCutTubs::GetInnerRadius()
const
110G4double G4UCutTubs::GetOuterRadius()
const
114G4double G4UCutTubs::GetZHalfLength()
const
118G4double G4UCutTubs::GetStartPhiAngle()
const
122G4double G4UCutTubs::GetDeltaPhiAngle()
const
126G4double G4UCutTubs::GetSinStartPhi()
const
128 return std::sin(GetStartPhiAngle());
130G4double G4UCutTubs::GetCosStartPhi()
const
132 return std::cos(GetStartPhiAngle());
134G4double G4UCutTubs::GetSinEndPhi()
const
136 return std::sin(GetStartPhiAngle()+GetDeltaPhiAngle());
138G4double G4UCutTubs::GetCosEndPhi()
const
140 return std::cos(GetStartPhiAngle()+GetDeltaPhiAngle());
144 U3Vector lc = BottomNormal();
145 return {lc.x(), lc.y(), lc.z()};
149 U3Vector
hc = TopNormal();
150 return {
hc.x(),
hc.y(),
hc.z()};
153void G4UCutTubs::SetInnerRadius(
G4double newRMin)
156 fRebuildPolyhedron =
true;
158void G4UCutTubs::SetOuterRadius(
G4double newRMax)
161 fRebuildPolyhedron =
true;
163void G4UCutTubs::SetZHalfLength(
G4double newDz)
166 fRebuildPolyhedron =
true;
171 fRebuildPolyhedron =
true;
173void G4UCutTubs::SetDeltaPhiAngle(
G4double newDPhi)
176 fRebuildPolyhedron =
true;
185 return new G4UCutTubs(*
this);
194 static G4bool checkBBox =
true;
201 G4double sinSphi = GetSinStartPhi();
202 G4double cosSphi = GetCosStartPhi();
207 G4double mag, topx, topy, dists, diste;
214 mag = std::sqrt(norm.
x()*norm.
x() + norm.
y()*norm.
y());
215 topx = (mag == 0) ? 0 : -rmax*norm.x()/mag;
216 topy = (mag == 0) ? 0 : -rmax*norm.
y()/mag;
217 dists = sinSphi*topx - cosSphi*topy;
218 diste = -sinEphi*topx + cosEphi*topy;
222 if (dists > 0 && diste > 0)iftop =
false;
227 if (dists <= 0 && diste <= 0) iftop =
true;
231 zmin = -(norm.
x()*topx + norm.
y()*topy)/norm.
z() - dz;
235 G4double z1 = -rmin*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() - dz;
236 G4double z2 = -rmin*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() - dz;
237 G4double z3 = -rmax*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() - dz;
238 G4double z4 = -rmax*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() - dz;
239 zmin = std::min(std::min(std::min(z1,z2),z3),z4);
245 norm = GetHighNorm();
246 mag = std::sqrt(norm.
x()*norm.
x() + norm.
y()*norm.
y());
247 topx = (mag == 0) ? 0 : -rmax*norm.x()/mag;
248 topy = (mag == 0) ? 0 : -rmax*norm.
y()/mag;
249 dists = sinSphi*topx - cosSphi*topy;
250 diste = -sinEphi*topx + cosEphi*topy;
254 if (dists > 0 && diste > 0) iftop =
false;
259 if (dists <= 0 && diste <= 0) iftop =
true;
263 zmax = -(norm.
x()*topx + norm.
y()*topy)/norm.
z() + dz;
267 G4double z1 = -rmin*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() + dz;
268 G4double z2 = -rmin*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() + dz;
269 G4double z3 = -rmax*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() + dz;
270 G4double z4 = -rmax*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() + dz;
271 zmax = std::max(std::max(std::max(z1,z2),z3),z4);
276 if (GetDeltaPhiAngle() < twopi)
280 GetSinStartPhi(),GetCosStartPhi(),
281 GetSinEndPhi(),GetCosEndPhi(),
283 pMin.
set(vmin.
x(),vmin.
y(), zmin);
284 pMax.
set(vmax.
x(),vmax.
y(), zmax);
288 pMin.
set(-rmax,-rmax, zmin);
289 pMax.
set( rmax, rmax, zmax);
294 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
296 std::ostringstream message;
297 message <<
"Bad bounding box (min >= max) for solid: "
299 <<
"\npMin = " << pMin
300 <<
"\npMax = " << pMax;
301 G4Exception(
"G4CUutTubs::BoundingLimits()",
"GeomMgt0001",
302 JustWarning, message);
319 std::ostringstream message;
320 message <<
"Inconsistency in bounding boxes for solid: "
322 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
323 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
324 G4Exception(
"G4UCutTubs::BoundingLimits()",
"GeomMgt0001",
336G4UCutTubs::CalculateExtent(
const EAxis pAxis,
345 BoundingLimits(bmin,bmax);
350 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
352 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
354 return exist = pMin < pMax;
366 const G4int NSTEPS = 24;
368 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-deg)/astep) + 1;
371 G4double sinHalf = std::sin(0.5*ang);
372 G4double cosHalf = std::cos(0.5*ang);
373 G4double sinStep = 2.*sinHalf*cosHalf;
374 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
379 if (rmin == 0 && dphi == twopi)
385 for (
G4int k=0; k<NSTEPS; ++k)
387 baseA[k].set(rext*cosCur,rext*sinCur,zmin);
388 baseB[k].set(rext*cosCur,rext*sinCur,zmax);
391 sinCur = sinCur*cosStep + cosCur*sinStep;
392 cosCur = cosCur*cosStep - sinTmp*sinStep;
394 std::vector<const G4ThreeVectorList *> polygons(2);
395 polygons[0] = &baseA;
396 polygons[1] = &baseB;
398 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
402 G4double sinStart = GetSinStartPhi();
403 G4double cosStart = GetCosStartPhi();
406 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
407 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
411 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
412 pols[0][0].set(rmin*cosStart,rmin*sinStart,zmax);
413 pols[0][1].set(rmin*cosStart,rmin*sinStart,zmin);
414 pols[0][2].set(rmax*cosStart,rmax*sinStart,zmin);
415 pols[0][3].set(rmax*cosStart,rmax*sinStart,zmax);
416 for (
G4int k=1; k<ksteps+1; ++k)
418 pols[k][0].set(rmin*cosCur,rmin*sinCur,zmax);
419 pols[k][1].set(rmin*cosCur,rmin*sinCur,zmin);
420 pols[k][2].set(rext*cosCur,rext*sinCur,zmin);
421 pols[k][3].set(rext*cosCur,rext*sinCur,zmax);
424 sinCur = sinCur*cosStep + cosCur*sinStep;
425 cosCur = cosCur*cosStep - sinTmp*sinStep;
427 pols[ksteps+1][0].set(rmin*cosEnd,rmin*sinEnd,zmax);
428 pols[ksteps+1][1].set(rmin*cosEnd,rmin*sinEnd,zmin);
429 pols[ksteps+1][2].set(rmax*cosEnd,rmax*sinEnd,zmin);
430 pols[ksteps+1][3].set(rmax*cosEnd,rmax*sinEnd,zmax);
433 std::vector<const G4ThreeVectorList *> polygons;
434 polygons.resize(ksteps+2);
435 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
437 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
456 newz = -GetZHalfLength()
457 - (p.
x()*fLowNorm.
x()+p.
y()*fLowNorm.
y())/fLowNorm.
z();
462 if(fHighNorm.
z()!=0.)
464 newz = GetZHalfLength()
465 - (p.
x()*fHighNorm.
x()+p.
y()*fHighNorm.
y())/fHighNorm.
z();
478 typedef G4int G4int4[4];
488 auto xyz =
new G4double3[
nn];
489 auto faces =
new G4int4[nf] ;
511 G4int* iEdge=
nullptr;
513 for(
G4int i=0; i<nf; ++i)
518 faces[i][k]=iNodes[k];
520 for(
G4int k=n; k<4; ++k)
525 ph->createPolyhedron(nn,nf,xyz,faces);
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
void set(double x, double y, double z)
G4Point3D GetVertex(G4int index) const
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=nullptr, G4int *iFaces=nullptr) const
G4int GetNoFacets() const
G4int GetNoVertices() const
const G4double hc
[MeV*fm]