35#if !defined(G4GEOM_USE_UTRD)
59 fDx1(pdx1), fDx2(pdx2), fDy1(pdy1), fDy2(pdy2), fDz(pdz)
72 fDx1(1.), fDx2(1.), fDy1(1.), fDy2(1.), fDz(1.)
90 :
G4CSGSolid(rhs), halfCarTolerance(rhs.halfCarTolerance),
91 fDx1(rhs.fDx1), fDx2(rhs.fDx2),
92 fDy1(rhs.fDy1), fDy2(rhs.fDy2), fDz(rhs.fDz),
93 fHx(rhs.fHx), fHy(rhs.fHy)
106 if (
this == &rhs) {
return *
this; }
156 std::ostringstream message;
157 message <<
"Invalid (too small or negative) dimensions for Solid: "
159 <<
"\n X - " <<
fDx1 <<
", " <<
fDx2
160 <<
"\n Y - " <<
fDy1 <<
", " <<
fDy2
162 G4Exception(
"G4Trd::CheckParameters()",
"GeomSolids0002",
176 fHx = std::sqrt(dy*dy + dz*dz);
177 fHy = std::sqrt(dx*dx + dz*dz);
258 pMin.set(-xmax,-ymax,-dz);
259 pMax.set( xmax, ymax, dz);
265 std::ostringstream message;
266 message <<
"Bad bounding box (min >= max) for solid: "
268 <<
"\npMin = " <<
pMin
269 <<
"\npMax = " <<
pMax;
296 return exist = (
pMin <
pMax) ?
true :
false;
308 baseA[0].set(-dx1,-dy1,-dz);
309 baseA[1].set( dx1,-dy1,-dz);
310 baseA[2].set( dx1, dy1,-dz);
311 baseA[3].set(-dx1, dy1,-dz);
312 baseB[0].set(-dx2,-dy2, dz);
313 baseB[1].set( dx2,-dy2, dz);
314 baseB[2].set( dx2, dy2, dz);
315 baseB[3].set(-dx2, dy2, dz);
317 std::vector<const G4ThreeVectorList *> polygons(2);
318 polygons[0] = &baseA;
319 polygons[1] = &baseB;
357 nz = (p.
z() < 0) ? -1 : 1;
406 std::ostringstream message;
407 G4int oldprc = message.precision(16);
408 message <<
"Point p is not on surface (!?) of solid: "
410 message <<
"Position:\n";
411 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
412 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
413 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
414 G4cout.precision(oldprc) ;
415 G4Exception(
"G4Trd::SurfaceNormal(p)",
"GeomSolids1002",
432 for (
G4int i=0; i<4; ++i)
437 if (
d > dist) { dist =
d; iside = i; }
466 G4double tmin0 = tzmin, tmax0 = tzmax;
475 if (tmin0 < tmp) tmin0 = tmp;
480 if (tmax0 > tmp) tmax0 = tmp;
483 G4double tmin1 = tmin0, tmax1 = tmax0;
490 if (tmin1 < tmp) tmin1 = tmp;
495 if (tmax1 > tmp) tmax1 = tmp;
500 G4double tmin2 = tmin1, tmax2 = tmax1;
509 if (tmin2 < tmp) tmin2 = tmp;
514 if (tmax2 > tmp) tmax2 = tmp;
517 G4double tmin3 = tmin2, tmax3 = tmax2;
524 if (tmin3 < tmp) tmin3 = tmp;
529 if (tmax3 > tmp) tmax3 = tmp;
534 G4double tmin = tmin3, tmax = tmax3;
554 return (dist > 0) ? dist : 0.;
574 n->set(0, 0, (p.
z() < 0) ? -1 : 1);
580 G4int iside = (vz < 0) ? -4 : -2;
601 if (tmax > tmp) { tmax = tmp; iside = i; }
623 if (tmax > tmp) { tmax = tmp; iside = i; }
633 n->set(0, 0, iside + 3);
650 std::ostringstream message;
651 G4int oldprc = message.precision(16);
652 message <<
"Point p is outside (!?) of solid: " <<
GetName() <<
G4endl;
653 message <<
"Position:\n";
654 message <<
" p.x() = " << p.
x()/
mm <<
" mm\n";
655 message <<
" p.y() = " << p.
y()/
mm <<
" mm\n";
656 message <<
" p.z() = " << p.
z()/
mm <<
" mm";
658 G4Exception(
"G4Trd::DistanceToOut(p)",
"GeomSolids1002",
670 return (dist < 0) ? -dist : 0.;
688 return new G4Trd(*
this);
697 G4int oldprc = os.precision(16);
698 os <<
"-----------------------------------------------------------\n"
699 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
700 <<
" ===================================================\n"
701 <<
" Solid type: G4Trd\n"
703 <<
" half length X, surface -dZ: " <<
fDx1/
mm <<
" mm \n"
704 <<
" half length X, surface +dZ: " <<
fDx2/
mm <<
" mm \n"
705 <<
" half length Y, surface -dZ: " <<
fDy1/
mm <<
" mm \n"
706 <<
" half length Y, surface +dZ: " <<
fDy2/
mm <<
" mm \n"
707 <<
" half length Z : " <<
fDz/
mm <<
" mm \n"
708 <<
"-----------------------------------------------------------\n";
709 os.precision(oldprc);
725 ssurf[1] += ssurf[0];
726 ssurf[2] += ssurf[1];
727 ssurf[3] += ssurf[2];
728 ssurf[4] += ssurf[3];
729 ssurf[5] += ssurf[4];
735 k -= (select <= ssurf[4]);
736 k -= (select <= ssurf[3]);
737 k -= (select <= ssurf[2]);
738 k -= (select <= ssurf[1]);
739 k -= (select <= ssurf[0]);
753 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
756 return (select <= ssurf[0] +
fDx1*
fHx) ?
762 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
765 return (select <= ssurf[1] +
fDx1*
fHx) ?
771 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
774 return (select <= ssurf[2] +
fDy1*
fHy) ?
780 if (u + v > 1.) { u = 1. - u; v = 1. - v; }
783 return (select <= ssurf[3] +
fDy1*
fHy) ?
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static const G4double pMax
static const G4double pMin
static constexpr double mm
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4bool fRebuildPolyhedron
G4CSGSolid & operator=(const G4CSGSolid &rhs)
void SetAllParameters(G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
G4double GetXHalfLength2() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
EInside Inside(const G4ThreeVector &p) const
G4Trd(const G4String &pName, G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4Trd & operator=(const G4Trd &rhs)
G4double halfCarTolerance
G4double GetYHalfLength2() const
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
std::ostream & StreamInfo(std::ostream &os) const
G4ThreeVector GetPointOnSurface() const
G4double GetXHalfLength1() const
G4GeometryType GetEntityType() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double GetYHalfLength1() const
G4double GetSurfaceArea()
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=nullptr, G4ThreeVector *n=nullptr) const
G4Polyhedron * CreatePolyhedron() const
struct G4Trd::@23 fPlanes[4]
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4double GetCubicVolume()
G4double GetZHalfLength() const
virtual void AddSolid(const G4Box &)=0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
static const G4double kInfinity
T max(const T t1, const T t2)
brief Return the largest of the two arguments