57 #define G4MT_phphi ((subInstanceManager.offset[instanceID]).fPhi)
93 r[0] = tail->
r;
z[0] = tail->
z;
94 r[1] = head->
r;
z[1] = head->
z;
131 b1(
r[1]*std::cos(phi),
r[1]*std::sin(phi),
z[1] ),
132 c1( prevRZ->
r*std::cos(phi), prevRZ->
r*std::sin(phi), prevRZ->
z ),
133 d1( nextRZ->
r*std::cos(phi), nextRZ->
r*std::sin(phi), nextRZ->
z ),
146 c2 =
G4ThreeVector( prevRZ->
r*std::cos(phi), prevRZ->
r*std::sin(phi), prevRZ->
z );
147 d2 =
G4ThreeVector( nextRZ->
r*std::cos(phi), nextRZ->
r*std::sin(phi), nextRZ->
z );
156 vec->
center = 0.25*( a1 + a2 + b1 + b2 );
158 tt = b2 + b1 - a2 - a1;
162 tt = b2 - b1 + a2 - a1;
191 adj = 0.5*(
c1+c2-a1-a2);
192 adj = adj.
cross(a12);
197 adj = 0.5*(
d1+d2-b1-b2);
198 adj = adj.
cross(a12);
207 vec->
edges[0] = edge;
211 vec->
edges[1] = edge;
239 edge = vec->
edges[0];
259 }
while( prev=vec, ++vec <
vecs + numSide );
277 if (normvec.
dot(vec->
surfPhi) > 0) normvec = -normvec;
289 vec =
vecs + numSide - 1;
293 if (normvec.
dot(vec->
surfPhi) < 0) normvec = -normvec;
317 : numSide(0), startPhi(0.), deltaPhi(0.), endPhi(0.),
318 phiIsOpen(false), allBehind(false), cone(0), vecs(0), edges(0),
319 lenRZ(0.), edgeNorm(0.),
kCarTolerance(0.), fSurfaceArea(0.), instanceID(0)
355 if (
this == &source)
return *
this;
403 *sourceEdge = source.
edges;
407 }
while( ++sourceEdge, ++edge <
edges + numEdges);
415 *sourceVec = source.
vecs;
475 G4double normSign = outgoing ? +1 : -1;
515 if (dotProd <= 0)
continue;
521 distFromSurface = -normSign*delta.
dot(vec->
normal);
523 if (distFromSurface < -surfTolerance)
continue;
537 if (normSign*qc.
cross(qd).
dot(v) < 0)
continue;
542 if (normSign*qa.
cross(qb).
dot(v) > 0)
continue;
557 if (distFromSurface < 0)
562 if (std::fabs(rz) >
lenRZ+surfTolerance)
return false;
565 if (std::fabs(pp) >
lenPhi[0] +
lenPhi[1]*rz + surfTolerance)
return false;
572 distance = distFromSurface/dotProd;
576 }
while( ++vec, ++face <
numSide );
587 G4double normSign = outgoing ? -1 : +1;
637 if ( (std::fabs(norm) < tolerance) && (*bestDistance < 2.0*tolerance) )
702 i1 = iPhi; i2 = iPhi;
718 if (answer > best) best = answer;
719 }
while( ++vec < list+4 );
815 if (dotProd <= 0)
return false;
822 distFromSurface = -normSign*delta.
dot(vec.
normal);
824 if (distFromSurface < -surfTolerance)
return false;
830 distance = distFromSurface/dotProd;
852 if (
r[0]==0)
return true;
854 if (atRZ < -
lenRZ*1.2)
return false;
860 if (normSign*qacb.
dot(v) < 0)
return false;
862 if (distFromSurface < 0)
864 if (atRZ < -
lenRZ-surfTolerance)
return false;
869 if (
r[1]==0)
return true;
871 if (atRZ >
lenRZ*1.2)
return false;
877 if (normSign*qacb.
dot(v) >= 0)
return false;
879 if (distFromSurface < 0)
881 if (atRZ >
lenRZ+surfTolerance)
return false;
911 *i1 =
PhiSegment( std::atan2( p.
y() + s1*v.
y(), p.
x() + s1*v.
x() ) );
914 return (*i1 < 0) ? 0 : 1;
920 *i2 =
PhiSegment( std::atan2( p.
y() + s2*v.
y(), p.
x() + s2*v.
x() ) );
921 if (*i1 == *i2)
return 0;
925 if (*i2 < 0)
return 0;
930 if (*i2 < 0)
return 1;
945 if (iPhi >= 0)
return iPhi;
961 return (d2 < d1) ? 0 :
numSide-1;
1093 if (pcDotRZ < -
lenRZ)
1100 if (pcDotPhi < -lenPhiZ)
1105 G4double distOutPhi = pcDotPhi+lenPhiZ;
1106 distOut2 = distOutPhi*distOutPhi + distOutZ*distOutZ;
1110 else if (pcDotPhi > lenPhiZ)
1115 G4double distOutPhi = pcDotPhi-lenPhiZ;
1116 distOut2 = distOutPhi*distOutPhi + distOutZ*distOutZ;
1126 distOut2 = distOutZ*distOutZ;
1130 else if (pcDotRZ >
lenRZ)
1137 if (pcDotPhi < -lenPhiZ)
1142 G4double distOutPhi = pcDotPhi+lenPhiZ;
1143 distOut2 = distOutPhi*distOutPhi + distOutZ*distOutZ;
1147 else if (pcDotPhi > lenPhiZ)
1152 G4double distOutPhi = pcDotPhi-lenPhiZ;
1153 distOut2 = distOutPhi*distOutPhi + distOutZ*distOutZ;
1162 distOut2 = distOutZ*distOutZ;
1173 if (pcDotPhi < -lenPhiZ)
1179 distOut2 = distOut*distOut;
1183 else if (pcDotPhi > lenPhiZ)
1189 distOut2 = distOut*distOut;
1198 return std::fabs(distFaceNorm);
1201 return std::sqrt( distFaceNorm*distFaceNorm + distOut2 );
1221 *p4=p2 + lambda1*w + lambda2*v;
1222 return 0.5*(v.cross(w)).mag();
1243 if( (chose>=0.) && (chose < aOne) )
1293 std::vector<G4double>areas;
1294 std::vector<G4ThreeVector>points;
1312 points.push_back(point1);
1313 areas.push_back(result1);
1321 Achose1=0;Achose2=0.;
1326 if(chose>=Achose1 && chose<Achose2)
1328 point1=points[i] ;
break;
1330 i++; Achose1=Achose2;
static G4GEOM_DLL G4PhSideManager subInstanceManager
CLHEP::Hep3Vector G4ThreeVector
void SetNormal(const G4ThreeVector &newNormal)
static const G4double kInfinity
G4double DistanceAway(const G4ThreeVector &p, const G4PolyhedraSideVec &vec, G4double *normDist)
G4PolyhedraSideEdge * edges[2]
G4int CreateSubInstance()
static double normal(HepRandomEngine *eptr)
double dot(const Hep3Vector &) const
G4double GetPhi(const G4ThreeVector &p)
const G4double kCarTolerance
G4IntersectingCone * cone
G4int LineHitsSegments(const G4ThreeVector &p, const G4ThreeVector &v, G4int *i1, G4int *i2)
G4double SurfaceTriangle(G4ThreeVector p1, G4ThreeVector p2, G4ThreeVector p3, G4ThreeVector *p4)
void AddSurface(const G4ClippablePolygon &surface)
EInside Inside(const G4ThreeVector &p, G4double tolerance, G4double *bestDistance)
void CalculateExtent(const EAxis axis, const G4VoxelLimits &voxelLimit, const G4AffineTransform &tranform, G4SolidExtentList &extentList)
static constexpr double ps
G4double DistanceToOneSide(const G4ThreeVector &p, const G4PolyhedraSideVec &vec, G4double *normDist)
G4double Extent(const G4ThreeVector axis)
G4int PhiSegment(G4double phi)
void CopyStuff(const G4PolyhedraSide &source)
static constexpr double twopi
G4int LineHitsCone(const G4ThreeVector &p, const G4ThreeVector &v, G4double *s1, G4double *s2)
G4PolyhedraSideVec * vecs
G4ThreeVector GetPointOnFace()
G4ThreeVector edgeNorm[2]
Hep3Vector cross(const Hep3Vector &) const
virtual G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
virtual ~G4PolyhedraSide()
G4ThreeVector GetPointOnPlane(G4ThreeVector p0, G4ThreeVector p1, G4ThreeVector p2, G4ThreeVector p3, G4double *Area)
G4ThreeVector cornNorm[2]
G4PolyhedraSideEdge * edges
G4ThreeVector Normal(const G4ThreeVector &p, G4double *bestDistance)
G4PolyhedraSide(const G4PolyhedraSideRZ *prevRZ, const G4PolyhedraSideRZ *tail, const G4PolyhedraSideRZ *head, const G4PolyhedraSideRZ *nextRZ, G4int numSide, G4double phiStart, G4double phiTotal, G4bool phiIsOpen, G4bool isAllBehind=false)
G4PolyhedraSide & operator=(const G4PolyhedraSide &source)
static G4GeometryTolerance * GetInstance()
virtual void AddVertexInOrder(const G4ThreeVector vertex)
G4bool IntersectSidePlane(const G4ThreeVector &p, const G4ThreeVector &v, const G4PolyhedraSideVec &vec, G4double normSign, G4double surfTolerance, G4double &distance, G4double &distFromSurface)
G4int ClosestPhiSegment(G4double phi)
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, G4bool outgoing, G4double surfTolerance, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal, G4bool &allBehind)
static const G4PhSideManager & GetSubInstanceManager()
G4double Distance(const G4ThreeVector &p, G4bool outgoing)
G4double GetSurfaceTolerance() const