34 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
40 using namespace CLHEP;
46 G4UPara::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);
62 G4UPara::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)
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",
127 G4UPara::G4UPara( __void__&
a )
130 SetAllParameters(1., 1., 1., 0., 0., 0.);
146 G4UPara::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]; }
157 G4UPara& 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]; }
181 G4double G4UPara::GetZHalfLength()
const
185 G4double G4UPara::GetYHalfLength()
const
189 G4double G4UPara::GetXHalfLength()
const
197 G4double G4UPara::GetTanAlpha()
const
202 void G4UPara::SetXHalfLength(
G4double val)
204 SetDimensions(val, GetY(), GetZ());
205 fRebuildPolyhedron =
true;
210 void G4UPara::SetYHalfLength(
G4double val)
212 SetDimensions(GetX(), val, GetZ());
213 fRebuildPolyhedron =
true;
218 void G4UPara::SetZHalfLength(
G4double val)
220 SetDimensions(GetX(), GetY(), val);
221 fRebuildPolyhedron =
true;
228 Base_t::SetAlpha(alpha);
229 fTalpha = std::tan(alpha);
230 fRebuildPolyhedron =
true;
234 void G4UPara::SetTanAlpha(
G4double val)
237 fRebuildPolyhedron =
true;
241 void 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);
278 void G4UPara::CheckParameters()
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",
299 void 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);
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())
379 message <<
"Bad bounding box (min >= max) for solid: "
381 <<
"\npMin = " << pMin
382 <<
"\npMax = " <<
pMax;
383 G4Exception(
"G4UPara::BoundingLimits()",
"GeomMgt0001",
393 G4bool G4UPara::CalculateExtent(
const EAxis pAxis,
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());
462 #endif // G4GEOM_USE_USOLIDS