50#define G4MT_pcphix ((subInstanceManager.offset[instanceID]).fPhix)
51#define G4MT_pcphiy ((subInstanceManager.offset[instanceID]).fPhiy)
52#define G4MT_pcphiz ((subInstanceManager.offset[instanceID]).fPhiz)
53#define G4MT_pcphik ((subInstanceManager.offset[instanceID]).fPhik)
59 return subInstanceManager;
84 r[0] = tail->
r;
z[0] = tail->
z;
85 r[1] = head->
r;
z[1] = head->
z;
170 : startPhi(0.), deltaPhi(0.),
171 rNorm(0.), zNorm(0.), rS(0.), zS(0.), length(0.),
172 prevRS(0.), prevZS(0.), nextRS(0.), nextZS(0.),
202 if (
this == &source) {
return *
this; }
226 kCarTolerance = source.kCarTolerance;
227 fSurfaceArea = source.fSurfaceArea;
270 G4double normSign = outgoing ? +1 : -1;
278 if (nside == 0)
return false;
290 if (normSign*v.
dot(normal) > 0)
307 if (normSign*v.
dot(pNormal) > 0)
313 distFromSurface = -normSign*
DistanceAway( p,
false, distOutside2 );
314 if (distOutside2 < surfTolerance*surfTolerance)
316 if (distFromSurface > -surfTolerance)
328 distFromSurface = s1;
341 if (nside==1)
return false;
353 if (normSign*v.
dot(normal) > 0)
358 if (normSign*v.
dot(pNormal) > 0)
361 distFromSurface = -normSign*
DistanceAway( p,
false, distOutside2 );
362 if (distOutside2 < surfTolerance*surfTolerance)
364 if (distFromSurface > -surfTolerance)
372 distFromSurface = s2;
392 G4double normSign = outgoing ? -1 : +1;
399 if (distFrom > -0.5*kCarTolerance )
405 return std::sqrt( distFrom*distFrom + distOut2 );
407 return std::fabs(distFrom);
414 if (distFrom > -0.5*kCarTolerance)
418 return std::sqrt( distFrom*distFrom + distOut2 );
420 return std::fabs(distFrom);
436 dist2 = distFrom*distFrom + distOut2;
438 *bestDistance = std::sqrt( dist2);
442 if ( (std::fabs(edgeRZnorm) < tolerance)
443 && (distOut2< tolerance*tolerance) )
445 else if (edgeRZnorm < 0)
462 *bestDistance = std::sqrt( dFrom*dFrom + dOut2 );
508 if (bd > ad) ad = bd;
509 if (cd > ad) ad = cd;
510 if (dd > ad) ad = dd;
563 G4double rFudge = 1.0/std::cos(0.5*sigPhi);
693 cosPhi = std::cos(phi),
694 sinPhi = std::sin(phi);
697 v1( r1*cosPhi, r1*sinPhi, z1 ),
712 cosPhi = std::cos(phi),
713 sinPhi = std::sin(phi);
776 }
while( --numPhi > 0 );
790 a1(
r[1]*cosPhi,
r[1]*sinPhi,
z[1] ),
791 b0( r0*cosPhi, r0*sinPhi,
z[0] ),
792 b1( r1*cosPhi, r1*sinPhi,
z[1] );
899 if (opposite) rx = -rx;
904 G4double deltaR = rx -
r[0], deltaZ = zx -
z[0];
914 if (edgeRZnorm !=
nullptr)
920 if (edgeRZnorm !=
nullptr)
930 if (edgeRZnorm !=
nullptr) *edgeRZnorm = answer;
952 if (d2 < d1) d1 = d2;
959 distOutside2 += dist*dist;
960 if (edgeRZnorm !=
nullptr)
962 *edgeRZnorm = std::max(std::fabs(*edgeRZnorm),std::fabs(dist));
988 if (rx < 0) part = -1;
993 G4double deltaR = rx -
r[0]*part, deltaZ = zx -
z[0];
1003 if (edgeRZnorm !=
nullptr)
1011 if (edgeRZnorm !=
nullptr)
1013 deltaR = rx -
r[1]*part;
1021 if (edgeRZnorm !=
nullptr) *edgeRZnorm = answer;
1043 if (d2 < d1) d1 = d2;
1050 distOutside2 += dist*dist;
1051 if (edgeRZnorm !=
nullptr)
1053 *edgeRZnorm = std::max(std::fabs(*edgeRZnorm),std::fabs(dist));
1075 if (!
cone->
HitOn( rx, hit.
z() ))
return false;
1079 G4double phiTolerant = 2.0*kCarTolerance/(rx+kCarTolerance);
1086 while( phi <
startPhi-phiTolerant )
1101 if (normSign*qacb.
dot(v) < 0)
return false;
1103 else if (phi < phiTolerant)
1110 if (normSign*qacb.
dot(v) < 0)
return false;
1142 G4double deter = tx1*ty2 - tx2*ty1;
1144 G4double s1 = ((x2-x1)*ty2 - tx2*(y2-y1))/deter;
1145 G4double s2 = ((x2-x1)*ty1 - tx1*(y2-y1))/deter;
1151 x = 0.5*( x1+s1*tx1 + x2+s2*tx2 );
1152 y = 0.5*( y1+s1*ty1 + y2+s2*ty2 );
1159 if(fSurfaceArea==0.)
1161 fSurfaceArea = (
r[0]+
r[1])* std::sqrt(
sqr(
r[0]-
r[1])+
sqr(
z[0]-
z[1]));
1164 return fSurfaceArea;
1173 dr=
r[1]-
r[0];dz=
z[1]-
z[0];
1194 zz =
z[0]+(rr-
r[0])*dz/dr;
const G4double kCarTolerance
CLHEP::Hep3Vector G4ThreeVector
Hep3Vector cross(const Hep3Vector &) const
double dot(const Hep3Vector &) const
virtual G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
virtual void AddVertexInOrder(const G4ThreeVector vertex)
virtual void ClearAllVertices()
void SetNormal(const G4ThreeVector &newNormal)
G4int CreateSubInstance()
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4bool HitOn(const G4double r, const G4double z)
G4int LineHitsCone(const G4ThreeVector &p, const G4ThreeVector &v, G4double *s1, G4double *s2)
void CalculateExtent(const EAxis axis, const G4VoxelLimits &voxelLimit, const G4AffineTransform &tranform, G4SolidExtentList &extentList) override
~G4PolyconeSide() override
G4double GetPhi(const G4ThreeVector &p)
static void FindLineIntersect(G4double x1, G4double y1, G4double tx1, G4double ty1, G4double x2, G4double y2, G4double tx2, G4double ty2, G4double &x, G4double &y)
G4ThreeVector GetPointOnFace() override
void CopyStuff(const G4PolyconeSide &source)
G4PolyconeSide(const G4PolyconeSideRZ *prevRZ, const G4PolyconeSideRZ *tail, const G4PolyconeSideRZ *head, const G4PolyconeSideRZ *nextRZ, G4double phiStart, G4double deltaPhi, G4bool phiIsOpen, G4bool isAllBehind=false)
G4ThreeVector Normal(const G4ThreeVector &p, G4double *bestDistance) override
G4double SurfaceArea() override
G4double DistanceAway(const G4ThreeVector &p, G4bool opposite, G4double &distOutside2, G4double *rzNorm=nullptr)
EInside Inside(const G4ThreeVector &p, G4double tolerance, G4double *bestDistance) override
G4IntersectingCone * cone
G4bool PointOnCone(const G4ThreeVector &hit, G4double normSign, const G4ThreeVector &p, const G4ThreeVector &v, G4ThreeVector &normal)
G4double Distance(const G4ThreeVector &p, G4bool outgoing) override
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, G4bool outgoing, G4double surfTolerance, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal, G4bool &isAllBehind) override
static const G4PlSideManager & GetSubInstanceManager()
G4double Extent(const G4ThreeVector axis) override
G4PolyconeSide & operator=(const G4PolyconeSide &source)
void AddSurface(const G4ClippablePolygon &surface)
const G4int kMaxMeshSections
const G4int kMinMeshSections
const G4double kMeshAngleDefault