36 #if ( defined(G4GEOM_USE_USOLIDS) || defined(G4GEOM_USE_PARTIAL_USOLIDS) )
42 using namespace CLHEP;
48 G4UPara::G4UPara(
const G4String& pName,
51 : Base_t(pName, pDx, pDy, pDz, pAlpha, pTheta, pPhi)
53 fTalpha = std::tan(pAlpha);
54 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
55 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
64 G4UPara::G4UPara(
const G4String& pName,
73 SetDimensions(fDx, fDy, fDz);
76 fTalpha = (pt[2].
x() + pt[3].
x() - pt[1].
x() - pt[0].
x())*0.25/fDy;
77 fTthetaCphi = (pt[4].
x() + fDy*fTalpha + fDx)/fDz;
78 fTthetaSphi = (pt[4].
y() + fDy)/fDz;
79 SetAlpha(std::atan(fTalpha));
80 SetTheta(std::atan(std::sqrt(fTthetaSphi*fTthetaSphi
81 + fTthetaCphi*fTthetaCphi)));
82 SetPhi (std::atan2(fTthetaSphi, fTthetaCphi));
89 G4double DzTthetaSphi = fDz*fTthetaSphi;
90 G4double DzTthetaCphi = fDz*fTthetaCphi;
91 v[0].
set(-DzTthetaCphi-DyTalpha-fDx, -DzTthetaSphi-fDy, -fDz);
92 v[1].
set(-DzTthetaCphi-DyTalpha+fDx, -DzTthetaSphi-fDy, -fDz);
93 v[2].
set(-DzTthetaCphi+DyTalpha-fDx, -DzTthetaSphi+fDy, -fDz);
94 v[3].
set(-DzTthetaCphi+DyTalpha+fDx, -DzTthetaSphi+fDy, -fDz);
95 v[4].
set( DzTthetaCphi-DyTalpha-fDx, DzTthetaSphi-fDy, fDz);
96 v[5].
set( DzTthetaCphi-DyTalpha+fDx, DzTthetaSphi-fDy, fDz);
97 v[6].
set( DzTthetaCphi+DyTalpha-fDx, DzTthetaSphi+fDy, fDz);
98 v[7].
set( DzTthetaCphi+DyTalpha+fDx, DzTthetaSphi+fDy, fDz);
102 for (
G4int i=0; i<8; ++i)
104 G4double delx = std::abs(pt[i].
x() - v[i].
x());
105 G4double dely = std::abs(pt[i].
y() - v[i].
y());
106 G4double delz = std::abs(pt[i].
z() - v[i].
z());
111 G4int oldprc = message.precision(16);
112 message <<
"Invalid vertice coordinates for Solid: " << GetName()
113 <<
"\nVertix #" << i <<
", discrepancy = " << discrepancy
114 <<
"\n original : " << pt[i]
115 <<
"\n recomputed : " << v[i];
117 G4Exception(
"G4UPara::G4UPara()",
"GeomSolids0002",
129 G4UPara::G4UPara( __void__&
a )
132 SetAllParameters(1., 1., 1., 0., 0., 0.);
133 fRebuildPolyhedron =
false;
148 G4UPara::G4UPara(
const G4UPara& rhs)
149 : Base_t(rhs), fTalpha(rhs.fTalpha),
150 fTthetaCphi(rhs.fTthetaCphi),fTthetaSphi(rhs.fTthetaSphi)
152 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
159 G4UPara& G4UPara::operator = (
const G4UPara& rhs)
163 if (
this == &rhs) {
return *
this; }
167 Base_t::operator=(rhs);
171 fTalpha = rhs.fTalpha;
172 fTthetaCphi = rhs.fTthetaCphi;
173 fTthetaSphi = rhs.fTthetaSphi;
174 for (
G4int i=0; i<4; ++i) { fPlanes[i] = rhs.fPlanes[i]; }
183 G4double G4UPara::GetZHalfLength()
const
187 G4double G4UPara::GetYHalfLength()
const
191 G4double G4UPara::GetXHalfLength()
const
199 G4double G4UPara::GetTanAlpha()
const
204 void G4UPara::SetXHalfLength(
G4double val)
206 SetDimensions(val, GetY(), GetZ());
207 fRebuildPolyhedron =
true;
212 void G4UPara::SetYHalfLength(
G4double val)
214 SetDimensions(GetX(), val, GetZ());
215 fRebuildPolyhedron =
true;
220 void G4UPara::SetZHalfLength(
G4double val)
222 SetDimensions(GetX(), GetY(), val);
223 fRebuildPolyhedron =
true;
230 Base_t::SetAlpha(alpha);
231 fTalpha = std::tan(alpha);
232 fRebuildPolyhedron =
true;
236 void G4UPara::SetTanAlpha(
G4double val)
239 fRebuildPolyhedron =
true;
243 void G4UPara::SetThetaAndPhi(
double pTheta,
double pPhi)
245 Base_t::SetThetaAndPhi(pTheta, pPhi);
246 G4double tanTheta = std::tan(pTheta);
247 fTthetaCphi = tanTheta*std::cos(pPhi);
248 fTthetaSphi = tanTheta*std::sin(pPhi);
249 fRebuildPolyhedron =
true;
262 fRebuildPolyhedron =
true;
265 SetDimensions(pDx, pDy, pDz);
266 Base_t::SetAlpha(pAlpha);
267 Base_t::SetThetaAndPhi(pTheta, pPhi);
268 fTalpha = std::tan(pAlpha);
269 fTthetaCphi = std::tan(pTheta)*std::cos(pPhi);
270 fTthetaSphi = std::tan(pTheta)*std::sin(pPhi);
280 void G4UPara::CheckParameters()
287 message <<
"Invalid (too small or negative) dimensions for Solid: "
289 <<
"\n X - " << GetX()
290 <<
"\n Y - " << GetY()
291 <<
"\n Z - " << GetZ();
292 G4Exception(
"G4UPara::CheckParameters()",
"GeomSolids0002",
301 void G4UPara::MakePlanes()
312 fPlanes[0].b = ynorm.
y();
313 fPlanes[0].c = ynorm.
z();
314 fPlanes[0].d = fPlanes[0].b*GetY();
317 fPlanes[1].b = -fPlanes[0].b;
318 fPlanes[1].c = -fPlanes[0].c;
319 fPlanes[1].d = fPlanes[0].d;
325 fPlanes[2].a = xnorm.
x();
326 fPlanes[2].b = xnorm.
y();
327 fPlanes[2].c = xnorm.
z();
328 fPlanes[2].d = fPlanes[2].a*GetZ();
330 fPlanes[3].a = -fPlanes[2].a;
331 fPlanes[3].b = -fPlanes[2].b;
332 fPlanes[3].c = -fPlanes[2].c;
333 fPlanes[3].d = fPlanes[2].d;
363 std::min(-x0-x1-dx,-x0+x1-dx),x0-x1-dx),x0+x1-dx);
367 std::max(-x0-x1+dx,-x0+x1+dx),x0-x1+dx),x0+x1+dx);
373 pMin.
set(xmin,ymin,-dz);
374 pMax.
set(xmax,ymax, dz);
378 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
381 message <<
"Bad bounding box (min >= max) for solid: "
383 <<
"\npMin = " << pMin
384 <<
"\npMax = " << pMax;
385 G4Exception(
"G4UPara::BoundingLimits()",
"GeomMgt0001",
395 G4bool G4UPara::CalculateExtent(
const EAxis pAxis,
405 BoundingLimits(bmin,bmax);
408 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
410 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
412 return exist = (pMin < pMax) ?
true :
false;
426 baseA[0].set(-x0-x1-dx,-y0-dy,-dz);
427 baseA[1].set(-x0-x1+dx,-y0-dy,-dz);
428 baseA[2].set(-x0+x1+dx,-y0+dy,-dz);
429 baseA[3].set(-x0+x1-dx,-y0+dy,-dz);
431 baseB[0].set(+x0-x1-dx, y0-dy, dz);
432 baseB[1].set(+x0-x1+dx, y0-dy, dz);
433 baseB[2].set(+x0+x1+dx, y0+dy, dz);
434 baseB[3].set(+x0+x1-dx, y0+dy, dz);
436 std::vector<const G4ThreeVectorList *> polygons(2);
437 polygons[0] = &baseA;
438 polygons[1] = &baseB;
441 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
451 return new G4UPara(*
this);
461 GetAlpha(), GetTheta(), GetPhi());
464 #endif // G4GEOM_USE_USOLIDS
void set(double x, double y, double z)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
Float_t x1[n_points_granero]
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
void message(RunManager *runmanager)
const G4double kCarTolerance
std::vector< G4ThreeVector > G4ThreeVectorList
static const G4double alpha
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
T min(const T t1, const T t2)
brief Return the smallest of the two arguments