36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
43 using namespace CLHEP;
50 G4UCutTubs::G4UCutTubs(
const G4String& pName,
56 : Base_t(pName, pRMin, pRMax, pDz, pSPhi, pDPhi,
57 pLowNorm.
x(), pLowNorm.
y(), pLowNorm.
z(),
58 pHighNorm.
x(), pHighNorm.
y(), pHighNorm.
z())
67 G4UCutTubs::G4UCutTubs( __void__&
a )
76 G4UCutTubs::~G4UCutTubs()
84 G4UCutTubs::G4UCutTubs(
const G4UCutTubs& rhs)
93 G4UCutTubs& G4UCutTubs::operator = (
const G4UCutTubs& rhs)
97 if (
this == &rhs) {
return *
this; }
101 Base_t::operator=(rhs);
110 G4double G4UCutTubs::GetInnerRadius()
const
114 G4double G4UCutTubs::GetOuterRadius()
const
118 G4double G4UCutTubs::GetZHalfLength()
const
122 G4double G4UCutTubs::GetStartPhiAngle()
const
126 G4double G4UCutTubs::GetDeltaPhiAngle()
const
130 G4double G4UCutTubs::GetSinStartPhi()
const
132 return std::sin(GetStartPhiAngle());
134 G4double G4UCutTubs::GetCosStartPhi()
const
136 return std::cos(GetStartPhiAngle());
138 G4double G4UCutTubs::GetSinEndPhi()
const
140 return std::sin(GetStartPhiAngle()+GetDeltaPhiAngle());
142 G4double G4UCutTubs::GetCosEndPhi()
const
144 return std::cos(GetStartPhiAngle()+GetDeltaPhiAngle());
148 U3Vector lc = BottomNormal();
153 U3Vector
hc = TopNormal();
157 void G4UCutTubs::SetInnerRadius(
G4double newRMin)
160 fRebuildPolyhedron =
true;
162 void G4UCutTubs::SetOuterRadius(
G4double newRMax)
165 fRebuildPolyhedron =
true;
167 void G4UCutTubs::SetZHalfLength(
G4double newDz)
170 fRebuildPolyhedron =
true;
175 fRebuildPolyhedron =
true;
177 void G4UCutTubs::SetDeltaPhiAngle(
G4double newDPhi)
180 fRebuildPolyhedron =
true;
189 return new G4UCutTubs(*
this);
198 static G4bool checkBBox =
true;
205 G4double sinSphi = GetSinStartPhi();
206 G4double cosSphi = GetCosStartPhi();
211 G4double mag, topx, topy, dists, diste;
218 mag = std::sqrt(norm.
x()*norm.
x() + norm.
y()*norm.
y());
219 topx = (mag == 0) ? 0 : -rmax*norm.
x()/mag;
220 topy = (mag == 0) ? 0 : -rmax*norm.
y()/mag;
221 dists = sinSphi*topx - cosSphi*topy;
222 diste = -sinEphi*topx + cosEphi*topy;
226 if (dists > 0 && diste > 0)iftop =
false;
231 if (dists <= 0 && diste <= 0) iftop =
true;
235 zmin = -(norm.
x()*topx + norm.
y()*topy)/norm.
z() - dz;
239 G4double z1 = -rmin*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() - dz;
240 G4double z2 = -rmin*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() - dz;
241 G4double z3 = -rmax*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() - dz;
242 G4double z4 = -rmax*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() - dz;
249 norm = GetHighNorm();
250 mag = std::sqrt(norm.
x()*norm.
x() + norm.
y()*norm.
y());
251 topx = (mag == 0) ? 0 : -rmax*norm.
x()/mag;
252 topy = (mag == 0) ? 0 : -rmax*norm.
y()/mag;
253 dists = sinSphi*topx - cosSphi*topy;
254 diste = -sinEphi*topx + cosEphi*topy;
258 if (dists > 0 && diste > 0) iftop =
false;
263 if (dists <= 0 && diste <= 0) iftop =
true;
267 zmax = -(norm.
x()*topx + norm.
y()*topy)/norm.
z() + dz;
271 G4double z1 = -rmin*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() + dz;
272 G4double z2 = -rmin*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() + dz;
273 G4double z3 = -rmax*(norm.
x()*cosSphi + norm.
y()*sinSphi)/norm.
z() + dz;
274 G4double z4 = -rmax*(norm.
x()*cosEphi + norm.
y()*sinEphi)/norm.
z() + dz;
280 if (GetDeltaPhiAngle() <
twopi)
284 GetSinStartPhi(),GetCosStartPhi(),
285 GetSinEndPhi(),GetCosEndPhi(),
287 pMin.
set(vmin.
x(),vmin.
y(), zmin);
288 pMax.
set(vmax.
x(),vmax.
y(), zmax);
292 pMin.
set(-rmax,-rmax, zmin);
293 pMax.
set( rmax, rmax, zmax);
298 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
301 message <<
"Bad bounding box (min >= max) for solid: "
303 <<
"\npMin = " << pMin
304 <<
"\npMax = " << pMax;
305 G4Exception(
"G4CUutTubs::BoundingLimits()",
"GeomMgt0001",
324 message <<
"Inconsistency in bounding boxes for solid: "
326 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
327 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
328 G4Exception(
"G4UCutTubs::BoundingLimits()",
"GeomMgt0001",
340 G4UCutTubs::CalculateExtent(
const EAxis pAxis,
349 BoundingLimits(bmin,bmax);
354 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
356 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
358 return exist = (pMin < pMax) ?
true :
false;
370 const G4int NSTEPS = 24;
372 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
375 G4double sinHalf = std::sin(0.5*ang);
376 G4double cosHalf = std::cos(0.5*ang);
377 G4double sinStep = 2.*sinHalf*cosHalf;
378 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
383 if (rmin == 0 && dphi ==
twopi)
389 for (
G4int k=0; k<NSTEPS; ++k)
391 baseA[k].set(rext*cosCur,rext*sinCur,zmin);
392 baseB[k].set(rext*cosCur,rext*sinCur,zmax);
395 sinCur = sinCur*cosStep + cosCur*sinStep;
396 cosCur = cosCur*cosStep - sinTmp*sinStep;
398 std::vector<const G4ThreeVectorList *> polygons(2);
399 polygons[0] = &baseA;
400 polygons[1] = &baseB;
402 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
406 G4double sinStart = GetSinStartPhi();
407 G4double cosStart = GetCosStartPhi();
410 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
411 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
415 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
416 pols[0][0].set(rmin*cosStart,rmin*sinStart,zmax);
417 pols[0][1].set(rmin*cosStart,rmin*sinStart,zmin);
418 pols[0][2].set(rmax*cosStart,rmax*sinStart,zmin);
419 pols[0][3].set(rmax*cosStart,rmax*sinStart,zmax);
420 for (
G4int k=1; k<ksteps+1; ++k)
422 pols[k][0].set(rmin*cosCur,rmin*sinCur,zmax);
423 pols[k][1].set(rmin*cosCur,rmin*sinCur,zmin);
424 pols[k][2].set(rext*cosCur,rext*sinCur,zmin);
425 pols[k][3].set(rext*cosCur,rext*sinCur,zmax);
428 sinCur = sinCur*cosStep + cosCur*sinStep;
429 cosCur = cosCur*cosStep - sinTmp*sinStep;
431 pols[ksteps+1][0].set(rmin*cosEnd,rmin*sinEnd,zmax);
432 pols[ksteps+1][1].set(rmin*cosEnd,rmin*sinEnd,zmin);
433 pols[ksteps+1][2].set(rmax*cosEnd,rmax*sinEnd,zmin);
434 pols[ksteps+1][3].set(rmax*cosEnd,rmax*sinEnd,zmax);
437 std::vector<const G4ThreeVectorList *> polygons;
438 polygons.resize(ksteps+2);
439 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
441 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
460 newz = -GetZHalfLength()
461 - (p.
x()*fLowNorm.
x()+p.
y()*fLowNorm.
y())/fLowNorm.
z();
466 if(fHighNorm.
z()!=0.)
468 newz = GetZHalfLength()
469 - (p.
x()*fHighNorm.
x()+p.
y()*fHighNorm.
y())/fHighNorm.
z();
482 typedef G4int G4int4[4];
492 G4double3* xyz =
new G4double3[
nn];
493 G4int4* faces =
new G4int4[nf] ;
517 for(
G4int i=0;i<nf;++i)
522 faces[i][k]=iNodes[k];
524 for(
G4int k=n;k<4;++k)
538 #endif // G4GEOM_USE_USOLIDS
G4Point3D GetVertex(G4int index) const
void set(double x, double y, double z)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
void message(RunManager *runmanager)
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
static constexpr double deg
static constexpr double twopi
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4int GetNoVertices() const
G4GLOB_DLL std::ostream G4cout
static constexpr double pi
G4int GetNoFacets() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
const G4double hc
[MeV*fm]