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,
68 G4double fDx = (pt[3].
x() - pt[2].x())*0.5;
69 G4double fDy = (pt[2].
y() - pt[1].y())*0.5;
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;
138G4UPara::~G4UPara() =
default;
144G4UPara::G4UPara(
const G4UPara& rhs)
145 : Base_t(rhs), fTalpha(rhs.fTalpha),
146 fTthetaCphi(rhs.fTthetaCphi),fTthetaSphi(rhs.fTthetaSphi)
148 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
155G4UPara& G4UPara::operator = (
const G4UPara& rhs)
159 if (
this == &rhs) {
return *
this; }
163 Base_t::operator=(rhs);
167 fTalpha = rhs.fTalpha;
168 fTthetaCphi = rhs.fTthetaCphi;
169 fTthetaSphi = rhs.fTthetaSphi;
170 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
179G4double G4UPara::GetZHalfLength()
const
183G4double G4UPara::GetYHalfLength()
const
187G4double G4UPara::GetXHalfLength()
const
195G4double G4UPara::GetTanAlpha()
const
202 return std::atan2(fTthetaSphi,fTthetaCphi);
207 return std::atan(std::sqrt(fTthetaCphi*fTthetaCphi
208 +fTthetaSphi*fTthetaSphi));
213 return std::atan(fTalpha);
216void G4UPara::SetXHalfLength(
G4double val)
218 SetDimensions(val, GetY(), GetZ());
219 fRebuildPolyhedron =
true;
224void G4UPara::SetYHalfLength(
G4double val)
226 SetDimensions(GetX(), val, GetZ());
227 fRebuildPolyhedron =
true;
232void G4UPara::SetZHalfLength(
G4double val)
234 SetDimensions(GetX(), GetY(), val);
235 fRebuildPolyhedron =
true;
240void G4UPara::SetAlpha(
G4double alpha)
242 Base_t::SetAlpha(alpha);
243 fTalpha = std::tan(alpha);
244 fRebuildPolyhedron =
true;
248void G4UPara::SetTanAlpha(
G4double val)
251 fRebuildPolyhedron =
true;
255void G4UPara::SetThetaAndPhi(
double pTheta,
double pPhi)
257 Base_t::SetThetaAndPhi(pTheta, pPhi);
258 G4double tanTheta = std::tan(pTheta);
259 fTthetaCphi = tanTheta*std::cos(pPhi);
260 fTthetaSphi = tanTheta*std::sin(pPhi);
261 fRebuildPolyhedron =
true;
274 fRebuildPolyhedron =
true;
277 SetDimensions(pDx, pDy, pDz);
278 Base_t::SetAlpha(pAlpha);
279 Base_t::SetThetaAndPhi(pTheta, pPhi);
280 fTalpha = std::tan(pAlpha);
281 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
282 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
292void G4UPara::CheckParameters()
298 std::ostringstream message;
299 message <<
"Invalid (too small or negative) dimensions for Solid: "
301 <<
"\n X - " << GetX()
302 <<
"\n Y - " << GetY()
303 <<
"\n Z - " << GetZ();
304 G4Exception(
"G4UPara::CheckParameters()",
"GeomSolids0002",
313void G4UPara::MakePlanes()
324 fPlanes[0].b = ynorm.
y();
325 fPlanes[0].c = ynorm.
z();
326 fPlanes[0].d = fPlanes[0].b*GetY();
329 fPlanes[1].b = -fPlanes[0].b;
330 fPlanes[1].c = -fPlanes[0].c;
331 fPlanes[1].d = fPlanes[0].d;
337 fPlanes[2].a = xnorm.
x();
338 fPlanes[2].b = xnorm.
y();
339 fPlanes[2].c = xnorm.
z();
340 fPlanes[2].d = fPlanes[2].a*GetZ();
342 fPlanes[3].a = -fPlanes[2].a;
343 fPlanes[3].b = -fPlanes[2].b;
344 fPlanes[3].c = -fPlanes[2].c;
345 fPlanes[3].d = fPlanes[2].d;
375 std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0+x1-dx);
379 std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0+x1+dx);
382 G4double ymin = std::min(-y0-dy,y0-dy);
383 G4double ymax = std::max(-y0+dy,y0+dy);
385 pMin.
set(xmin,ymin,-dz);
386 pMax.
set(xmax,ymax, dz);
390 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
392 std::ostringstream message;
393 message <<
"Bad bounding box (min >= max) for solid: "
395 <<
"\npMin = " << pMin
396 <<
"\npMax = " << pMax;
397 G4Exception(
"G4UPara::BoundingLimits()",
"GeomMgt0001",
417 BoundingLimits(bmin,bmax);
420 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
422 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
424 return exist = pMin < pMax;
438 baseA[0].set(-x0-x1-dx,-y0-dy,-dz);
439 baseA[1].set(-x0-x1+dx,-y0-dy,-dz);
440 baseA[2].set(-x0+x1+dx,-y0+dy,-dz);
441 baseA[3].set(-x0+x1-dx,-y0+dy,-dz);
443 baseB[0].set(+x0-x1-dx, y0-dy, dz);
444 baseB[1].set(+x0-x1+dx, y0-dy, dz);
445 baseB[2].set(+x0+x1+dx, y0+dy, dz);
446 baseB[3].set(+x0+x1-dx, y0+dy, dz);
448 std::vector<const G4ThreeVectorList *> polygons(2);
449 polygons[0] = &baseA;
450 polygons[1] = &baseB;
453 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
463 return new G4UPara(*
this);
473 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