68 G4bool start = (phiOther > phi);
89 G4double midPhi = phi + (start ? +0.5 : -0.5)*deltaPhi;
91 sinMid = std::sin(midPhi);
107 corn->
r = iterRZ.
GetA();
108 corn->
z = iterRZ.
GetB();
117 { corn->
prev = helper; }
122 { corn->
next = corn+1;}
127 }
while( ++corn, iterRZ.
Next() );
137 G4double rFact = std::cos(0.5*deltaPhi);
138 G4double rFactNormalize = 1.0/std::sqrt(1.0+rFact*rFact);
151 dz = here->z - prev->
z;
153 edge->
length = std::sqrt( dr*dr + dz*dz );
165 G4double zSignOther = start ? -1 : 1;
167 -zSignOther*std::cos(phiOther), 0 );
174 sideNorm *= rFactNormalize;
193 G4double norm = std::sqrt( rPart*rPart + zPart*zPart );
217 G4double zSignOther = start ? -1 : 1;
219 -zSignOther*std::cos(phiOther), 0 );
221 xyVector = -
normal - normalOther;
264 test -= 1E-6*corner->
norm3D;
267 G4Exception(
"G4PolyPhiFace::Diagnose()",
"GeomSolids0002",
276 : numEdges(0), rMin(0.), rMax(0.), zMin(0.), zMax(0.),
kCarTolerance(0.)
306 if (
this == &source) {
return *
this; }
358 * sourceEdge = source.
edges;
378 G4double normSign = outgoing ? +1 : -1;
392 if (dotProd <= 0)
return false;
399 distFromSurface = -normSign*ps.
dot(
normal);
401 if (distFromSurface < -surfTolerance)
return false;
407 distance = distFromSurface/dotProd;
426 G4double normSign = outgoing ? +1 : -1;
435 else if (distPhi < 0)
460 return std::sqrt( distPhi*distPhi + distRZ2 );
489 if (
InsideEdges( r, p.
z(), &distRZ2, &base3Dnorm, &head3Dnorm ))
494 *bestDistance = std::fabs(distPhi);
499 if (distPhi < -tolerance)
return kInside;
500 if (distPhi < tolerance)
return kSurface;
509 *bestDistance = std::sqrt( distPhi*distPhi + distRZ2 );
519 if ( distRZ2 > tolerance*tolerance )
527 if (normDist < -tolerance)
return kInside;
528 if (normDist < tolerance)
return kSurface;
562 *bestDistance = std::fabs(distPhi);
569 *bestDistance = std::sqrt( distPhi*distPhi + distRZ2 );
588 + axis.
z()*corner->
z;
589 if (here > max) max = here;
675 prevZ =
ExactZOrder( z, qx, qy, qz, v, normSign, prev );
681 cornZ =
ExactZOrder( z, qx, qy, qz, v, normSign, corn );
685 if (prevZ < 0)
continue;
689 if (prevZ > 0)
continue;
698 if (prevZ == 0)
continue;
715 nextZ =
ExactZOrder( z, qx, qy, qz, v, normSign, next );
716 }
while( nextZ == 0 );
721 if (nextZ*prevZ < 0)
continue;
730 G4ThreeVector qa( qx - prev->x, qy - prev->y, qz - prev->z ),
731 qb( qx - corn->
x, qy - corn->
y, qz - corn->
z );
733 G4double aboveOrBelow = normSign*qa.cross(qb).dot(v);
735 if (aboveOrBelow > 0)
737 else if (aboveOrBelow < 0)
783 if ( r < rMin || r >
rMax )
return false;
784 if ( z < zMin || z >
zMax )
return false;
815 G4double dr = (r-v0_vertex->
r), dz = (z-v0_vertex->
z);
818 G4double distance2 = distOut*distOut;
819 if (distance2 > bestDistance2)
continue;
834 else if (q > edge->
length)
844 if (distance2 < bestDistance2)
846 bestDistance2 = distance2;
847 if (testMe !=
nullptr)
850 answer = (distNorm <= 0);
851 if (base3Dnorm !=
nullptr)
853 *base3Dnorm = testMe;
854 *head3Dnorm = &testMe->
norm3D;
859 answer = (distOut <= 0);
860 if (base3Dnorm !=
nullptr)
862 *base3Dnorm = v0_vertex;
863 *head3Dnorm = &edge->
norm3D;
869 *bestDist2 = bestDistance2;
888 *p4=p2 + lambda1*w + lambda2*v;
889 return 0.5*(v.
cross(w)).mag();
918 return ((b.
x()-a.
x())*(c.
y()-a.
y())-
919 (c.
x()-a.
x())*(b.
y()-a.
y()));
928 return Area2(a,b,c)>0;
937 return Area2(a,b,c)>=0;
946 return Area2(a,b,c)==0;
960 Positive = !(
Left(a,b,c))^!(
Left(a,b,d));
961 return Positive && (!
Left(c,d,a)^!
Left(c,d,b));
969 if( !
Collinear(a,b,c) ) {
return false; }
973 return ((a.
x()<=c.
x())&&(c.
x()<=b.
x()))||
974 ((a.
x()>=c.
x())&&(c.
x()>=b.
x()));
978 return ((a.
y()<=c.
y())&&(c.
y()<=b.
y()))||
979 ((a.
y()>=c.
y())&&(c.
y()>=b.
y()));
1013 corner_next=corner->
next;
1017 if( (corner!=a)&&(corner_next!=a)
1018 &&(corner!=b)&&(corner_next!=b) )
1025 if(
Intersect(rz1,rz2,rz3,rz4) ) {
return false; }
1027 corner=corner->
next;
1050 if(
LeftOn(arz,arz1,arz0))
1052 return Left(arz,brz,arz0)&&
Left(brz,arz,arz1);
1080 c_next=corner->
next;
1081 c_prev=corner->
prev;
1086 corner=corner->
next;
1103 std::vector<G4double> areas;
1104 std::vector<G4ThreeVector> points;
1115 triang->
r = helper->
r;
1116 triang->
z = helper->
z;
1117 triang->
x = helper->
x;
1118 triang->
y= helper->
y;
1125 { triang->
prev=helper2; }
1130 { triang->
next=triang+1; }
1134 helper=helper->
next;
1135 triang=triang->
next;
1167 points.push_back(p4);
1168 areas.push_back(result1);
1196 "Maximum number of steps is reached for triangulation!" );
1209 points.push_back(p4);
1210 areas.push_back(result1);
1225 Achose1=0; Achose2=0.;
1230 if(chose>=Achose1 && chose<Achose2)
1237 i++; Achose1=Achose2;
const G4double kCarTolerance
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
CLHEP::Hep2Vector G4TwoVector
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)
void SetNormal(const G4ThreeVector &newNormal)
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4bool Left(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4bool Collinear(G4TwoVector a, G4TwoVector b, G4TwoVector c)
void Diagnose(G4VSolid *solid)
G4PolyPhiFace & operator=(const G4PolyPhiFace &source)
G4bool Diagonal(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4ThreeVector surface_point
G4bool InsideEdges(G4double r, G4double z)
G4bool Diagonalie(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4bool IntersectProp(G4TwoVector a, G4TwoVector b, G4TwoVector c, G4TwoVector d)
G4bool LeftOn(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, G4bool outgoing, G4double surfTolerance, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal, G4bool &allBehind)
G4ThreeVector Normal(const G4ThreeVector &p, G4double *bestDistance)
void CopyStuff(const G4PolyPhiFace &source)
void CalculateExtent(const EAxis axis, const G4VoxelLimits &voxelLimit, const G4AffineTransform &tranform, G4SolidExtentList &extentList)
G4double Area2(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4double ExactZOrder(G4double z, G4double qx, G4double qy, G4double qz, const G4ThreeVector &v, G4double normSign, const G4PolyPhiFaceVertex *vert) const
G4double Distance(const G4ThreeVector &p, G4bool outgoing)
G4double Extent(const G4ThreeVector axis)
G4PolyPhiFaceEdge * edges
G4bool InCone(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4bool Between(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4PolyPhiFaceVertex * corners
G4PolyPhiFaceVertex * triangles
EInside Inside(const G4ThreeVector &p, G4double tolerance, G4double *bestDistance)
G4ThreeVector GetPointOnFace()
G4double SurfaceTriangle(G4ThreeVector p1, G4ThreeVector p2, G4ThreeVector p3, G4ThreeVector *p4)
G4bool InsideEdgesExact(G4double r, G4double z, G4double normSign, const G4ThreeVector &p, const G4ThreeVector &v)
G4PolyPhiFace(const G4ReduciblePolygon *rz, G4double phi, G4double deltaPhi, G4double phiOther)
G4int NumVertices() const
void AddSurface(const G4ClippablePolygon &surface)
virtual EInside Inside(const G4ThreeVector &p) const =0
G4PolyPhiFaceVertex * next
G4PolyPhiFaceVertex * prev