72 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
73 fFormerTwisted(0), fInnerHype(0), fOuterHype(0),
74 fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
78 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
82 G4double sinhalftwist = std::sin(0.5 * twistedangle);
84 G4double endinnerradX = endinnerrad * sinhalftwist;
85 G4double innerrad = std::sqrt( endinnerrad * endinnerrad
86 - endinnerradX * endinnerradX );
88 G4double endouterradX = endouterrad * sinhalftwist;
89 G4double outerrad = std::sqrt( endouterrad * endouterrad
90 - endouterradX * endouterradX );
93 SetFields(twistedangle, innerrad, outerrad, -halfzlen, halfzlen);
105 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
106 fFormerTwisted(0), fInnerHype(0), fOuterHype(0),
107 fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
112 std::ostringstream message;
113 message <<
"Invalid number of segments." <<
G4endl
114 <<
" nseg = " << nseg;
115 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
120 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
124 G4double sinhalftwist = std::sin(0.5 * twistedangle);
126 G4double endinnerradX = endinnerrad * sinhalftwist;
127 G4double innerrad = std::sqrt( endinnerrad * endinnerrad
128 - endinnerradX * endinnerradX );
130 G4double endouterradX = endouterrad * sinhalftwist;
131 G4double outerrad = std::sqrt( endouterrad * endouterrad
132 - endouterradX * endouterradX );
135 fDPhi = totphi / nseg;
136 SetFields(twistedangle, innerrad, outerrad, -halfzlen, halfzlen);
148 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
149 fFormerTwisted(0), fInnerHype(0), fOuterHype(0),
150 fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
154 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
158 SetFields(twistedangle, innerrad, outerrad, negativeEndz, positiveEndz);
171 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0),
172 fFormerTwisted(0), fInnerHype(0), fOuterHype(0),
173 fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
177 std::ostringstream message;
178 message <<
"Invalid number of segments." <<
G4endl
179 <<
" nseg = " << nseg;
180 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
185 G4Exception(
"G4TwistedTubs::G4TwistedTubs()",
"GeomSolids0002",
189 fDPhi = totphi / nseg;
190 SetFields(twistedangle, innerrad, outerrad, negativeEndz, positiveEndz);
198 :
G4VSolid(a), fPhiTwist(0.), fInnerRadius(0.), fOuterRadius(0.), fDPhi(0.),
199 fZHalfLength(0.), fInnerStereo(0.), fOuterStereo(0.), fTanInnerStereo(0.),
200 fTanOuterStereo(0.), fKappa(0.), fInnerRadius2(0.), fOuterRadius2(0.),
201 fTanInnerStereo2(0.), fTanOuterStereo2(0.), fLowerEndcap(0), fUpperEndcap(0),
202 fLatterTwisted(0), fFormerTwisted(0), fInnerHype(0), fOuterHype(0),
203 fCubicVolume(0.), fSurfaceArea(0.), fpPolyhedron(0)
230 :
G4VSolid(rhs), fPhiTwist(rhs.fPhiTwist),
231 fInnerRadius(rhs.fInnerRadius), fOuterRadius(rhs.fOuterRadius),
232 fDPhi(rhs.fDPhi), fZHalfLength(rhs.fZHalfLength),
233 fInnerStereo(rhs.fInnerStereo), fOuterStereo(rhs.fOuterStereo),
234 fTanInnerStereo(rhs.fTanInnerStereo), fTanOuterStereo(rhs.fTanOuterStereo),
235 fKappa(rhs.fKappa), fInnerRadius2(rhs.fInnerRadius2),
236 fOuterRadius2(rhs.fOuterRadius2), fTanInnerStereo2(rhs.fTanInnerStereo2),
237 fTanOuterStereo2(rhs.fTanOuterStereo2),
238 fLowerEndcap(0), fUpperEndcap(0), fLatterTwisted(0), fFormerTwisted(0),
239 fInnerHype(0), fOuterHype(0),
240 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
241 fpPolyhedron(0), fLastInside(rhs.fLastInside), fLastNormal(rhs.fLastNormal),
242 fLastDistanceToIn(rhs.fLastDistanceToIn),
243 fLastDistanceToOut(rhs.fLastDistanceToOut),
244 fLastDistanceToInWithV(rhs.fLastDistanceToInWithV),
245 fLastDistanceToOutWithV(rhs.fLastDistanceToOutWithV)
247 for (
size_t i=0; i<2; ++i)
267 if (
this == &rhs) {
return *
this; }
292 for (
size_t i=0; i<2; ++i)
316 "G4TwistedTubs does not support Parameterisation.");
344 G4double rFudge = 1.0/std::cos(0.5*sigPhi);
345 G4double fudgeEndOuterRad = rFudge * maxEndOuterRad;
393 if ( phimax >
pi/2) { phimax =
pi-phimax; }
409 G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi,
412 G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi,
417 G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi, 0));
460 cosPhi = std::cos(phimax);
461 sinPhi = std::sin(phimax);
466 G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi,
469 G4ThreeVector(fudgeEndOuterRad*cosPhi, fudgeEndOuterRad*sinPhi,
555 phiPoly.
SetNormal( (v1-v0).cross(w0-v0).unit() );
583 tmpp->set(p.x(), p.y(), p.z());
588 G4double distanceToOut = p.getRho() - innerhyperho;
590 if ((outerhypearea ==
kOutside) || (distanceToOut < -halftol))
600 if (distanceToOut <= halftol)
635 tmpp->set(p.x(), p.y(), p.z());
654 if (tmpdistance < distance)
656 distance = tmpdistance;
662 tmpsurface[0] = surfaces[besti];
663 *tmpnormal = tmpsurface[0]->
GetNormal(bestxx,
true);
697 tmpp->set(p.x(), p.y(), p.z());
698 tmpv->set(v.x(), v.y(), v.z());
748 if (tmpdistance < distance)
750 distance = tmpdistance;
782 tmpp->set(p.x(), p.y(), p.z());
820 if (tmpdistance < distance)
822 distance = tmpdistance;
831 G4Exception(
"G4TwistedTubs::DistanceToIn(p)",
"GeomSolids0003",
870 tmpp->set(p.x(), p.y(), p.z());
871 tmpv->set(v.x(), v.y(), v.z());
896 *norm = (blockedsurface->
GetNormal(p,
true));
928 if (tmpdistance < distance)
930 distance = tmpdistance;
940 *norm = (surfaces[besti]->
GetNormal(p,
true));
974 tmpp->set(p.x(), p.y(), p.z());
1010 for (i=0; i< 6; i++)
1013 if (tmpdistance < distance)
1015 distance = tmpdistance;
1019 *tmpdist = distance;
1025 G4Exception(
"G4TwistedTubs::DistanceToOut(p)",
"GeomSolids0003",
1041 G4int oldprc = os.precision(16);
1042 os <<
"-----------------------------------------------------------\n"
1043 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1044 <<
" ===================================================\n"
1045 <<
" Solid type: G4TwistedTubs\n"
1046 <<
" Parameters: \n"
1047 <<
" -ve end Z : " <<
fEndZ[0]/
mm <<
" mm \n"
1048 <<
" +ve end Z : " <<
fEndZ[1]/
mm <<
" mm \n"
1058 <<
" phi-width of a piece : " <<
fDPhi/
degree <<
" degrees \n"
1059 <<
"-----------------------------------------------------------\n";
1060 os.precision(oldprc);
1082 return G4VisExtent( -maxEndOuterRad, maxEndOuterRad,
1083 -maxEndOuterRad, maxEndOuterRad,
1096 G4int(G4Polyhedron::GetNumberOfRotationSteps() * dA / twopi) + 2;
1098 G4int(G4Polyhedron::GetNumberOfRotationSteps() *
fPhiTwist / twopi) + 2;
1100 const G4int nnodes = 4*(k-1)*(n-2) + 2*k*k ;
1101 const G4int nfaces = 4*(k-1)*(n-1) + 2*(k-1)*(k-1) ;
1105 typedef G4int G4int4[4];
1106 G4double3* xyz =
new G4double3[nnodes];
1107 G4int4* faces =
new G4int4[nfaces] ;
1115 ph->createPolyhedron(nnodes,nfaces,xyz,faces);
1157 rotHalfDPhi.rotateZ(0.5*
fDPhi);
1266 else if ( (chose >= a1) && (chose < a1 + a2 ) )
1276 else if ( (chose >= a1 + a2 ) && (chose < a1 + a2 + a3 ) )
1286 else if ( (chose >= a1 + a2 + a3 ) && (chose < a1 + a2 + a3 + a4 ) )
1295 else if( (chose >= a1 + a2 + a3 + a4 )&&(chose < a1 + a2 + a3 + a4 + a5 ) )
ThreeVector shoot(const G4int Ap, const G4int Af)
G4double GetEndInnerRadius() const
static const G4double kInfinity
CLHEP::Hep3Vector G4ThreeVector
G4ThreeVector GetPointOnSurface() const
CLHEP::HepRotation G4RotationMatrix
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx, G4bool isGlobal)=0
static void AddPolyToExtent(const G4ThreeVector &v0, const G4ThreeVector &v1, const G4ThreeVector &w1, const G4ThreeVector &w0, const G4VoxelLimits &voxellimit, const EAxis axis, G4SolidExtentList &extentlist)
std::ostream & StreamInfo(std::ostream &os) const
G4bool GetExtent(G4double &min, G4double &max) const
G4Polyhedron * CreatePolyhedron() const
G4VTwistSurface * fFormerTwisted
void SetNormal(const G4ThreeVector &newNormal)
G4double fEndOuterRadius[2]
LastValueWithDoubleVector fLastDistanceToInWithV
virtual G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
virtual void AddVertexInOrder(const G4ThreeVector vertex)
LastValue fLastDistanceToIn
EInside Inside(const G4ThreeVector &p) const
virtual void AddSolid(const G4Box &)=0
void ComputeDimensions(G4VPVParameterisation *, const G4int, const G4VPhysicalVolume *)
G4double fEndInnerRadius[2]
G4bool IsValidNorm() const
G4GeometryType GetEntityType() const
G4VTwistSurface * fUpperEndcap
virtual G4double DistanceToIn(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
G4double GetEndOuterRadius() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
static double normal(HepRandomEngine *eptr)
G4VTwistSurface * fOuterHype
virtual G4double GetSurfaceArea()=0
void SetNeighbours(G4VTwistSurface *axis0min, G4VTwistSurface *axis1min, G4VTwistSurface *axis0max, G4VTwistSurface *axis1max)
virtual G4double DistanceTo(const G4ThreeVector &gp, G4ThreeVector &gxx)
void DescribeYourselfTo(G4VGraphicsScene &scene) const
virtual G4double DistanceToOut(const G4ThreeVector &gp, const G4ThreeVector &gv, G4ThreeVector &gxxbest)
virtual G4ThreeVector SurfacePoint(G4double, G4double, G4bool isGlobal=false)=0
G4double GetRadialTolerance() const
G4VTwistSurface ** surface
void SetFields(G4double phitwist, G4double innerrad, G4double outerrad, G4double negativeEndz, G4double positiveEndz)
void AddSurface(const G4ClippablePolygon &surface)
LastValueWithDoubleVector fLastDistanceToOutWithV
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcnorm=G4bool(false), G4bool *validnorm=0, G4ThreeVector *n=0) const
virtual G4double GetBoundaryMax(G4double)=0
G4double GetSurfaceArea()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
LastValue fLastDistanceToOut
virtual void GetFacets(G4int m, G4int n, G4double xyz[][3], G4int faces[][4], G4int iside)=0
virtual G4double GetBoundaryMin(G4double)=0
G4VTwistSurface * fLatterTwisted
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4VTwistSurface * fInnerHype
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
static const double degree
G4double fTanInnerStereo2
G4Polyhedron * fpPolyhedron
G4TwistedTubs(const G4String &pname, G4double twistedangle, G4double endinnerrad, G4double endouterrad, G4double halfzlen, G4double dphi)
G4VSolid & operator=(const G4VSolid &rhs)
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
G4double fTanOuterStereo2
G4double GetCubicVolume()
G4VTwistSurface * fLowerEndcap
G4VisExtent GetExtent() const
virtual G4double GetSurfaceArea()
static G4GeometryTolerance * GetInstance()
G4Polyhedron * GetPolyhedron() const
G4bool CalculateExtent(const EAxis paxis, const G4VoxelLimits &pvoxellimit, const G4AffineTransform &ptransform, G4double &pmin, G4double &pmax) const
G4TwistedTubs & operator=(const G4TwistedTubs &rhs)