36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
42 using namespace CLHEP;
48 G4UTrap::G4UTrap(
const G4String& pName,
55 : Base_t(pName, pdz, pTheta, pPhi, pdy1, pdx1, pdx2,
56 pAlp1, pdy2, pdx3, pdx4, pAlp2)
60 G4UTrap::G4UTrap(
const G4String& pName,
67 G4UTrap::G4UTrap(
const G4String& pName,
71 : Base_t(pName, pZ, pY, pX, pLTX)
75 G4UTrap::G4UTrap(
const G4String& pName,
79 : Base_t(pName, pdx1, pdx2, pdy1, pdy2, pdz)
83 G4UTrap::G4UTrap(
const G4String& pName,
86 : Base_t(pName, pdx, pdy, pdz, pAlpha, pTheta, pPhi)
90 G4UTrap::G4UTrap(
const G4String& pName )
100 G4UTrap::G4UTrap( __void__&
a )
117 G4UTrap::G4UTrap(
const G4UTrap& rhs)
126 G4UTrap& G4UTrap::operator = (
const G4UTrap& rhs)
130 if (
this == &rhs) {
return *
this; }
134 Base_t::operator=(rhs);
143 G4double G4UTrap::GetZHalfLength()
const
147 G4double G4UTrap::GetYHalfLength1()
const
151 G4double G4UTrap::GetXHalfLength1()
const
155 G4double G4UTrap::GetXHalfLength2()
const
159 G4double G4UTrap::GetYHalfLength2()
const
163 G4double G4UTrap::GetXHalfLength3()
const
167 G4double G4UTrap::GetXHalfLength4()
const
171 G4double G4UTrap::GetThetaCphi()
const
173 return GetTanThetaCosPhi();
175 G4double G4UTrap::GetThetaSphi()
const
177 return GetTanThetaSinPhi();
182 plane.
a = GetStruct().GetPlane(n).fA;
183 plane.
b = GetStruct().GetPlane(n).fB;
184 plane.
c = GetStruct().GetPlane(n).fC;
185 plane.
d = GetStruct().GetPlane(n).fD;
190 G4double tanThetaSphi = GetTanThetaSinPhi();
191 G4double tanThetaCphi = GetTanThetaCosPhi();
192 G4double tan2Theta = tanThetaSphi*tanThetaSphi + tanThetaCphi*tanThetaCphi;
193 G4double cosTheta = 1.0 / std::sqrt(1 + tan2Theta);
194 return G4ThreeVector(tanThetaCphi*cosTheta, tanThetaSphi*cosTheta, cosTheta);
210 SetTanAlpha1(std::tan(pAlp1));
211 SetTanAlpha1(std::tan(pAlp2));
215 fRebuildPolyhedron =
true;
221 for (
unsigned int i=0; i<8; ++i)
223 upt[i] = U3Vector(pt[i].
x(), pt[i].
y(), pt[i].
z());
225 fromCornersToParameters(upt);
226 fRebuildPolyhedron =
true;
247 return new G4UTrap(*
this);
256 static G4bool checkBBox =
true;
259 for (
G4int i=0; i<4; ++i) { planes[i] = GetSidePlane(i); }
264 for (
G4int i=0; i<8; ++i)
266 G4int iy = (i==0 || i==1 || i==4 || i==5) ? 0 : 1;
267 G4int ix = (i==0 || i==2 || i==4 || i==6) ? 2 : 3;
269 G4double y = -(planes[iy].
c*z + planes[iy].
d)/planes[iy].b;
270 G4double x = -(planes[ix].
b*y + planes[ix].
c*z + planes[ix].
d)/planes[ix].
a;
271 if (x < xmin) xmin =
x;
272 if (x > xmax) xmax =
x;
273 if (y < ymin) ymin =
y;
274 if (y > ymax) ymax =
y;
277 pMin.
set(xmin,ymin,-dz);
278 pMax.
set(xmax,ymax, dz);
282 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
285 message <<
"Bad bounding box (min >= max) for solid: "
287 <<
"\npMin = " << pMin
288 <<
"\npMax = " << pMax;
289 G4Exception(
"G4UTrap::BoundingLimits()",
"GeomMgt0001",
301 if (std::abs(pMin.
x()-vmin.x()) > tolerance ||
302 std::abs(pMin.
y()-vmin.y()) > tolerance ||
303 std::abs(pMin.
z()-vmin.z()) > tolerance ||
304 std::abs(pMax.
x()-vmax.x()) > tolerance ||
305 std::abs(pMax.
y()-vmax.y()) > tolerance ||
306 std::abs(pMax.
z()-vmax.z()) > tolerance)
309 message <<
"Inconsistency in bounding boxes for solid: "
311 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
312 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
313 G4Exception(
"G4UTrap::BoundingLimits()",
"GeomMgt0001",
325 G4UTrap::CalculateExtent(
const EAxis pAxis,
335 BoundingLimits(bmin,bmax);
338 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
340 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
342 return exist = (pMin < pMax) ?
true :
false;
348 for (
G4int i=0; i<4; ++i) { planes[i] = GetSidePlane(i); }
352 for (
G4int i=0; i<8; ++i)
354 G4int iy = (i==0 || i==1 || i==4 || i==5) ? 0 : 1;
355 G4int ix = (i==0 || i==2 || i==4 || i==6) ? 2 : 3;
357 G4double y = -(planes[iy].
c*z + planes[iy].
d)/planes[iy].b;
358 G4double x = -(planes[ix].
b*y + planes[ix].
c*z + planes[ix].
d)/planes[ix].
a;
373 std::vector<const G4ThreeVectorList *> polygons(2);
374 polygons[0] = &baseA;
375 polygons[1] = &baseB;
378 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
388 G4double fTthetaSphi = GetThetaSphi();
389 G4double fTthetaCphi = GetThetaCphi();
390 G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
391 G4double alpha1 = std::atan(GetTanAlpha1());
392 G4double alpha2 = std::atan(GetTanAlpha2());
393 G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
397 GetXHalfLength1(), GetXHalfLength2(), alpha1,
399 GetXHalfLength3(), GetXHalfLength4(), alpha2);
402 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
static const G4double kInfinity
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
void message(RunManager *runmanager)
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout