65 : fSurfaceArea(0.), triangles(0)
79 G4bool start = (phiOther > phi);
100 G4double midPhi = phi + (start ? +0.5 : -0.5)*deltaPhi;
102 sinMid = std::sin(midPhi);
119 corn->
r = iterRZ.
GetA();
120 corn->
z = iterRZ.
GetB();
129 { corn->
prev = helper; }
134 { corn->
next = corn+1;}
139 }
while( ++corn, iterRZ.
Next() );
149 G4double rFact = std::cos(0.5*deltaPhi);
150 G4double rFactNormalize = 1.0/std::sqrt(1.0+rFact*rFact);
163 dz = here->z - prev->
z;
165 edge->
length = std::sqrt( dr*dr + dz*dz );
177 G4double zSignOther = start ? -1 : 1;
179 -zSignOther*std::cos(phiOther), 0 );
186 sideNorm *= rFactNormalize;
190 edge->
norm3D = sideNorm.unit();
191 }
while( edge++, prev=here, ++here <
corners+numEdges );
205 G4double norm = std::sqrt( rPart*rPart + zPart*zPart );
229 G4double zSignOther = start ? -1 : 1;
231 -zSignOther*std::cos(phiOther), 0 );
233 xyVector = -
normal - normalOther;
253 }
while( prevEdge=edge, ++edge <
edges+numEdges );
278 test -= 1E-6*corner->
norm3D;
281 G4Exception(
"G4PolyPhiFace::Diagnose()",
"GeomSolids0002",
292 : numEdges(0), edges(0), corners(0), rMin(0.), rMax(0.), zMin(0.), zMax(0.),
293 allBehind(false), kCarTolerance(0.), fSurfaceArea(0.), triangles(0)
323 if (
this == &source) {
return *
this; }
375 *sourceEdge = source.
edges;
381 }
while( ++sourceEdge, ++edge, prev=here, ++here <
corners+numEdges );
397 G4double normSign = outgoing ? +1 : -1;
411 if (dotProd <= 0)
return false;
418 distFromSurface = -normSign*ps.dot(
normal);
420 if (distFromSurface < -surfTolerance)
return false;
426 distance = distFromSurface/dotProd;
447 G4double normSign = outgoing ? +1 : -1;
456 else if (distPhi < 0)
481 return std::sqrt( distPhi*distPhi + distRZ2 );
512 if (
InsideEdges( r, p.z(), &distRZ2, &base3Dnorm, &head3Dnorm ))
517 *bestDistance = std::fabs(distPhi);
522 if (distPhi < -tolerance)
return kInside;
523 if (distPhi < tolerance)
return kSurface;
532 *bestDistance = std::sqrt( distPhi*distPhi + distRZ2 );
541 G4double normDist = head3Dnorm->dot(cc);
542 if ( distRZ2 > tolerance*tolerance )
550 if (normDist < -tolerance)
return kInside;
551 if (normDist < tolerance)
return kSurface;
587 *bestDistance = std::fabs(distPhi);
594 *bestDistance = std::sqrt( distPhi*distPhi + distRZ2 );
614 + axis.y()*corner->
r*
radial.y()
615 + axis.z()*corner->
z;
616 if (here > max) max = here;
710 prevZ =
ExactZOrder( z, qx, qy, qz, v, normSign, prev );
716 cornZ =
ExactZOrder( z, qx, qy, qz, v, normSign, corn );
720 if (prevZ < 0)
continue;
724 if (prevZ > 0)
continue;
733 if (prevZ == 0)
continue;
750 nextZ =
ExactZOrder( z, qx, qy, qz, v, normSign, next );
751 }
while( nextZ == 0 );
756 if (nextZ*prevZ < 0)
continue;
765 G4ThreeVector qa( qx - prev->x, qy - prev->y, qz - prev->z ),
766 qb( qx - corn->
x, qy - corn->
y, qz - corn->
z );
768 G4double aboveOrBelow = normSign*qa.cross(qb).dot(v);
770 if (aboveOrBelow > 0)
772 else if (aboveOrBelow < 0)
783 }
while( prevZ = cornZ, prev=corn, ++corn <
corners+numEdges );
827 if ( r < rMin || r >
rMax )
return false;
828 if ( z < zMin || z >
zMax )
return false;
862 G4double distance2 = distOut*distOut;
863 if (distance2 > bestDistance2)
continue;
878 else if (q > edge->
length)
892 if (distance2 < bestDistance2)
894 bestDistance2 = distance2;
898 answer = (distNorm <= 0);
901 *base3Dnorm = testMe;
902 *head3Dnorm = &testMe->
norm3D;
907 answer = (distOut <= 0);
910 *base3Dnorm = edge->
v0;
911 *head3Dnorm = &edge->
norm3D;
917 *bestDist2 = bestDistance2;
937 *p4=p2 + lambda1*w + lambda2*v;
938 return 0.5*(v.cross(w)).mag();
970 return ((b.x()-a.x())*(c.y()-a.y())-
971 (c.x()-a.x())*(b.y()-a.y()));
981 return Area2(a,b,c)>0;
991 return Area2(a,b,c)>=0;
1001 return Area2(a,b,c)==0;
1016 Positive = !(
Left(a,b,c))^!(
Left(a,b,d));
1017 return Positive && (!
Left(c,d,a)^!
Left(c,d,b));
1026 if( !
Collinear(a,b,c) ) {
return false; }
1030 return ((a.x()<=c.x())&&(c.x()<=b.x()))||
1031 ((a.x()>=c.x())&&(c.x()>=b.x()));
1035 return ((a.y()<=c.y())&&(c.y()<=b.y()))||
1036 ((a.y()>=c.y())&&(c.y()>=b.y()));
1072 corner_next=corner->
next;
1076 if( (corner!=a)&&(corner_next!=a)
1077 &&(corner!=b)&&(corner_next!=b) )
1084 if(
Intersect(rz1,rz2,rz3,rz4) ) {
return false; }
1086 corner=corner->
next;
1110 if(
LeftOn(arz,arz1,arz0))
1112 return Left(arz,brz,arz0)&&
Left(brz,arz,arz1);
1142 c_next=corner->
next;
1143 c_prev=corner->
prev;
1148 corner=corner->
next;
1166 std::vector<G4double> areas;
1167 std::vector<G4ThreeVector> points;
1178 triang->
r = helper->
r;
1179 triang->
z = helper->
z;
1180 triang->
x = helper->
x;
1181 triang->
y= helper->
y;
1188 { triang->
prev=helper2; }
1193 { triang->
next=triang+1; }
1197 helper=helper->
next;
1198 triang=triang->
next;
1230 points.push_back(p4);
1231 areas.push_back(result1);
1259 "Maximum number of steps is reached for triangulation!" );
1272 points.push_back(p4);
1273 areas.push_back(result1);
1288 Achose1=0; Achose2=0.;
1293 if(chose>=Achose1 && chose<Achose2)
1300 i++; Achose1=Achose2;
G4double ExactZOrder(G4double z, G4double qx, G4double qy, G4double qz, const G4ThreeVector &v, G4double normSign, const G4PolyPhiFaceVertex *vert) const
G4bool InsideEdgesExact(G4double r, G4double z, G4double normSign, const G4ThreeVector &p, const G4ThreeVector &v)
static const G4double kInfinity
G4ThreeVector surface_point
CLHEP::Hep3Vector G4ThreeVector
G4double GetSurfaceTolerance() const
void SetNormal(const G4ThreeVector &newNormal)
virtual G4bool PartialClip(const G4VoxelLimits &voxelLimit, const EAxis IgnoreMe)
virtual void AddVertexInOrder(const G4ThreeVector vertex)
G4bool Between(G4TwoVector a, G4TwoVector b, G4TwoVector c)
static const G4double tolerance
void Diagnose(G4VSolid *solid)
G4bool InsideEdges(G4double r, G4double z)
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)
G4int NumVertices() const
virtual EInside Inside(const G4ThreeVector &p) const =0
G4double SurfaceTriangle(G4ThreeVector p1, G4ThreeVector p2, G4ThreeVector p3, G4ThreeVector *p4)
EInside Inside(const G4ThreeVector &p, G4double tolerance, G4double *bestDistance)
G4PolyPhiFaceVertex * next
void AddSurface(const G4ClippablePolygon &surface)
G4PolyPhiFaceVertex * prev
void CalculateExtent(const EAxis axis, const G4VoxelLimits &voxelLimit, const G4AffineTransform &tranform, G4SolidExtentList &extentList)
G4double Distance(const G4ThreeVector &p, G4bool outgoing)
G4PolyPhiFaceVertex * corners
G4bool Collinear(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4bool Diagonalie(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4PolyPhiFace & operator=(const G4PolyPhiFace &source)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4ThreeVector Normal(const G4ThreeVector &p, G4double *bestDistance)
G4ThreeVector GetPointOnFace()
G4double Extent(const G4ThreeVector axis)
G4bool InCone(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4PolyPhiFaceVertex * triangles
G4bool IntersectProp(G4TwoVector a, G4TwoVector b, G4TwoVector c, G4TwoVector d)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double Area2(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4bool Diagonal(G4PolyPhiFaceVertex *a, G4PolyPhiFaceVertex *b)
G4PolyPhiFace(const G4ReduciblePolygon *rz, G4double phi, G4double deltaPhi, G4double phiOther)
CLHEP::Hep2Vector G4TwoVector
void CopyStuff(const G4PolyPhiFace &source)
static G4GeometryTolerance * GetInstance()
G4bool Left(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4PolyPhiFaceEdge * edges