47 #if !defined(G4GEOM_USE_UTRD)
60 using namespace CLHEP;
71 fDx1(pdx1), fDx2(pdx2), fDy1(pdy1), fDy2(pdy2), fDz(pdz)
84 fDx1(1.), fDx2(1.), fDy1(1.), fDy2(1.), fDz(1.)
102 :
G4CSGSolid(rhs), halfCarTolerance(rhs.halfCarTolerance),
103 fDx1(rhs.fDx1), fDx2(rhs.fDx2),
104 fDy1(rhs.fDy1), fDy2(rhs.fDy2), fDz(rhs.fDz)
117 if (
this == &rhs) {
return *
this; }
167 message <<
"Invalid (too small or negative) dimensions for Solid: "
169 <<
"\n X - " <<
fDx1 <<
", " <<
fDx2
170 <<
"\n Y - " <<
fDy1 <<
", " <<
fDy2
172 G4Exception(
"G4Trd::CheckParameters()",
"GeomSolids0002",
186 G4double magx = std::sqrt(dx*dx + dz*dz);
187 G4double magy = std::sqrt(dy*dy + dz*dz);
270 pMin.
set(-xmax,-ymax,-dz);
271 pMax.
set( xmax, ymax, dz);
275 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
278 message <<
"Bad bounding box (min >= max) for solid: "
280 <<
"\npMin = " << pMin
281 <<
"\npMax = " << pMax;
304 if (
true)
return bbox.
CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
308 return exist = (pMin < pMax) ?
true :
false;
320 baseA[0].set(-dx1,-dy1,-dz);
321 baseA[1].set( dx1,-dy1,-dz);
322 baseA[2].set( dx1, dy1,-dz);
323 baseA[3].set(-dx1, dy1,-dz);
324 baseB[0].set(-dx2,-dy2, dz);
325 baseB[1].set( dx2,-dy2, dz);
326 baseB[2].set( dx2, dy2, dz);
327 baseB[3].set(-dx2, dy2, dz);
329 std::vector<const G4ThreeVectorList *> polygons(2);
330 polygons[0] = &baseA;
331 polygons[1] = &baseB;
369 nz = (p.
z() < 0) ? -1 : 1;
419 G4int oldprc = message.precision(16);
420 message <<
"Point p is not on surface (!?) of solid: "
422 message <<
"Position:\n";
423 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
424 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
425 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
426 G4cout.precision(oldprc) ;
427 G4Exception(
"G4Trd::SurfaceNormal(p)",
"GeomSolids1002",
444 for (
G4int i=0; i<4; ++i)
449 if (d > dist) { dist =
d; iside = i; }
478 G4double tmin0 = tzmin, tmax0 = tzmax;
487 if (tmin0 < tmp) tmin0 =
tmp;
492 if (tmax0 > tmp) tmax0 =
tmp;
495 G4double tmin1 = tmin0, tmax1 = tmax0;
502 if (tmin1 < tmp) tmin1 =
tmp;
507 if (tmax1 > tmp) tmax1 =
tmp;
512 G4double tmin2 = tmin1, tmax2 = tmax1;
521 if (tmin2 < tmp) tmin2 =
tmp;
526 if (tmax2 > tmp) tmax2 =
tmp;
529 G4double tmin3 = tmin2, tmax3 = tmax2;
536 if (tmin3 < tmp) tmin3 =
tmp;
541 if (tmax3 > tmp) tmax3 =
tmp;
546 G4double tmin = tmin3, tmax = tmax3;
566 return (dist > 0) ? dist : 0.;
586 n->
set(0, 0, (p.
z() < 0) ? -1 : 1);
592 G4int iside = (vz < 0) ? -4 : -2;
613 if (tmax > tmp) { tmax =
tmp; iside = i; }
635 if (tmax > tmp) { tmax =
tmp; iside = i; }
645 n->
set(0, 0, iside + 3);
663 G4int oldprc = message.precision(16);
664 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
G4endl;
665 message <<
"Position:\n";
666 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
667 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
668 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
669 G4cout.precision(oldprc) ;
670 G4Exception(
"G4Trd::DistanceToOut(p)",
"GeomSolids1002",
682 return (dist < 0) ? -dist : 0.;
700 return new G4Trd(*
this);
709 G4int oldprc = os.precision(16);
710 os <<
"-----------------------------------------------------------\n"
711 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
712 <<
" ===================================================\n"
713 <<
" Solid type: G4Trd\n"
715 <<
" half length X, surface -dZ: " <<
fDx1/
mm <<
" mm \n"
716 <<
" half length X, surface +dZ: " <<
fDx2/
mm <<
" mm \n"
717 <<
" half length Y, surface -dZ: " <<
fDy1/
mm <<
" mm \n"
718 <<
" half length Y, surface +dZ: " <<
fDy2/
mm <<
" mm \n"
719 <<
" half length Z : " <<
fDz/
mm <<
" mm \n"
720 <<
"-----------------------------------------------------------\n";
721 os.precision(oldprc);
747 { {0,1,3,2}, {0,4,5,1}, {2,3,7,6}, {0,2,6,4}, {1,5,7,3}, {4,6,7,5} };
754 for (
G4int i=1; i<6; ++i) { sface[i] += sface[i-1]; }
760 if (select <= sface[4]) k = 4;
761 if (select <= sface[3]) k = 3;
762 if (select <= sface[2]) k = 2;
763 if (select <= sface[1]) k = 1;
764 if (select <= sface[0]) k = 0;
768 G4int i0 = iface[k][0];
769 G4int i1 = iface[k][1];
770 G4int i2 = iface[k][2];
771 G4int i3 = iface[k][3];
780 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
781 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
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
std::vector< ExP01TrackerHit * > a
virtual void AddSolid(const G4Box &)=0
static const G4double kInfinity
G4double halfCarTolerance
G4double GetCubicVolume()
static constexpr double mm
G4CSGSolid & operator=(const G4CSGSolid &rhs)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
void message(RunManager *runmanager)
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
const G4double kCarTolerance
G4double GetSurfaceArea()
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
G4Trd(const G4String &pName, G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
G4double GetYHalfLength2() const
G4double GetZHalfLength() const
G4double GetXHalfLength1() const
EInside Inside(const G4ThreeVector &p) const
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
std::vector< G4ThreeVector > G4ThreeVectorList
std::ostream & StreamInfo(std::ostream &os) const
G4double GetYHalfLength1() const
G4Polyhedron * CreatePolyhedron() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double GetXHalfLength2() const
G4GLOB_DLL std::ostream G4cout
G4GeometryType GetEntityType() const
struct G4Trd::@34 fPlanes[4]
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4bool fRebuildPolyhedron
void SetAllParameters(G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4Trd & operator=(const G4Trd &rhs)
G4ThreeVector GetPointOnSurface() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const