34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
48G4UCons::G4UCons(
const G4String& pName,
53 : Base_t(pName, pRmin1, pRmax1, pRmin2, pRmax2, pDz, pSPhi, pDPhi)
62G4UCons::G4UCons( __void__& a )
71G4UCons::~G4UCons() =
default;
77G4UCons::G4UCons(
const G4UCons& rhs)
86G4UCons& G4UCons::operator = (
const G4UCons& rhs)
90 if (
this == &rhs) {
return *
this; }
94 Base_t::operator=(rhs);
103G4double G4UCons::GetInnerRadiusMinusZ()
const
107G4double G4UCons::GetOuterRadiusMinusZ()
const
111G4double G4UCons::GetInnerRadiusPlusZ()
const
115G4double G4UCons::GetOuterRadiusPlusZ()
const
119G4double G4UCons::GetZHalfLength()
const
123G4double G4UCons::GetStartPhiAngle()
const
127G4double G4UCons::GetDeltaPhiAngle()
const
131G4double G4UCons::GetSinStartPhi()
const
134 return std::sin(phi);
136G4double G4UCons::GetCosStartPhi()
const
139 return std::cos(phi);
141G4double G4UCons::GetSinEndPhi()
const
143 G4double phi = GetStartPhiAngle() + GetDeltaPhiAngle();
144 return std::sin(phi);
146G4double G4UCons::GetCosEndPhi()
const
148 G4double phi = GetStartPhiAngle() + GetDeltaPhiAngle();
149 return std::cos(phi);
152void G4UCons::SetInnerRadiusMinusZ(
G4double Rmin1)
155 fRebuildPolyhedron =
true;
157void G4UCons::SetOuterRadiusMinusZ(
G4double Rmax1)
160 fRebuildPolyhedron =
true;
162void G4UCons::SetInnerRadiusPlusZ(
G4double Rmin2)
165 fRebuildPolyhedron =
true;
167void G4UCons::SetOuterRadiusPlusZ(
G4double Rmax2)
170 fRebuildPolyhedron =
true;
172void G4UCons::SetZHalfLength(
G4double newDz)
175 fRebuildPolyhedron =
true;
180 fRebuildPolyhedron =
true;
182void G4UCons::SetDeltaPhiAngle(
G4double newDPhi)
185 fRebuildPolyhedron =
true;
206 return new G4UCons(*
this);
215 static G4bool checkBBox =
true;
217 G4double rmin = std::min(GetInnerRadiusMinusZ(),GetInnerRadiusPlusZ());
218 G4double rmax = std::max(GetOuterRadiusMinusZ(),GetOuterRadiusPlusZ());
223 if (GetDeltaPhiAngle() < twopi)
227 GetSinStartPhi(),GetCosStartPhi(),
228 GetSinEndPhi(),GetCosEndPhi(),
230 pMin.
set(vmin.
x(),vmin.
y(),-dz);
231 pMax.
set(vmax.
x(),vmax.
y(), dz);
235 pMin.
set(-rmax,-rmax,-dz);
236 pMax.
set( rmax, rmax, dz);
241 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
243 std::ostringstream message;
244 message <<
"Bad bounding box (min >= max) for solid: "
246 <<
"\npMin = " << pMin
247 <<
"\npMax = " << pMax;
248 G4Exception(
"G4UCons::BoundingLimits()",
"GeomMgt0001",
266 std::ostringstream message;
267 message <<
"Inconsistency in bounding boxes for solid: "
269 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
270 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
271 G4Exception(
"G4UCons::BoundingLimits()",
"GeomMgt0001",
283G4UCons::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;
305 G4double rmin1 = GetInnerRadiusMinusZ();
306 G4double rmax1 = GetOuterRadiusMinusZ();
307 G4double rmin2 = GetInnerRadiusPlusZ();
308 G4double rmax2 = GetOuterRadiusPlusZ();
314 const G4int NSTEPS = 24;
316 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-deg)/astep) + 1;
319 G4double sinHalf = std::sin(0.5*ang);
320 G4double cosHalf = std::cos(0.5*ang);
321 G4double sinStep = 2.*sinHalf*cosHalf;
322 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
328 if (rmin1 == 0 && rmin2 == 0 && dphi == twopi)
334 for (
G4int k=0; k<NSTEPS; ++k)
336 baseA[k].set(rext1*cosCur,rext1*sinCur,-dz);
337 baseB[k].set(rext2*cosCur,rext2*sinCur, dz);
340 sinCur = sinCur*cosStep + cosCur*sinStep;
341 cosCur = cosCur*cosStep - sinTmp*sinStep;
343 std::vector<const G4ThreeVectorList *> polygons(2);
344 polygons[0] = &baseA;
345 polygons[1] = &baseB;
347 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
351 G4double sinStart = GetSinStartPhi();
352 G4double cosStart = GetCosStartPhi();
355 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
356 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
360 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
361 pols[0][0].set(rmin2*cosStart,rmin2*sinStart, dz);
362 pols[0][1].set(rmin1*cosStart,rmin1*sinStart,-dz);
363 pols[0][2].set(rmax1*cosStart,rmax1*sinStart,-dz);
364 pols[0][3].set(rmax2*cosStart,rmax2*sinStart, dz);
365 for (
G4int k=1; k<ksteps+1; ++k)
367 pols[k][0].set(rmin2*cosCur,rmin2*sinCur, dz);
368 pols[k][1].set(rmin1*cosCur,rmin1*sinCur,-dz);
369 pols[k][2].set(rext1*cosCur,rext1*sinCur,-dz);
370 pols[k][3].set(rext2*cosCur,rext2*sinCur, dz);
373 sinCur = sinCur*cosStep + cosCur*sinStep;
374 cosCur = cosCur*cosStep - sinTmp*sinStep;
376 pols[ksteps+1][0].set(rmin2*cosEnd,rmin2*sinEnd, dz);
377 pols[ksteps+1][1].set(rmin1*cosEnd,rmin1*sinEnd,-dz);
378 pols[ksteps+1][2].set(rmax1*cosEnd,rmax1*sinEnd,-dz);
379 pols[ksteps+1][3].set(rmax2*cosEnd,rmax2*sinEnd, dz);
382 std::vector<const G4ThreeVectorList *> polygons;
383 polygons.resize(ksteps+2);
384 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
386 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
398 GetOuterRadiusMinusZ(),
399 GetInnerRadiusPlusZ(),
400 GetOuterRadiusPlusZ(),
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const