36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
43 using namespace CLHEP;
50 G4UCons::G4UCons(
const G4String& pName,
55 : Base_t(pName, pRmin1, pRmax1, pRmin2, pRmax2, pDz, pSPhi, pDPhi)
64 G4UCons::G4UCons( __void__&
a )
81 G4UCons::G4UCons(
const G4UCons& rhs)
90 G4UCons& G4UCons::operator = (
const G4UCons& rhs)
94 if (
this == &rhs) {
return *
this; }
98 Base_t::operator=(rhs);
107 G4double G4UCons::GetInnerRadiusMinusZ()
const
111 G4double G4UCons::GetOuterRadiusMinusZ()
const
115 G4double G4UCons::GetInnerRadiusPlusZ()
const
119 G4double G4UCons::GetOuterRadiusPlusZ()
const
123 G4double G4UCons::GetZHalfLength()
const
127 G4double G4UCons::GetStartPhiAngle()
const
131 G4double G4UCons::GetDeltaPhiAngle()
const
135 G4double G4UCons::GetSinStartPhi()
const
138 return std::sin(phi);
140 G4double G4UCons::GetCosStartPhi()
const
143 return std::cos(phi);
145 G4double G4UCons::GetSinEndPhi()
const
147 G4double phi = GetStartPhiAngle() + GetDeltaPhiAngle();
148 return std::sin(phi);
150 G4double G4UCons::GetCosEndPhi()
const
152 G4double phi = GetStartPhiAngle() + GetDeltaPhiAngle();
153 return std::cos(phi);
156 void G4UCons::SetInnerRadiusMinusZ(
G4double Rmin1)
159 fRebuildPolyhedron =
true;
161 void G4UCons::SetOuterRadiusMinusZ(
G4double Rmax1)
164 fRebuildPolyhedron =
true;
166 void G4UCons::SetInnerRadiusPlusZ(
G4double Rmin2)
169 fRebuildPolyhedron =
true;
171 void G4UCons::SetOuterRadiusPlusZ(
G4double Rmax2)
174 fRebuildPolyhedron =
true;
176 void G4UCons::SetZHalfLength(
G4double newDz)
179 fRebuildPolyhedron =
true;
184 fRebuildPolyhedron =
true;
186 void G4UCons::SetDeltaPhiAngle(
G4double newDPhi)
189 fRebuildPolyhedron =
true;
210 return new G4UCons(*
this);
219 static G4bool checkBBox =
true;
227 if (GetDeltaPhiAngle() <
twopi)
231 GetSinStartPhi(),GetCosStartPhi(),
232 GetSinEndPhi(),GetCosEndPhi(),
234 pMin.
set(vmin.
x(),vmin.
y(),-dz);
235 pMax.
set(vmax.
x(),vmax.
y(), dz);
239 pMin.
set(-rmax,-rmax,-dz);
240 pMax.
set( rmax, rmax, 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(
"G4UCons::BoundingLimits()",
"GeomMgt0001",
271 message <<
"Inconsistency in bounding boxes for solid: "
273 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
274 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
275 G4Exception(
"G4UCons::BoundingLimits()",
"GeomMgt0001",
287 G4UCons::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;
309 G4double rmin1 = GetInnerRadiusMinusZ();
310 G4double rmax1 = GetOuterRadiusMinusZ();
311 G4double rmin2 = GetInnerRadiusPlusZ();
312 G4double rmax2 = GetOuterRadiusPlusZ();
318 const G4int NSTEPS = 24;
320 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
323 G4double sinHalf = std::sin(0.5*ang);
324 G4double cosHalf = std::cos(0.5*ang);
325 G4double sinStep = 2.*sinHalf*cosHalf;
326 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
332 if (rmin1 == 0 && rmin2 == 0 && dphi ==
twopi)
338 for (
G4int k=0; k<NSTEPS; ++k)
340 baseA[k].set(rext1*cosCur,rext1*sinCur,-dz);
341 baseB[k].set(rext2*cosCur,rext2*sinCur, dz);
344 sinCur = sinCur*cosStep + cosCur*sinStep;
345 cosCur = cosCur*cosStep - sinTmp*sinStep;
347 std::vector<const G4ThreeVectorList *> polygons(2);
348 polygons[0] = &baseA;
349 polygons[1] = &baseB;
351 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
355 G4double sinStart = GetSinStartPhi();
356 G4double cosStart = GetCosStartPhi();
359 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
360 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
364 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
365 pols[0][0].set(rmin2*cosStart,rmin2*sinStart, dz);
366 pols[0][1].set(rmin1*cosStart,rmin1*sinStart,-dz);
367 pols[0][2].set(rmax1*cosStart,rmax1*sinStart,-dz);
368 pols[0][3].set(rmax2*cosStart,rmax2*sinStart, dz);
369 for (
G4int k=1; k<ksteps+1; ++k)
371 pols[k][0].set(rmin2*cosCur,rmin2*sinCur, dz);
372 pols[k][1].set(rmin1*cosCur,rmin1*sinCur,-dz);
373 pols[k][2].set(rext1*cosCur,rext1*sinCur,-dz);
374 pols[k][3].set(rext2*cosCur,rext2*sinCur, dz);
377 sinCur = sinCur*cosStep + cosCur*sinStep;
378 cosCur = cosCur*cosStep - sinTmp*sinStep;
380 pols[ksteps+1][0].set(rmin2*cosEnd,rmin2*sinEnd, dz);
381 pols[ksteps+1][1].set(rmin1*cosEnd,rmin1*sinEnd,-dz);
382 pols[ksteps+1][2].set(rmax1*cosEnd,rmax1*sinEnd,-dz);
383 pols[ksteps+1][3].set(rmax2*cosEnd,rmax2*sinEnd, dz);
386 std::vector<const G4ThreeVectorList *> polygons;
387 polygons.resize(ksteps+2);
388 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
390 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
402 GetOuterRadiusMinusZ(),
403 GetInnerRadiusPlusZ(),
404 GetOuterRadiusPlusZ(),
410 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
std::vector< ExP01TrackerHit * > a
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
void message(RunManager *runmanager)
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
static constexpr double deg
static constexpr double twopi
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
T min(const T t1, const T t2)
brief Return the smallest of the two arguments