scripts
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user