36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
42 using namespace CLHEP;
48 G4UTrap::G4UTrap(
const G4String& pName,
55 : G4USolid(pName, new UTrap(pName, pdz, pTheta, pPhi,
56 pdy1, pdx1, pdx2, pAlp1, pdy2, pdx3, pdx4, pAlp2))
60 G4UTrap::G4UTrap(
const G4String& pName,
62 : G4USolid(pName, new UTrap(pName))
67 G4UTrap::G4UTrap(
const G4String& pName,
71 : G4USolid(pName, new UTrap(pName, pZ, pY, pX, pLTX))
75 G4UTrap::G4UTrap(
const G4String& pName,
79 : G4USolid(pName, new UTrap(pName, pdx1, pdx2, pdy1, pdy2, pdz))
83 G4UTrap::G4UTrap(
const G4String& pName,
86 : G4USolid(pName, new UTrap(pName, pdx, pdy, pdz, pAlpha, pTheta, pPhi))
90 G4UTrap::G4UTrap(
const G4String& pName )
91 : G4USolid(pName, new UTrap(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 G4USolid::operator=(rhs);
143 G4double G4UTrap::GetZHalfLength()
const
145 return GetShape()->GetZHalfLength();
147 G4double G4UTrap::GetYHalfLength1()
const
149 return GetShape()->GetYHalfLength1();
151 G4double G4UTrap::GetXHalfLength1()
const
153 return GetShape()->GetXHalfLength1();
155 G4double G4UTrap::GetXHalfLength2()
const
157 return GetShape()->GetXHalfLength2();
159 G4double G4UTrap::GetTanAlpha1()
const
161 return GetShape()->GetTanAlpha1();
163 G4double G4UTrap::GetYHalfLength2()
const
165 return GetShape()->GetYHalfLength2();
167 G4double G4UTrap::GetXHalfLength3()
const
169 return GetShape()->GetXHalfLength3();
171 G4double G4UTrap::GetXHalfLength4()
const
173 return GetShape()->GetXHalfLength4();
175 G4double G4UTrap::GetTanAlpha2()
const
177 return GetShape()->GetTanAlpha2();
181 UTrapSidePlane iplane = GetShape()->GetSidePlane(n);
187 UVector3 axis = GetShape()->GetSymAxis();
197 GetShape()->SetAllParameters(pDz, pTheta, pPhi,
198 pDy1, pDx1, pDx2, pAlp1,
199 pDy2, pDx3, pDx4, pAlp2);
200 fRebuildPolyhedron =
true;
206 for (
unsigned int i=0; i<8; ++i)
208 upt[i] = UVector3(pt[i].
x(), pt[i].y(), pt[i].
z());
210 GetShape()->SetPlanes(upt);
211 fRebuildPolyhedron =
true;
232 return new G4UTrap(*
this);
241 static G4bool checkBBox =
true;
250 G4double fTthetaSphi = GetShape()->GetThetaSphi();
251 G4double fTthetaCphi = GetShape()->GetThetaCphi();
259 std::min(-x0-x1-dx1,-x0+x1-dx2),x0-x2-dx3),x0+x2-dx4);
263 std::max(-x0-x1+dx1,-x0+x1+dx2),x0-x2+dx3),x0+x2+dx4);
269 pMin.
set(xmin,ymin,-dz);
270 pMax.
set(xmax,ymax, dz);
274 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
276 std::ostringstream message;
277 message <<
"Bad bounding box (min >= max) for solid: "
279 <<
"\npMin = " << pMin
280 <<
"\npMax = " << pMax;
291 GetShape()->Extent(vmin,vmax);
292 if (std::abs(pMin.
x()-vmin.x()) > tolerance ||
293 std::abs(pMin.
y()-vmin.y()) > tolerance ||
294 std::abs(pMin.
z()-vmin.z()) > tolerance ||
295 std::abs(pMax.
x()-vmax.x()) > tolerance ||
296 std::abs(pMax.
y()-vmax.y()) > tolerance ||
297 std::abs(pMax.
z()-vmax.z()) > tolerance)
299 std::ostringstream message;
300 message <<
"Inconsistency in bounding boxes for solid: "
302 <<
"\nBBox min: wrapper = " << pMin <<
" solid = " << vmin
303 <<
"\nBBox max: wrapper = " << pMax <<
" solid = " << vmax;
315 G4UTrap::CalculateExtent(
const EAxis pAxis,
328 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
330 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
332 return exist = (pMin < pMax) ?
true :
false;
344 G4double fTthetaSphi = GetShape()->GetThetaSphi();
345 G4double fTthetaCphi = GetShape()->GetThetaCphi();
353 baseA[0].set(-x0-x1-dx1,-y0-dy1,-dz);
354 baseA[1].set(-x0-x1+dx1,-y0-dy1,-dz);
355 baseA[2].set(-x0+x1+dx2,-y0+dy1,-dz);
356 baseA[3].set(-x0+x1-dx2,-y0+dy1,-dz);
358 baseB[0].set( x0-x2-dx3, y0-dy2, dz);
359 baseB[1].set( x0-x2+dx3, y0-dy2, dz);
360 baseB[2].set( x0+x2+dx4, y0+dy2, dz);
361 baseB[3].set( x0+x2-dx4, y0+dy2, dz);
363 std::vector<const G4ThreeVectorList *> polygons(2);
364 polygons[0] = &baseA;
365 polygons[1] = &baseB;
368 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
378 G4double fTthetaSphi = GetShape()->GetThetaSphi();
379 G4double fTthetaCphi = GetShape()->GetThetaCphi();
380 G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
381 G4double alpha1 = std::atan(GetTanAlpha1());
382 G4double alpha2 = std::atan(GetTanAlpha2());
383 G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
387 GetXHalfLength1(), GetXHalfLength2(), alpha1,
389 GetXHalfLength3(), GetXHalfLength4(), alpha2);
392 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
G4GLOB_DLL std::ostream G4cout
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments