34#if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
46G4UPara::G4UPara(
const G4String& pName,
49 : Base_t(pName, pDx, pDy, pDz, pAlpha, pTheta, pPhi)
51 fTalpha = std::tan(pAlpha);
52 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
53 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
62G4UPara::G4UPara(
const G4String& pName,
71 SetDimensions(fDx, fDy, fDz);
74 fTalpha = (pt[2].
x() + pt[3].
x() - pt[1].
x() - pt[0].
x())*0.25/fDy;
75 fTthetaCphi = (pt[4].
x() + fDy*fTalpha + fDx)/fDz;
76 fTthetaSphi = (pt[4].
y() + fDy)/fDz;
77 SetAlpha(std::atan(fTalpha));
78 SetTheta(std::atan(std::sqrt(fTthetaSphi*fTthetaSphi
79 + fTthetaCphi*fTthetaCphi)));
80 SetPhi (std::atan2(fTthetaSphi, fTthetaCphi));
87 G4double DzTthetaSphi = fDz*fTthetaSphi;
88 G4double DzTthetaCphi = fDz*fTthetaCphi;
89 v[0].
set(-DzTthetaCphi-DyTalpha-fDx, -DzTthetaSphi-fDy, -fDz);
90 v[1].
set(-DzTthetaCphi-DyTalpha+fDx, -DzTthetaSphi-fDy, -fDz);
91 v[2].
set(-DzTthetaCphi+DyTalpha-fDx, -DzTthetaSphi+fDy, -fDz);
92 v[3].
set(-DzTthetaCphi+DyTalpha+fDx, -DzTthetaSphi+fDy, -fDz);
93 v[4].
set( DzTthetaCphi-DyTalpha-fDx, DzTthetaSphi-fDy, fDz);
94 v[5].
set( DzTthetaCphi-DyTalpha+fDx, DzTthetaSphi-fDy, fDz);
95 v[6].
set( DzTthetaCphi+DyTalpha-fDx, DzTthetaSphi+fDy, fDz);
96 v[7].
set( DzTthetaCphi+DyTalpha+fDx, DzTthetaSphi+fDy, fDz);
100 for (
G4int i=0; i<8; ++i)
102 G4double delx = std::abs(pt[i].x() - v[i].x());
103 G4double dely = std::abs(pt[i].y() - v[i].y());
104 G4double delz = std::abs(pt[i].z() - v[i].z());
105 G4double discrepancy = std::max(std::max(delx,dely),delz);
108 std::ostringstream message;
109 G4long oldprc = message.precision(16);
110 message <<
"Invalid vertice coordinates for Solid: " << GetName()
111 <<
"\nVertix #" << i <<
", discrepancy = " << discrepancy
112 <<
"\n original : " << pt[i]
113 <<
"\n recomputed : " << v[i];
115 G4Exception(
"G4UPara::G4UPara()",
"GeomSolids0002",
127G4UPara::G4UPara( __void__& a )
130 SetAllParameters(1., 1., 1., 0., 0., 0.);
131 fRebuildPolyhedron =
false;
146G4UPara::G4UPara(
const G4UPara& rhs)
147 : Base_t(rhs), fTalpha(rhs.fTalpha),
148 fTthetaCphi(rhs.fTthetaCphi),fTthetaSphi(rhs.fTthetaSphi)
150 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
157G4UPara& G4UPara::operator = (
const G4UPara& rhs)
161 if (
this == &rhs) {
return *
this; }
165 Base_t::operator=(rhs);
169 fTalpha = rhs.fTalpha;
170 fTthetaCphi = rhs.fTthetaCphi;
171 fTthetaSphi = rhs.fTthetaSphi;
172 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
181G4double G4UPara::GetZHalfLength()
const
185G4double G4UPara::GetYHalfLength()
const
189G4double G4UPara::GetXHalfLength()
const
197G4double G4UPara::GetTanAlpha()
const
204 return std::atan2(fTthetaSphi,fTthetaCphi);
209 return std::atan(std::sqrt(fTthetaCphi*fTthetaCphi
210 +fTthetaSphi*fTthetaSphi));
215 return std::atan(fTalpha);
218void G4UPara::SetXHalfLength(
G4double val)
220 SetDimensions(val, GetY(), GetZ());
221 fRebuildPolyhedron =
true;
226void G4UPara::SetYHalfLength(
G4double val)
228 SetDimensions(GetX(), val, GetZ());
229 fRebuildPolyhedron =
true;
234void G4UPara::SetZHalfLength(
G4double val)
236 SetDimensions(GetX(), GetY(), val);
237 fRebuildPolyhedron =
true;
242void G4UPara::SetAlpha(
G4double alpha)
244 Base_t::SetAlpha(alpha);
245 fTalpha = std::tan(alpha);
246 fRebuildPolyhedron =
true;
250void G4UPara::SetTanAlpha(
G4double val)
253 fRebuildPolyhedron =
true;
257void G4UPara::SetThetaAndPhi(
double pTheta,
double pPhi)
259 Base_t::SetThetaAndPhi(pTheta, pPhi);
260 G4double tanTheta = std::tan(pTheta);
261 fTthetaCphi = tanTheta*std::cos(pPhi);
262 fTthetaSphi = tanTheta*std::sin(pPhi);
263 fRebuildPolyhedron =
true;
276 fRebuildPolyhedron =
true;
279 SetDimensions(pDx, pDy, pDz);
280 Base_t::SetAlpha(pAlpha);
281 Base_t::SetThetaAndPhi(pTheta, pPhi);
282 fTalpha = std::tan(pAlpha);
283 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
284 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
294void G4UPara::CheckParameters()
300 std::ostringstream message;
301 message <<
"Invalid (too small or negative) dimensions for Solid: "
303 <<
"\n X - " << GetX()
304 <<
"\n Y - " << GetY()
305 <<
"\n Z - " << GetZ();
306 G4Exception(
"G4UPara::CheckParameters()",
"GeomSolids0002",
315void G4UPara::MakePlanes()
326 fPlanes[0].b = ynorm.
y();
327 fPlanes[0].c = ynorm.
z();
328 fPlanes[0].d = fPlanes[0].b*GetY();
331 fPlanes[1].b = -fPlanes[0].b;
332 fPlanes[1].c = -fPlanes[0].c;
333 fPlanes[1].d = fPlanes[0].d;
339 fPlanes[2].a = xnorm.
x();
340 fPlanes[2].b = xnorm.
y();
341 fPlanes[2].c = xnorm.
z();
342 fPlanes[2].d = fPlanes[2].a*GetZ();
344 fPlanes[3].a = -fPlanes[2].a;
345 fPlanes[3].b = -fPlanes[2].b;
346 fPlanes[3].c = -fPlanes[2].c;
347 fPlanes[3].d = fPlanes[2].d;
377 std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0+x1-dx);
381 std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0+x1+dx);
384 G4double ymin = std::min(-y0-dy,y0-dy);
385 G4double ymax = std::max(-y0+dy,y0+dy);
387 pMin.
set(xmin,ymin,-dz);
388 pMax.
set(xmax,ymax, dz);
392 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
394 std::ostringstream message;
395 message <<
"Bad bounding box (min >= max) for solid: "
397 <<
"\npMin = " << pMin
398 <<
"\npMax = " << pMax;
399 G4Exception(
"G4UPara::BoundingLimits()",
"GeomMgt0001",
419 BoundingLimits(bmin,bmax);
422 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
424 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
426 return exist = (pMin < pMax) ?
true :
false;
440 baseA[0].set(-x0-x1-dx,-y0-dy,-dz);
441 baseA[1].set(-x0-x1+dx,-y0-dy,-dz);
442 baseA[2].set(-x0+x1+dx,-y0+dy,-dz);
443 baseA[3].set(-x0+x1-dx,-y0+dy,-dz);
445 baseB[0].set(+x0-x1-dx, y0-dy, dz);
446 baseB[1].set(+x0-x1+dx, y0-dy, dz);
447 baseB[2].set(+x0+x1+dx, y0+dy, dz);
448 baseB[3].set(+x0+x1-dx, y0+dy, dz);
450 std::vector<const G4ThreeVectorList *> polygons(2);
451 polygons[0] = &baseA;
452 polygons[1] = &baseB;
455 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
465 return new G4UPara(*
this);
475 GetAlpha(), GetTheta(), GetPhi());
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const