68 G4bool start = (phiOther > phi);
89 G4double midPhi = phi + (start ? +0.5 : -0.5)*deltaPhi;
91 sinMid = std::sin(midPhi);
108 corn->
r = iterRZ.
GetA();
109 corn->
z = iterRZ.
GetB();
118 { corn->
prev = helper; }
122 if( corn <
corners+maxEdges-1 )
123 { corn->
next = corn+1;}
128 }
while( ++corn, iterRZ.
Next() );
138 G4double rFact = std::cos(0.5*deltaPhi);
139 G4double rFactNormalize = 1.0/std::sqrt(1.0+rFact*rFact);
152 dz = here->z - prev->
z;
154 edge->
length = std::sqrt( dr*dr + dz*dz );
166 G4double zSignOther = start ? -1 : 1;
168 -zSignOther*std::cos(phiOther), 0 );
175 sideNorm *= rFactNormalize;
180 }
while( edge++, prev=here, ++here <
corners+maxEdges );
194 G4double norm = std::sqrt( rPart*rPart + zPart*zPart );
218 G4double zSignOther = start ? -1 : 1;
220 -zSignOther*std::cos(phiOther), 0 );
222 xyVector = -
normal - normalOther;
242 }
while( prevEdge=edge, ++edge <
edges+maxEdges );
265 test -= 1E-6*corner->
norm3D;
268 G4Exception(
"G4PolyPhiFace::Diagnose()",
"GeomSolids0002",
277 : numEdges(0), rMin(0.), rMax(0.), zMin(0.), zMax(0.),
kCarTolerance(0.)
306 if (
this == &source) {
return *
this; }
350 }
while( ++sourceCorn, ++corn <
corners+maxEdges );
360 * sourceEdge = source.
edges;
366 }
while( ++sourceEdge, ++edge, prev=here, ++here <
corners+maxEdges );
380 G4double normSign = outgoing ? +1 : -1;
394 if (dotProd <= 0)
return false;
401 distFromSurface = -normSign*ps.
dot(
normal);
403 if (distFromSurface < -surfTolerance)
return false;
409 distance = distFromSurface/dotProd;
428 G4double normSign = outgoing ? +1 : -1;
437 else if (distPhi < 0)
462 return std::sqrt( distPhi*distPhi + distRZ2 );
491 if (
InsideEdges( r, p.
z(), &distRZ2, &base3Dnorm, &head3Dnorm ))
496 *bestDistance = std::fabs(distPhi);
501 if (distPhi < -tolerance)
return kInside;
502 if (distPhi < tolerance)
return kSurface;
511 *bestDistance = std::sqrt( distPhi*distPhi + distRZ2 );
521 if ( distRZ2 > tolerance*tolerance )
529 if (normDist < -tolerance)
return kInside;
530 if (normDist < tolerance)
return kSurface;
564 *bestDistance = std::fabs(distPhi);
571 *bestDistance = std::sqrt( distPhi*distPhi + distRZ2 );
590 + axis.
z()*corner->
z;
591 if (here > max) max = here;
677 prevZ =
ExactZOrder( z, qx, qy, qz, v, normSign, prev );
683 cornZ =
ExactZOrder( z, qx, qy, qz, v, normSign, corn );
687 if (prevZ < 0)
continue;
691 if (prevZ > 0)
continue;
700 if (prevZ == 0)
continue;
717 nextZ =
ExactZOrder( z, qx, qy, qz, v, normSign, next );
718 }
while( nextZ == 0 );
723 if (nextZ*prevZ < 0)
continue;
732 G4ThreeVector qa( qx - prev->x, qy - prev->y, qz - prev->z ),
733 qb( qx - corn->
x, qy - corn->
y, qz - corn->
z );
735 G4double aboveOrBelow = normSign*qa.cross(qb).dot(v);
737 if (aboveOrBelow > 0)
739 else if (aboveOrBelow < 0)
785 if ( r < rMin || r >
rMax )
return false;
786 if ( z < zMin || z >
zMax )
return false;
817 G4double dr = (r-v0_vertex->
r), dz = (z-v0_vertex->
z);
820 G4double distance2 = distOut*distOut;
821 if (distance2 > bestDistance2)
continue;
836 else if (q > edge->
length)
846 if (distance2 < bestDistance2)
848 bestDistance2 = distance2;
849 if (testMe !=
nullptr)
852 answer = (distNorm <= 0);
853 if (base3Dnorm !=
nullptr)
855 *base3Dnorm = testMe;
856 *head3Dnorm = &testMe->
norm3D;
861 answer = (distOut <= 0);
862 if (base3Dnorm !=
nullptr)
864 *base3Dnorm = v0_vertex;
865 *head3Dnorm = &edge->
norm3D;
871 *bestDist2 = bestDistance2;
890 *p4=p2 + lambda1*w + lambda2*v;
920 return ((b.
x()-a.
x())*(c.
y()-a.
y())-
921 (c.
x()-a.
x())*(b.
y()-a.
y()));
930 return Area2(a,b,c)>0;
939 return Area2(a,b,c)>=0;
948 return Area2(a,b,c)==0;
962 Positive = !(
Left(a,b,c))^!(
Left(a,b,d));
963 return Positive && ((!
Left(c,d,a)^!
Left(c,d,b)) != 0);
971 if( !
Collinear(a,b,c) ) {
return false; }
975 return ((a.
x()<=c.
x())&&(c.
x()<=b.
x()))||
976 ((a.
x()>=c.
x())&&(c.
x()>=b.
x()));
980 return ((a.
y()<=c.
y())&&(c.
y()<=b.
y()))||
981 ((a.
y()>=c.
y())&&(c.
y()>=b.
y()));
1015 corner_next=corner->
next;
1019 if( (corner!=a)&&(corner_next!=a)
1020 &&(corner!=b)&&(corner_next!=b) )
1027 if(
Intersect(rz1,rz2,rz3,rz4) ) {
return false; }
1029 corner=corner->
next;
1052 if(
LeftOn(arz,arz1,arz0))
1054 return Left(arz,brz,arz0)&&
Left(brz,arz,arz1);
1082 c_next=corner->
next;
1083 c_prev=corner->
prev;
1088 corner=corner->
next;
1106 std::vector<G4double> areas;
1107 std::vector<G4ThreeVector> points;
1118 triang->
r = helper->
r;
1119 triang->
z = helper->
z;
1120 triang->
x = helper->
x;
1121 triang->
y = helper->
y;
1128 { triang->
prev=helper2; }
1132 if( helper<
corners+maxEdges-1 )
1133 { triang->
next=triang+1; }
1137 helper=helper->
next;
1138 triang=triang->
next;
1170 points.push_back(p4);
1171 areas.push_back(result1);
1199 "Maximum number of steps is reached for triangulation!" );
1203 if(v2->
next !=
nullptr)
1212 points.push_back(p4);
1213 areas.push_back(result1);
1228 Achose1=0; Achose2=0.;
1233 if(chose>=Achose1 && chose<Achose2)
1240 ++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()
G4double Distance(const G4ThreeVector &p, G4bool outgoing) override
G4double Area2(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c)
G4bool LeftOn(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c)
G4ThreeVector GetPointOnFace() override
EInside Inside(const G4ThreeVector &p, G4double tolerance, G4double *bestDistance) override
G4bool Collinear(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c)
void Diagnose(G4VSolid *solid)
void CalculateExtent(const EAxis axis, const G4VoxelLimits &voxelLimit, const G4AffineTransform &tranform, G4SolidExtentList &extentList) override
G4PolyPhiFace & operator=(const G4PolyPhiFace &source)
G4bool Diagonal(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4ThreeVector surface_point
G4bool InsideEdges(G4double r, G4double z)
G4bool Left(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c)
G4bool Diagonalie(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4double SurfaceTriangle(const G4ThreeVector &p1, const G4ThreeVector &p2, const G4ThreeVector &p3, G4ThreeVector *p4)
G4bool IntersectProp(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c, const G4TwoVector &d)
void CopyStuff(const G4PolyPhiFace &source)
G4double ExactZOrder(G4double z, G4double qx, G4double qy, G4double qz, const G4ThreeVector &v, G4double normSign, const G4PolyPhiFaceVertex *vert) const
G4double Extent(const G4ThreeVector axis) override
G4PolyPhiFaceEdge * edges
G4ThreeVector Normal(const G4ThreeVector &p, G4double *bestDistance) override
G4bool InCone(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4bool Intersect(const G4ThreeVector &p, const G4ThreeVector &v, G4bool outgoing, G4double surfTolerance, G4double &distance, G4double &distFromSurface, G4ThreeVector &normal, G4bool &allBehind) override
G4PolyPhiFaceVertex * corners
G4PolyPhiFaceVertex * triangles
~G4PolyPhiFace() override
G4double SurfaceArea() override
G4bool Between(const G4TwoVector &a, const G4TwoVector &b, const G4TwoVector &c)
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