69 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
70 fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
74 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
78 G4double sinhalftwist = std::sin(0.5 * twistedangle);
80 G4double endinnerradX = endinnerrad * sinhalftwist;
81 G4double innerrad = std::sqrt( endinnerrad * endinnerrad
82 - endinnerradX * endinnerradX );
84 G4double endouterradX = endouterrad * sinhalftwist;
85 G4double outerrad = std::sqrt( endouterrad * endouterrad
86 - endouterradX * endouterradX );
89 SetFields(twistedangle, innerrad, outerrad, -halfzlen, halfzlen);
101 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
102 fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
107 std::ostringstream message;
108 message <<
"Invalid number of segments." <<
G4endl
109 <<
" nseg = " << nseg;
110 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
115 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
119 G4double sinhalftwist = std::sin(0.5 * twistedangle);
121 G4double endinnerradX = endinnerrad * sinhalftwist;
122 G4double innerrad = std::sqrt( endinnerrad * endinnerrad
123 - endinnerradX * endinnerradX );
125 G4double endouterradX = endouterrad * sinhalftwist;
126 G4double outerrad = std::sqrt( endouterrad * endouterrad
127 - endouterradX * endouterradX );
130 fDPhi = totphi / nseg;
131 SetFields(twistedangle, innerrad, outerrad, -halfzlen, halfzlen);
143 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
144 fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
148 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
152 SetFields(twistedangle, innerrad, outerrad, negativeEndz, positiveEndz);
165 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
166 fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
170 std::ostringstream message;
171 message <<
"Invalid number of segments." <<
G4endl
172 <<
" nseg = " << nseg;
173 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
178 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
182 fDPhi = totphi / nseg;
183 SetFields(twistedangle, innerrad, outerrad, negativeEndz, positiveEndz);
191 :
G4VSolid(a), fPhiTwist(0.), fInnerRadius(0.), fOuterRadius(0.), fDPhi(0.),
192 fZHalfLength(0.), fInnerStereo(0.), fOuterStereo(0.), fTanInnerStereo(0.),
193 fTanOuterStereo(0.), fKappa(0.), fInnerRadius2(0.), fOuterRadius2(0.),
194 fTanInnerStereo2(0.), fTanOuterStereo2(0.), fLowerEndcap(0), fUpperEndcap(0),
195 fLatterTwisted(0), fFormerTwisted(0), fInnerHype(0), fOuterHype(0)
217 :
G4VSolid(rhs), fPhiTwist(rhs.fPhiTwist),
218 fInnerRadius(rhs.fInnerRadius), fOuterRadius(rhs.fOuterRadius),
219 fDPhi(rhs.fDPhi), fZHalfLength(rhs.fZHalfLength),
220 fInnerStereo(rhs.fInnerStereo), fOuterStereo(rhs.fOuterStereo),
221 fTanInnerStereo(rhs.fTanInnerStereo), fTanOuterStereo(rhs.fTanOuterStereo),
222 fKappa(rhs.fKappa), fInnerRadius2(rhs.fInnerRadius2),
223 fOuterRadius2(rhs.fOuterRadius2), fTanInnerStereo2(rhs.fTanInnerStereo2),
224 fTanOuterStereo2(rhs.fTanOuterStereo2),
225 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0), fFormerTwisted(0),
226 fInnerHype(0), fOuterHype(0),
227 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
228 fLastInside(rhs.fLastInside), fLastNormal(rhs.fLastNormal),
229 fLastDistanceToIn(rhs.fLastDistanceToIn),
230 fLastDistanceToOut(rhs.fLastDistanceToOut),
231 fLastDistanceToInWithV(rhs.fLastDistanceToInWithV),
232 fLastDistanceToOutWithV(rhs.fLastDistanceToOutWithV)
234 for (
auto i=0; i<2; ++i)
253 if (
this == &rhs) {
return *
this; }
278 for (
auto i=0; i<2; ++i)
303 "G4TwistedTubs does not support Parameterisation.");
327 pMin.set(-rmax,-rmax, zmin);
328 pMax.set( rmax, rmax, zmax);
334 pMin.set(vmin.
x(), vmin.
y(), zmin);
335 pMax.set(vmax.
x(), vmax.
y(), zmax);
342 std::ostringstream message;
343 message <<
"Bad bounding box (min >= max) for solid: "
345 <<
"\npMin = " <<
pMin
346 <<
"\npMax = " <<
pMax;
347 G4Exception(
"G4TwistedTubs::BoundingLimits()",
"GeomMgt0001",
395 tmpp->
set(p.
x(), p.
y(), p.
z());
402 if ((outerhypearea ==
kOutside) || (distanceToOut < -halftol))
412 if (distanceToOut <= halftol)
447 tmpp->
set(p.
x(), p.
y(), p.
z());
462 for (
auto i=0; i<6; ++i)
465 if (tmpdistance < distance)
467 distance = tmpdistance;
473 tmpsurface[0] = surfaces[besti];
474 *tmpnormal = tmpsurface[0]->
GetNormal(bestxx,
true);
508 tmpp->
set(p.
x(), p.
y(), p.
z());
509 tmpv->
set(v.
x(), v.
y(), v.
z());
555 for (
auto i=0; i<6; ++i)
558 if (tmpdistance < distance)
560 distance = tmpdistance;
592 tmpp->
set(p.
x(), p.
y(), p.
z());
626 for (
auto i=0; i<6; ++i)
629 if (tmpdistance < distance)
631 distance = tmpdistance;
640 G4Exception(
"G4TwistedTubs::DistanceToIn(p)",
"GeomSolids0003",
679 tmpp->
set(p.
x(), p.
y(), p.
z());
680 tmpv->
set(v.
x(), v.
y(), v.
z());
705 *norm = (blockedsurface->
GetNormal(p,
true));
733 for (
auto i=0; i<6; ++i)
736 if (tmpdistance < distance)
738 distance = tmpdistance;
748 *norm = (surfaces[besti]->
GetNormal(p,
true));
782 tmpp->
set(p.
x(), p.
y(), p.
z());
817 for (
auto i=0; i<6; ++i)
820 if (tmpdistance < distance)
822 distance = tmpdistance;
832 G4Exception(
"G4TwistedTubs::DistanceToOut(p)",
"GeomSolids0003",
848 G4int oldprc = os.precision(16);
849 os <<
"-----------------------------------------------------------\n"
850 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
851 <<
" ===================================================\n"
852 <<
" Solid type: G4TwistedTubs\n"
854 <<
" -ve end Z : " <<
fEndZ[0]/
mm <<
" mm \n"
855 <<
" +ve end Z : " <<
fEndZ[1]/
mm <<
" mm \n"
865 <<
" phi-width of a piece : " <<
fDPhi/
degree <<
" degrees \n"
866 <<
"-----------------------------------------------------------\n";
867 os.precision(oldprc);
909 const G4int nnodes = 4*(k-1)*(
n-2) + 2*k*k ;
910 const G4int nfaces = 4*(k-1)*(
n-1) + 2*(k-1)*(k-1) ;
914 typedef G4int G4int4[4];
915 G4double3* xyz =
new G4double3[nnodes];
916 G4int4* faces =
new G4int4[nfaces] ;
1047 +
Z1*(R1out + R1in)*(R1out - R1in)
1048 - Z0*(R0out + R0in)*(R0out - R0in))*DPhi/6.;
1092 else if ( (chose >= a1) && (chose < a1 + a2 ) )
1102 else if ( (chose >= a1 + a2 ) && (chose < a1 + a2 + a3 ) )
1112 else if ( (chose >= a1 + a2 + a3 ) && (chose < a1 + a2 + a3 + a4 ) )
1121 else if( (chose >= a1 + a2 + a3 + a4 )&&(chose < a1 + a2 + a3 + a4 + a5 ) )
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static const G4double pMax
static const G4double pMin
static constexpr double twopi
static constexpr double mm
static constexpr double degree
#define G4MUTEX_INITIALIZER
void set(double x, double y, double z)
HepRotation & rotateZ(double delta)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4double GetRadialTolerance() const
static G4GeometryTolerance * GetInstance()
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4VTwistSurface ** surface
G4double GetOuterRadius() const
G4double fTanInnerStereo2
LastValue fLastDistanceToOut
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
LastValue fLastDistanceToIn
G4double GetSurfaceArea()
G4VTwistSurface * fLatterTwisted
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4Polyhedron * CreatePolyhedron() const
void SetFields(G4double phitwist, G4double innerrad, G4double outerrad, G4double negativeEndz, G4double positiveEndz)
void ComputeDimensions(G4VPVParameterisation *, const G4int, const G4VPhysicalVolume *)
G4VTwistSurface * fFormerTwisted
G4TwistedTubs & operator=(const G4TwistedTubs &rhs)
G4double GetEndInnerRadius() const
G4double GetEndOuterRadius() const
G4VTwistSurface * fUpperEndcap
G4double fEndInnerRadius[2]
G4double GetCubicVolume()
G4Polyhedron * GetPolyhedron() const
G4double fTanOuterStereo2
G4VTwistSurface * fLowerEndcap
G4GeometryType GetEntityType() const
LastValueWithDoubleVector fLastDistanceToOutWithV
G4double GetEndPhi(G4int i) const
G4TwistedTubs(const G4String &pname, G4double twistedangle, G4double endinnerrad, G4double endouterrad, G4double halfzlen, G4double dphi)
LastValueWithDoubleVector fLastDistanceToInWithV
G4VTwistSurface * fInnerHype
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
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4bool fRebuildPolyhedron
G4double GetEndZ(G4int i) const
G4Polyhedron * fpPolyhedron
G4double GetInnerRadius() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4VTwistSurface * fOuterHype
G4double fEndOuterRadius[2]
std::ostream & StreamInfo(std::ostream &os) const
virtual void AddSolid(const G4Box &)=0
G4VSolid & operator=(const G4VSolid &rhs)
virtual G4double GetSurfaceArea()
virtual void GetFacets(G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)=0
void SetNeighbours(G4VTwistSurface *ax0min, G4VTwistSurface *ax1min, G4VTwistSurface *ax0max, G4VTwistSurface *ax1max)
virtual G4double GetBoundaryMin(G4double)=0
G4bool IsValidNorm() const
virtual G4double DistanceTo(const G4ThreeVector &gp, G4ThreeVector &gxx)
virtual G4double DistanceToOut(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
virtual G4double DistanceToIn(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
virtual G4ThreeVector SurfacePoint(G4double, G4double, G4bool isGlobal=false)=0
virtual G4double GetBoundaryMax(G4double)=0
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal)=0
virtual G4double GetSurfaceArea()=0
static G4int GetNumberOfRotationSteps()
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
static const G4double kInfinity
static constexpr double twopi
static double normal(HepRandomEngine *eptr)
ThreeVector shoot(const G4int Ap, const G4int Af)
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
static const G4double Z1[5]