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 );
821 if ( r < rMin || r >
rMax )
return false;
822 if ( z < zMin || z >
zMax )
return false;
856 G4double distance2 = distOut*distOut;
857 if (distance2 > bestDistance2)
continue;
872 else if (q > edge->
length)
886 if (distance2 < bestDistance2)
888 bestDistance2 = distance2;
892 answer = (distNorm <= 0);
895 *base3Dnorm = testMe;
896 *head3Dnorm = &testMe->
norm3D;
901 answer = (distOut <= 0);
904 *base3Dnorm = edge->
v0;
905 *head3Dnorm = &edge->
norm3D;
911 *bestDist2 = bestDistance2;
931 *p4=p2 + lambda1*w + lambda2*v;
932 return 0.5*(v.cross(w)).mag();
964 return ((b.x()-a.x())*(c.y()-a.y())-
965 (c.x()-a.x())*(b.y()-a.y()));
975 return Area2(a,b,c)>0;
985 return Area2(a,b,c)>=0;
995 return Area2(a,b,c)==0;
1010 Positive = !(
Left(a,b,c))^!(
Left(a,b,d));
1011 return Positive && (!
Left(c,d,a)^!
Left(c,d,b));
1020 if( !
Collinear(a,b,c) ) {
return false; }
1024 return ((a.x()<=c.x())&&(c.x()<=b.x()))||
1025 ((a.x()>=c.x())&&(c.x()>=b.x()));
1029 return ((a.y()<=c.y())&&(c.y()<=b.y()))||
1030 ((a.y()>=c.y())&&(c.y()>=b.y()));
1066 corner_next=corner->
next;
1070 if( (corner!=a)&&(corner_next!=a)
1071 &&(corner!=b)&&(corner_next!=b) )
1078 if(
Intersect(rz1,rz2,rz3,rz4) ) {
return false; }
1080 corner=corner->
next;
1104 if(
LeftOn(arz,arz1,arz0))
1106 return Left(arz,brz,arz0)&&
Left(brz,arz,arz1);
1136 c_next=corner->
next;
1137 c_prev=corner->
prev;
1142 corner=corner->
next;
1160 std::vector<G4double> areas;
1161 std::vector<G4ThreeVector> points;
1172 triang->
r = helper->
r;
1173 triang->
z = helper->
z;
1174 triang->
x = helper->
x;
1175 triang->
y= helper->
y;
1182 { triang->
prev=helper2; }
1187 { triang->
next=triang+1; }
1191 helper=helper->
next;
1192 triang=triang->
next;
1224 points.push_back(p4);
1225 areas.push_back(result1);
1253 "Maximum number of steps is reached for triangulation!" );
1266 points.push_back(p4);
1267 areas.push_back(result1);
1282 Achose1=0; Achose2=0.;
1287 if(chose>=Achose1 && chose<Achose2)
1294 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
static const G4float tolerance
G4double GetSurfaceTolerance() const
const G4double w[NPOINTSGL]
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)
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)
const G4double x[NPOINTSGL]
CLHEP::Hep2Vector G4TwoVector
void CopyStuff(const G4PolyPhiFace &source)
static G4GeometryTolerance * GetInstance()
G4bool Left(G4TwoVector a, G4TwoVector b, G4TwoVector c)
G4PolyPhiFaceEdge * edges