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 G4int 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
202void G4UPara::SetXHalfLength(
G4double val)
204 SetDimensions(val, GetY(), GetZ());
205 fRebuildPolyhedron =
true;
210void G4UPara::SetYHalfLength(
G4double val)
212 SetDimensions(GetX(), val, GetZ());
213 fRebuildPolyhedron =
true;
218void G4UPara::SetZHalfLength(
G4double val)
220 SetDimensions(GetX(), GetY(), val);
221 fRebuildPolyhedron =
true;
226void G4UPara::SetAlpha(
G4double alpha)
228 Base_t::SetAlpha(alpha);
229 fTalpha = std::tan(alpha);
230 fRebuildPolyhedron =
true;
234void G4UPara::SetTanAlpha(
G4double val)
237 fRebuildPolyhedron =
true;
241void G4UPara::SetThetaAndPhi(
double pTheta,
double pPhi)
243 Base_t::SetThetaAndPhi(pTheta, pPhi);
244 G4double tanTheta = std::tan(pTheta);
245 fTthetaCphi = tanTheta*std::cos(pPhi);
246 fTthetaSphi = tanTheta*std::sin(pPhi);
247 fRebuildPolyhedron =
true;
260 fRebuildPolyhedron =
true;
263 SetDimensions(pDx, pDy, pDz);
264 Base_t::SetAlpha(pAlpha);
265 Base_t::SetThetaAndPhi(pTheta, pPhi);
266 fTalpha = std::tan(pAlpha);
267 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
268 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
278void G4UPara::CheckParameters()
284 std::ostringstream message;
285 message <<
"Invalid (too small or negative) dimensions for Solid: "
287 <<
"\n X - " << GetX()
288 <<
"\n Y - " << GetY()
289 <<
"\n Z - " << GetZ();
290 G4Exception(
"G4UPara::CheckParameters()",
"GeomSolids0002",
299void G4UPara::MakePlanes()
310 fPlanes[0].b = ynorm.
y();
311 fPlanes[0].c = ynorm.
z();
312 fPlanes[0].d = fPlanes[0].b*GetY();
315 fPlanes[1].b = -fPlanes[0].b;
316 fPlanes[1].c = -fPlanes[0].c;
317 fPlanes[1].d = fPlanes[0].d;
323 fPlanes[2].a = xnorm.
x();
324 fPlanes[2].b = xnorm.
y();
325 fPlanes[2].c = xnorm.
z();
326 fPlanes[2].d = fPlanes[2].a*GetZ();
328 fPlanes[3].a = -fPlanes[2].a;
329 fPlanes[3].b = -fPlanes[2].b;
330 fPlanes[3].c = -fPlanes[2].c;
331 fPlanes[3].d = fPlanes[2].d;
361 std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0+x1-dx);
365 std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0+x1+dx);
368 G4double ymin = std::min(-y0-dy,y0-dy);
369 G4double ymax = std::max(-y0+dy,y0+dy);
371 pMin.
set(xmin,ymin,-dz);
372 pMax.
set(xmax,ymax, dz);
376 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
378 std::ostringstream message;
379 message <<
"Bad bounding box (min >= max) for solid: "
381 <<
"\npMin = " << pMin
382 <<
"\npMax = " << pMax;
383 G4Exception(
"G4UPara::BoundingLimits()",
"GeomMgt0001",
403 BoundingLimits(bmin,bmax);
406 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
408 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
410 return exist = (pMin < pMax) ?
true :
false;
424 baseA[0].set(-x0-x1-dx,-y0-dy,-dz);
425 baseA[1].set(-x0-x1+dx,-y0-dy,-dz);
426 baseA[2].set(-x0+x1+dx,-y0+dy,-dz);
427 baseA[3].set(-x0+x1-dx,-y0+dy,-dz);
429 baseB[0].set(+x0-x1-dx, y0-dy, dz);
430 baseB[1].set(+x0-x1+dx, y0-dy, dz);
431 baseB[2].set(+x0+x1+dx, y0+dy, dz);
432 baseB[3].set(+x0+x1-dx, y0+dy, dz);
434 std::vector<const G4ThreeVectorList *> polygons(2);
435 polygons[0] = &baseA;
436 polygons[1] = &baseB;
439 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
449 return new G4UPara(*
this);
459 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