34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
40 using namespace CLHEP;
46 G4UTrap::G4UTrap(
const G4String& pName,
53 : Base_t(pName, pdz, pTheta, pPhi, pdy1, pdx1, pdx2,
54 pAlp1, pdy2, pdx3, pdx4, pAlp2)
58 G4UTrap::G4UTrap(
const G4String& pName,
65 G4UTrap::G4UTrap(
const G4String& pName,
69 : Base_t(pName, pZ, pY, pX, pLTX)
73 G4UTrap::G4UTrap(
const G4String& pName,
77 : Base_t(pName, pdx1, pdx2, pdy1, pdy2, pdz)
81 G4UTrap::G4UTrap(
const G4String& pName,
84 : Base_t(pName, pdx, pdy, pdz, pAlpha, pTheta, pPhi)
88 G4UTrap::G4UTrap(
const G4String& pName )
98 G4UTrap::G4UTrap( __void__&
a )
115 G4UTrap::G4UTrap(
const G4UTrap& rhs)
124 G4UTrap& G4UTrap::operator = (
const G4UTrap& rhs)
128 if (
this == &rhs) {
return *
this; }
132 Base_t::operator=(rhs);
141 G4double G4UTrap::GetZHalfLength()
const
145 G4double G4UTrap::GetYHalfLength1()
const
149 G4double G4UTrap::GetXHalfLength1()
const
153 G4double G4UTrap::GetXHalfLength2()
const
157 G4double G4UTrap::GetYHalfLength2()
const
161 G4double G4UTrap::GetXHalfLength3()
const
165 G4double G4UTrap::GetXHalfLength4()
const
169 G4double G4UTrap::GetThetaCphi()
const
171 return GetTanThetaCosPhi();
173 G4double G4UTrap::GetThetaSphi()
const
175 return GetTanThetaSinPhi();
180 plane.
a = GetStruct().GetPlane(n).fA;
181 plane.
b = GetStruct().GetPlane(n).fB;
182 plane.
c = GetStruct().GetPlane(n).fC;
183 plane.
d = GetStruct().GetPlane(n).fD;
188 G4double tanThetaSphi = GetTanThetaSinPhi();
189 G4double tanThetaCphi = GetTanThetaCosPhi();
190 G4double tan2Theta = tanThetaSphi*tanThetaSphi + tanThetaCphi*tanThetaCphi;
191 G4double cosTheta = 1.0 / std::sqrt(1 + tan2Theta);
192 return G4ThreeVector(tanThetaCphi*cosTheta, tanThetaSphi*cosTheta, cosTheta);
208 SetTanAlpha1(std::tan(pAlp1));
209 SetTanAlpha1(std::tan(pAlp2));
213 fRebuildPolyhedron =
true;
219 for (
unsigned int i=0; i<8; ++i)
221 upt[i] = U3Vector(pt[i].
x(), pt[i].
y(), pt[i].
z());
223 fromCornersToParameters(upt);
224 fRebuildPolyhedron =
true;
245 return new G4UTrap(*
this);
254 static G4bool checkBBox =
true;
257 for (
G4int i=0; i<4; ++i) { planes[i] = GetSidePlane(i); }
262 for (
G4int i=0; i<8; ++i)
264 G4int iy = (i==0 || i==1 || i==4 || i==5) ? 0 : 1;
265 G4int ix = (i==0 || i==2 || i==4 || i==6) ? 2 : 3;
267 G4double y = -(planes[iy].
c*z + planes[iy].
d)/planes[iy].
b;
268 G4double x = -(planes[ix].
b*y + planes[ix].
c*z + planes[ix].
d)/planes[ix].
a;
269 if (x < xmin) xmin =
x;
270 if (x > xmax) xmax =
x;
271 if (y < ymin) ymin =
y;
272 if (y > ymax) ymax =
y;
275 pMin.
set(xmin,ymin,-dz);
276 pMax.
set(xmax,ymax, dz);
280 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
283 message <<
"Bad bounding box (min >= max) for solid: "
285 <<
"\npMin = " << pMin
286 <<
"\npMax = " <<
pMax;
287 G4Exception(
"G4UTrap::BoundingLimits()",
"GeomMgt0001",
299 if (
std::abs(pMin.
x()-vmin.x()) > tolerance ||
300 std::abs(pMin.
y()-vmin.y()) > tolerance ||
301 std::abs(pMin.
z()-vmin.z()) > tolerance ||
302 std::abs(pMax.
x()-vmax.x()) > tolerance ||
303 std::abs(pMax.
y()-vmax.y()) > tolerance ||
307 message <<
"Inconsistency in bounding boxes for solid: "
309 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
310 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
311 G4Exception(
"G4UTrap::BoundingLimits()",
"GeomMgt0001",
323 G4UTrap::CalculateExtent(
const EAxis pAxis,
333 BoundingLimits(bmin,bmax);
336 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
338 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
340 return exist = (pMin <
pMax) ?
true :
false;
346 for (
G4int i=0; i<4; ++i) { planes[i] = GetSidePlane(i); }
350 for (
G4int i=0; i<8; ++i)
352 G4int iy = (i==0 || i==1 || i==4 || i==5) ? 0 : 1;
353 G4int ix = (i==0 || i==2 || i==4 || i==6) ? 2 : 3;
355 G4double y = -(planes[iy].
c*z + planes[iy].
d)/planes[iy].
b;
356 G4double x = -(planes[ix].
b*y + planes[ix].
c*z + planes[ix].
d)/planes[ix].
a;
371 std::vector<const G4ThreeVectorList *> polygons(2);
372 polygons[0] = &baseA;
373 polygons[1] = &baseB;
376 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
386 G4double fTthetaSphi = GetThetaSphi();
387 G4double fTthetaCphi = GetThetaCphi();
388 G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
389 G4double alpha1 = std::atan(GetTanAlpha1());
390 G4double alpha2 = std::atan(GetTanAlpha2());
391 G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
395 GetXHalfLength1(), GetXHalfLength2(), alpha1,
397 GetXHalfLength3(), GetXHalfLength4(), alpha2);
400 #endif // G4GEOM_USE_USOLIDS