55 #if !defined(G4GEOM_USE_UTRAP)
71 using namespace CLHEP;
112 && pt[0].
z() == pt[1].
z()
113 && pt[0].
z() == pt[2].
z()
114 && pt[0].
z() == pt[3].
z()
117 && pt[4].
z() == pt[5].
z()
118 && pt[4].
z() == pt[6].
z()
119 && pt[4].
z() == pt[7].
z()
123 && pt[0].
y() == pt[1].
y()
124 && pt[2].
y() == pt[3].
y()
125 && pt[4].
y() == pt[5].
y()
126 && pt[6].
y() == pt[7].
y()
129 && std::fabs(pt[0].
x()+pt[1].
x()+pt[4].
x()+pt[5].
x() +
133 message <<
"Invalid vertice coordinates for Solid: " <<
GetName();
142 fDy1 = ((pt[2]).
y()-(pt[1]).
y())*0.5;
143 fDx1 = ((pt[1]).
x()-(pt[0]).
x())*0.5;
144 fDx2 = ((pt[3]).
x()-(pt[2]).
x())*0.5;
147 fDy2 = ((pt[6]).
y()-(pt[5]).
y())*0.5;
148 fDx3 = ((pt[5]).
x()-(pt[4]).
x())*0.5;
149 fDx4 = ((pt[7]).
x()-(pt[6]).
x())*0.5;
225 fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
226 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
227 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
239 fDz(1.), fTthetaCphi(0.), fTthetaSphi(0.),
240 fDy1(1.), fDx1(1.), fDx2(1.), fTalpha1(0.),
241 fDy2(1.), fDx3(1.), fDx4(1.), fTalpha2(0.)
259 :
G4CSGSolid(rhs), halfCarTolerance(rhs.halfCarTolerance),
260 fDz(rhs.fDz), fTthetaCphi(rhs.fTthetaCphi), fTthetaSphi(rhs.fTthetaSphi),
261 fDy1(rhs.fDy1), fDx1(rhs.fDx1), fDx2(rhs.fDx2), fTalpha1(rhs.fTalpha1),
262 fDy2(rhs.fDy2), fDx3(rhs.fDx3), fDx4(rhs.fDx4), fTalpha2(rhs.fTalpha2)
276 if (
this == &rhs) {
return *
this; }
338 message <<
"Invalid Length Parameters for Solid: " <<
GetName()
342 G4Exception(
"G4Trap::CheckParameters()",
"GeomSolids0002",
379 G4int iface[4][4] = { {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3} };
380 G4String side[4] = {
"~-Y",
"~+Y",
"~-X",
"~+X" };
382 for (
G4int i=0; i<4; ++i)
393 for (
G4int k=0; k<4; ++k)
396 if (std::abs(dist) > std::abs(dmax)) dmax = dist;
399 message <<
"Side face " << side[i] <<
" is not planar for solid: "
400 <<
GetName() <<
"\nDiscrepancy: " << dmax/
mm <<
" mm\n";
402 G4Exception(
"G4Trap::MakePlanes()",
"GeomSolids0002",
454 normal = normal.
unit();
457 plane.
a = normal.
x();
458 plane.
b = normal.
y();
459 plane.
c = normal.
z();
460 plane.
d = -normal.
dot(centre);
492 (dx4 + dx3 - dx2 - dx1)*(dy2 - dy1)/3)*dz*0.125;
507 { {0,1,3,2}, {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3}, {4,6,7,5} };
510 for (
G4int i=0; i<6; ++i)
515 pt[iface[i][3]]).
mag();
544 for (
G4int i=0; i<8; ++i)
547 if (x < xmin) xmin =
x;
548 if (x > xmax) xmax =
x;
550 if (y < ymin) ymin =
y;
551 if (y > ymax) ymax =
y;
555 pMin.
set(xmin,ymin,-dz);
556 pMax.
set(xmax,ymax, dz);
560 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
563 message <<
"Bad bounding box (min >= max) for solid: "
565 <<
"\npMin = " << pMin
566 <<
"\npMax = " << pMax;
567 G4Exception(
"G4Trap::BoundingLimits()",
"GeomMgt0001",
590 if (
true)
return bbox.
CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
594 return exist = (pMin < pMax) ?
true :
false;
613 std::vector<const G4ThreeVectorList *> polygons(2);
614 polygons[0] = &baseA;
615 polygons[1] = &baseB;
695 nz = (p.
z() < 0) ? -1 : 1;
703 for (
G4int i=0; i<2; ++i)
712 for (
G4int i=2; i<4; ++i)
729 for (
G4int i=2; i<4; ++i)
782 G4int oldprc = message.precision(16);
783 message <<
"Point p is not on surface (!?) of solid: "
785 message <<
"Position:\n";
786 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
787 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
788 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
789 G4cout.precision(oldprc) ;
790 G4Exception(
"G4Trap::SurfaceNormal(p)",
"GeomSolids1002",
807 for (
G4int i=0; i<4; ++i)
812 if (d > dist) { dist =
d; iside = i; }
851 if (tymin < tmp) tymin =
tmp;
856 if (tymax > tmp) tymax =
tmp;
872 if (txmin < tmp) txmin =
tmp;
877 if (txmax > tmp) txmax =
tmp;
912 return (dist > 0) ? dist : 0.;
923 return (dist > 0) ? dist : 0.;
932 return (dist > 0) ? dist : 0.;
941 return (dist > 0) ? dist : 0.;
964 n->
set(0, 0, (p.
z() < 0) ? -1 : 1);
970 G4int iside = (vz < 0) ? -4 : -2;
991 if (tmax > tmp) { tmax =
tmp; iside = i; }
1014 if (tmax > tmp) { tmax =
tmp; iside = i; }
1024 n->
set(0, 0, iside + 3);
1042 G4int oldprc = message.precision(16);
1043 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
G4endl;
1044 message <<
"Position:\n";
1045 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
1046 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
1047 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
1048 G4cout.precision(oldprc) ;
1049 G4Exception(
"G4Trap::DistanceToOut(p)",
"GeomSolids1002",
1068 return (dist < 0) ? -dist : 0.;
1079 return (dist < 0) ? -dist : 0.;
1088 return (dist < 0) ? -dist : 0.;
1097 return (dist < 0) ? -dist : 0.;
1118 return new G4Trap(*
this);
1134 G4int oldprc = os.precision(16);
1135 os <<
"-----------------------------------------------------------\n"
1136 <<
" *** Dump for solid: " <<
GetName() <<
" ***\n"
1137 <<
" ===================================================\n"
1138 <<
" Solid type: G4Trap\n"
1140 <<
" half length Z: " <<
fDz/
mm <<
" mm\n"
1141 <<
" half length Y, face -Dz: " <<
fDy1/
mm <<
" mm\n"
1142 <<
" half length X, face -Dz, side -Dy1: " <<
fDx1/
mm <<
" mm\n"
1143 <<
" half length X, face -Dz, side +Dy1: " <<
fDx2/
mm <<
" mm\n"
1144 <<
" half length Y, face +Dz: " <<
fDy2/
mm <<
" mm\n"
1145 <<
" half length X, face +Dz, side -Dy2: " <<
fDx3/
mm <<
" mm\n"
1146 <<
" half length X, face +Dz, side +Dy2: " <<
fDx4/
mm <<
" mm\n"
1147 <<
" theta: " << theta/
degree << signDegree <<
"\n"
1148 <<
" phi: " << phi/
degree << signDegree <<
"\n"
1149 <<
" alpha, face -Dz: " << alpha1/
degree << signDegree <<
"\n"
1150 <<
" alpha, face +Dz: " << alpha2/
degree << signDegree <<
"\n"
1151 <<
"-----------------------------------------------------------\n";
1152 os.precision(oldprc);
1163 for (
G4int i=0; i<8; ++i)
1165 G4int iy = (i==0 || i==1 || i==4 || i==5) ? 0 : 1;
1166 G4int ix = (i==0 || i==2 || i==4 || i==6) ? 2 : 3;
1182 G4int iface [6][4] =
1183 { {0,1,3,2}, {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3}, {4,6,7,5} };
1188 for (
G4int i=0; i<6; ++i)
1193 pt[iface[i][3]]).
mag();
1202 if (select <= sface[4]) k = 4;
1203 if (select <= sface[3]) k = 3;
1204 if (select <= sface[2]) k = 2;
1205 if (select <= sface[1]) k = 1;
1206 if (select <= sface[0]) k = 0;
1210 G4int i0 = iface[k][0];
1211 G4int i1 = iface[k][1];
1212 G4int i2 = iface[k][2];
1213 G4int i3 = iface[k][3];
1222 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
1223 return (1.-u-v)*pt[i0] + u*pt[i1] + v*pt[i3];
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
void set(double x, double y, double z)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
virtual void AddSolid(const G4Box &)=0
static const G4double kInfinity
G4bool MakePlane(const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3, const G4ThreeVector &p4, TrapSidePlane &plane)
void SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
void GetVertices(G4ThreeVector pt[8]) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
static constexpr double mm
G4CSGSolid & operator=(const G4CSGSolid &rhs)
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
void message(RunManager *runmanager)
G4double GetZHalfLength() const
static double normal(HepRandomEngine *eptr)
double dot(const Hep3Vector &) const
const G4double kCarTolerance
EInside Inside(const G4ThreeVector &p) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4Polyhedron * CreatePolyhedron() const
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
std::vector< G4ThreeVector > G4ThreeVectorList
G4Trap & operator=(const G4Trap &rhs)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4GeometryType GetEntityType() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4ThreeVector GetPointOnSurface() const
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
static constexpr double degree
G4GLOB_DLL std::ostream G4cout
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double GetCubicVolume()
std::ostream & StreamInfo(std::ostream &os) const
G4double halfCarTolerance
G4bool fRebuildPolyhedron
G4double GetSurfaceArea()
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4Trap(const G4String &pName, G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)