74 fLowerEndcap(0), fUpperEndcap(0), fSide0(0),
75 fSide90(0), fSide180(0), fSide270(0)
97 fDx = ( fDxUp > fDxDown ? fDxUp : fDxDown ) ;
107 std::ostringstream message;
108 message <<
"Not planar surface in untwisted Trapezoid: "
110 <<
"fDy2 is " <<
fDy2 <<
" but should be "
112 G4Exception(
"G4VTwistedFaceted::G4VTwistedFaceted()",
"GeomSolids0002",
127 std::ostringstream message;
128 message <<
"Not planar surface in untwisted Trapezoid: "
130 <<
"One endcap is rectangular, the other is a trapezoid." <<
G4endl
131 <<
"For planarity reasons they have to be rectangles or trapezoids "
133 G4Exception(
"G4VTwistedFaceted::G4VTwistedFaceted()",
"GeomSolids0002",
164 && ( std::fabs(
fPhiTwist) > 2*kAngTolerance )
167 && ( fTheta < pi/2 && fTheta >= 0 ) )
170 std::ostringstream message;
171 message <<
"Invalid dimensions. Too small, or twist angle too big: "
192 fTheta(0.), fPhi(0.), fDy1(0.),
193 fDx1(0.), fDx2(0.), fDy2(0.), fDx3(0.), fDx4(0.),
194 fDz(0.), fDx(0.), fDy(0.), fAlph(0.),
195 fTAlph(0.), fdeltaX(0.), fdeltaY(0.), fPhiTwist(0.),
196 fLowerEndcap(0), fUpperEndcap(0), fSide0(0), fSide90(0), fSide180(0),
223 fTheta(rhs.fTheta), fPhi(rhs.fPhi),
224 fDy1(rhs.fDy1), fDx1(rhs.fDx1), fDx2(rhs.fDx2), fDy2(rhs.fDy2),
225 fDx3(rhs.fDx3), fDx4(rhs.fDx4), fDz(rhs.fDz), fDx(rhs.fDx), fDy(rhs.fDy),
226 fAlph(rhs.fAlph), fTAlph(rhs.fTAlph), fdeltaX(rhs.fdeltaX),
227 fdeltaY(rhs.fdeltaY), fPhiTwist(rhs.fPhiTwist), fLowerEndcap(0),
228 fUpperEndcap(0), fSide0(0), fSide90(0), fSide180(0), fSide270(0),
229 fCubicVolume(rhs.fCubicVolume), fSurfaceArea(rhs.fSurfaceArea),
230 fLastInside(rhs.fLastInside), fLastNormal(rhs.fLastNormal),
231 fLastDistanceToIn(rhs.fLastDistanceToIn),
232 fLastDistanceToOut(rhs.fLastDistanceToOut),
233 fLastDistanceToInWithV(rhs.fLastDistanceToInWithV),
234 fLastDistanceToOutWithV(rhs.fLastDistanceToOutWithV)
247 if (
this == &rhs) {
return *
this; }
283 G4Exception(
"G4VTwistedFaceted::ComputeDimensions()",
285 "G4VTwistedFaceted does not support Parameterisation.");
296 pMin.set(-maxRad,-maxRad,-
fDz);
297 pMax.set( maxRad, maxRad,
fDz);
338 tmpp->
set(p.
x(), p.
y(), p.
z());
351 G4double posx = px * cphi - py * sphi ;
352 G4double posy = px * sphi + py * cphi ;
444 tmpp->
set(p.
x(), p.
y(), p.
z());
464 if (tmpdistance < distance)
466 distance = tmpdistance;
472 tmpsurface[0] = surfaces[besti];
473 *tmpnormal = tmpsurface[0]->
GetNormal(bestxx,
true);
508 tmpp->
set(p.
x(), p.
y(), p.
z());
509 tmpv->
set(v.
x(), v.
y(), v.
z());
553 for (
auto i=0; i < 6 ; ++i)
560 G4cout <<
"Solid DistanceToIn : distance = " << tmpdistance <<
G4endl ;
563 if (tmpdistance < distance)
565 distance = tmpdistance;
604 tmpp->
set(p.
x(), p.
y(), p.
z());
644 for (
auto i=0; i< 6; ++i)
647 if (tmpdistance < distance)
649 distance = tmpdistance;
659 G4Exception(
"G4VTwistedFaceted::DistanceToIn(p)",
"GeomSolids0003",
700 tmpp->
set(p.
x(), p.
y(), p.
z());
701 tmpv->
set(v.
x(), v.
y(), v.
z());
724 *norm = (blockedsurface->
GetNormal(p,
true));
751 for (
auto i=0; i<6 ; ++i)
754 if (tmpdistance < distance)
756 distance = tmpdistance;
766 *norm = (surfaces[besti]->
GetNormal(p,
true));
800 tmpp->
set(p.
x(), p.
y(), p.
z());
822 G4cout.precision(oldprc) ;
823 G4Exception(
"G4VTwistedFaceted::DistanceToOut(p)",
"GeomSolids1002",
854 for (
auto i=0; i<6; ++i)
857 if (tmpdistance < distance)
859 distance = tmpdistance;
871 G4Exception(
"G4VTwistedFaceted::DistanceToOut(p)",
"GeomSolids0003",
889 G4int oldprc = os.precision(16);
890 os <<
"-----------------------------------------------------------\n"
891 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
892 <<
" ===================================================\n"
893 <<
" Solid type: G4VTwistedFaceted\n"
899 <<
" Half length along y (lower endcap) = " <<
fDy1/
cm <<
" cm"
901 <<
" Half length along x (lower endcap, bottom) = " <<
fDx1/
cm <<
" cm"
903 <<
" Half length along x (lower endcap, top) = " <<
fDx2/
cm <<
" cm"
905 <<
" Half length along y (upper endcap) = " <<
fDy2/
cm <<
" cm"
907 <<
" Half length along x (upper endcap, bottom) = " <<
fDx3/
cm <<
" cm"
909 <<
" Half length along x (upper endcap, top) = " <<
fDx4/
cm <<
" cm"
911 <<
"-----------------------------------------------------------\n";
912 os.precision(oldprc);
994 return G4String(
"G4VTwistedFaceted");
1029 if ( z ==
fDz ) z -= 0.1*
fDz ;
1030 if ( z == -
fDz ) z += 0.1*
fDz ;
1080 else if( (chose >= a1) && (chose < a1 + a2 ) )
1089 else if( (chose >= a1 + a2 ) && (chose < a1 + a2 + a3 ) )
1097 else if( (chose >= a1 + a2 + a3 ) && (chose < a1 + a2 + a3 + a4 ) )
1104 else if( (chose >= a1 + a2 + a3 + a4 ) && (chose < a1 + a2 + a3 + a4 + a5 ) )
1137 const G4int nnodes = 4*(k-1)*(
n-2) + 2*k*k ;
1138 const G4int nfaces = 4*(k-1)*(
n-1) + 2*(k-1)*(k-1) ;
1142 typedef G4int G4int4[4];
1143 G4double3* xyz =
new G4double3[nnodes];
1144 G4int4* faces =
new G4int4[nfaces] ;
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
static constexpr double pi
static constexpr double cm
static constexpr double deg
#define G4MUTEX_INITIALIZER
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
static G4GeometryTolerance * GetInstance()
G4double GetAngularTolerance() const
G4int GetNumberOfRotationStepsAtTimeOfCreation() const
virtual void AddSolid(const G4Box &)=0
G4VSolid & operator=(const G4VSolid &rhs)
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
G4VTwistSurface ** surface
G4VTwistSurface * fSide180
LastValue fLastDistanceToIn
virtual void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4VTwistedFaceted & operator=(const G4VTwistedFaceted &rhs)
G4Polyhedron * fpPolyhedron
virtual G4Polyhedron * GetPolyhedron() const
G4ThreeVector GetPointOnSurface() const
virtual G4GeometryType GetEntityType() const
G4VTwistSurface * fSide90
LastValue fLastDistanceToOut
G4bool fRebuildPolyhedron
G4ThreeVector GetPointInSolid(G4double z) const
virtual G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4VTwistSurface * fLowerEndcap
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcnorm=false, G4bool *validnorm=nullptr, G4ThreeVector *n=nullptr) const
G4VTwistSurface * fSide270
virtual EInside Inside(const G4ThreeVector &p) const
virtual std::ostream & StreamInfo(std::ostream &os) const
virtual ~G4VTwistedFaceted()
virtual void ComputeDimensions(G4VPVParameterisation *, const G4int, const G4VPhysicalVolume *)
virtual G4VisExtent GetExtent() const
virtual G4Polyhedron * CreatePolyhedron() const
G4VTwistSurface * fUpperEndcap
G4VTwistedFaceted(const G4String &pname, G4double PhiTwist, G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlph)
LastValueWithDoubleVector fLastDistanceToOutWithV
virtual void DescribeYourselfTo(G4VGraphicsScene &scene) const
LastValueWithDoubleVector fLastDistanceToInWithV
G4double GetValueB(G4double phi) const
G4double Xcoef(G4double u, G4double phi, G4double ftg) const
static G4int GetNumberOfRotationSteps()
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
static const G4double kInfinity
static double normal(HepRandomEngine *eptr)
ThreeVector shoot(const G4int Ap, const G4int Af)