Added Shewchuk's robust geometric predicates

Fixed bug in sweepline algorithm

git-svn-id: https://triangle.svn.codeplex.com/svn@73454 0e2699bc-83d4-4a8f-98e7-55e24ab8c7a5
This commit is contained in:
SND\wo80_cp
2013-08-20 14:52:38 +00:00
parent 467ff666cc
commit f07cb1ded7
4 changed files with 914 additions and 143 deletions
+33 -36
View File
@@ -31,7 +31,7 @@ namespace TriangleNet.Algorithm
}
Mesh mesh;
double xminextreme; // Nonexistent x value used as a flag in sweepline.
double xminextreme; // Nonexistent x value used as a flag in sweepline.
List<SplayNode> splaynodes;
#region Heap
@@ -177,7 +177,6 @@ namespace TriangleNet.Algorithm
evt.xkey = thisvertex.x;
evt.ykey = thisvertex.y;
HeapInsert(eventheap, i++, evt);
}
}
@@ -357,7 +356,23 @@ namespace TriangleNet.Algorithm
return newsplaynode;
}
#endregion
SplayNode FrontLocate(SplayNode splayroot, Otri bottommost, Vertex searchvertex,
ref Otri searchtri, ref bool farright)
{
bool farrightflag;
bottommost.Copy(ref searchtri);
splayroot = Splay(splayroot, searchvertex, ref searchtri);
farrightflag = false;
while (!farrightflag && RightOfHyperbola(ref searchtri, searchvertex))
{
searchtri.OnextSelf();
farrightflag = searchtri.Equal(bottommost);
}
farright = farrightflag;
return splayroot;
}
SplayNode CircleTopInsert(SplayNode splayroot, Otri newkey,
Vertex pa, Vertex pb, Vertex pc, double topy)
@@ -380,6 +395,8 @@ namespace TriangleNet.Algorithm
return SplayInsert(Splay(splayroot, searchpoint, ref dummytri), newkey, searchpoint);
}
#endregion
bool RightOfHyperbola(ref Otri fronttri, Point newsite)
{
Vertex leftvertex, rightvertex;
@@ -449,24 +466,6 @@ namespace TriangleNet.Algorithm
}
}
SplayNode FrontLocate(SplayNode splayroot, Otri bottommost, Vertex searchvertex,
ref Otri searchtri, ref bool farright)
{
bool farrightflag;
bottommost.Copy(ref searchtri);
splayroot = Splay(splayroot, searchvertex, ref searchtri);
farrightflag = false;
while (!farrightflag && RightOfHyperbola(ref searchtri, searchvertex))
{
searchtri.OnextSelf();
farrightflag = searchtri.Equal(bottommost);
}
farright = farrightflag;
return splayroot;
}
/// <summary>
/// Removes ghost triangles.
/// </summary>
@@ -574,7 +573,7 @@ namespace TriangleNet.Algorithm
{
if (heapsize == 0)
{
SimpleLog.Instance.Error("Input vertices are all identical.", "SweepLine.SweepLineDelaunay()");
SimpleLog.Instance.Error("Input vertices are all identical.", "SweepLine.Triangulate()");
throw new Exception("Input vertices are all identical.");
}
secondvertex = eventheap[0].vertexEvent;
@@ -585,8 +584,8 @@ namespace TriangleNet.Algorithm
{
if (Behavior.Verbose)
{
SimpleLog.Instance.Warning("A duplicate vertex appeared and was ignored.",
"SweepLine.SweepLineDelaunay().1");
SimpleLog.Instance.Warning("A duplicate vertex appeared and was ignored (ID " + secondvertex.id + ").",
"SweepLine.Triangulate().1");
}
secondvertex.type = VertexType.UndeadVertex;
mesh.undeads++;
@@ -641,8 +640,8 @@ namespace TriangleNet.Algorithm
{
if (Behavior.Verbose)
{
SimpleLog.Instance.Warning("A duplicate vertex appeared and was ignored.",
"SweepLine.SweepLineDelaunay().2");
SimpleLog.Instance.Warning("A duplicate vertex appeared and was ignored (ID " + nextvertex.id + ").",
"SweepLine.Triangulate().2");
}
nextvertex.type = VertexType.UndeadVertex;
mesh.undeads++;
@@ -652,17 +651,15 @@ namespace TriangleNet.Algorithm
{
lastvertex = nextvertex;
splayroot = FrontLocate(splayroot, bottommost, nextvertex,
ref searchtri, ref farrightflag);
//
bottommost.Copy(ref searchtri);
farrightflag = false;
while (!farrightflag && RightOfHyperbola(ref searchtri, nextvertex))
{
searchtri.OnextSelf();
farrightflag = searchtri.Equal(bottommost);
}
splayroot = FrontLocate(splayroot, bottommost, nextvertex, ref searchtri, ref farrightflag);
//bottommost.Copy(ref searchtri);
//farrightflag = false;
//while (!farrightflag && RightOfHyperbola(ref searchtri, nextvertex))
//{
// searchtri.OnextSelf();
// farrightflag = searchtri.Equal(bottommost);
//}
Check4DeadEvent(ref searchtri, eventheap, ref heapsize);
+2 -1
View File
@@ -2705,7 +2705,8 @@ namespace TriangleNet
{
if (Behavior.Verbose)
{
logger.Warning("Endpoints of segments are coincident.", "Mesh.FormSkeleton()");
logger.Warning("Endpoints of segment (IDs " + end1 + "/" + end2 + ") are coincident.",
"Mesh.FormSkeleton()");
}
}
else
+1 -1
View File
@@ -4100,7 +4100,7 @@ namespace TriangleNet
if (ahead < 0.0)
{
// Turn around so that 'searchpoint' is to the left of the
// edge specified by 'searchtri'.
// edge specified by 'searchtri'.
searchtri.SymSelf();
searchtri.Copy(ref horiz);
intersect = mesh.locator.PreciseLocate(newvertex, ref horiz, false);
File diff suppressed because it is too large Load Diff