36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
43 using namespace CLHEP;
50 G4UCons::G4UCons(
const G4String& pName,
55 : G4USolid(pName, new UCons(pName, pRmin1, pRmax1, pRmin2, pRmax2,
65 G4UCons::G4UCons( __void__&
a )
82 G4UCons::G4UCons(
const G4UCons& rhs)
91 G4UCons& G4UCons::operator = (
const G4UCons& rhs)
95 if (
this == &rhs) {
return *
this; }
99 G4USolid::operator=(rhs);
108 G4double G4UCons::GetInnerRadiusMinusZ()
const
110 return GetShape()->GetInnerRadiusMinusZ();
112 G4double G4UCons::GetOuterRadiusMinusZ()
const
114 return GetShape()->GetOuterRadiusMinusZ();
116 G4double G4UCons::GetInnerRadiusPlusZ()
const
118 return GetShape()->GetInnerRadiusPlusZ();
120 G4double G4UCons::GetOuterRadiusPlusZ()
const
122 return GetShape()->GetOuterRadiusPlusZ();
124 G4double G4UCons::GetZHalfLength()
const
126 return GetShape()->GetZHalfLength();
128 G4double G4UCons::GetStartPhiAngle()
const
130 return GetShape()->GetStartPhiAngle();
132 G4double G4UCons::GetDeltaPhiAngle()
const
134 return GetShape()->GetDeltaPhiAngle();
136 G4double G4UCons::GetSinStartPhi()
const
138 G4double phi = GetShape()->GetStartPhiAngle();
139 return std::sin(phi);
141 G4double G4UCons::GetCosStartPhi()
const
143 G4double phi = GetShape()->GetStartPhiAngle();
144 return std::cos(phi);
146 G4double G4UCons::GetSinEndPhi()
const
148 G4double phi = GetShape()->GetStartPhiAngle() +
149 GetShape()->GetDeltaPhiAngle();
150 return std::sin(phi);
152 G4double G4UCons::GetCosEndPhi()
const
154 G4double phi = GetShape()->GetStartPhiAngle() +
155 GetShape()->GetDeltaPhiAngle();
156 return std::cos(phi);
159 void G4UCons::SetInnerRadiusMinusZ(
G4double Rmin1)
161 GetShape()->SetInnerRadiusMinusZ(Rmin1);
162 fRebuildPolyhedron =
true;
164 void G4UCons::SetOuterRadiusMinusZ(
G4double Rmax1)
166 GetShape()->SetOuterRadiusMinusZ(Rmax1);
167 fRebuildPolyhedron =
true;
169 void G4UCons::SetInnerRadiusPlusZ(
G4double Rmin2)
171 GetShape()->SetInnerRadiusPlusZ(Rmin2);
172 fRebuildPolyhedron =
true;
174 void G4UCons::SetOuterRadiusPlusZ(
G4double Rmax2)
176 GetShape()->SetOuterRadiusPlusZ(Rmax2);
177 fRebuildPolyhedron =
true;
179 void G4UCons::SetZHalfLength(
G4double newDz)
181 GetShape()->SetZHalfLength(newDz);
182 fRebuildPolyhedron =
true;
186 GetShape()->SetStartPhiAngle(newSPhi, trig);
187 fRebuildPolyhedron =
true;
189 void G4UCons::SetDeltaPhiAngle(
G4double newDPhi)
191 GetShape()->SetDeltaPhiAngle(newDPhi);
192 fRebuildPolyhedron =
true;
213 return new G4UCons(*
this);
222 static G4bool checkBBox =
true;
230 if (GetDeltaPhiAngle() <
twopi)
234 GetSinStartPhi(),GetCosStartPhi(),
235 GetSinEndPhi(),GetCosEndPhi(),
237 pMin.set(vmin.x(),vmin.y(),-dz);
238 pMax.set(vmax.x(),vmax.y(), dz);
242 pMin.set(-rmax,-rmax,-dz);
243 pMax.set( rmax, rmax, dz);
248 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
250 std::ostringstream message;
251 message <<
"Bad bounding box (min >= max) for solid: "
253 <<
"\npMin = " << pMin
254 <<
"\npMax = " << pMax;
264 GetShape()->Extent(vmin,vmax);
272 std::ostringstream message;
273 message <<
"Inconsistency in bounding boxes for solid: "
275 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
276 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
288 G4UCons::CalculateExtent(
const EAxis pAxis,
302 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
304 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
306 return exist = (pMin < pMax) ?
true :
false;
310 G4double rmin1 = GetInnerRadiusMinusZ();
311 G4double rmax1 = GetOuterRadiusMinusZ();
312 G4double rmin2 = GetInnerRadiusPlusZ();
313 G4double rmax2 = GetOuterRadiusPlusZ();
319 const G4int NSTEPS = 24;
321 G4int ksteps = (dphi <= astep) ? 1 : (
G4int)((dphi-
deg)/astep) + 1;
324 G4double sinHalf = std::sin(0.5*ang);
325 G4double cosHalf = std::cos(0.5*ang);
326 G4double sinStep = 2.*sinHalf*cosHalf;
327 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
333 if (rmin1 == 0 && rmin2 == 0 && dphi ==
twopi)
339 for (
G4int k=0; k<NSTEPS; ++k)
341 baseA[k].set(rext1*cosCur,rext1*sinCur,-dz);
342 baseB[k].set(rext2*cosCur,rext2*sinCur, dz);
345 sinCur = sinCur*cosStep + cosCur*sinStep;
346 cosCur = cosCur*cosStep - sinTmp*sinStep;
348 std::vector<const G4ThreeVectorList *> polygons(2);
349 polygons[0] = &baseA;
350 polygons[1] = &baseB;
352 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
356 G4double sinStart = GetSinStartPhi();
357 G4double cosStart = GetCosStartPhi();
360 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
361 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
365 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
366 pols[0][0].set(rmin2*cosStart,rmin2*sinStart, dz);
367 pols[0][1].set(rmin1*cosStart,rmin1*sinStart,-dz);
368 pols[0][2].set(rmax1*cosStart,rmax1*sinStart,-dz);
369 pols[0][3].set(rmax2*cosStart,rmax2*sinStart, dz);
370 for (
G4int k=1; k<ksteps+1; ++k)
372 pols[k][0].set(rmin2*cosCur,rmin2*sinCur, dz);
373 pols[k][1].set(rmin1*cosCur,rmin1*sinCur,-dz);
374 pols[k][2].set(rext1*cosCur,rext1*sinCur,-dz);
375 pols[k][3].set(rext2*cosCur,rext2*sinCur, dz);
378 sinCur = sinCur*cosStep + cosCur*sinStep;
379 cosCur = cosCur*cosStep - sinTmp*sinStep;
381 pols[ksteps+1][0].set(rmin2*cosEnd,rmin2*sinEnd, dz);
382 pols[ksteps+1][1].set(rmin1*cosEnd,rmin1*sinEnd,-dz);
383 pols[ksteps+1][2].set(rmax1*cosEnd,rmax1*sinEnd,-dz);
384 pols[ksteps+1][3].set(rmax2*cosEnd,rmax2*sinEnd, dz);
387 std::vector<const G4ThreeVectorList *> polygons;
388 polygons.resize(ksteps+2);
389 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
391 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
403 GetOuterRadiusMinusZ(),
404 GetInnerRadiusPlusZ(),
405 GetOuterRadiusPlusZ(),
411 #endif // G4GEOM_USE_USOLIDS
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
static constexpr double twopi
G4GLOB_DLL std::ostream G4cout
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
CLHEP::Hep2Vector G4TwoVector
static constexpr double deg