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)
61G4UCons::G4UCons(
const G4UCons& rhs)
70G4UCons& G4UCons::operator = (
const G4UCons& rhs)
74 if (
this == &rhs) {
return *
this; }
78 Base_t::operator=(rhs);
87G4double G4UCons::GetInnerRadiusMinusZ()
const
91G4double G4UCons::GetOuterRadiusMinusZ()
const
95G4double G4UCons::GetInnerRadiusPlusZ()
const
99G4double G4UCons::GetOuterRadiusPlusZ()
const
103G4double G4UCons::GetZHalfLength()
const
107G4double G4UCons::GetStartPhiAngle()
const
111G4double G4UCons::GetDeltaPhiAngle()
const
115G4double G4UCons::GetSinStartPhi()
const
118 return std::sin(phi);
120G4double G4UCons::GetCosStartPhi()
const
123 return std::cos(phi);
125G4double G4UCons::GetSinEndPhi()
const
127 G4double phi = GetStartPhiAngle() + GetDeltaPhiAngle();
128 return std::sin(phi);
130G4double G4UCons::GetCosEndPhi()
const
132 G4double phi = GetStartPhiAngle() + GetDeltaPhiAngle();
133 return std::cos(phi);
136void G4UCons::SetInnerRadiusMinusZ(
G4double Rmin1)
139 fRebuildPolyhedron =
true;
141void G4UCons::SetOuterRadiusMinusZ(
G4double Rmax1)
144 fRebuildPolyhedron =
true;
146void G4UCons::SetInnerRadiusPlusZ(
G4double Rmin2)
149 fRebuildPolyhedron =
true;
151void G4UCons::SetOuterRadiusPlusZ(
G4double Rmax2)
154 fRebuildPolyhedron =
true;
156void G4UCons::SetZHalfLength(
G4double newDz)
159 fRebuildPolyhedron =
true;
164 fRebuildPolyhedron =
true;
166void G4UCons::SetDeltaPhiAngle(
G4double newDPhi)
169 fRebuildPolyhedron =
true;
190 return new G4UCons(*
this);
199 static G4bool checkBBox =
true;
201 G4double rmin = std::min(GetInnerRadiusMinusZ(),GetInnerRadiusPlusZ());
202 G4double rmax = std::max(GetOuterRadiusMinusZ(),GetOuterRadiusPlusZ());
207 if (GetDeltaPhiAngle() < twopi)
211 GetSinStartPhi(),GetCosStartPhi(),
212 GetSinEndPhi(),GetCosEndPhi(),
214 pMin.
set(vmin.
x(),vmin.
y(),-dz);
215 pMax.
set(vmax.
x(),vmax.
y(), dz);
219 pMin.
set(-rmax,-rmax,-dz);
220 pMax.
set( rmax, rmax, dz);
225 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
227 std::ostringstream message;
228 message <<
"Bad bounding box (min >= max) for solid: "
230 <<
"\npMin = " << pMin
231 <<
"\npMax = " << pMax;
232 G4Exception(
"G4UCons::BoundingLimits()",
"GeomMgt0001",
250 std::ostringstream message;
251 message <<
"Inconsistency in bounding boxes for solid: "
253 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
254 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
255 G4Exception(
"G4UCons::BoundingLimits()",
"GeomMgt0001",
267G4UCons::CalculateExtent(
const EAxis pAxis,
276 BoundingLimits(bmin,bmax);
281 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
283 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
285 return exist = pMin < pMax;
289 G4double rmin1 = GetInnerRadiusMinusZ();
290 G4double rmax1 = GetOuterRadiusMinusZ();
291 G4double rmin2 = GetInnerRadiusPlusZ();
292 G4double rmax2 = GetOuterRadiusPlusZ();
298 const G4int NSTEPS = 24;
300 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-deg)/astep) + 1;
303 G4double sinHalf = std::sin(0.5*ang);
304 G4double cosHalf = std::cos(0.5*ang);
305 G4double sinStep = 2.*sinHalf*cosHalf;
306 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
312 if (rmin1 == 0 && rmin2 == 0 && dphi == twopi)
318 for (
G4int k=0; k<NSTEPS; ++k)
320 baseA[k].set(rext1*cosCur,rext1*sinCur,-dz);
321 baseB[k].set(rext2*cosCur,rext2*sinCur, dz);
324 sinCur = sinCur*cosStep + cosCur*sinStep;
325 cosCur = cosCur*cosStep - sinTmp*sinStep;
327 std::vector<const G4ThreeVectorList *> polygons(2);
328 polygons[0] = &baseA;
329 polygons[1] = &baseB;
331 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
335 G4double sinStart = GetSinStartPhi();
336 G4double cosStart = GetCosStartPhi();
339 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
340 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
344 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
345 pols[0][0].set(rmin2*cosStart,rmin2*sinStart, dz);
346 pols[0][1].set(rmin1*cosStart,rmin1*sinStart,-dz);
347 pols[0][2].set(rmax1*cosStart,rmax1*sinStart,-dz);
348 pols[0][3].set(rmax2*cosStart,rmax2*sinStart, dz);
349 for (
G4int k=1; k<ksteps+1; ++k)
351 pols[k][0].set(rmin2*cosCur,rmin2*sinCur, dz);
352 pols[k][1].set(rmin1*cosCur,rmin1*sinCur,-dz);
353 pols[k][2].set(rext1*cosCur,rext1*sinCur,-dz);
354 pols[k][3].set(rext2*cosCur,rext2*sinCur, dz);
357 sinCur = sinCur*cosStep + cosCur*sinStep;
358 cosCur = cosCur*cosStep - sinTmp*sinStep;
360 pols[ksteps+1][0].set(rmin2*cosEnd,rmin2*sinEnd, dz);
361 pols[ksteps+1][1].set(rmin1*cosEnd,rmin1*sinEnd,-dz);
362 pols[ksteps+1][2].set(rmax1*cosEnd,rmax1*sinEnd,-dz);
363 pols[ksteps+1][3].set(rmax2*cosEnd,rmax2*sinEnd, dz);
366 std::vector<const G4ThreeVectorList *> polygons;
367 polygons.resize(ksteps+2);
368 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
370 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
382 GetOuterRadiusMinusZ(),
383 GetInnerRadiusPlusZ(),
384 GetOuterRadiusPlusZ(),
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
CLHEP::Hep2Vector G4TwoVector
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4BoundingEnvelope is a helper class to facilitate calculation of the extent of a solid within the li...
G4Cons is, in the general case, a Phi segment of a cone, with half-length fDz, inner and outer radii ...
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...