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",
126G4UPara::G4UPara(
const G4UPara& rhs)
127 : Base_t(rhs), fTalpha(rhs.fTalpha),
128 fTthetaCphi(rhs.fTthetaCphi),fTthetaSphi(rhs.fTthetaSphi)
130 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
137G4UPara& G4UPara::operator = (
const G4UPara& rhs)
141 if (
this == &rhs) {
return *
this; }
145 Base_t::operator=(rhs);
149 fTalpha = rhs.fTalpha;
150 fTthetaCphi = rhs.fTthetaCphi;
151 fTthetaSphi = rhs.fTthetaSphi;
152 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
161G4double G4UPara::GetZHalfLength()
const
165G4double G4UPara::GetYHalfLength()
const
169G4double G4UPara::GetXHalfLength()
const
177G4double G4UPara::GetTanAlpha()
const
184 return std::atan2(fTthetaSphi,fTthetaCphi);
189 return std::atan(std::sqrt(fTthetaCphi*fTthetaCphi
190 +fTthetaSphi*fTthetaSphi));
195 return std::atan(fTalpha);
198void G4UPara::SetXHalfLength(
G4double val)
200 SetDimensions(val, GetY(), GetZ());
201 fRebuildPolyhedron =
true;
206void G4UPara::SetYHalfLength(
G4double val)
208 SetDimensions(GetX(), val, GetZ());
209 fRebuildPolyhedron =
true;
214void G4UPara::SetZHalfLength(
G4double val)
216 SetDimensions(GetX(), GetY(), val);
217 fRebuildPolyhedron =
true;
222void G4UPara::SetAlpha(
G4double alpha)
224 Base_t::SetAlpha(alpha);
225 fTalpha = std::tan(alpha);
226 fRebuildPolyhedron =
true;
230void G4UPara::SetTanAlpha(
G4double val)
233 fRebuildPolyhedron =
true;
237void G4UPara::SetThetaAndPhi(
double pTheta,
double pPhi)
239 Base_t::SetThetaAndPhi(pTheta, pPhi);
240 G4double tanTheta = std::tan(pTheta);
241 fTthetaCphi = tanTheta*std::cos(pPhi);
242 fTthetaSphi = tanTheta*std::sin(pPhi);
243 fRebuildPolyhedron =
true;
256 fRebuildPolyhedron =
true;
259 SetDimensions(pDx, pDy, pDz);
260 Base_t::SetAlpha(pAlpha);
261 Base_t::SetThetaAndPhi(pTheta, pPhi);
262 fTalpha = std::tan(pAlpha);
263 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
264 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
274void G4UPara::CheckParameters()
280 std::ostringstream message;
281 message <<
"Invalid (too small or negative) dimensions for Solid: "
283 <<
"\n X - " << GetX()
284 <<
"\n Y - " << GetY()
285 <<
"\n Z - " << GetZ();
286 G4Exception(
"G4UPara::CheckParameters()",
"GeomSolids0002",
295void G4UPara::MakePlanes()
306 fPlanes[0].b = ynorm.
y();
307 fPlanes[0].c = ynorm.
z();
308 fPlanes[0].d = fPlanes[0].b*GetY();
311 fPlanes[1].b = -fPlanes[0].b;
312 fPlanes[1].c = -fPlanes[0].c;
313 fPlanes[1].d = fPlanes[0].d;
319 fPlanes[2].a = xnorm.
x();
320 fPlanes[2].b = xnorm.
y();
321 fPlanes[2].c = xnorm.
z();
322 fPlanes[2].d = fPlanes[2].a*GetZ();
324 fPlanes[3].a = -fPlanes[2].a;
325 fPlanes[3].b = -fPlanes[2].b;
326 fPlanes[3].c = -fPlanes[2].c;
327 fPlanes[3].d = fPlanes[2].d;
357 std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0+x1-dx);
361 std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0+x1+dx);
364 G4double ymin = std::min(-y0-dy,y0-dy);
365 G4double ymax = std::max(-y0+dy,y0+dy);
367 pMin.
set(xmin,ymin,-dz);
368 pMax.
set(xmax,ymax, dz);
372 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
374 std::ostringstream message;
375 message <<
"Bad bounding box (min >= max) for solid: "
377 <<
"\npMin = " << pMin
378 <<
"\npMax = " << pMax;
379 G4Exception(
"G4UPara::BoundingLimits()",
"GeomMgt0001",
399 BoundingLimits(bmin,bmax);
402 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
404 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
406 return exist = pMin < pMax;
420 baseA[0].set(-x0-x1-dx,-y0-dy,-dz);
421 baseA[1].set(-x0-x1+dx,-y0-dy,-dz);
422 baseA[2].set(-x0+x1+dx,-y0+dy,-dz);
423 baseA[3].set(-x0+x1-dx,-y0+dy,-dz);
425 baseB[0].set(+x0-x1-dx, y0-dy, dz);
426 baseB[1].set(+x0-x1+dx, y0-dy, dz);
427 baseB[2].set(+x0+x1+dx, y0+dy, dz);
428 baseB[3].set(+x0+x1-dx, y0+dy, dz);
430 std::vector<const G4ThreeVectorList *> polygons(2);
431 polygons[0] = &baseA;
432 polygons[1] = &baseB;
435 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
445 return new G4UPara(*
this);
455 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)
G4BoundingEnvelope is a helper class to facilitate calculation of the extent of a solid within the li...
G4Para represents a parallelepiped, essentially a box with half lengths dx,dy,dz 'skewed' so that the...
G4VPVParameterisation ia an abstract base class for Parameterisation, able to compute the transformat...
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4VPhysicalVolume is an abstract base class for the representation of a positioned volume....
G4VSolid is an abstract base class for solids, physical shapes that can be tracked through....
G4VoxelLimits represents limitation/restrictions of space, where restrictions are only made perpendic...