43#ifndef G4TWISTEDTUBS_HH
44#define G4TWISTEDTUBS_HH
111 const G4bool calcnorm =
false,
112 G4bool* validnorm =
nullptr,
125 std::ostream &
StreamInfo(std::ostream& os)
const;
146 {
return fEndInnerRadius[i]; }
148 {
return fEndOuterRadius[i]; }
150 {
return (fEndInnerRadius[0] > fEndInnerRadius[1] ?
151 fEndInnerRadius[0] : fEndInnerRadius[1]); }
153 {
return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
154 fEndOuterRadius[0] : fEndOuterRadius[1]); }
190 void CreateSurfaces();
226 mutable G4bool fRebuildPolyhedron =
false;
234 p.
set(kInfinity,kInfinity,kInfinity);
238 LastState(
const LastState& r) : p(r.p), inside(r.inside){}
239 LastState& operator=(
const LastState& r)
241 if (
this == &r) {
return *
this; }
242 p = r.p; inside = r.inside;
255 p.
set(kInfinity,kInfinity,kInfinity);
256 vec.set(kInfinity,kInfinity,kInfinity);
263 LastVector(
const LastVector& r) : p(r.p), vec(r.vec)
266 surface[0] = r.surface[0];
268 LastVector& operator=(
const LastVector& r)
270 if (&r ==
this) {
return *
this; }
271 p = r.p; vec = r.vec;
273 surface[0] = r.surface[0];
287 p.
set(kInfinity,kInfinity,kInfinity);
291 LastValue(
const LastValue& r) : p(r.p), value(r.value){}
292 LastValue& operator=(
const LastValue& r)
294 if (
this == &r) {
return *
this; }
295 p = r.p; value = r.value;
303 class LastValueWithDoubleVector
306 LastValueWithDoubleVector()
308 p.
set(kInfinity,kInfinity,kInfinity);
309 vec.set(kInfinity,kInfinity,kInfinity);
312 ~LastValueWithDoubleVector(){}
313 LastValueWithDoubleVector(
const LastValueWithDoubleVector& r)
314 : p(r.p), vec(r.vec), value(r.value){}
315 LastValueWithDoubleVector& operator=(
const LastValueWithDoubleVector& r)
317 if (
this == &r) {
return *
this; }
318 p = r.p; vec = r.vec; value = r.value;
327 LastState fLastInside;
328 LastVector fLastNormal;
329 LastValue fLastDistanceToIn;
330 LastValue fLastDistanceToOut;
331 LastValueWithDoubleVector fLastDistanceToInWithV;
332 LastValueWithDoubleVector fLastDistanceToOutWithV;
348 fPhiTwist = phitwist;
349 fEndZ[0] = negativeEndz;
350 fEndZ[1] = positiveEndz;
351 fEndZ2[0] = fEndZ[0] * fEndZ[0];
352 fEndZ2[1] = fEndZ[1] * fEndZ[1];
353 fInnerRadius = innerrad;
354 fOuterRadius = outerrad;
355 fInnerRadius2 = fInnerRadius * fInnerRadius;
356 fOuterRadius2 = fOuterRadius * fOuterRadius;
358 if (std::fabs(fEndZ[0]) >= std::fabs(fEndZ[1]))
360 fZHalfLength = std::fabs(fEndZ[0]);
364 fZHalfLength = std::fabs(fEndZ[1]);
367 G4double parity = (fPhiTwist > 0 ? 1 : -1);
368 G4double tanHalfTwist = std::tan(0.5 * fPhiTwist);
369 G4double innerNumerator = std::fabs(fInnerRadius * tanHalfTwist) * parity;
370 G4double outerNumerator = std::fabs(fOuterRadius * tanHalfTwist) * parity;
372 fTanInnerStereo = innerNumerator / fZHalfLength;
373 fTanOuterStereo = outerNumerator / fZHalfLength;
374 fTanInnerStereo2 = fTanInnerStereo * fTanInnerStereo;
375 fTanOuterStereo2 = fTanOuterStereo * fTanOuterStereo;
376 fInnerStereo = std::atan2(innerNumerator, fZHalfLength);
377 fOuterStereo = std::atan2(outerNumerator, fZHalfLength);
378 fEndInnerRadius[0] = std::sqrt(fInnerRadius2 + fEndZ2[0] * fTanInnerStereo2);
379 fEndInnerRadius[1] = std::sqrt(fInnerRadius2 + fEndZ2[1] * fTanInnerStereo2);
380 fEndOuterRadius[0] = std::sqrt(fOuterRadius2 + fEndZ2[0] * fTanOuterStereo2);
381 fEndOuterRadius[1] = std::sqrt(fOuterRadius2 + fEndZ2[1] * fTanOuterStereo2);
383 fKappa = tanHalfTwist / fZHalfLength;
384 fEndPhi[0] = std::atan2(fEndZ[0] * tanHalfTwist, fZHalfLength);
385 fEndPhi[1] = std::atan2(fEndZ[1] * tanHalfTwist, fZHalfLength);
388 G4cout <<
"/********* G4TwistedTubs::SetFields() Field Parameters ***************** " <<
G4endl;
390 G4cout <<
"/* fEndZ(0, 1) : " << fEndZ[0] <<
" , " << fEndZ[1] <<
G4endl;
391 G4cout <<
"/* fEndPhi(0, 1) : " << fEndPhi[0] <<
" , " << fEndPhi[1] <<
G4endl;
392 G4cout <<
"/* fInnerRadius, fOuterRadius : " << fInnerRadius <<
" , " << fOuterRadius <<
G4endl;
393 G4cout <<
"/* fEndInnerRadius(0, 1) : " << fEndInnerRadius[0] <<
" , "
394 << fEndInnerRadius[1] <<
G4endl;
395 G4cout <<
"/* fEndOuterRadius(0, 1) : " << fEndOuterRadius[0] <<
" , "
396 << fEndOuterRadius[1] <<
G4endl;
397 G4cout <<
"/* fInnerStereo, fOuterStereo : " << fInnerStereo <<
" , " << fOuterStereo <<
G4endl;
398 G4cout <<
"/* tanHalfTwist, fKappa : " << tanHalfTwist <<
" , " << fKappa <<
G4endl;
399 G4cout <<
"/*********************************************************************** " <<
G4endl;
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4double GetOuterRadius() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4ThreeVector GetPointOnSurface() const
G4double GetZHalfLength() const
G4double GetPhiTwist() const
G4double GetSurfaceArea()
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4Polyhedron * CreatePolyhedron() const
G4double GetInnerStereo() const
G4double GetTanInnerStereo() const
void ComputeDimensions(G4VPVParameterisation *, const G4int, const G4VPhysicalVolume *)
G4TwistedTubs & operator=(const G4TwistedTubs &rhs)
G4double GetEndInnerRadius() const
G4double GetEndOuterRadius() const
G4double GetOuterStereo() const
G4double GetCubicVolume()
G4Polyhedron * GetPolyhedron() const
G4GeometryType GetEntityType() const
G4double GetEndPhi(G4int i) const
G4double GetTanOuterStereo() const
EInside Inside(const G4ThreeVector &p) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcnorm=false, G4bool *validnorm=nullptr, G4ThreeVector *n=nullptr) const
G4VisExtent GetExtent() const
G4double GetTanInnerStereo2() const
G4double GetTanOuterStereo2() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double GetEndZ(G4int i) const
G4double GetKappa() const
G4double GetEndInnerRadius(G4int i) const
G4double GetInnerRadius() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
std::ostream & StreamInfo(std::ostream &os) const
G4double GetEndOuterRadius(G4int i) const