scripts
This commit is contained in:
@@ -0,0 +1,569 @@
|
||||
using System;
|
||||
using TriangleNet.Data;
|
||||
using TriangleNet.Log;
|
||||
|
||||
namespace TriangleNet.Algorithm
|
||||
{
|
||||
// Token: 0x0200003C RID: 60
|
||||
internal class Dwyer
|
||||
{
|
||||
// Token: 0x06000221 RID: 545 RVA: 0x00019578 File Offset: 0x00017778
|
||||
private void VertexSort(int left, int right)
|
||||
{
|
||||
int num = left;
|
||||
int num2 = right;
|
||||
if (right - left + 1 < 32)
|
||||
{
|
||||
for (int i = left + 1; i <= right; i++)
|
||||
{
|
||||
Vertex vertex = this.sortarray[i];
|
||||
int num3 = i - 1;
|
||||
while (num3 >= left && (this.sortarray[num3].x > vertex.x || (this.sortarray[num3].x == vertex.x && this.sortarray[num3].y > vertex.y)))
|
||||
{
|
||||
this.sortarray[num3 + 1] = this.sortarray[num3];
|
||||
num3--;
|
||||
}
|
||||
this.sortarray[num3 + 1] = vertex;
|
||||
}
|
||||
return;
|
||||
}
|
||||
int num4 = Dwyer.rand.Next(left, right);
|
||||
double x = this.sortarray[num4].x;
|
||||
double y = this.sortarray[num4].y;
|
||||
left--;
|
||||
right++;
|
||||
while (left < right)
|
||||
{
|
||||
do
|
||||
{
|
||||
left++;
|
||||
}
|
||||
while (left <= right && (this.sortarray[left].x < x || (this.sortarray[left].x == x && this.sortarray[left].y < y)));
|
||||
do
|
||||
{
|
||||
right--;
|
||||
}
|
||||
while (left <= right && (this.sortarray[right].x > x || (this.sortarray[right].x == x && this.sortarray[right].y > y)));
|
||||
if (left < right)
|
||||
{
|
||||
Vertex vertex2 = this.sortarray[left];
|
||||
this.sortarray[left] = this.sortarray[right];
|
||||
this.sortarray[right] = vertex2;
|
||||
}
|
||||
}
|
||||
if (left > num)
|
||||
{
|
||||
this.VertexSort(num, left);
|
||||
}
|
||||
if (num2 > right + 1)
|
||||
{
|
||||
this.VertexSort(right + 1, num2);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000222 RID: 546 RVA: 0x0001972C File Offset: 0x0001792C
|
||||
private void VertexMedian(int left, int right, int median, int axis)
|
||||
{
|
||||
int num = right - left + 1;
|
||||
int num2 = left;
|
||||
int num3 = right;
|
||||
if (num == 2)
|
||||
{
|
||||
if (this.sortarray[left][axis] > this.sortarray[right][axis] || (this.sortarray[left][axis] == this.sortarray[right][axis] && this.sortarray[left][1 - axis] > this.sortarray[right][1 - axis]))
|
||||
{
|
||||
Vertex vertex = this.sortarray[right];
|
||||
this.sortarray[right] = this.sortarray[left];
|
||||
this.sortarray[left] = vertex;
|
||||
}
|
||||
return;
|
||||
}
|
||||
int num4 = Dwyer.rand.Next(left, right);
|
||||
double num5 = this.sortarray[num4][axis];
|
||||
double num6 = this.sortarray[num4][1 - axis];
|
||||
left--;
|
||||
right++;
|
||||
while (left < right)
|
||||
{
|
||||
do
|
||||
{
|
||||
left++;
|
||||
}
|
||||
while (left <= right && (this.sortarray[left][axis] < num5 || (this.sortarray[left][axis] == num5 && this.sortarray[left][1 - axis] < num6)));
|
||||
do
|
||||
{
|
||||
right--;
|
||||
}
|
||||
while (left <= right && (this.sortarray[right][axis] > num5 || (this.sortarray[right][axis] == num5 && this.sortarray[right][1 - axis] > num6)));
|
||||
if (left < right)
|
||||
{
|
||||
Vertex vertex = this.sortarray[left];
|
||||
this.sortarray[left] = this.sortarray[right];
|
||||
this.sortarray[right] = vertex;
|
||||
}
|
||||
}
|
||||
if (left > median)
|
||||
{
|
||||
this.VertexMedian(num2, left - 1, median, axis);
|
||||
}
|
||||
if (right < median - 1)
|
||||
{
|
||||
this.VertexMedian(right + 1, num3, median, axis);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000223 RID: 547 RVA: 0x000198E8 File Offset: 0x00017AE8
|
||||
private void AlternateAxes(int left, int right, int axis)
|
||||
{
|
||||
int num = right - left + 1;
|
||||
int num2 = num >> 1;
|
||||
if (num <= 3)
|
||||
{
|
||||
axis = 0;
|
||||
}
|
||||
this.VertexMedian(left, right, left + num2, axis);
|
||||
if (num - num2 >= 2)
|
||||
{
|
||||
if (num2 >= 2)
|
||||
{
|
||||
this.AlternateAxes(left, left + num2 - 1, 1 - axis);
|
||||
}
|
||||
this.AlternateAxes(left + num2, right, 1 - axis);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000224 RID: 548 RVA: 0x00019938 File Offset: 0x00017B38
|
||||
private void MergeHulls(ref Otri farleft, ref Otri innerleft, ref Otri innerright, ref Otri farright, int axis)
|
||||
{
|
||||
Otri otri = default(Otri);
|
||||
Otri otri2 = default(Otri);
|
||||
Otri otri3 = default(Otri);
|
||||
Otri otri4 = default(Otri);
|
||||
Otri otri5 = default(Otri);
|
||||
Otri otri6 = default(Otri);
|
||||
Otri otri7 = default(Otri);
|
||||
Otri otri8 = default(Otri);
|
||||
Vertex vertex = innerleft.Dest();
|
||||
Vertex vertex2 = innerleft.Apex();
|
||||
Vertex vertex3 = innerright.Org();
|
||||
Vertex vertex4 = innerright.Apex();
|
||||
Vertex vertex5;
|
||||
Vertex vertex7;
|
||||
if (this.useDwyer && axis == 1)
|
||||
{
|
||||
vertex5 = farleft.Org();
|
||||
Vertex vertex6 = farleft.Apex();
|
||||
vertex7 = farright.Dest();
|
||||
Vertex vertex8 = farright.Apex();
|
||||
while (vertex6.y < vertex5.y)
|
||||
{
|
||||
farleft.LnextSelf();
|
||||
farleft.SymSelf();
|
||||
vertex5 = vertex6;
|
||||
vertex6 = farleft.Apex();
|
||||
}
|
||||
innerleft.Sym(ref otri7);
|
||||
Vertex vertex9 = otri7.Apex();
|
||||
while (vertex9.y > vertex.y)
|
||||
{
|
||||
otri7.Lnext(ref innerleft);
|
||||
vertex2 = vertex;
|
||||
vertex = vertex9;
|
||||
innerleft.Sym(ref otri7);
|
||||
vertex9 = otri7.Apex();
|
||||
}
|
||||
while (vertex4.y < vertex3.y)
|
||||
{
|
||||
innerright.LnextSelf();
|
||||
innerright.SymSelf();
|
||||
vertex3 = vertex4;
|
||||
vertex4 = innerright.Apex();
|
||||
}
|
||||
farright.Sym(ref otri7);
|
||||
vertex9 = otri7.Apex();
|
||||
while (vertex9.y > vertex7.y)
|
||||
{
|
||||
otri7.Lnext(ref farright);
|
||||
vertex7 = vertex9;
|
||||
farright.Sym(ref otri7);
|
||||
vertex9 = otri7.Apex();
|
||||
}
|
||||
}
|
||||
bool flag;
|
||||
do
|
||||
{
|
||||
flag = false;
|
||||
if (Primitives.CounterClockwise(vertex, vertex2, vertex3) > 0.0)
|
||||
{
|
||||
innerleft.LprevSelf();
|
||||
innerleft.SymSelf();
|
||||
vertex = vertex2;
|
||||
vertex2 = innerleft.Apex();
|
||||
flag = true;
|
||||
}
|
||||
if (Primitives.CounterClockwise(vertex4, vertex3, vertex) > 0.0)
|
||||
{
|
||||
innerright.LnextSelf();
|
||||
innerright.SymSelf();
|
||||
vertex3 = vertex4;
|
||||
vertex4 = innerright.Apex();
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
while (flag);
|
||||
innerleft.Sym(ref otri);
|
||||
innerright.Sym(ref otri2);
|
||||
this.mesh.MakeTriangle(ref otri8);
|
||||
otri8.Bond(ref innerleft);
|
||||
otri8.LnextSelf();
|
||||
otri8.Bond(ref innerright);
|
||||
otri8.LnextSelf();
|
||||
otri8.SetOrg(vertex3);
|
||||
otri8.SetDest(vertex);
|
||||
vertex5 = farleft.Org();
|
||||
if (vertex == vertex5)
|
||||
{
|
||||
otri8.Lnext(ref farleft);
|
||||
}
|
||||
vertex7 = farright.Dest();
|
||||
if (vertex3 == vertex7)
|
||||
{
|
||||
otri8.Lprev(ref farright);
|
||||
}
|
||||
Vertex vertex10 = vertex;
|
||||
Vertex vertex11 = vertex3;
|
||||
Vertex vertex12 = otri.Apex();
|
||||
Vertex vertex13 = otri2.Apex();
|
||||
for (;;)
|
||||
{
|
||||
bool flag2 = Primitives.CounterClockwise(vertex12, vertex10, vertex11) <= 0.0;
|
||||
bool flag3 = Primitives.CounterClockwise(vertex13, vertex10, vertex11) <= 0.0;
|
||||
if (flag2 && flag3)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!flag2)
|
||||
{
|
||||
otri.Lprev(ref otri3);
|
||||
otri3.SymSelf();
|
||||
Vertex vertex14 = otri3.Apex();
|
||||
if (vertex14 != null)
|
||||
{
|
||||
bool flag4 = Primitives.InCircle(vertex10, vertex11, vertex12, vertex14) > 0.0;
|
||||
while (flag4)
|
||||
{
|
||||
otri3.LnextSelf();
|
||||
otri3.Sym(ref otri5);
|
||||
otri3.LnextSelf();
|
||||
otri3.Sym(ref otri4);
|
||||
otri3.Bond(ref otri5);
|
||||
otri.Bond(ref otri4);
|
||||
otri.LnextSelf();
|
||||
otri.Sym(ref otri6);
|
||||
otri3.LprevSelf();
|
||||
otri3.Bond(ref otri6);
|
||||
otri.SetOrg(vertex10);
|
||||
otri.SetDest(null);
|
||||
otri.SetApex(vertex14);
|
||||
otri3.SetOrg(null);
|
||||
otri3.SetDest(vertex12);
|
||||
otri3.SetApex(vertex14);
|
||||
vertex12 = vertex14;
|
||||
otri4.Copy(ref otri3);
|
||||
vertex14 = otri3.Apex();
|
||||
flag4 = vertex14 != null && Primitives.InCircle(vertex10, vertex11, vertex12, vertex14) > 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag3)
|
||||
{
|
||||
otri2.Lnext(ref otri3);
|
||||
otri3.SymSelf();
|
||||
Vertex vertex14 = otri3.Apex();
|
||||
if (vertex14 != null)
|
||||
{
|
||||
bool flag4 = Primitives.InCircle(vertex10, vertex11, vertex13, vertex14) > 0.0;
|
||||
while (flag4)
|
||||
{
|
||||
otri3.LprevSelf();
|
||||
otri3.Sym(ref otri5);
|
||||
otri3.LprevSelf();
|
||||
otri3.Sym(ref otri4);
|
||||
otri3.Bond(ref otri5);
|
||||
otri2.Bond(ref otri4);
|
||||
otri2.LprevSelf();
|
||||
otri2.Sym(ref otri6);
|
||||
otri3.LnextSelf();
|
||||
otri3.Bond(ref otri6);
|
||||
otri2.SetOrg(null);
|
||||
otri2.SetDest(vertex11);
|
||||
otri2.SetApex(vertex14);
|
||||
otri3.SetOrg(vertex13);
|
||||
otri3.SetDest(null);
|
||||
otri3.SetApex(vertex14);
|
||||
vertex13 = vertex14;
|
||||
otri4.Copy(ref otri3);
|
||||
vertex14 = otri3.Apex();
|
||||
flag4 = vertex14 != null && Primitives.InCircle(vertex10, vertex11, vertex13, vertex14) > 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag2 || (!flag3 && Primitives.InCircle(vertex12, vertex10, vertex11, vertex13) > 0.0))
|
||||
{
|
||||
otri8.Bond(ref otri2);
|
||||
otri2.Lprev(ref otri8);
|
||||
otri8.SetDest(vertex10);
|
||||
vertex11 = vertex13;
|
||||
otri8.Sym(ref otri2);
|
||||
vertex13 = otri2.Apex();
|
||||
}
|
||||
else
|
||||
{
|
||||
otri8.Bond(ref otri);
|
||||
otri.Lnext(ref otri8);
|
||||
otri8.SetOrg(vertex11);
|
||||
vertex10 = vertex12;
|
||||
otri8.Sym(ref otri);
|
||||
vertex12 = otri.Apex();
|
||||
}
|
||||
}
|
||||
this.mesh.MakeTriangle(ref otri3);
|
||||
otri3.SetOrg(vertex10);
|
||||
otri3.SetDest(vertex11);
|
||||
otri3.Bond(ref otri8);
|
||||
otri3.LnextSelf();
|
||||
otri3.Bond(ref otri2);
|
||||
otri3.LnextSelf();
|
||||
otri3.Bond(ref otri);
|
||||
if (this.useDwyer && axis == 1)
|
||||
{
|
||||
vertex5 = farleft.Org();
|
||||
Vertex vertex6 = farleft.Apex();
|
||||
vertex7 = farright.Dest();
|
||||
Vertex vertex8 = farright.Apex();
|
||||
farleft.Sym(ref otri7);
|
||||
Vertex vertex9 = otri7.Apex();
|
||||
while (vertex9.x < vertex5.x)
|
||||
{
|
||||
otri7.Lprev(ref farleft);
|
||||
vertex5 = vertex9;
|
||||
farleft.Sym(ref otri7);
|
||||
vertex9 = otri7.Apex();
|
||||
}
|
||||
while (vertex8.x > vertex7.x)
|
||||
{
|
||||
farright.LprevSelf();
|
||||
farright.SymSelf();
|
||||
vertex7 = vertex8;
|
||||
vertex8 = farright.Apex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000225 RID: 549 RVA: 0x00019FAC File Offset: 0x000181AC
|
||||
private void DivconqRecurse(int left, int right, int axis, ref Otri farleft, ref Otri farright)
|
||||
{
|
||||
Otri otri = default(Otri);
|
||||
Otri otri2 = default(Otri);
|
||||
Otri otri3 = default(Otri);
|
||||
Otri otri4 = default(Otri);
|
||||
Otri otri5 = default(Otri);
|
||||
Otri otri6 = default(Otri);
|
||||
int num = right - left + 1;
|
||||
if (num == 2)
|
||||
{
|
||||
this.mesh.MakeTriangle(ref farleft);
|
||||
farleft.SetOrg(this.sortarray[left]);
|
||||
farleft.SetDest(this.sortarray[left + 1]);
|
||||
this.mesh.MakeTriangle(ref farright);
|
||||
farright.SetOrg(this.sortarray[left + 1]);
|
||||
farright.SetDest(this.sortarray[left]);
|
||||
farleft.Bond(ref farright);
|
||||
farleft.LprevSelf();
|
||||
farright.LnextSelf();
|
||||
farleft.Bond(ref farright);
|
||||
farleft.LprevSelf();
|
||||
farright.LnextSelf();
|
||||
farleft.Bond(ref farright);
|
||||
farright.Lprev(ref farleft);
|
||||
return;
|
||||
}
|
||||
if (num != 3)
|
||||
{
|
||||
int num2 = num >> 1;
|
||||
this.DivconqRecurse(left, left + num2 - 1, 1 - axis, ref farleft, ref otri5);
|
||||
this.DivconqRecurse(left + num2, right, 1 - axis, ref otri6, ref farright);
|
||||
this.MergeHulls(ref farleft, ref otri5, ref otri6, ref farright, axis);
|
||||
return;
|
||||
}
|
||||
this.mesh.MakeTriangle(ref otri);
|
||||
this.mesh.MakeTriangle(ref otri2);
|
||||
this.mesh.MakeTriangle(ref otri3);
|
||||
this.mesh.MakeTriangle(ref otri4);
|
||||
double num3 = Primitives.CounterClockwise(this.sortarray[left], this.sortarray[left + 1], this.sortarray[left + 2]);
|
||||
if (num3 == 0.0)
|
||||
{
|
||||
otri.SetOrg(this.sortarray[left]);
|
||||
otri.SetDest(this.sortarray[left + 1]);
|
||||
otri2.SetOrg(this.sortarray[left + 1]);
|
||||
otri2.SetDest(this.sortarray[left]);
|
||||
otri3.SetOrg(this.sortarray[left + 2]);
|
||||
otri3.SetDest(this.sortarray[left + 1]);
|
||||
otri4.SetOrg(this.sortarray[left + 1]);
|
||||
otri4.SetDest(this.sortarray[left + 2]);
|
||||
otri.Bond(ref otri2);
|
||||
otri3.Bond(ref otri4);
|
||||
otri.LnextSelf();
|
||||
otri2.LprevSelf();
|
||||
otri3.LnextSelf();
|
||||
otri4.LprevSelf();
|
||||
otri.Bond(ref otri4);
|
||||
otri2.Bond(ref otri3);
|
||||
otri.LnextSelf();
|
||||
otri2.LprevSelf();
|
||||
otri3.LnextSelf();
|
||||
otri4.LprevSelf();
|
||||
otri.Bond(ref otri2);
|
||||
otri3.Bond(ref otri4);
|
||||
otri2.Copy(ref farleft);
|
||||
otri3.Copy(ref farright);
|
||||
return;
|
||||
}
|
||||
otri.SetOrg(this.sortarray[left]);
|
||||
otri2.SetDest(this.sortarray[left]);
|
||||
otri4.SetOrg(this.sortarray[left]);
|
||||
if (num3 > 0.0)
|
||||
{
|
||||
otri.SetDest(this.sortarray[left + 1]);
|
||||
otri2.SetOrg(this.sortarray[left + 1]);
|
||||
otri3.SetDest(this.sortarray[left + 1]);
|
||||
otri.SetApex(this.sortarray[left + 2]);
|
||||
otri3.SetOrg(this.sortarray[left + 2]);
|
||||
otri4.SetDest(this.sortarray[left + 2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
otri.SetDest(this.sortarray[left + 2]);
|
||||
otri2.SetOrg(this.sortarray[left + 2]);
|
||||
otri3.SetDest(this.sortarray[left + 2]);
|
||||
otri.SetApex(this.sortarray[left + 1]);
|
||||
otri3.SetOrg(this.sortarray[left + 1]);
|
||||
otri4.SetDest(this.sortarray[left + 1]);
|
||||
}
|
||||
otri.Bond(ref otri2);
|
||||
otri.LnextSelf();
|
||||
otri.Bond(ref otri3);
|
||||
otri.LnextSelf();
|
||||
otri.Bond(ref otri4);
|
||||
otri2.LprevSelf();
|
||||
otri3.LnextSelf();
|
||||
otri2.Bond(ref otri3);
|
||||
otri2.LprevSelf();
|
||||
otri4.LprevSelf();
|
||||
otri2.Bond(ref otri4);
|
||||
otri3.LnextSelf();
|
||||
otri4.LprevSelf();
|
||||
otri3.Bond(ref otri4);
|
||||
otri2.Copy(ref farleft);
|
||||
if (num3 > 0.0)
|
||||
{
|
||||
otri3.Copy(ref farright);
|
||||
return;
|
||||
}
|
||||
farleft.Lnext(ref farright);
|
||||
}
|
||||
|
||||
// Token: 0x06000226 RID: 550 RVA: 0x0001A3E4 File Offset: 0x000185E4
|
||||
private int RemoveGhosts(ref Otri startghost)
|
||||
{
|
||||
Otri otri = default(Otri);
|
||||
Otri otri2 = default(Otri);
|
||||
Otri otri3 = default(Otri);
|
||||
bool flag = !this.mesh.behavior.Poly;
|
||||
startghost.Lprev(ref otri);
|
||||
otri.SymSelf();
|
||||
Mesh.dummytri.neighbors[0] = otri;
|
||||
startghost.Copy(ref otri2);
|
||||
int num = 0;
|
||||
do
|
||||
{
|
||||
num++;
|
||||
otri2.Lnext(ref otri3);
|
||||
otri2.LprevSelf();
|
||||
otri2.SymSelf();
|
||||
if (flag && otri2.triangle != Mesh.dummytri)
|
||||
{
|
||||
Vertex vertex = otri2.Org();
|
||||
if (vertex.mark == 0)
|
||||
{
|
||||
vertex.mark = 1;
|
||||
}
|
||||
}
|
||||
otri2.Dissolve();
|
||||
otri3.Sym(ref otri2);
|
||||
this.mesh.TriangleDealloc(otri3.triangle);
|
||||
}
|
||||
while (!otri2.Equal(startghost));
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000227 RID: 551 RVA: 0x0001A4C0 File Offset: 0x000186C0
|
||||
public int Triangulate(Mesh m)
|
||||
{
|
||||
Otri otri = default(Otri);
|
||||
Otri otri2 = default(Otri);
|
||||
this.mesh = m;
|
||||
this.sortarray = new Vertex[m.invertices];
|
||||
int num = 0;
|
||||
foreach (Vertex vertex in m.vertices.Values)
|
||||
{
|
||||
this.sortarray[num++] = vertex;
|
||||
}
|
||||
this.VertexSort(0, m.invertices - 1);
|
||||
num = 0;
|
||||
for (int i = 1; i < m.invertices; i++)
|
||||
{
|
||||
if (this.sortarray[num].x == this.sortarray[i].x && this.sortarray[num].y == this.sortarray[i].y)
|
||||
{
|
||||
if (Behavior.Verbose)
|
||||
{
|
||||
SimpleLog.Instance.Warning(string.Format("A duplicate vertex appeared and was ignored (ID {0}).", this.sortarray[i].hash), "DivConquer.DivconqDelaunay()");
|
||||
}
|
||||
this.sortarray[i].type = VertexType.UndeadVertex;
|
||||
m.undeads++;
|
||||
}
|
||||
else
|
||||
{
|
||||
num++;
|
||||
this.sortarray[num] = this.sortarray[i];
|
||||
}
|
||||
}
|
||||
num++;
|
||||
if (this.useDwyer)
|
||||
{
|
||||
int num2 = num >> 1;
|
||||
if (num - num2 >= 2)
|
||||
{
|
||||
if (num2 >= 2)
|
||||
{
|
||||
this.AlternateAxes(0, num2 - 1, 1);
|
||||
}
|
||||
this.AlternateAxes(num2, num - 1, 1);
|
||||
}
|
||||
}
|
||||
this.DivconqRecurse(0, num - 1, 0, ref otri, ref otri2);
|
||||
return this.RemoveGhosts(ref otri);
|
||||
}
|
||||
|
||||
// Token: 0x0400012C RID: 300
|
||||
private static Random rand = new Random(DateTime.Now.Millisecond);
|
||||
|
||||
// Token: 0x0400012D RID: 301
|
||||
private bool useDwyer = true;
|
||||
|
||||
// Token: 0x0400012E RID: 302
|
||||
private Vertex[] sortarray;
|
||||
|
||||
// Token: 0x0400012F RID: 303
|
||||
private Mesh mesh;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace TriangleNet.Algorithm
|
||||
{
|
||||
// Token: 0x0200003B RID: 59
|
||||
public interface ITriangulator
|
||||
{
|
||||
// Token: 0x06000220 RID: 544
|
||||
int Triangulate(Mesh mesh);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using TriangleNet.Data;
|
||||
using TriangleNet.Geometry;
|
||||
using TriangleNet.Log;
|
||||
|
||||
namespace TriangleNet.Algorithm
|
||||
{
|
||||
// Token: 0x0200003D RID: 61
|
||||
internal class Incremental
|
||||
{
|
||||
// Token: 0x0600022A RID: 554 RVA: 0x0001A694 File Offset: 0x00018894
|
||||
private void GetBoundingBox()
|
||||
{
|
||||
Otri otri = default(Otri);
|
||||
BoundingBox bounds = this.mesh.bounds;
|
||||
double num = bounds.Width;
|
||||
if (bounds.Height > num)
|
||||
{
|
||||
num = bounds.Height;
|
||||
}
|
||||
if (num == 0.0)
|
||||
{
|
||||
num = 1.0;
|
||||
}
|
||||
this.mesh.infvertex1 = new Vertex(bounds.MinX - 50.0 * num, bounds.MinY - 40.0 * num);
|
||||
this.mesh.infvertex2 = new Vertex(bounds.MaxX + 50.0 * num, bounds.MinY - 40.0 * num);
|
||||
this.mesh.infvertex3 = new Vertex(0.5 * (bounds.MinX + bounds.MaxX), bounds.MaxY + 60.0 * num);
|
||||
this.mesh.MakeTriangle(ref otri);
|
||||
otri.SetOrg(this.mesh.infvertex1);
|
||||
otri.SetDest(this.mesh.infvertex2);
|
||||
otri.SetApex(this.mesh.infvertex3);
|
||||
Mesh.dummytri.neighbors[0] = otri;
|
||||
}
|
||||
|
||||
// Token: 0x0600022B RID: 555 RVA: 0x0001A7D8 File Offset: 0x000189D8
|
||||
private int RemoveBox()
|
||||
{
|
||||
Otri otri = default(Otri);
|
||||
Otri otri2 = default(Otri);
|
||||
Otri otri3 = default(Otri);
|
||||
Otri otri4 = default(Otri);
|
||||
Otri otri5 = default(Otri);
|
||||
Otri otri6 = default(Otri);
|
||||
bool flag = !this.mesh.behavior.Poly;
|
||||
otri4.triangle = Mesh.dummytri;
|
||||
otri4.orient = 0;
|
||||
otri4.SymSelf();
|
||||
otri4.Lprev(ref otri5);
|
||||
otri4.LnextSelf();
|
||||
otri4.SymSelf();
|
||||
otri4.Lprev(ref otri2);
|
||||
otri2.SymSelf();
|
||||
otri4.Lnext(ref otri3);
|
||||
otri3.SymSelf();
|
||||
if (otri3.triangle == Mesh.dummytri)
|
||||
{
|
||||
otri2.LprevSelf();
|
||||
otri2.SymSelf();
|
||||
}
|
||||
Mesh.dummytri.neighbors[0] = otri2;
|
||||
int num = -2;
|
||||
while (!otri4.Equal(otri5))
|
||||
{
|
||||
num++;
|
||||
otri4.Lprev(ref otri6);
|
||||
otri6.SymSelf();
|
||||
if (flag && otri6.triangle != Mesh.dummytri)
|
||||
{
|
||||
Vertex vertex = otri6.Org();
|
||||
if (vertex.mark == 0)
|
||||
{
|
||||
vertex.mark = 1;
|
||||
}
|
||||
}
|
||||
otri6.Dissolve();
|
||||
otri4.Lnext(ref otri);
|
||||
otri.Sym(ref otri4);
|
||||
this.mesh.TriangleDealloc(otri.triangle);
|
||||
if (otri4.triangle == Mesh.dummytri)
|
||||
{
|
||||
otri6.Copy(ref otri4);
|
||||
}
|
||||
}
|
||||
this.mesh.TriangleDealloc(otri5.triangle);
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x0600022C RID: 556 RVA: 0x0001A958 File Offset: 0x00018B58
|
||||
public int Triangulate(Mesh mesh)
|
||||
{
|
||||
this.mesh = mesh;
|
||||
Otri otri = default(Otri);
|
||||
this.GetBoundingBox();
|
||||
foreach (Vertex vertex in mesh.vertices.Values)
|
||||
{
|
||||
otri.triangle = Mesh.dummytri;
|
||||
Osub osub = default(Osub);
|
||||
if (mesh.InsertVertex(vertex, ref otri, ref osub, false, false) == InsertVertexResult.Duplicate)
|
||||
{
|
||||
if (Behavior.Verbose)
|
||||
{
|
||||
SimpleLog.Instance.Warning("A duplicate vertex appeared and was ignored.", "Incremental.IncrementalDelaunay()");
|
||||
}
|
||||
vertex.type = VertexType.UndeadVertex;
|
||||
mesh.undeads++;
|
||||
}
|
||||
}
|
||||
return this.RemoveBox();
|
||||
}
|
||||
|
||||
// Token: 0x04000130 RID: 304
|
||||
private Mesh mesh;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,651 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TriangleNet.Data;
|
||||
using TriangleNet.Geometry;
|
||||
using TriangleNet.Log;
|
||||
using TriangleNet.Tools;
|
||||
|
||||
namespace TriangleNet.Algorithm
|
||||
{
|
||||
// Token: 0x0200003E RID: 62
|
||||
internal class SweepLine
|
||||
{
|
||||
// Token: 0x0600022E RID: 558 RVA: 0x0001AA18 File Offset: 0x00018C18
|
||||
private int randomnation(int choices)
|
||||
{
|
||||
SweepLine.randomseed = (SweepLine.randomseed * 1366 + 150889) % 714025;
|
||||
return SweepLine.randomseed / (714025 / choices + 1);
|
||||
}
|
||||
|
||||
// Token: 0x0600022F RID: 559 RVA: 0x0001AA48 File Offset: 0x00018C48
|
||||
private void HeapInsert(SweepLine.SweepEvent[] heap, int heapsize, SweepLine.SweepEvent newevent)
|
||||
{
|
||||
double xkey = newevent.xkey;
|
||||
double ykey = newevent.ykey;
|
||||
int num = heapsize;
|
||||
bool flag = num > 0;
|
||||
while (flag)
|
||||
{
|
||||
int num2 = num - 1 >> 1;
|
||||
if (heap[num2].ykey < ykey || (heap[num2].ykey == ykey && heap[num2].xkey <= xkey))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
heap[num] = heap[num2];
|
||||
heap[num].heapposition = num;
|
||||
num = num2;
|
||||
flag = num > 0;
|
||||
}
|
||||
}
|
||||
heap[num] = newevent;
|
||||
newevent.heapposition = num;
|
||||
}
|
||||
|
||||
// Token: 0x06000230 RID: 560 RVA: 0x0001AAC0 File Offset: 0x00018CC0
|
||||
private void Heapify(SweepLine.SweepEvent[] heap, int heapsize, int eventnum)
|
||||
{
|
||||
SweepLine.SweepEvent sweepEvent = heap[eventnum];
|
||||
double xkey = sweepEvent.xkey;
|
||||
double ykey = sweepEvent.ykey;
|
||||
int num = 2 * eventnum + 1;
|
||||
bool flag = num < heapsize;
|
||||
while (flag)
|
||||
{
|
||||
int num2;
|
||||
if (heap[num].ykey < ykey || (heap[num].ykey == ykey && heap[num].xkey < xkey))
|
||||
{
|
||||
num2 = num;
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = eventnum;
|
||||
}
|
||||
int num3 = num + 1;
|
||||
if (num3 < heapsize && (heap[num3].ykey < heap[num2].ykey || (heap[num3].ykey == heap[num2].ykey && heap[num3].xkey < heap[num2].xkey)))
|
||||
{
|
||||
num2 = num3;
|
||||
}
|
||||
if (num2 == eventnum)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
heap[eventnum] = heap[num2];
|
||||
heap[eventnum].heapposition = eventnum;
|
||||
heap[num2] = sweepEvent;
|
||||
sweepEvent.heapposition = num2;
|
||||
eventnum = num2;
|
||||
num = 2 * eventnum + 1;
|
||||
flag = num < heapsize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000231 RID: 561 RVA: 0x0001ABA4 File Offset: 0x00018DA4
|
||||
private void HeapDelete(SweepLine.SweepEvent[] heap, int heapsize, int eventnum)
|
||||
{
|
||||
SweepLine.SweepEvent sweepEvent = heap[heapsize - 1];
|
||||
if (eventnum > 0)
|
||||
{
|
||||
double xkey = sweepEvent.xkey;
|
||||
double ykey = sweepEvent.ykey;
|
||||
bool flag;
|
||||
do
|
||||
{
|
||||
int num = eventnum - 1 >> 1;
|
||||
if (heap[num].ykey < ykey || (heap[num].ykey == ykey && heap[num].xkey <= xkey))
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
heap[eventnum] = heap[num];
|
||||
heap[eventnum].heapposition = eventnum;
|
||||
eventnum = num;
|
||||
flag = eventnum > 0;
|
||||
}
|
||||
}
|
||||
while (flag);
|
||||
}
|
||||
heap[eventnum] = sweepEvent;
|
||||
sweepEvent.heapposition = eventnum;
|
||||
this.Heapify(heap, heapsize - 1, eventnum);
|
||||
}
|
||||
|
||||
// Token: 0x06000232 RID: 562 RVA: 0x0001AC28 File Offset: 0x00018E28
|
||||
private void CreateHeap(out SweepLine.SweepEvent[] eventheap)
|
||||
{
|
||||
int num = 3 * this.mesh.invertices / 2;
|
||||
eventheap = new SweepLine.SweepEvent[num];
|
||||
int num2 = 0;
|
||||
foreach (Vertex vertex in this.mesh.vertices.Values)
|
||||
{
|
||||
SweepLine.SweepEvent sweepEvent = new SweepLine.SweepEvent();
|
||||
sweepEvent.vertexEvent = vertex;
|
||||
sweepEvent.xkey = vertex.x;
|
||||
sweepEvent.ykey = vertex.y;
|
||||
this.HeapInsert(eventheap, num2++, sweepEvent);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000233 RID: 563 RVA: 0x0001ACCC File Offset: 0x00018ECC
|
||||
private SweepLine.SplayNode Splay(SweepLine.SplayNode splaytree, Point searchpoint, ref Otri searchtri)
|
||||
{
|
||||
if (splaytree == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (splaytree.keyedge.Dest() == splaytree.keydest)
|
||||
{
|
||||
bool flag = this.RightOfHyperbola(ref splaytree.keyedge, searchpoint);
|
||||
SweepLine.SplayNode splayNode;
|
||||
if (flag)
|
||||
{
|
||||
splaytree.keyedge.Copy(ref searchtri);
|
||||
splayNode = splaytree.rchild;
|
||||
}
|
||||
else
|
||||
{
|
||||
splayNode = splaytree.lchild;
|
||||
}
|
||||
if (splayNode == null)
|
||||
{
|
||||
return splaytree;
|
||||
}
|
||||
if (splayNode.keyedge.Dest() != splayNode.keydest)
|
||||
{
|
||||
splayNode = this.Splay(splayNode, searchpoint, ref searchtri);
|
||||
if (splayNode == null)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
splaytree.rchild = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
splaytree.lchild = null;
|
||||
}
|
||||
return splaytree;
|
||||
}
|
||||
}
|
||||
bool flag2 = this.RightOfHyperbola(ref splayNode.keyedge, searchpoint);
|
||||
SweepLine.SplayNode splayNode2;
|
||||
if (flag2)
|
||||
{
|
||||
splayNode.keyedge.Copy(ref searchtri);
|
||||
splayNode2 = this.Splay(splayNode.rchild, searchpoint, ref searchtri);
|
||||
splayNode.rchild = splayNode2;
|
||||
}
|
||||
else
|
||||
{
|
||||
splayNode2 = this.Splay(splayNode.lchild, searchpoint, ref searchtri);
|
||||
splayNode.lchild = splayNode2;
|
||||
}
|
||||
if (splayNode2 == null)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
splaytree.rchild = splayNode.lchild;
|
||||
splayNode.lchild = splaytree;
|
||||
}
|
||||
else
|
||||
{
|
||||
splaytree.lchild = splayNode.rchild;
|
||||
splayNode.rchild = splaytree;
|
||||
}
|
||||
return splayNode;
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
splaytree.rchild = splayNode.lchild;
|
||||
splayNode.lchild = splaytree;
|
||||
}
|
||||
else
|
||||
{
|
||||
splaytree.lchild = splayNode2.rchild;
|
||||
splayNode2.rchild = splaytree;
|
||||
}
|
||||
splayNode.rchild = splayNode2.lchild;
|
||||
splayNode2.lchild = splayNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
splaytree.rchild = splayNode2.lchild;
|
||||
splayNode2.lchild = splaytree;
|
||||
}
|
||||
else
|
||||
{
|
||||
splaytree.lchild = splayNode.rchild;
|
||||
splayNode.rchild = splaytree;
|
||||
}
|
||||
splayNode.lchild = splayNode2.rchild;
|
||||
splayNode2.rchild = splayNode;
|
||||
}
|
||||
return splayNode2;
|
||||
}
|
||||
else
|
||||
{
|
||||
SweepLine.SplayNode splayNode3 = this.Splay(splaytree.lchild, searchpoint, ref searchtri);
|
||||
SweepLine.SplayNode splayNode4 = this.Splay(splaytree.rchild, searchpoint, ref searchtri);
|
||||
this.splaynodes.Remove(splaytree);
|
||||
if (splayNode3 == null)
|
||||
{
|
||||
return splayNode4;
|
||||
}
|
||||
if (splayNode4 == null)
|
||||
{
|
||||
return splayNode3;
|
||||
}
|
||||
if (splayNode3.rchild == null)
|
||||
{
|
||||
splayNode3.rchild = splayNode4.lchild;
|
||||
splayNode4.lchild = splayNode3;
|
||||
return splayNode4;
|
||||
}
|
||||
if (splayNode4.lchild == null)
|
||||
{
|
||||
splayNode4.lchild = splayNode3.rchild;
|
||||
splayNode3.rchild = splayNode4;
|
||||
return splayNode3;
|
||||
}
|
||||
SweepLine.SplayNode splayNode5 = splayNode3.rchild;
|
||||
while (splayNode5.rchild != null)
|
||||
{
|
||||
splayNode5 = splayNode5.rchild;
|
||||
}
|
||||
splayNode5.rchild = splayNode4;
|
||||
return splayNode3;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000234 RID: 564 RVA: 0x0001AF00 File Offset: 0x00019100
|
||||
private SweepLine.SplayNode SplayInsert(SweepLine.SplayNode splayroot, Otri newkey, Point searchpoint)
|
||||
{
|
||||
SweepLine.SplayNode splayNode = new SweepLine.SplayNode();
|
||||
this.splaynodes.Add(splayNode);
|
||||
newkey.Copy(ref splayNode.keyedge);
|
||||
splayNode.keydest = newkey.Dest();
|
||||
if (splayroot == null)
|
||||
{
|
||||
splayNode.lchild = null;
|
||||
splayNode.rchild = null;
|
||||
}
|
||||
else if (this.RightOfHyperbola(ref splayroot.keyedge, searchpoint))
|
||||
{
|
||||
splayNode.lchild = splayroot;
|
||||
splayNode.rchild = splayroot.rchild;
|
||||
splayroot.rchild = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
splayNode.lchild = splayroot.lchild;
|
||||
splayNode.rchild = splayroot;
|
||||
splayroot.lchild = null;
|
||||
}
|
||||
return splayNode;
|
||||
}
|
||||
|
||||
// Token: 0x06000235 RID: 565 RVA: 0x0001AF94 File Offset: 0x00019194
|
||||
private SweepLine.SplayNode FrontLocate(SweepLine.SplayNode splayroot, Otri bottommost, Vertex searchvertex, ref Otri searchtri, ref bool farright)
|
||||
{
|
||||
bottommost.Copy(ref searchtri);
|
||||
splayroot = this.Splay(splayroot, searchvertex, ref searchtri);
|
||||
bool flag = false;
|
||||
while (!flag && this.RightOfHyperbola(ref searchtri, searchvertex))
|
||||
{
|
||||
searchtri.OnextSelf();
|
||||
flag = searchtri.Equal(bottommost);
|
||||
}
|
||||
farright = flag;
|
||||
return splayroot;
|
||||
}
|
||||
|
||||
// Token: 0x06000236 RID: 566 RVA: 0x0001AFE0 File Offset: 0x000191E0
|
||||
private SweepLine.SplayNode CircleTopInsert(SweepLine.SplayNode splayroot, Otri newkey, Vertex pa, Vertex pb, Vertex pc, double topy)
|
||||
{
|
||||
Point point = new Point();
|
||||
Otri otri = default(Otri);
|
||||
double num = Primitives.CounterClockwise(pa, pb, pc);
|
||||
double num2 = pa.x - pc.x;
|
||||
double num3 = pa.y - pc.y;
|
||||
double num4 = pb.x - pc.x;
|
||||
double num5 = pb.y - pc.y;
|
||||
double num6 = num2 * num2 + num3 * num3;
|
||||
double num7 = num4 * num4 + num5 * num5;
|
||||
point.x = pc.x - (num3 * num7 - num5 * num6) / (2.0 * num);
|
||||
point.y = topy;
|
||||
return this.SplayInsert(this.Splay(splayroot, point, ref otri), newkey, point);
|
||||
}
|
||||
|
||||
// Token: 0x06000237 RID: 567 RVA: 0x0001B098 File Offset: 0x00019298
|
||||
private bool RightOfHyperbola(ref Otri fronttri, Point newsite)
|
||||
{
|
||||
Statistic.HyperbolaCount += 1L;
|
||||
Vertex vertex = fronttri.Dest();
|
||||
Vertex vertex2 = fronttri.Apex();
|
||||
if (vertex.y < vertex2.y || (vertex.y == vertex2.y && vertex.x < vertex2.x))
|
||||
{
|
||||
if (newsite.x >= vertex2.x)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (newsite.x <= vertex.x)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
double num = vertex.x - newsite.x;
|
||||
double num2 = vertex.y - newsite.y;
|
||||
double num3 = vertex2.x - newsite.x;
|
||||
double num4 = vertex2.y - newsite.y;
|
||||
return num2 * (num3 * num3 + num4 * num4) > num4 * (num * num + num2 * num2);
|
||||
}
|
||||
|
||||
// Token: 0x06000238 RID: 568 RVA: 0x0001B160 File Offset: 0x00019360
|
||||
private double CircleTop(Vertex pa, Vertex pb, Vertex pc, double ccwabc)
|
||||
{
|
||||
Statistic.CircleTopCount += 1L;
|
||||
double num = pa.x - pc.x;
|
||||
double num2 = pa.y - pc.y;
|
||||
double num3 = pb.x - pc.x;
|
||||
double num4 = pb.y - pc.y;
|
||||
double num5 = pa.x - pb.x;
|
||||
double num6 = pa.y - pb.y;
|
||||
double num7 = num * num + num2 * num2;
|
||||
double num8 = num3 * num3 + num4 * num4;
|
||||
double num9 = num5 * num5 + num6 * num6;
|
||||
return pc.y + (num * num8 - num3 * num7 + Math.Sqrt(num7 * num8 * num9)) / (2.0 * ccwabc);
|
||||
}
|
||||
|
||||
// Token: 0x06000239 RID: 569 RVA: 0x0001B218 File Offset: 0x00019418
|
||||
private void Check4DeadEvent(ref Otri checktri, SweepLine.SweepEvent[] eventheap, ref int heapsize)
|
||||
{
|
||||
SweepLine.SweepEventVertex sweepEventVertex = checktri.Org() as SweepLine.SweepEventVertex;
|
||||
if (sweepEventVertex != null)
|
||||
{
|
||||
int heapposition = sweepEventVertex.evt.heapposition;
|
||||
this.HeapDelete(eventheap, heapsize, heapposition);
|
||||
heapsize--;
|
||||
checktri.SetOrg(null);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600023A RID: 570 RVA: 0x0001B260 File Offset: 0x00019460
|
||||
private int RemoveGhosts(ref Otri startghost)
|
||||
{
|
||||
Otri otri = default(Otri);
|
||||
Otri otri2 = default(Otri);
|
||||
Otri otri3 = default(Otri);
|
||||
bool flag = !this.mesh.behavior.Poly;
|
||||
startghost.Lprev(ref otri);
|
||||
otri.SymSelf();
|
||||
Mesh.dummytri.neighbors[0] = otri;
|
||||
startghost.Copy(ref otri2);
|
||||
int num = 0;
|
||||
do
|
||||
{
|
||||
num++;
|
||||
otri2.Lnext(ref otri3);
|
||||
otri2.LprevSelf();
|
||||
otri2.SymSelf();
|
||||
if (flag && otri2.triangle != Mesh.dummytri)
|
||||
{
|
||||
Vertex vertex = otri2.Org();
|
||||
if (vertex.mark == 0)
|
||||
{
|
||||
vertex.mark = 1;
|
||||
}
|
||||
}
|
||||
otri2.Dissolve();
|
||||
otri3.Sym(ref otri2);
|
||||
this.mesh.TriangleDealloc(otri3.triangle);
|
||||
}
|
||||
while (!otri2.Equal(startghost));
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x0600023B RID: 571 RVA: 0x0001B33C File Offset: 0x0001953C
|
||||
public int Triangulate(Mesh mesh)
|
||||
{
|
||||
this.mesh = mesh;
|
||||
this.xminextreme = 10.0 * mesh.bounds.MinX - 9.0 * mesh.bounds.MaxX;
|
||||
Otri otri = default(Otri);
|
||||
Otri otri2 = default(Otri);
|
||||
Otri otri3 = default(Otri);
|
||||
Otri otri4 = default(Otri);
|
||||
Otri otri5 = default(Otri);
|
||||
Otri otri6 = default(Otri);
|
||||
Otri otri7 = default(Otri);
|
||||
bool flag = false;
|
||||
this.splaynodes = new List<SweepLine.SplayNode>();
|
||||
SweepLine.SplayNode splayNode = null;
|
||||
SweepLine.SweepEvent[] array;
|
||||
this.CreateHeap(out array);
|
||||
int i = mesh.invertices;
|
||||
mesh.MakeTriangle(ref otri3);
|
||||
mesh.MakeTriangle(ref otri4);
|
||||
otri3.Bond(ref otri4);
|
||||
otri3.LnextSelf();
|
||||
otri4.LprevSelf();
|
||||
otri3.Bond(ref otri4);
|
||||
otri3.LnextSelf();
|
||||
otri4.LprevSelf();
|
||||
otri3.Bond(ref otri4);
|
||||
Vertex vertexEvent = array[0].vertexEvent;
|
||||
this.HeapDelete(array, i, 0);
|
||||
i--;
|
||||
while (i != 0)
|
||||
{
|
||||
Vertex vertexEvent2 = array[0].vertexEvent;
|
||||
this.HeapDelete(array, i, 0);
|
||||
i--;
|
||||
if (vertexEvent.x == vertexEvent2.x && vertexEvent.y == vertexEvent2.y)
|
||||
{
|
||||
if (Behavior.Verbose)
|
||||
{
|
||||
SimpleLog.Instance.Warning("A duplicate vertex appeared and was ignored (ID " + vertexEvent2.id + ").", "SweepLine.Triangulate().1");
|
||||
}
|
||||
vertexEvent2.type = VertexType.UndeadVertex;
|
||||
mesh.undeads++;
|
||||
}
|
||||
if (vertexEvent.x != vertexEvent2.x || vertexEvent.y != vertexEvent2.y)
|
||||
{
|
||||
otri3.SetOrg(vertexEvent);
|
||||
otri3.SetDest(vertexEvent2);
|
||||
otri4.SetOrg(vertexEvent2);
|
||||
otri4.SetDest(vertexEvent);
|
||||
otri3.Lprev(ref otri);
|
||||
Vertex vertex = vertexEvent2;
|
||||
while (i > 0)
|
||||
{
|
||||
SweepLine.SweepEvent sweepEvent = array[0];
|
||||
this.HeapDelete(array, i, 0);
|
||||
i--;
|
||||
bool flag2 = true;
|
||||
if (sweepEvent.xkey < mesh.bounds.MinX)
|
||||
{
|
||||
Otri otriEvent = sweepEvent.otriEvent;
|
||||
otriEvent.Oprev(ref otri5);
|
||||
this.Check4DeadEvent(ref otri5, array, ref i);
|
||||
otriEvent.Onext(ref otri6);
|
||||
this.Check4DeadEvent(ref otri6, array, ref i);
|
||||
if (otri5.Equal(otri))
|
||||
{
|
||||
otriEvent.Lprev(ref otri);
|
||||
}
|
||||
mesh.Flip(ref otriEvent);
|
||||
otriEvent.SetApex(null);
|
||||
otriEvent.Lprev(ref otri3);
|
||||
otriEvent.Lnext(ref otri4);
|
||||
otri3.Sym(ref otri5);
|
||||
if (this.randomnation(SweepLine.SAMPLERATE) == 0)
|
||||
{
|
||||
otriEvent.SymSelf();
|
||||
Vertex vertex2 = otriEvent.Dest();
|
||||
Vertex vertex3 = otriEvent.Apex();
|
||||
Vertex vertex4 = otriEvent.Org();
|
||||
splayNode = this.CircleTopInsert(splayNode, otri3, vertex2, vertex3, vertex4, sweepEvent.ykey);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Vertex vertexEvent3 = sweepEvent.vertexEvent;
|
||||
if (vertexEvent3.x == vertex.x && vertexEvent3.y == vertex.y)
|
||||
{
|
||||
if (Behavior.Verbose)
|
||||
{
|
||||
SimpleLog.Instance.Warning("A duplicate vertex appeared and was ignored (ID " + vertexEvent3.id + ").", "SweepLine.Triangulate().2");
|
||||
}
|
||||
vertexEvent3.type = VertexType.UndeadVertex;
|
||||
mesh.undeads++;
|
||||
flag2 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
vertex = vertexEvent3;
|
||||
splayNode = this.FrontLocate(splayNode, otri, vertexEvent3, ref otri2, ref flag);
|
||||
this.Check4DeadEvent(ref otri2, array, ref i);
|
||||
otri2.Copy(ref otri6);
|
||||
otri2.Sym(ref otri5);
|
||||
mesh.MakeTriangle(ref otri3);
|
||||
mesh.MakeTriangle(ref otri4);
|
||||
Vertex vertex5 = otri6.Dest();
|
||||
otri3.SetOrg(vertex5);
|
||||
otri3.SetDest(vertexEvent3);
|
||||
otri4.SetOrg(vertexEvent3);
|
||||
otri4.SetDest(vertex5);
|
||||
otri3.Bond(ref otri4);
|
||||
otri3.LnextSelf();
|
||||
otri4.LprevSelf();
|
||||
otri3.Bond(ref otri4);
|
||||
otri3.LnextSelf();
|
||||
otri4.LprevSelf();
|
||||
otri3.Bond(ref otri5);
|
||||
otri4.Bond(ref otri6);
|
||||
if (!flag && otri6.Equal(otri))
|
||||
{
|
||||
otri3.Copy(ref otri);
|
||||
}
|
||||
if (this.randomnation(SweepLine.SAMPLERATE) == 0)
|
||||
{
|
||||
splayNode = this.SplayInsert(splayNode, otri3, vertexEvent3);
|
||||
}
|
||||
else if (this.randomnation(SweepLine.SAMPLERATE) == 0)
|
||||
{
|
||||
otri4.Lnext(ref otri7);
|
||||
splayNode = this.SplayInsert(splayNode, otri7, vertexEvent3);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
Vertex vertex2 = otri5.Apex();
|
||||
Vertex vertex3 = otri3.Dest();
|
||||
Vertex vertex4 = otri3.Apex();
|
||||
double num = Primitives.CounterClockwise(vertex2, vertex3, vertex4);
|
||||
if (num > 0.0)
|
||||
{
|
||||
SweepLine.SweepEvent sweepEvent2 = new SweepLine.SweepEvent();
|
||||
sweepEvent2.xkey = this.xminextreme;
|
||||
sweepEvent2.ykey = this.CircleTop(vertex2, vertex3, vertex4, num);
|
||||
sweepEvent2.otriEvent = otri3;
|
||||
this.HeapInsert(array, i, sweepEvent2);
|
||||
i++;
|
||||
otri3.SetOrg(new SweepLine.SweepEventVertex(sweepEvent2));
|
||||
}
|
||||
vertex2 = otri4.Apex();
|
||||
vertex3 = otri4.Org();
|
||||
vertex4 = otri6.Apex();
|
||||
double num2 = Primitives.CounterClockwise(vertex2, vertex3, vertex4);
|
||||
if (num2 > 0.0)
|
||||
{
|
||||
SweepLine.SweepEvent sweepEvent2 = new SweepLine.SweepEvent();
|
||||
sweepEvent2.xkey = this.xminextreme;
|
||||
sweepEvent2.ykey = this.CircleTop(vertex2, vertex3, vertex4, num2);
|
||||
sweepEvent2.otriEvent = otri6;
|
||||
this.HeapInsert(array, i, sweepEvent2);
|
||||
i++;
|
||||
otri6.SetOrg(new SweepLine.SweepEventVertex(sweepEvent2));
|
||||
}
|
||||
}
|
||||
}
|
||||
this.splaynodes.Clear();
|
||||
otri.LprevSelf();
|
||||
return this.RemoveGhosts(ref otri);
|
||||
}
|
||||
}
|
||||
SimpleLog.Instance.Error("Input vertices are all identical.", "SweepLine.Triangulate()");
|
||||
throw new Exception("Input vertices are all identical.");
|
||||
}
|
||||
|
||||
// Token: 0x04000131 RID: 305
|
||||
private static int randomseed = 1;
|
||||
|
||||
// Token: 0x04000132 RID: 306
|
||||
private static int SAMPLERATE = 10;
|
||||
|
||||
// Token: 0x04000133 RID: 307
|
||||
private Mesh mesh;
|
||||
|
||||
// Token: 0x04000134 RID: 308
|
||||
private double xminextreme;
|
||||
|
||||
// Token: 0x04000135 RID: 309
|
||||
private List<SweepLine.SplayNode> splaynodes;
|
||||
|
||||
// Token: 0x02000046 RID: 70
|
||||
private class SweepEvent
|
||||
{
|
||||
// Token: 0x0400014C RID: 332
|
||||
public double xkey;
|
||||
|
||||
// Token: 0x0400014D RID: 333
|
||||
public double ykey;
|
||||
|
||||
// Token: 0x0400014E RID: 334
|
||||
public Vertex vertexEvent;
|
||||
|
||||
// Token: 0x0400014F RID: 335
|
||||
public Otri otriEvent;
|
||||
|
||||
// Token: 0x04000150 RID: 336
|
||||
public int heapposition;
|
||||
}
|
||||
|
||||
// Token: 0x02000047 RID: 71
|
||||
private class SweepEventVertex : Vertex
|
||||
{
|
||||
// Token: 0x06000258 RID: 600 RVA: 0x0001BE5D File Offset: 0x0001A05D
|
||||
public SweepEventVertex(SweepLine.SweepEvent e)
|
||||
{
|
||||
this.evt = e;
|
||||
}
|
||||
|
||||
// Token: 0x04000151 RID: 337
|
||||
public SweepLine.SweepEvent evt;
|
||||
}
|
||||
|
||||
// Token: 0x02000048 RID: 72
|
||||
private class SplayNode
|
||||
{
|
||||
// Token: 0x04000152 RID: 338
|
||||
public Otri keyedge;
|
||||
|
||||
// Token: 0x04000153 RID: 339
|
||||
public Vertex keydest;
|
||||
|
||||
// Token: 0x04000154 RID: 340
|
||||
public SweepLine.SplayNode lchild;
|
||||
|
||||
// Token: 0x04000155 RID: 341
|
||||
public SweepLine.SplayNode rchild;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user