54#ifndef __G4TWISTEDTUBS__
55#define __G4TWISTEDTUBS__
135 std::ostream &
StreamInfo(std::ostream& os)
const;
156 {
return fEndInnerRadius[i]; }
158 {
return fEndOuterRadius[i]; }
160 {
return (fEndInnerRadius[0] > fEndInnerRadius[1] ?
161 fEndInnerRadius[0] : fEndInnerRadius[1]); }
163 {
return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
164 fEndOuterRadius[0] : fEndOuterRadius[1]); }
200 void CreateSurfaces();
250 p.
set(kInfinity,kInfinity,kInfinity);
254 LastState(
const LastState& r) : p(r.p), inside(r.inside){}
255 LastState& operator=(
const LastState& r)
257 if (
this == &r) {
return *
this; }
258 p = r.p; inside = r.inside;
271 p.
set(kInfinity,kInfinity,kInfinity);
272 vec.set(kInfinity,kInfinity,kInfinity);
279 LastVector(
const LastVector& r) : p(r.p), vec(r.vec)
282 surface[0] = r.surface[0];
284 LastVector& operator=(
const LastVector& r)
286 if (&r ==
this) {
return *
this; }
287 p = r.p; vec = r.vec;
289 surface[0] = r.surface[0];
303 p.
set(kInfinity,kInfinity,kInfinity);
307 LastValue(
const LastValue& r) : p(r.p), value(r.value){}
308 LastValue& operator=(
const LastValue& r)
310 if (
this == &r) {
return *
this; }
311 p = r.p; value = r.value;
319 class LastValueWithDoubleVector
322 LastValueWithDoubleVector()
324 p.
set(kInfinity,kInfinity,kInfinity);
325 vec.set(kInfinity,kInfinity,kInfinity);
328 ~LastValueWithDoubleVector(){}
329 LastValueWithDoubleVector(
const LastValueWithDoubleVector& r)
330 : p(r.p), vec(r.vec), value(r.value){}
331 LastValueWithDoubleVector& operator=(
const LastValueWithDoubleVector& r)
333 if (
this == &r) {
return *
this; }
334 p = r.p; vec = r.vec; value = r.value;
343 LastState fLastInside;
344 LastVector fLastNormal;
345 LastValue fLastDistanceToIn;
346 LastValue fLastDistanceToOut;
347 LastValueWithDoubleVector fLastDistanceToInWithV;
348 LastValueWithDoubleVector fLastDistanceToOutWithV;
364 fPhiTwist = phitwist;
365 fEndZ[0] = negativeEndz;
366 fEndZ[1] = positiveEndz;
367 fEndZ2[0] = fEndZ[0] * fEndZ[0];
368 fEndZ2[1] = fEndZ[1] * fEndZ[1];
369 fInnerRadius = innerrad;
370 fOuterRadius = outerrad;
371 fInnerRadius2 = fInnerRadius * fInnerRadius;
372 fOuterRadius2 = fOuterRadius * fOuterRadius;
374 if (std::fabs(fEndZ[0]) >= std::fabs(fEndZ[1])) {
375 fZHalfLength = std::fabs(fEndZ[0]);
377 fZHalfLength = std::fabs(fEndZ[1]);
380 G4double parity = (fPhiTwist > 0 ? 1 : -1);
381 G4double tanHalfTwist = std::tan(0.5 * fPhiTwist);
382 G4double innerNumerator = std::fabs(fInnerRadius * tanHalfTwist) * parity;
383 G4double outerNumerator = std::fabs(fOuterRadius * tanHalfTwist) * parity;
385 fTanInnerStereo = innerNumerator / fZHalfLength;
386 fTanOuterStereo = outerNumerator / fZHalfLength;
387 fTanInnerStereo2 = fTanInnerStereo * fTanInnerStereo;
388 fTanOuterStereo2 = fTanOuterStereo * fTanOuterStereo;
389 fInnerStereo = std::atan2(innerNumerator, fZHalfLength);
390 fOuterStereo = std::atan2(outerNumerator, fZHalfLength);
391 fEndInnerRadius[0] = std::sqrt(fInnerRadius2 + fEndZ2[0] * fTanInnerStereo2);
392 fEndInnerRadius[1] = std::sqrt(fInnerRadius2 + fEndZ2[1] * fTanInnerStereo2);
393 fEndOuterRadius[0] = std::sqrt(fOuterRadius2 + fEndZ2[0] * fTanOuterStereo2);
394 fEndOuterRadius[1] = std::sqrt(fOuterRadius2 + fEndZ2[1] * fTanOuterStereo2);
396 fKappa = tanHalfTwist / fZHalfLength;
397 fEndPhi[0] = std::atan2(fEndZ[0] * tanHalfTwist, fZHalfLength);
398 fEndPhi[1] = std::atan2(fEndZ[1] * tanHalfTwist, fZHalfLength);
401 G4cout <<
"/********* G4TwistedTubs::SetFields() Field Parameters ***************** " <<
G4endl;
403 G4cout <<
"/* fEndZ(0, 1) : " << fEndZ[0] <<
" , " << fEndZ[1] <<
G4endl;
404 G4cout <<
"/* fEndPhi(0, 1) : " << fEndPhi[0] <<
" , " << fEndPhi[1] <<
G4endl;
405 G4cout <<
"/* fInnerRadius, fOuterRadius : " << fInnerRadius <<
" , " << fOuterRadius <<
G4endl;
406 G4cout <<
"/* fEndInnerRadius(0, 1) : " << fEndInnerRadius[0] <<
" , "
407 << fEndInnerRadius[1] <<
G4endl;
408 G4cout <<
"/* fEndOuterRadius(0, 1) : " << fEndOuterRadius[0] <<
" , "
409 << fEndOuterRadius[1] <<
G4endl;
410 G4cout <<
"/* fInnerStereo, fOuterStereo : " << fInnerStereo <<
" , " << fOuterStereo <<
G4endl;
411 G4cout <<
"/* tanHalfTwist, fKappa : " << tanHalfTwist <<
" , " << fKappa <<
G4endl;
412 G4cout <<
"/*********************************************************************** " <<
G4endl;
G4DLLIMPORT std::ostream G4cout
void set(double x, double y, double z)
G4double GetOuterRadius() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4ThreeVector GetPointOnSurface() const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcnorm=G4bool(false), G4bool *validnorm=0, G4ThreeVector *n=0) const
G4double GetZHalfLength() const
G4double GetPhiTwist() const
G4double GetSurfaceArea()
G4bool CalculateExtent(const EAxis paxis, const G4VoxelLimits &pvoxellimit, const G4AffineTransform &ptransform, G4double &pmin, G4double &pmax) const
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
G4VisExtent GetExtent() const
G4double GetTanInnerStereo2() const
G4double GetTanOuterStereo2() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4NURBS * CreateNURBS() const
G4double GetEndZ(G4int i) const
G4double GetKappa() const
G4double GetEndInnerRadius(G4int i) const
G4double GetInnerRadius() const
std::ostream & StreamInfo(std::ostream &os) const
G4double GetEndOuterRadius(G4int i) const