47 #if !defined(G4GEOM_USE_UTRD)
58 using namespace CLHEP;
81 if ( pdx1>0&&pdx2>0&&pdy1>0&&pdy2>0&&pdz>0 )
89 if ( pdx1>=0 && pdx2>=0 && pdy1>=0 && pdy2>=0 && pdz>=0 )
103 std::ostringstream message;
104 message <<
"Invalid negative dimensions for Solid: " <<
GetName()
106 <<
" X - " << pdx1 <<
", " << pdx2 <<
G4endl
107 <<
" Y - " << pdy1 <<
", " << pdy2 <<
G4endl
124 :
G4CSGSolid(a), fDx1(0.), fDx2(0.), fDy1(0.), fDy2(0.), fDz(0.)
141 :
G4CSGSolid(rhs), fDx1(rhs.fDx1), fDx2(rhs.fDx2),
142 fDy1(rhs.fDy1), fDy2(rhs.fDy2), fDz(rhs.fDz)
154 if (
this == &rhs) {
return *
this; }
206 pMin.set(-xmax,-ymax,-dz);
207 pMax.set( xmax, ymax, dz);
211 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
213 std::ostringstream message;
214 message <<
"Bad bounding box (min >= max) for solid: "
216 <<
"\npMin = " << pMin
217 <<
"\npMax = " << pMax;
240 if (
true)
return bbox.
CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
244 return exist = (pMin < pMax) ?
true :
false;
256 baseA[0].set(-dx1,-dy1,-dz);
257 baseA[1].set( dx1,-dy1,-dz);
258 baseA[2].set( dx1, dy1,-dz);
259 baseA[3].set(-dx1, dy1,-dz);
260 baseB[0].set(-dx2,-dy2, dz);
261 baseB[1].set( dx2,-dy2, dz);
262 baseB[2].set( dx2, dy2, dz);
263 baseB[3].set(-dx2, dy2, dz);
265 std::vector<const G4ThreeVectorList *> polygons(2);
266 polygons[0] = &baseA;
267 polygons[1] = &baseB;
291 if (std::fabs(p.x())<=x)
294 if (std::fabs(p.y())<=y)
308 if (std::fabs(p.y())<=y)
324 if (std::fabs(p.x())<=x)
329 if (std::fabs(p.y())<=y) in=
kSurface;
344 G4int noSurfaces = 0;
351 secx = std::sqrt(1.0+tanx*tanx);
352 newpx = std::fabs(p.x())-p.z()*tanx;
356 secy = std::sqrt(1.0+tany*tany);
357 newpy = std::fabs(p.y())-p.z()*tany;
360 distx = std::fabs(newpx-widx)/secx;
361 disty = std::fabs(newpy-widy)/secy;
362 distz = std::fabs(std::fabs(p.z())-
fDz);
376 if ( p.x() >= 0.) sumnorm += nX;
382 if ( p.y() >= 0.) sumnorm += nY;
388 if ( p.z() >= 0.) sumnorm += nZ;
391 if ( noSurfaces == 0 )
395 "Point p is not on surface !?" );
399 else if ( noSurfaces == 1 ) norm = sumnorm;
400 else norm = sumnorm.unit();
420 secx=std::sqrt(1.0+tanx*tanx);
421 newpx=std::fabs(p.x())-p.z()*tanx;
425 secy=std::sqrt(1.0+tany*tany);
426 newpy=std::fabs(p.y())-p.z()*tany;
429 distx=std::fabs(newpx-widx)/secx;
430 disty=std::fabs(newpy-widy)/secy;
431 distz=std::fabs(std::fabs(p.z())-
fDz);
509 G4double ss1,ss2,sn1=0.,sn2=0.,Dist;
520 smin = -(
fDz + p.z())/v.z() ;
531 smin = (
fDz - p.z())/v.z() ;
535 if (smin < 0 ) smin = 0 ;
539 if (std::fabs(p.z()) >=
fDz )
return snxt ;
552 s1 = 0.5*(
fDx1+
fDx2) + tanxz*p.z() ;
553 ds1 = v.x() - tanxz*v.z() ;
554 ds2 = v.x() + tanxz*v.z() ;
560 if (ss1 < 0 && ss2 <= 0 )
566 if ( ds2 < 0 ) sn2 = ss2/ds2 ;
571 else if ( ss1 >= 0 && ss2 > 0 )
577 if (ds1 > 0) sn2 = ss1/ds1 ;
583 else if (ss1 >= 0 && ss2 <= 0 )
603 if ( Dist < sn2 ) sn2 = Dist ;
608 else if (ss1 < 0 && ss2 > 0 )
612 if ( ds1 >= 0 || ds2 <= 0 )
620 if (Dist > sn1 ) sn1 = Dist ;
627 if ( sn1 > smin ) smin = sn1 ;
628 if ( sn2 < smax ) smax = sn2 ;
633 if ( smax < smin )
return snxt ;
639 s2 = 0.5*(
fDy1+
fDy2) + tanyz*p.z() ;
640 ds1 = v.y() - tanyz*v.z() ;
641 ds2 = v.y() + tanyz*v.z() ;
645 if ( ss1 < 0 && ss2 <= 0 )
650 if ( ds2 < 0 ) sn2 = ss2/ds2 ;
655 else if ( ss1 >= 0 && ss2 > 0 )
660 if ( ds1 > 0 ) sn2 = ss1/ds1 ;
665 else if (ss1 >= 0 && ss2 <= 0 )
685 if (Dist < sn2) sn2=Dist;
690 else if (ss1 < 0 && ss2 > 0 )
694 if (ds1 >= 0 || ds2 <= 0 )
702 if (Dist > sn1 ) sn1 = Dist ;
709 if ( sn1 > smin) smin = sn1 ;
710 if ( sn2 < smax) smax = sn2 ;
715 if ( smax > smin ) snxt = smin ;
736 safe=std::fabs(p.z())-
fDz;
747 distx=std::fabs(p.x())-(
fDx1+tanxz*zbase);
750 safx=distx/std::sqrt(1.0+tanxz*tanxz);
751 if (safx>safe) safe=safx;
758 disty=std::fabs(p.y())-(
fDy1+tanyz*zbase);
761 safy=disty/std::sqrt(1.0+tanyz*tanyz);
762 if (safy>safe) safe=safy;
784 G4double central,ss1,ss2,ds1,ds2,sn=0.,sn2=0.;
785 G4double tanxz=0.,cosxz=0.,tanyz=0.,cosyz=0.;
787 if (calcNorm) *validNorm=
true;
837 ss1=central+tanxz*p.z()-p.x();
839 ds1=v.x()-tanxz*v.z();
843 ss2=-tanxz*p.z()-p.x()-central;
845 ds2=tanxz*v.z()+v.x();
863 else if (ds1>0&&ds2>=0)
876 else if (ds1>0&&ds2<0)
914 else if (ss1<=0&&ss2<0)
941 else if (ss1>0&&ss2>=0)
985 ss1=central+tanyz*p.z()-p.y();
987 ds1=v.y()-tanyz*v.z();
991 ss2=-tanyz*p.z()-p.y()-central;
993 ds2=tanyz*v.z()+v.y();
1012 else if (ds1>0&&ds2>=0)
1025 else if (ds1>0&&ds2<0)
1063 else if (ss1<=0&&ss2<0)
1090 else if (ss1>0&&ss2>=0)
1131 cosxz=1.0/std::sqrt(1.0+tanxz*tanxz);
1135 cosxz=-1.0/std::sqrt(1.0+tanxz*tanxz);
1139 cosyz=1.0/std::sqrt(1.0+tanyz*tanyz);
1143 cosyz=-1.0/std::sqrt(1.0+tanyz*tanyz);
1156 "Undefined side for valid surface normal to solid.");
1185 G4cout.precision(oldprc) ;
1187 "Point p is outside !?" );
1191 safe=
fDz-std::fabs(p.z());
1199 xdist=
fDx1+tanxz*zbase-std::fabs(p.x());
1200 saf1=xdist/std::sqrt(1.0+tanxz*tanxz);
1204 ydist=
fDy1+tanyz*zbase-std::fabs(p.y());
1205 saf2=ydist/std::sqrt(1.0+tanyz*tanyz);
1209 if (safe>saf1) safe=saf1;
1210 if (safe>saf2) safe=saf2;
1231 return new G4Trd(*
this);
1240 G4int oldprc = os.precision(16);
1241 os <<
"-----------------------------------------------------------\n"
1242 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1243 <<
" ===================================================\n"
1244 <<
" Solid type: G4Trd\n"
1245 <<
" Parameters: \n"
1246 <<
" half length X, surface -dZ: " <<
fDx1/
mm <<
" mm \n"
1247 <<
" half length X, surface +dZ: " <<
fDx2/
mm <<
" mm \n"
1248 <<
" half length Y, surface -dZ: " <<
fDy1/
mm <<
" mm \n"
1249 <<
" half length Y, surface +dZ: " <<
fDy2/
mm <<
" mm \n"
1250 <<
" half length Z : " <<
fDz/
mm <<
" mm \n"
1251 <<
"-----------------------------------------------------------\n";
1252 os.precision(oldprc);
1267 G4double px, py, pz, tgX, tgY, secX, secY, select, sumS, tmp;
1268 G4double Sxy1, Sxy2, Sxy, Sxz, Syz;
1271 secX = std::sqrt(1+tgX*tgX);
1273 secY = std::sqrt(1+tgY*tgY);
1282 sumS = Sxy + Sxz + Syz;
1301 else if ( ( select - Sxy ) < Sxz )
1306 tmp = fDy1 + (pz +
fDz)*tgY;
1314 tmp = fDy1 + (pz +
fDz)*tgY;
void DescribeYourselfTo(G4VGraphicsScene &scene) const
void SetAllParameters(G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
static constexpr double mm
static const G4double kInfinity
G4double GetYHalfLength1() const
CLHEP::Hep3Vector G4ThreeVector
G4bool fRebuildPolyhedron
std::vector< ExP01TrackerHit * > a
std::ostream & StreamInfo(std::ostream &os) const
G4GeometryType GetEntityType() const
G4double fcos(G4double arg)
G4double GetZHalfLength() const
virtual void AddSolid(const G4Box &)=0
G4ThreeVector GetPointOnSurface() const
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
G4double GetXHalfLength2() const
G4GLOB_DLL std::ostream G4cout
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4Polyhedron * CreatePolyhedron() const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
EInside Inside(const G4ThreeVector &p) const
G4double GetYHalfLength2() const
std::vector< G4ThreeVector > G4ThreeVectorList
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
void CheckAndSetAllParameters(G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
G4Trd & operator=(const G4Trd &rhs)
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double GetXHalfLength1() const
G4Trd(const G4String &pName, G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
G4CSGSolid & operator=(const G4CSGSolid &rhs)