44#ifndef G4TWISTEDTUBS_HH
45#define G4TWISTEDTUBS_HH
112 const G4bool calcnorm =
false,
113 G4bool* validnorm =
nullptr,
126 std::ostream &
StreamInfo(std::ostream& os)
const;
147 {
return fEndInnerRadius[i]; }
149 {
return fEndOuterRadius[i]; }
151 {
return (fEndInnerRadius[0] > fEndInnerRadius[1] ?
152 fEndInnerRadius[0] : fEndInnerRadius[1]); }
154 {
return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
155 fEndOuterRadius[0] : fEndOuterRadius[1]); }
190 void CreateSurfaces();
228 mutable G4bool fRebuildPolyhedron =
false;
236 p.
set(kInfinity,kInfinity,kInfinity);
240 LastState(
const LastState& r) : p(r.p), inside(r.inside){}
243 if (
this == &r) {
return *
this; }
244 p = r.p; inside = r.inside;
257 p.
set(kInfinity,kInfinity,kInfinity);
258 vec.set(kInfinity,kInfinity,kInfinity);
265 LastVector(
const LastVector& r) : p(r.p), vec(r.vec)
268 surface[0] = r.surface[0];
270 LastVector&
operator=(
const LastVector& r)
272 if (&r ==
this) {
return *
this; }
273 p = r.p; vec = r.vec;
275 surface[0] = r.surface[0];
289 p.
set(kInfinity,kInfinity,kInfinity);
293 LastValue(
const LastValue& r) : p(r.p), value(r.value){}
296 if (
this == &r) {
return *
this; }
297 p = r.p; value = r.value;
305 class LastValueWithDoubleVector
308 LastValueWithDoubleVector()
310 p.
set(kInfinity,kInfinity,kInfinity);
311 vec.set(kInfinity,kInfinity,kInfinity);
314 ~LastValueWithDoubleVector(){}
315 LastValueWithDoubleVector(
const LastValueWithDoubleVector& r)
316 : p(r.p), vec(r.vec), value(r.value){}
317 LastValueWithDoubleVector&
operator=(
const LastValueWithDoubleVector& r)
319 if (
this == &r) {
return *
this; }
320 p = r.p; vec = r.vec; value = r.value;
329 LastState fLastInside;
330 LastVector fLastNormal;
331 LastValue fLastDistanceToIn;
332 LastValue fLastDistanceToOut;
333 LastValueWithDoubleVector fLastDistanceToInWithV;
334 LastValueWithDoubleVector fLastDistanceToOutWithV;
350 fPhiTwist = phitwist;
351 fEndZ[0] = negativeEndz;
352 fEndZ[1] = positiveEndz;
353 fEndZ2[0] = fEndZ[0] * fEndZ[0];
354 fEndZ2[1] = fEndZ[1] * fEndZ[1];
355 fInnerRadius = innerrad;
356 fOuterRadius = outerrad;
357 fInnerRadius2 = fInnerRadius * fInnerRadius;
358 fOuterRadius2 = fOuterRadius * fOuterRadius;
360 if (std::fabs(fEndZ[0]) >= std::fabs(fEndZ[1]))
362 fZHalfLength = std::fabs(fEndZ[0]);
366 fZHalfLength = std::fabs(fEndZ[1]);
369 G4double parity = (fPhiTwist > 0 ? 1 : -1);
370 G4double tanHalfTwist = std::tan(0.5 * fPhiTwist);
371 G4double innerNumerator = std::fabs(fInnerRadius * tanHalfTwist) * parity;
372 G4double outerNumerator = std::fabs(fOuterRadius * tanHalfTwist) * parity;
374 fTanInnerStereo = innerNumerator / fZHalfLength;
375 fTanOuterStereo = outerNumerator / fZHalfLength;
376 fTanInnerStereo2 = fTanInnerStereo * fTanInnerStereo;
377 fTanOuterStereo2 = fTanOuterStereo * fTanOuterStereo;
378 fInnerStereo = std::atan2(innerNumerator, fZHalfLength);
379 fOuterStereo = std::atan2(outerNumerator, fZHalfLength);
380 fEndInnerRadius[0] = std::sqrt(fInnerRadius2 + fEndZ2[0] * fTanInnerStereo2);
381 fEndInnerRadius[1] = std::sqrt(fInnerRadius2 + fEndZ2[1] * fTanInnerStereo2);
382 fEndOuterRadius[0] = std::sqrt(fOuterRadius2 + fEndZ2[0] * fTanOuterStereo2);
383 fEndOuterRadius[1] = std::sqrt(fOuterRadius2 + fEndZ2[1] * fTanOuterStereo2);
385 fKappa = tanHalfTwist / fZHalfLength;
386 fEndPhi[0] = std::atan2(fEndZ[0] * tanHalfTwist, fZHalfLength);
387 fEndPhi[1] = std::atan2(fEndZ[1] * tanHalfTwist, fZHalfLength);
390 G4cout <<
"/********* G4TwistedTubs::SetFields() Field Parameters ***************** " <<
G4endl;
392 G4cout <<
"/* fEndZ(0, 1) : " << fEndZ[0] <<
" , " << fEndZ[1] <<
G4endl;
393 G4cout <<
"/* fEndPhi(0, 1) : " << fEndPhi[0] <<
" , " << fEndPhi[1] <<
G4endl;
394 G4cout <<
"/* fInnerRadius, fOuterRadius : " << fInnerRadius <<
" , " << fOuterRadius <<
G4endl;
395 G4cout <<
"/* fEndInnerRadius(0, 1) : " << fEndInnerRadius[0] <<
" , "
396 << fEndInnerRadius[1] <<
G4endl;
397 G4cout <<
"/* fEndOuterRadius(0, 1) : " << fEndOuterRadius[0] <<
" , "
398 << fEndOuterRadius[1] <<
G4endl;
399 G4cout <<
"/* fInnerStereo, fOuterStereo : " << fInnerStereo <<
" , " << fOuterStereo <<
G4endl;
400 G4cout <<
"/* tanHalfTwist, fKappa : " << tanHalfTwist <<
" , " << fKappa <<
G4endl;
401 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
yystype & operator=(const yystype &right)