scripts
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000007 RID: 7
|
||||
public class AdvancingFront
|
||||
{
|
||||
// Token: 0x0600004D RID: 77 RVA: 0x00002CD8 File Offset: 0x00000ED8
|
||||
public AdvancingFront(AdvancingFrontNode head, AdvancingFrontNode tail)
|
||||
{
|
||||
this.Head = head;
|
||||
this.Tail = tail;
|
||||
this.Search = head;
|
||||
this.AddNode(head);
|
||||
this.AddNode(tail);
|
||||
}
|
||||
|
||||
// Token: 0x0600004E RID: 78 RVA: 0x00002101 File Offset: 0x00000301
|
||||
public void AddNode(AdvancingFrontNode node)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600004F RID: 79 RVA: 0x00002101 File Offset: 0x00000301
|
||||
public void RemoveNode(AdvancingFrontNode node)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000050 RID: 80 RVA: 0x00002D04 File Offset: 0x00000F04
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (AdvancingFrontNode advancingFrontNode = this.Head; advancingFrontNode != this.Tail; advancingFrontNode = advancingFrontNode.Next)
|
||||
{
|
||||
stringBuilder.Append(advancingFrontNode.Point.X).Append("->");
|
||||
}
|
||||
stringBuilder.Append(this.Tail.Point.X);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
// Token: 0x06000051 RID: 81 RVA: 0x00002D69 File Offset: 0x00000F69
|
||||
private AdvancingFrontNode FindSearchNode(double x)
|
||||
{
|
||||
return this.Search;
|
||||
}
|
||||
|
||||
// Token: 0x06000052 RID: 82 RVA: 0x00002D71 File Offset: 0x00000F71
|
||||
public AdvancingFrontNode LocateNode(TriangulationPoint point)
|
||||
{
|
||||
return this.LocateNode(point.X);
|
||||
}
|
||||
|
||||
// Token: 0x06000053 RID: 83 RVA: 0x00002D80 File Offset: 0x00000F80
|
||||
private AdvancingFrontNode LocateNode(double x)
|
||||
{
|
||||
AdvancingFrontNode advancingFrontNode = this.FindSearchNode(x);
|
||||
if (x < advancingFrontNode.Value)
|
||||
{
|
||||
while ((advancingFrontNode = advancingFrontNode.Prev) != null)
|
||||
{
|
||||
if (x >= advancingFrontNode.Value)
|
||||
{
|
||||
this.Search = advancingFrontNode;
|
||||
return advancingFrontNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((advancingFrontNode = advancingFrontNode.Next) != null)
|
||||
{
|
||||
if (x < advancingFrontNode.Value)
|
||||
{
|
||||
this.Search = advancingFrontNode.Prev;
|
||||
return advancingFrontNode.Prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000054 RID: 84 RVA: 0x00002DE8 File Offset: 0x00000FE8
|
||||
public AdvancingFrontNode LocatePoint(TriangulationPoint point)
|
||||
{
|
||||
double x = point.X;
|
||||
AdvancingFrontNode advancingFrontNode = this.FindSearchNode(x);
|
||||
double x2 = advancingFrontNode.Point.X;
|
||||
if (x == x2)
|
||||
{
|
||||
if (point != advancingFrontNode.Point)
|
||||
{
|
||||
if (point == advancingFrontNode.Prev.Point)
|
||||
{
|
||||
advancingFrontNode = advancingFrontNode.Prev;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (point != advancingFrontNode.Next.Point)
|
||||
{
|
||||
throw new Exception("Failed to find Node for given afront point");
|
||||
}
|
||||
advancingFrontNode = advancingFrontNode.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (x < x2)
|
||||
{
|
||||
while ((advancingFrontNode = advancingFrontNode.Prev) != null)
|
||||
{
|
||||
if (point == advancingFrontNode.Point)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((advancingFrontNode = advancingFrontNode.Next) != null && point != advancingFrontNode.Point)
|
||||
{
|
||||
}
|
||||
}
|
||||
this.Search = advancingFrontNode;
|
||||
return advancingFrontNode;
|
||||
}
|
||||
|
||||
// Token: 0x0400000F RID: 15
|
||||
public AdvancingFrontNode Head;
|
||||
|
||||
// Token: 0x04000010 RID: 16
|
||||
public AdvancingFrontNode Tail;
|
||||
|
||||
// Token: 0x04000011 RID: 17
|
||||
protected AdvancingFrontNode Search;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000008 RID: 8
|
||||
public class AdvancingFrontNode
|
||||
{
|
||||
// Token: 0x06000055 RID: 85 RVA: 0x00002E8C File Offset: 0x0000108C
|
||||
public AdvancingFrontNode(TriangulationPoint point)
|
||||
{
|
||||
this.Point = point;
|
||||
this.Value = point.X;
|
||||
}
|
||||
|
||||
// Token: 0x17000009 RID: 9
|
||||
// (get) Token: 0x06000056 RID: 86 RVA: 0x00002EA7 File Offset: 0x000010A7
|
||||
public bool HasNext
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Next != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700000A RID: 10
|
||||
// (get) Token: 0x06000057 RID: 87 RVA: 0x00002EB2 File Offset: 0x000010B2
|
||||
public bool HasPrev
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Prev != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000012 RID: 18
|
||||
public AdvancingFrontNode Next;
|
||||
|
||||
// Token: 0x04000013 RID: 19
|
||||
public AdvancingFrontNode Prev;
|
||||
|
||||
// Token: 0x04000014 RID: 20
|
||||
public double Value;
|
||||
|
||||
// Token: 0x04000015 RID: 21
|
||||
public TriangulationPoint Point;
|
||||
|
||||
// Token: 0x04000016 RID: 22
|
||||
public DelaunayTriangle Triangle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000012 RID: 18
|
||||
public class ConstrainedPointSet : PointSet
|
||||
{
|
||||
// Token: 0x17000015 RID: 21
|
||||
// (get) Token: 0x060000A0 RID: 160 RVA: 0x0000494D File Offset: 0x00002B4D
|
||||
// (set) Token: 0x060000A1 RID: 161 RVA: 0x00004955 File Offset: 0x00002B55
|
||||
public int[] EdgeIndex { get; private set; }
|
||||
|
||||
// Token: 0x060000A2 RID: 162 RVA: 0x0000495E File Offset: 0x00002B5E
|
||||
public ConstrainedPointSet(List<TriangulationPoint> points, int[] index)
|
||||
: base(points)
|
||||
{
|
||||
this.EdgeIndex = index;
|
||||
}
|
||||
|
||||
// Token: 0x17000016 RID: 22
|
||||
// (get) Token: 0x060000A3 RID: 163 RVA: 0x000048B8 File Offset: 0x00002AB8
|
||||
public override TriangulationMode TriangulationMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return TriangulationMode.Constrained;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060000A4 RID: 164 RVA: 0x00004970 File Offset: 0x00002B70
|
||||
public override void Prepare(TriangulationContext tcx)
|
||||
{
|
||||
base.Prepare(tcx);
|
||||
for (int i = 0; i < this.EdgeIndex.Length; i += 2)
|
||||
{
|
||||
tcx.NewConstraint(base.Points[this.EdgeIndex[i]], base.Points[this.EdgeIndex[i + 1]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,770 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000009 RID: 9
|
||||
public static class DTSweep
|
||||
{
|
||||
// Token: 0x06000058 RID: 88 RVA: 0x00002EBD File Offset: 0x000010BD
|
||||
public static void Triangulate(DTSweepContext tcx)
|
||||
{
|
||||
tcx.CreateAdvancingFront();
|
||||
DTSweep.Sweep(tcx);
|
||||
if (tcx.TriangulationMode == TriangulationMode.Polygon)
|
||||
{
|
||||
DTSweep.FinalizationPolygon(tcx);
|
||||
}
|
||||
else
|
||||
{
|
||||
DTSweep.FinalizationConvexHull(tcx);
|
||||
}
|
||||
tcx.Done();
|
||||
}
|
||||
|
||||
// Token: 0x06000059 RID: 89 RVA: 0x00002EE8 File Offset: 0x000010E8
|
||||
private static void Sweep(DTSweepContext tcx)
|
||||
{
|
||||
List<TriangulationPoint> points = tcx.Points;
|
||||
for (int i = 1; i < points.Count; i++)
|
||||
{
|
||||
TriangulationPoint triangulationPoint = points[i];
|
||||
AdvancingFrontNode advancingFrontNode = DTSweep.PointEvent(tcx, triangulationPoint);
|
||||
if (triangulationPoint.HasEdges)
|
||||
{
|
||||
foreach (DTSweepConstraint dtsweepConstraint in triangulationPoint.Edges)
|
||||
{
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.ActiveConstraint = dtsweepConstraint;
|
||||
}
|
||||
DTSweep.EdgeEvent(tcx, dtsweepConstraint, advancingFrontNode);
|
||||
}
|
||||
}
|
||||
tcx.Update(null);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600005A RID: 90 RVA: 0x00002F8C File Offset: 0x0000118C
|
||||
private static void FinalizationConvexHull(DTSweepContext tcx)
|
||||
{
|
||||
AdvancingFrontNode advancingFrontNode = tcx.Front.Head.Next;
|
||||
AdvancingFrontNode advancingFrontNode2 = advancingFrontNode.Next;
|
||||
AdvancingFrontNode next = advancingFrontNode2.Next;
|
||||
TriangulationPoint triangulationPoint = advancingFrontNode.Point;
|
||||
DTSweep.TurnAdvancingFrontConvex(tcx, advancingFrontNode, advancingFrontNode2);
|
||||
advancingFrontNode = tcx.Front.Tail.Prev;
|
||||
DelaunayTriangle delaunayTriangle;
|
||||
if (advancingFrontNode.Triangle.Contains(advancingFrontNode.Next.Point) && advancingFrontNode.Triangle.Contains(advancingFrontNode.Prev.Point))
|
||||
{
|
||||
delaunayTriangle = advancingFrontNode.Triangle.NeighborAcrossFrom(advancingFrontNode.Point);
|
||||
DTSweep.RotateTrianglePair(advancingFrontNode.Triangle, advancingFrontNode.Point, delaunayTriangle, delaunayTriangle.OppositePoint(advancingFrontNode.Triangle, advancingFrontNode.Point));
|
||||
tcx.MapTriangleToNodes(advancingFrontNode.Triangle);
|
||||
tcx.MapTriangleToNodes(delaunayTriangle);
|
||||
}
|
||||
advancingFrontNode = tcx.Front.Head.Next;
|
||||
if (advancingFrontNode.Triangle.Contains(advancingFrontNode.Prev.Point) && advancingFrontNode.Triangle.Contains(advancingFrontNode.Next.Point))
|
||||
{
|
||||
delaunayTriangle = advancingFrontNode.Triangle.NeighborAcrossFrom(advancingFrontNode.Point);
|
||||
DTSweep.RotateTrianglePair(advancingFrontNode.Triangle, advancingFrontNode.Point, delaunayTriangle, delaunayTriangle.OppositePoint(advancingFrontNode.Triangle, advancingFrontNode.Point));
|
||||
tcx.MapTriangleToNodes(advancingFrontNode.Triangle);
|
||||
tcx.MapTriangleToNodes(delaunayTriangle);
|
||||
}
|
||||
triangulationPoint = tcx.Front.Head.Point;
|
||||
advancingFrontNode2 = tcx.Front.Tail.Prev;
|
||||
delaunayTriangle = advancingFrontNode2.Triangle;
|
||||
TriangulationPoint triangulationPoint2 = advancingFrontNode2.Point;
|
||||
for (;;)
|
||||
{
|
||||
tcx.RemoveFromList(delaunayTriangle);
|
||||
triangulationPoint2 = delaunayTriangle.PointCCWFrom(triangulationPoint2);
|
||||
if (triangulationPoint2 == triangulationPoint)
|
||||
{
|
||||
break;
|
||||
}
|
||||
delaunayTriangle = delaunayTriangle.NeighborCCWFrom(triangulationPoint2);
|
||||
}
|
||||
triangulationPoint = tcx.Front.Head.Next.Point;
|
||||
triangulationPoint2 = delaunayTriangle.PointCWFrom(tcx.Front.Head.Point);
|
||||
delaunayTriangle = delaunayTriangle.NeighborCWFrom(tcx.Front.Head.Point);
|
||||
do
|
||||
{
|
||||
tcx.RemoveFromList(delaunayTriangle);
|
||||
triangulationPoint2 = delaunayTriangle.PointCCWFrom(triangulationPoint2);
|
||||
delaunayTriangle = delaunayTriangle.NeighborCCWFrom(triangulationPoint2);
|
||||
}
|
||||
while (triangulationPoint2 != triangulationPoint);
|
||||
tcx.FinalizeTriangulation();
|
||||
}
|
||||
|
||||
// Token: 0x0600005B RID: 91 RVA: 0x00003198 File Offset: 0x00001398
|
||||
private static void TurnAdvancingFrontConvex(DTSweepContext tcx, AdvancingFrontNode b, AdvancingFrontNode c)
|
||||
{
|
||||
AdvancingFrontNode advancingFrontNode = b;
|
||||
while (c != tcx.Front.Tail)
|
||||
{
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.ActiveNode = c;
|
||||
}
|
||||
if (TriangulationUtil.Orient2d(b.Point, c.Point, c.Next.Point) == Orientation.CCW)
|
||||
{
|
||||
DTSweep.Fill(tcx, c);
|
||||
c = c.Next;
|
||||
}
|
||||
else if (b != advancingFrontNode && TriangulationUtil.Orient2d(b.Prev.Point, b.Point, c.Point) == Orientation.CCW)
|
||||
{
|
||||
DTSweep.Fill(tcx, b);
|
||||
b = b.Prev;
|
||||
}
|
||||
else
|
||||
{
|
||||
b = c;
|
||||
c = c.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600005C RID: 92 RVA: 0x00003240 File Offset: 0x00001440
|
||||
private static void FinalizationPolygon(DTSweepContext tcx)
|
||||
{
|
||||
DelaunayTriangle delaunayTriangle = tcx.Front.Head.Next.Triangle;
|
||||
TriangulationPoint point = tcx.Front.Head.Next.Point;
|
||||
while (!delaunayTriangle.GetConstrainedEdgeCW(point))
|
||||
{
|
||||
delaunayTriangle = delaunayTriangle.NeighborCCWFrom(point);
|
||||
}
|
||||
tcx.MeshClean(delaunayTriangle);
|
||||
}
|
||||
|
||||
// Token: 0x0600005D RID: 93 RVA: 0x00003294 File Offset: 0x00001494
|
||||
private static AdvancingFrontNode PointEvent(DTSweepContext tcx, TriangulationPoint point)
|
||||
{
|
||||
AdvancingFrontNode advancingFrontNode = tcx.LocateNode(point);
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.ActiveNode = advancingFrontNode;
|
||||
}
|
||||
AdvancingFrontNode advancingFrontNode2 = DTSweep.NewFrontTriangle(tcx, point, advancingFrontNode);
|
||||
if (point.X <= advancingFrontNode.Point.X + TriangulationUtil.EPSILON)
|
||||
{
|
||||
DTSweep.Fill(tcx, advancingFrontNode);
|
||||
}
|
||||
tcx.AddNode(advancingFrontNode2);
|
||||
DTSweep.FillAdvancingFront(tcx, advancingFrontNode2);
|
||||
return advancingFrontNode2;
|
||||
}
|
||||
|
||||
// Token: 0x0600005E RID: 94 RVA: 0x000032F8 File Offset: 0x000014F8
|
||||
private static AdvancingFrontNode NewFrontTriangle(DTSweepContext tcx, TriangulationPoint point, AdvancingFrontNode node)
|
||||
{
|
||||
DelaunayTriangle delaunayTriangle = new DelaunayTriangle(point, node.Point, node.Next.Point);
|
||||
delaunayTriangle.MarkNeighbor(node.Triangle);
|
||||
tcx.Triangles.Add(delaunayTriangle);
|
||||
AdvancingFrontNode advancingFrontNode = new AdvancingFrontNode(point);
|
||||
advancingFrontNode.Next = node.Next;
|
||||
advancingFrontNode.Prev = node;
|
||||
node.Next.Prev = advancingFrontNode;
|
||||
node.Next = advancingFrontNode;
|
||||
tcx.AddNode(advancingFrontNode);
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.ActiveNode = advancingFrontNode;
|
||||
}
|
||||
if (!DTSweep.Legalize(tcx, delaunayTriangle))
|
||||
{
|
||||
tcx.MapTriangleToNodes(delaunayTriangle);
|
||||
}
|
||||
return advancingFrontNode;
|
||||
}
|
||||
|
||||
// Token: 0x0600005F RID: 95 RVA: 0x00003390 File Offset: 0x00001590
|
||||
private static void EdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
try
|
||||
{
|
||||
tcx.EdgeEvent.ConstrainedEdge = edge;
|
||||
tcx.EdgeEvent.Right = edge.P.X > edge.Q.X;
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.PrimaryTriangle = node.Triangle;
|
||||
}
|
||||
if (!DTSweep.IsEdgeSideOfTriangle(node.Triangle, edge.P, edge.Q))
|
||||
{
|
||||
DTSweep.FillEdgeEvent(tcx, edge, node);
|
||||
DTSweep.EdgeEvent(tcx, edge.P, edge.Q, node.Triangle, edge.Q);
|
||||
}
|
||||
}
|
||||
catch (PointOnEdgeException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000060 RID: 96 RVA: 0x0000343C File Offset: 0x0000163C
|
||||
private static void FillEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
if (tcx.EdgeEvent.Right)
|
||||
{
|
||||
DTSweep.FillRightAboveEdgeEvent(tcx, edge, node);
|
||||
return;
|
||||
}
|
||||
DTSweep.FillLeftAboveEdgeEvent(tcx, edge, node);
|
||||
}
|
||||
|
||||
// Token: 0x06000061 RID: 97 RVA: 0x0000345C File Offset: 0x0000165C
|
||||
private static void FillRightConcaveEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
DTSweep.Fill(tcx, node.Next);
|
||||
if (node.Next.Point != edge.P && TriangulationUtil.Orient2d(edge.Q, node.Next.Point, edge.P) == Orientation.CCW && TriangulationUtil.Orient2d(node.Point, node.Next.Point, node.Next.Next.Point) == Orientation.CCW)
|
||||
{
|
||||
DTSweep.FillRightConcaveEdgeEvent(tcx, edge, node);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000062 RID: 98 RVA: 0x000034D8 File Offset: 0x000016D8
|
||||
private static void FillRightConvexEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
if (TriangulationUtil.Orient2d(node.Next.Point, node.Next.Next.Point, node.Next.Next.Next.Point) == Orientation.CCW)
|
||||
{
|
||||
DTSweep.FillRightConcaveEdgeEvent(tcx, edge, node.Next);
|
||||
return;
|
||||
}
|
||||
if (TriangulationUtil.Orient2d(edge.Q, node.Next.Next.Point, edge.P) == Orientation.CCW)
|
||||
{
|
||||
DTSweep.FillRightConvexEdgeEvent(tcx, edge, node.Next);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000063 RID: 99 RVA: 0x0000355C File Offset: 0x0000175C
|
||||
private static void FillRightBelowEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.ActiveNode = node;
|
||||
}
|
||||
if (node.Point.X < edge.P.X)
|
||||
{
|
||||
if (TriangulationUtil.Orient2d(node.Point, node.Next.Point, node.Next.Next.Point) == Orientation.CCW)
|
||||
{
|
||||
DTSweep.FillRightConcaveEdgeEvent(tcx, edge, node);
|
||||
return;
|
||||
}
|
||||
DTSweep.FillRightConvexEdgeEvent(tcx, edge, node);
|
||||
DTSweep.FillRightBelowEdgeEvent(tcx, edge, node);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000064 RID: 100 RVA: 0x000035D8 File Offset: 0x000017D8
|
||||
private static void FillRightAboveEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
while (node.Next.Point.X < edge.P.X)
|
||||
{
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.ActiveNode = node;
|
||||
}
|
||||
if (TriangulationUtil.Orient2d(edge.Q, node.Next.Point, edge.P) == Orientation.CCW)
|
||||
{
|
||||
DTSweep.FillRightBelowEdgeEvent(tcx, edge, node);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = node.Next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000065 RID: 101 RVA: 0x0000364C File Offset: 0x0000184C
|
||||
private static void FillLeftConvexEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
if (TriangulationUtil.Orient2d(node.Prev.Point, node.Prev.Prev.Point, node.Prev.Prev.Prev.Point) == Orientation.CW)
|
||||
{
|
||||
DTSweep.FillLeftConcaveEdgeEvent(tcx, edge, node.Prev);
|
||||
return;
|
||||
}
|
||||
if (TriangulationUtil.Orient2d(edge.Q, node.Prev.Prev.Point, edge.P) == Orientation.CW)
|
||||
{
|
||||
DTSweep.FillLeftConvexEdgeEvent(tcx, edge, node.Prev);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000066 RID: 102 RVA: 0x000036D0 File Offset: 0x000018D0
|
||||
private static void FillLeftConcaveEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
DTSweep.Fill(tcx, node.Prev);
|
||||
if (node.Prev.Point != edge.P && TriangulationUtil.Orient2d(edge.Q, node.Prev.Point, edge.P) == Orientation.CW && TriangulationUtil.Orient2d(node.Point, node.Prev.Point, node.Prev.Prev.Point) == Orientation.CW)
|
||||
{
|
||||
DTSweep.FillLeftConcaveEdgeEvent(tcx, edge, node);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000067 RID: 103 RVA: 0x0000374C File Offset: 0x0000194C
|
||||
private static void FillLeftBelowEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.ActiveNode = node;
|
||||
}
|
||||
if (node.Point.X > edge.P.X)
|
||||
{
|
||||
if (TriangulationUtil.Orient2d(node.Point, node.Prev.Point, node.Prev.Prev.Point) == Orientation.CW)
|
||||
{
|
||||
DTSweep.FillLeftConcaveEdgeEvent(tcx, edge, node);
|
||||
return;
|
||||
}
|
||||
DTSweep.FillLeftConvexEdgeEvent(tcx, edge, node);
|
||||
DTSweep.FillLeftBelowEdgeEvent(tcx, edge, node);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000068 RID: 104 RVA: 0x000037C8 File Offset: 0x000019C8
|
||||
private static void FillLeftAboveEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node)
|
||||
{
|
||||
while (node.Prev.Point.X > edge.P.X)
|
||||
{
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.ActiveNode = node;
|
||||
}
|
||||
if (TriangulationUtil.Orient2d(edge.Q, node.Prev.Point, edge.P) == Orientation.CW)
|
||||
{
|
||||
DTSweep.FillLeftBelowEdgeEvent(tcx, edge, node);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = node.Prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000069 RID: 105 RVA: 0x00003838 File Offset: 0x00001A38
|
||||
private static bool IsEdgeSideOfTriangle(DelaunayTriangle triangle, TriangulationPoint ep, TriangulationPoint eq)
|
||||
{
|
||||
int num = triangle.EdgeIndex(ep, eq);
|
||||
if (num == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
triangle.MarkConstrainedEdge(num);
|
||||
triangle = triangle.Neighbors[num];
|
||||
if (triangle != null)
|
||||
{
|
||||
triangle.MarkConstrainedEdge(ep, eq);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x0600006A RID: 106 RVA: 0x00003878 File Offset: 0x00001A78
|
||||
private static void EdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle triangle, TriangulationPoint point)
|
||||
{
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.PrimaryTriangle = triangle;
|
||||
}
|
||||
if (DTSweep.IsEdgeSideOfTriangle(triangle, ep, eq))
|
||||
{
|
||||
return;
|
||||
}
|
||||
TriangulationPoint triangulationPoint = triangle.PointCCWFrom(point);
|
||||
Orientation orientation = TriangulationUtil.Orient2d(eq, triangulationPoint, ep);
|
||||
if (orientation == Orientation.Collinear)
|
||||
{
|
||||
throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet", eq, triangulationPoint, ep);
|
||||
}
|
||||
TriangulationPoint triangulationPoint2 = triangle.PointCWFrom(point);
|
||||
Orientation orientation2 = TriangulationUtil.Orient2d(eq, triangulationPoint2, ep);
|
||||
if (orientation2 == Orientation.Collinear)
|
||||
{
|
||||
throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet", eq, triangulationPoint2, ep);
|
||||
}
|
||||
if (orientation == orientation2)
|
||||
{
|
||||
if (orientation == Orientation.CW)
|
||||
{
|
||||
triangle = triangle.NeighborCCWFrom(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
triangle = triangle.NeighborCWFrom(point);
|
||||
}
|
||||
DTSweep.EdgeEvent(tcx, ep, eq, triangle, point);
|
||||
return;
|
||||
}
|
||||
DTSweep.FlipEdgeEvent(tcx, ep, eq, triangle, point);
|
||||
}
|
||||
|
||||
// Token: 0x0600006B RID: 107 RVA: 0x00003920 File Offset: 0x00001B20
|
||||
private static void SplitEdge(TriangulationPoint ep, TriangulationPoint eq, TriangulationPoint p)
|
||||
{
|
||||
eq.Edges.First((DTSweepConstraint e) => e.Q == ep || e.P == ep).P = p;
|
||||
new DTSweepConstraint(ep, p);
|
||||
}
|
||||
|
||||
// Token: 0x0600006C RID: 108 RVA: 0x00003964 File Offset: 0x00001B64
|
||||
private static void FlipEdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle t, TriangulationPoint p)
|
||||
{
|
||||
DelaunayTriangle delaunayTriangle = t.NeighborAcrossFrom(p);
|
||||
TriangulationPoint triangulationPoint = delaunayTriangle.OppositePoint(t, p);
|
||||
if (delaunayTriangle == null)
|
||||
{
|
||||
throw new InvalidOperationException("[BUG:FIXME] FLIP failed due to missing triangle");
|
||||
}
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
tcx.DTDebugContext.PrimaryTriangle = t;
|
||||
tcx.DTDebugContext.SecondaryTriangle = delaunayTriangle;
|
||||
}
|
||||
if (TriangulationUtil.InScanArea(p, t.PointCCWFrom(p), t.PointCWFrom(p), triangulationPoint))
|
||||
{
|
||||
DTSweep.RotateTrianglePair(t, p, delaunayTriangle, triangulationPoint);
|
||||
tcx.MapTriangleToNodes(t);
|
||||
tcx.MapTriangleToNodes(delaunayTriangle);
|
||||
if (p != eq || triangulationPoint != ep)
|
||||
{
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
Console.WriteLine("[FLIP] - flipping and continuing with triangle still crossing edge");
|
||||
}
|
||||
Orientation orientation = TriangulationUtil.Orient2d(eq, triangulationPoint, ep);
|
||||
t = DTSweep.NextFlipTriangle(tcx, orientation, t, delaunayTriangle, p, triangulationPoint);
|
||||
DTSweep.FlipEdgeEvent(tcx, ep, eq, t, p);
|
||||
return;
|
||||
}
|
||||
if (eq == tcx.EdgeEvent.ConstrainedEdge.Q && ep == tcx.EdgeEvent.ConstrainedEdge.P)
|
||||
{
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
Console.WriteLine("[FLIP] - constrained edge done");
|
||||
}
|
||||
t.MarkConstrainedEdge(ep, eq);
|
||||
delaunayTriangle.MarkConstrainedEdge(ep, eq);
|
||||
DTSweep.Legalize(tcx, t);
|
||||
DTSweep.Legalize(tcx, delaunayTriangle);
|
||||
return;
|
||||
}
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
Console.WriteLine("[FLIP] - subedge done");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TriangulationPoint triangulationPoint2 = DTSweep.NextFlipPoint(ep, eq, delaunayTriangle, triangulationPoint);
|
||||
DTSweep.FlipScanEdgeEvent(tcx, ep, eq, t, delaunayTriangle, triangulationPoint2);
|
||||
DTSweep.EdgeEvent(tcx, ep, eq, t, p);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600006D RID: 109 RVA: 0x00003AB4 File Offset: 0x00001CB4
|
||||
private static TriangulationPoint NextFlipPoint(TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle ot, TriangulationPoint op)
|
||||
{
|
||||
switch (TriangulationUtil.Orient2d(eq, op, ep))
|
||||
{
|
||||
case Orientation.CW:
|
||||
return ot.PointCCWFrom(op);
|
||||
case Orientation.CCW:
|
||||
return ot.PointCWFrom(op);
|
||||
case Orientation.Collinear:
|
||||
throw new PointOnEdgeException("Point on constrained edge not supported yet", eq, op, ep);
|
||||
default:
|
||||
throw new NotImplementedException("Orientation not handled");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600006E RID: 110 RVA: 0x00003B08 File Offset: 0x00001D08
|
||||
private static DelaunayTriangle NextFlipTriangle(DTSweepContext tcx, Orientation o, DelaunayTriangle t, DelaunayTriangle ot, TriangulationPoint p, TriangulationPoint op)
|
||||
{
|
||||
int num;
|
||||
if (o == Orientation.CCW)
|
||||
{
|
||||
num = ot.EdgeIndex(p, op);
|
||||
ot.EdgeIsDelaunay[num] = true;
|
||||
DTSweep.Legalize(tcx, ot);
|
||||
ot.EdgeIsDelaunay.Clear();
|
||||
return t;
|
||||
}
|
||||
num = t.EdgeIndex(p, op);
|
||||
t.EdgeIsDelaunay[num] = true;
|
||||
DTSweep.Legalize(tcx, t);
|
||||
t.EdgeIsDelaunay.Clear();
|
||||
return ot;
|
||||
}
|
||||
|
||||
// Token: 0x0600006F RID: 111 RVA: 0x00003B74 File Offset: 0x00001D74
|
||||
private static void FlipScanEdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle flipTriangle, DelaunayTriangle t, TriangulationPoint p)
|
||||
{
|
||||
DelaunayTriangle delaunayTriangle = t.NeighborAcrossFrom(p);
|
||||
TriangulationPoint triangulationPoint = delaunayTriangle.OppositePoint(t, p);
|
||||
if (delaunayTriangle == null)
|
||||
{
|
||||
throw new Exception("[BUG:FIXME] FLIP failed due to missing triangle");
|
||||
}
|
||||
if (tcx.IsDebugEnabled)
|
||||
{
|
||||
Console.WriteLine("[FLIP:SCAN] - scan next point");
|
||||
tcx.DTDebugContext.PrimaryTriangle = t;
|
||||
tcx.DTDebugContext.SecondaryTriangle = delaunayTriangle;
|
||||
}
|
||||
if (TriangulationUtil.InScanArea(eq, flipTriangle.PointCCWFrom(eq), flipTriangle.PointCWFrom(eq), triangulationPoint))
|
||||
{
|
||||
DTSweep.FlipEdgeEvent(tcx, eq, triangulationPoint, delaunayTriangle, triangulationPoint);
|
||||
return;
|
||||
}
|
||||
TriangulationPoint triangulationPoint2 = DTSweep.NextFlipPoint(ep, eq, delaunayTriangle, triangulationPoint);
|
||||
DTSweep.FlipScanEdgeEvent(tcx, ep, eq, flipTriangle, delaunayTriangle, triangulationPoint2);
|
||||
}
|
||||
|
||||
// Token: 0x06000070 RID: 112 RVA: 0x00003C08 File Offset: 0x00001E08
|
||||
private static void FillAdvancingFront(DTSweepContext tcx, AdvancingFrontNode n)
|
||||
{
|
||||
AdvancingFrontNode advancingFrontNode = n.Next;
|
||||
while (advancingFrontNode.HasNext)
|
||||
{
|
||||
double num = DTSweep.HoleAngle(advancingFrontNode);
|
||||
if (num > 1.5707963267948966 || num < -1.5707963267948966)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DTSweep.Fill(tcx, advancingFrontNode);
|
||||
advancingFrontNode = advancingFrontNode.Next;
|
||||
}
|
||||
advancingFrontNode = n.Prev;
|
||||
while (advancingFrontNode.HasPrev)
|
||||
{
|
||||
double num = DTSweep.HoleAngle(advancingFrontNode);
|
||||
if (num > 1.5707963267948966 || num < -1.5707963267948966)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DTSweep.Fill(tcx, advancingFrontNode);
|
||||
advancingFrontNode = advancingFrontNode.Prev;
|
||||
}
|
||||
if (n.HasNext && n.Next.HasNext)
|
||||
{
|
||||
double num = DTSweep.BasinAngle(n);
|
||||
if (num < 2.356194490192345)
|
||||
{
|
||||
DTSweep.FillBasin(tcx, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000071 RID: 113 RVA: 0x00003CC0 File Offset: 0x00001EC0
|
||||
private static void FillBasin(DTSweepContext tcx, AdvancingFrontNode node)
|
||||
{
|
||||
if (TriangulationUtil.Orient2d(node.Point, node.Next.Point, node.Next.Next.Point) == Orientation.CCW)
|
||||
{
|
||||
tcx.Basin.leftNode = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
tcx.Basin.leftNode = node.Next;
|
||||
}
|
||||
tcx.Basin.bottomNode = tcx.Basin.leftNode;
|
||||
while (tcx.Basin.bottomNode.HasNext && tcx.Basin.bottomNode.Point.Y >= tcx.Basin.bottomNode.Next.Point.Y)
|
||||
{
|
||||
tcx.Basin.bottomNode = tcx.Basin.bottomNode.Next;
|
||||
}
|
||||
if (tcx.Basin.bottomNode == tcx.Basin.leftNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
tcx.Basin.rightNode = tcx.Basin.bottomNode;
|
||||
while (tcx.Basin.rightNode.HasNext && tcx.Basin.rightNode.Point.Y < tcx.Basin.rightNode.Next.Point.Y)
|
||||
{
|
||||
tcx.Basin.rightNode = tcx.Basin.rightNode.Next;
|
||||
}
|
||||
if (tcx.Basin.rightNode == tcx.Basin.bottomNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
tcx.Basin.width = tcx.Basin.rightNode.Point.X - tcx.Basin.leftNode.Point.X;
|
||||
tcx.Basin.leftHighest = tcx.Basin.leftNode.Point.Y > tcx.Basin.rightNode.Point.Y;
|
||||
DTSweep.FillBasinReq(tcx, tcx.Basin.bottomNode);
|
||||
}
|
||||
|
||||
// Token: 0x06000072 RID: 114 RVA: 0x00003EB4 File Offset: 0x000020B4
|
||||
private static void FillBasinReq(DTSweepContext tcx, AdvancingFrontNode node)
|
||||
{
|
||||
if (DTSweep.IsShallow(tcx, node))
|
||||
{
|
||||
return;
|
||||
}
|
||||
DTSweep.Fill(tcx, node);
|
||||
if (node.Prev == tcx.Basin.leftNode && node.Next == tcx.Basin.rightNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (node.Prev == tcx.Basin.leftNode)
|
||||
{
|
||||
if (TriangulationUtil.Orient2d(node.Point, node.Next.Point, node.Next.Next.Point) == Orientation.CW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
node = node.Next;
|
||||
}
|
||||
else if (node.Next == tcx.Basin.rightNode)
|
||||
{
|
||||
if (TriangulationUtil.Orient2d(node.Point, node.Prev.Point, node.Prev.Prev.Point) == Orientation.CCW)
|
||||
{
|
||||
return;
|
||||
}
|
||||
node = node.Prev;
|
||||
}
|
||||
else if (node.Prev.Point.Y < node.Next.Point.Y)
|
||||
{
|
||||
node = node.Prev;
|
||||
}
|
||||
else
|
||||
{
|
||||
node = node.Next;
|
||||
}
|
||||
DTSweep.FillBasinReq(tcx, node);
|
||||
}
|
||||
|
||||
// Token: 0x06000073 RID: 115 RVA: 0x00003FC4 File Offset: 0x000021C4
|
||||
private static bool IsShallow(DTSweepContext tcx, AdvancingFrontNode node)
|
||||
{
|
||||
double num;
|
||||
if (tcx.Basin.leftHighest)
|
||||
{
|
||||
num = tcx.Basin.leftNode.Point.Y - node.Point.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = tcx.Basin.rightNode.Point.Y - node.Point.Y;
|
||||
}
|
||||
return tcx.Basin.width > num;
|
||||
}
|
||||
|
||||
// Token: 0x06000074 RID: 116 RVA: 0x00004038 File Offset: 0x00002238
|
||||
private static double HoleAngle(AdvancingFrontNode node)
|
||||
{
|
||||
double x = node.Point.X;
|
||||
double y = node.Point.Y;
|
||||
double num = node.Next.Point.X - x;
|
||||
double num2 = node.Next.Point.Y - y;
|
||||
double num3 = node.Prev.Point.X - x;
|
||||
double num4 = node.Prev.Point.Y - y;
|
||||
return Math.Atan2(num * num4 - num2 * num3, num * num3 + num2 * num4);
|
||||
}
|
||||
|
||||
// Token: 0x06000075 RID: 117 RVA: 0x000040C4 File Offset: 0x000022C4
|
||||
private static double BasinAngle(AdvancingFrontNode node)
|
||||
{
|
||||
double num = node.Point.X - node.Next.Next.Point.X;
|
||||
return Math.Atan2(node.Point.Y - node.Next.Next.Point.Y, num);
|
||||
}
|
||||
|
||||
// Token: 0x06000076 RID: 118 RVA: 0x0000411C File Offset: 0x0000231C
|
||||
private static void Fill(DTSweepContext tcx, AdvancingFrontNode node)
|
||||
{
|
||||
DelaunayTriangle delaunayTriangle = new DelaunayTriangle(node.Prev.Point, node.Point, node.Next.Point);
|
||||
delaunayTriangle.MarkNeighbor(node.Prev.Triangle);
|
||||
delaunayTriangle.MarkNeighbor(node.Triangle);
|
||||
tcx.Triangles.Add(delaunayTriangle);
|
||||
node.Prev.Next = node.Next;
|
||||
node.Next.Prev = node.Prev;
|
||||
tcx.RemoveNode(node);
|
||||
if (!DTSweep.Legalize(tcx, delaunayTriangle))
|
||||
{
|
||||
tcx.MapTriangleToNodes(delaunayTriangle);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000077 RID: 119 RVA: 0x000041B0 File Offset: 0x000023B0
|
||||
private static bool Legalize(DTSweepContext tcx, DelaunayTriangle t)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (!t.EdgeIsDelaunay[i])
|
||||
{
|
||||
DelaunayTriangle delaunayTriangle = t.Neighbors[i];
|
||||
if (delaunayTriangle != null)
|
||||
{
|
||||
TriangulationPoint triangulationPoint = t.Points[i];
|
||||
TriangulationPoint triangulationPoint2 = delaunayTriangle.OppositePoint(t, triangulationPoint);
|
||||
int num = delaunayTriangle.IndexOf(triangulationPoint2);
|
||||
if (delaunayTriangle.EdgeIsConstrained[num] || delaunayTriangle.EdgeIsDelaunay[num])
|
||||
{
|
||||
t.EdgeIsConstrained[i] = delaunayTriangle.EdgeIsConstrained[num];
|
||||
}
|
||||
else if (TriangulationUtil.SmartIncircle(triangulationPoint, t.PointCCWFrom(triangulationPoint), t.PointCWFrom(triangulationPoint), triangulationPoint2))
|
||||
{
|
||||
t.EdgeIsDelaunay[i] = true;
|
||||
delaunayTriangle.EdgeIsDelaunay[num] = true;
|
||||
DTSweep.RotateTrianglePair(t, triangulationPoint, delaunayTriangle, triangulationPoint2);
|
||||
if (!DTSweep.Legalize(tcx, t))
|
||||
{
|
||||
tcx.MapTriangleToNodes(t);
|
||||
}
|
||||
if (!DTSweep.Legalize(tcx, delaunayTriangle))
|
||||
{
|
||||
tcx.MapTriangleToNodes(delaunayTriangle);
|
||||
}
|
||||
t.EdgeIsDelaunay[i] = false;
|
||||
delaunayTriangle.EdgeIsDelaunay[num] = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x06000078 RID: 120 RVA: 0x000042C4 File Offset: 0x000024C4
|
||||
private static void RotateTrianglePair(DelaunayTriangle t, TriangulationPoint p, DelaunayTriangle ot, TriangulationPoint op)
|
||||
{
|
||||
DelaunayTriangle delaunayTriangle = t.NeighborCCWFrom(p);
|
||||
DelaunayTriangle delaunayTriangle2 = t.NeighborCWFrom(p);
|
||||
DelaunayTriangle delaunayTriangle3 = ot.NeighborCCWFrom(op);
|
||||
DelaunayTriangle delaunayTriangle4 = ot.NeighborCWFrom(op);
|
||||
bool constrainedEdgeCCW = t.GetConstrainedEdgeCCW(p);
|
||||
bool constrainedEdgeCW = t.GetConstrainedEdgeCW(p);
|
||||
bool constrainedEdgeCCW2 = ot.GetConstrainedEdgeCCW(op);
|
||||
bool constrainedEdgeCW2 = ot.GetConstrainedEdgeCW(op);
|
||||
bool delaunayEdgeCCW = t.GetDelaunayEdgeCCW(p);
|
||||
bool delaunayEdgeCW = t.GetDelaunayEdgeCW(p);
|
||||
bool delaunayEdgeCCW2 = ot.GetDelaunayEdgeCCW(op);
|
||||
bool delaunayEdgeCW2 = ot.GetDelaunayEdgeCW(op);
|
||||
t.Legalize(p, op);
|
||||
ot.Legalize(op, p);
|
||||
ot.SetDelaunayEdgeCCW(p, delaunayEdgeCCW);
|
||||
t.SetDelaunayEdgeCW(p, delaunayEdgeCW);
|
||||
t.SetDelaunayEdgeCCW(op, delaunayEdgeCCW2);
|
||||
ot.SetDelaunayEdgeCW(op, delaunayEdgeCW2);
|
||||
ot.SetConstrainedEdgeCCW(p, constrainedEdgeCCW);
|
||||
t.SetConstrainedEdgeCW(p, constrainedEdgeCW);
|
||||
t.SetConstrainedEdgeCCW(op, constrainedEdgeCCW2);
|
||||
ot.SetConstrainedEdgeCW(op, constrainedEdgeCW2);
|
||||
t.Neighbors.Clear();
|
||||
ot.Neighbors.Clear();
|
||||
if (delaunayTriangle != null)
|
||||
{
|
||||
ot.MarkNeighbor(delaunayTriangle);
|
||||
}
|
||||
if (delaunayTriangle2 != null)
|
||||
{
|
||||
t.MarkNeighbor(delaunayTriangle2);
|
||||
}
|
||||
if (delaunayTriangle3 != null)
|
||||
{
|
||||
t.MarkNeighbor(delaunayTriangle3);
|
||||
}
|
||||
if (delaunayTriangle4 != null)
|
||||
{
|
||||
ot.MarkNeighbor(delaunayTriangle4);
|
||||
}
|
||||
t.MarkNeighbor(ot);
|
||||
}
|
||||
|
||||
// Token: 0x04000017 RID: 23
|
||||
private const double PI_div2 = 1.5707963267948966;
|
||||
|
||||
// Token: 0x04000018 RID: 24
|
||||
private const double PI_3div4 = 2.356194490192345;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200000A RID: 10
|
||||
public class DTSweepBasin
|
||||
{
|
||||
// Token: 0x04000019 RID: 25
|
||||
public AdvancingFrontNode leftNode;
|
||||
|
||||
// Token: 0x0400001A RID: 26
|
||||
public AdvancingFrontNode bottomNode;
|
||||
|
||||
// Token: 0x0400001B RID: 27
|
||||
public AdvancingFrontNode rightNode;
|
||||
|
||||
// Token: 0x0400001C RID: 28
|
||||
public double width;
|
||||
|
||||
// Token: 0x0400001D RID: 29
|
||||
public bool leftHighest;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200000B RID: 11
|
||||
public class DTSweepConstraint : TriangulationConstraint
|
||||
{
|
||||
// Token: 0x0600007A RID: 122 RVA: 0x000043E0 File Offset: 0x000025E0
|
||||
public DTSweepConstraint(TriangulationPoint p1, TriangulationPoint p2)
|
||||
{
|
||||
this.P = p1;
|
||||
this.Q = p2;
|
||||
if (p1.Y > p2.Y)
|
||||
{
|
||||
this.Q = p1;
|
||||
this.P = p2;
|
||||
}
|
||||
else if (p1.Y == p2.Y)
|
||||
{
|
||||
if (p1.X > p2.X)
|
||||
{
|
||||
this.Q = p1;
|
||||
this.P = p2;
|
||||
}
|
||||
else
|
||||
{
|
||||
double x = p1.X;
|
||||
double x2 = p2.X;
|
||||
}
|
||||
}
|
||||
this.Q.AddEdge(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200000C RID: 12
|
||||
public class DTSweepContext : TriangulationContext
|
||||
{
|
||||
// Token: 0x1700000B RID: 11
|
||||
// (get) Token: 0x0600007B RID: 123 RVA: 0x00004465 File Offset: 0x00002665
|
||||
// (set) Token: 0x0600007C RID: 124 RVA: 0x0000446D File Offset: 0x0000266D
|
||||
public TriangulationPoint Head { get; set; }
|
||||
|
||||
// Token: 0x1700000C RID: 12
|
||||
// (get) Token: 0x0600007D RID: 125 RVA: 0x00004476 File Offset: 0x00002676
|
||||
// (set) Token: 0x0600007E RID: 126 RVA: 0x0000447E File Offset: 0x0000267E
|
||||
public TriangulationPoint Tail { get; set; }
|
||||
|
||||
// Token: 0x0600007F RID: 127 RVA: 0x00004487 File Offset: 0x00002687
|
||||
public DTSweepContext()
|
||||
{
|
||||
this.Clear();
|
||||
}
|
||||
|
||||
// Token: 0x1700000D RID: 13
|
||||
// (get) Token: 0x06000080 RID: 128 RVA: 0x000044C1 File Offset: 0x000026C1
|
||||
// (set) Token: 0x06000081 RID: 129 RVA: 0x000044C9 File Offset: 0x000026C9
|
||||
public override bool IsDebugEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.IsDebugEnabled;
|
||||
}
|
||||
protected set
|
||||
{
|
||||
if (value && base.DebugContext == null)
|
||||
{
|
||||
base.DebugContext = new DTSweepDebugContext(this);
|
||||
}
|
||||
base.IsDebugEnabled = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000082 RID: 130 RVA: 0x000044E9 File Offset: 0x000026E9
|
||||
public void RemoveFromList(DelaunayTriangle triangle)
|
||||
{
|
||||
this.Triangles.Remove(triangle);
|
||||
}
|
||||
|
||||
// Token: 0x06000083 RID: 131 RVA: 0x000044F8 File Offset: 0x000026F8
|
||||
public void MeshClean(DelaunayTriangle triangle)
|
||||
{
|
||||
this.MeshCleanReq(triangle);
|
||||
}
|
||||
|
||||
// Token: 0x06000084 RID: 132 RVA: 0x00004504 File Offset: 0x00002704
|
||||
private void MeshCleanReq(DelaunayTriangle triangle)
|
||||
{
|
||||
if (triangle != null && !triangle.IsInterior)
|
||||
{
|
||||
triangle.IsInterior = true;
|
||||
base.Triangulatable.AddTriangle(triangle);
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (!triangle.EdgeIsConstrained[i])
|
||||
{
|
||||
this.MeshCleanReq(triangle.Neighbors[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000085 RID: 133 RVA: 0x0000455B File Offset: 0x0000275B
|
||||
public override void Clear()
|
||||
{
|
||||
base.Clear();
|
||||
this.Triangles.Clear();
|
||||
}
|
||||
|
||||
// Token: 0x06000086 RID: 134 RVA: 0x0000456E File Offset: 0x0000276E
|
||||
public void AddNode(AdvancingFrontNode node)
|
||||
{
|
||||
this.Front.AddNode(node);
|
||||
}
|
||||
|
||||
// Token: 0x06000087 RID: 135 RVA: 0x0000457C File Offset: 0x0000277C
|
||||
public void RemoveNode(AdvancingFrontNode node)
|
||||
{
|
||||
this.Front.RemoveNode(node);
|
||||
}
|
||||
|
||||
// Token: 0x06000088 RID: 136 RVA: 0x0000458A File Offset: 0x0000278A
|
||||
public AdvancingFrontNode LocateNode(TriangulationPoint point)
|
||||
{
|
||||
return this.Front.LocateNode(point);
|
||||
}
|
||||
|
||||
// Token: 0x06000089 RID: 137 RVA: 0x00004598 File Offset: 0x00002798
|
||||
public void CreateAdvancingFront()
|
||||
{
|
||||
DelaunayTriangle delaunayTriangle = new DelaunayTriangle(this.Points[0], this.Tail, this.Head);
|
||||
this.Triangles.Add(delaunayTriangle);
|
||||
AdvancingFrontNode advancingFrontNode = new AdvancingFrontNode(delaunayTriangle.Points[1]);
|
||||
advancingFrontNode.Triangle = delaunayTriangle;
|
||||
AdvancingFrontNode advancingFrontNode2 = new AdvancingFrontNode(delaunayTriangle.Points[0]);
|
||||
advancingFrontNode2.Triangle = delaunayTriangle;
|
||||
AdvancingFrontNode advancingFrontNode3 = new AdvancingFrontNode(delaunayTriangle.Points[2]);
|
||||
this.Front = new AdvancingFront(advancingFrontNode, advancingFrontNode3);
|
||||
this.Front.AddNode(advancingFrontNode2);
|
||||
this.Front.Head.Next = advancingFrontNode2;
|
||||
advancingFrontNode2.Next = this.Front.Tail;
|
||||
advancingFrontNode2.Prev = this.Front.Head;
|
||||
this.Front.Tail.Prev = advancingFrontNode2;
|
||||
}
|
||||
|
||||
// Token: 0x0600008A RID: 138 RVA: 0x00004670 File Offset: 0x00002870
|
||||
public void MapTriangleToNodes(DelaunayTriangle t)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (t.Neighbors[i] == null)
|
||||
{
|
||||
AdvancingFrontNode advancingFrontNode = this.Front.LocatePoint(t.PointCWFrom(t.Points[i]));
|
||||
if (advancingFrontNode != null)
|
||||
{
|
||||
advancingFrontNode.Triangle = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600008B RID: 139 RVA: 0x000046C0 File Offset: 0x000028C0
|
||||
public override void PrepareTriangulation(Triangulatable t)
|
||||
{
|
||||
base.PrepareTriangulation(t);
|
||||
double num2;
|
||||
double num = (num2 = this.Points[0].X);
|
||||
double num4;
|
||||
double num3 = (num4 = this.Points[0].Y);
|
||||
foreach (TriangulationPoint triangulationPoint in this.Points)
|
||||
{
|
||||
if (triangulationPoint.X > num2)
|
||||
{
|
||||
num2 = triangulationPoint.X;
|
||||
}
|
||||
if (triangulationPoint.X < num)
|
||||
{
|
||||
num = triangulationPoint.X;
|
||||
}
|
||||
if (triangulationPoint.Y > num4)
|
||||
{
|
||||
num4 = triangulationPoint.Y;
|
||||
}
|
||||
if (triangulationPoint.Y < num3)
|
||||
{
|
||||
num3 = triangulationPoint.Y;
|
||||
}
|
||||
}
|
||||
double num5 = (double)this.ALPHA * (num2 - num);
|
||||
double num6 = (double)this.ALPHA * (num4 - num3);
|
||||
TriangulationPoint triangulationPoint2 = new TriangulationPoint(num2 + num5, num3 - num6, -1);
|
||||
TriangulationPoint triangulationPoint3 = new TriangulationPoint(num - num5, num3 - num6, -1);
|
||||
this.Head = triangulationPoint2;
|
||||
this.Tail = triangulationPoint3;
|
||||
this.Points.Sort(this._comparator);
|
||||
}
|
||||
|
||||
// Token: 0x0600008C RID: 140 RVA: 0x000047E0 File Offset: 0x000029E0
|
||||
public void FinalizeTriangulation()
|
||||
{
|
||||
base.Triangulatable.AddTriangles(this.Triangles);
|
||||
this.Triangles.Clear();
|
||||
}
|
||||
|
||||
// Token: 0x0600008D RID: 141 RVA: 0x000047FE File Offset: 0x000029FE
|
||||
public override TriangulationConstraint NewConstraint(TriangulationPoint a, TriangulationPoint b)
|
||||
{
|
||||
return new DTSweepConstraint(a, b);
|
||||
}
|
||||
|
||||
// Token: 0x1700000E RID: 14
|
||||
// (get) Token: 0x0600008E RID: 142 RVA: 0x00004807 File Offset: 0x00002A07
|
||||
public override TriangulationAlgorithm Algorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return TriangulationAlgorithm.DTSweep;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0400001E RID: 30
|
||||
private readonly float ALPHA = 0.3f;
|
||||
|
||||
// Token: 0x0400001F RID: 31
|
||||
public AdvancingFront Front;
|
||||
|
||||
// Token: 0x04000022 RID: 34
|
||||
public DTSweepBasin Basin = new DTSweepBasin();
|
||||
|
||||
// Token: 0x04000023 RID: 35
|
||||
public DTSweepEdgeEvent EdgeEvent = new DTSweepEdgeEvent();
|
||||
|
||||
// Token: 0x04000024 RID: 36
|
||||
private DTSweepPointComparator _comparator = new DTSweepPointComparator();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200000D RID: 13
|
||||
public class DTSweepDebugContext : TriangulationDebugContext
|
||||
{
|
||||
// Token: 0x1700000F RID: 15
|
||||
// (get) Token: 0x0600008F RID: 143 RVA: 0x0000480A File Offset: 0x00002A0A
|
||||
// (set) Token: 0x06000090 RID: 144 RVA: 0x00004812 File Offset: 0x00002A12
|
||||
public DelaunayTriangle PrimaryTriangle
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._primaryTriangle;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._primaryTriangle = value;
|
||||
this._tcx.Update("set PrimaryTriangle");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000010 RID: 16
|
||||
// (get) Token: 0x06000091 RID: 145 RVA: 0x0000482B File Offset: 0x00002A2B
|
||||
// (set) Token: 0x06000092 RID: 146 RVA: 0x00004833 File Offset: 0x00002A33
|
||||
public DelaunayTriangle SecondaryTriangle
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._secondaryTriangle;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._secondaryTriangle = value;
|
||||
this._tcx.Update("set SecondaryTriangle");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000011 RID: 17
|
||||
// (get) Token: 0x06000093 RID: 147 RVA: 0x0000484C File Offset: 0x00002A4C
|
||||
// (set) Token: 0x06000094 RID: 148 RVA: 0x00004854 File Offset: 0x00002A54
|
||||
public TriangulationPoint ActivePoint
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._activePoint;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._activePoint = value;
|
||||
this._tcx.Update("set ActivePoint");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000012 RID: 18
|
||||
// (get) Token: 0x06000095 RID: 149 RVA: 0x0000486D File Offset: 0x00002A6D
|
||||
// (set) Token: 0x06000096 RID: 150 RVA: 0x00004875 File Offset: 0x00002A75
|
||||
public AdvancingFrontNode ActiveNode
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._activeNode;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._activeNode = value;
|
||||
this._tcx.Update("set ActiveNode");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000013 RID: 19
|
||||
// (get) Token: 0x06000097 RID: 151 RVA: 0x0000488E File Offset: 0x00002A8E
|
||||
// (set) Token: 0x06000098 RID: 152 RVA: 0x00004896 File Offset: 0x00002A96
|
||||
public DTSweepConstraint ActiveConstraint
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._activeConstraint;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._activeConstraint = value;
|
||||
this._tcx.Update("set ActiveConstraint");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000099 RID: 153 RVA: 0x000048AF File Offset: 0x00002AAF
|
||||
public DTSweepDebugContext(DTSweepContext tcx)
|
||||
: base(tcx)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x17000014 RID: 20
|
||||
// (get) Token: 0x0600009A RID: 154 RVA: 0x000048B8 File Offset: 0x00002AB8
|
||||
public bool IsDebugContext
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600009B RID: 155 RVA: 0x000048BB File Offset: 0x00002ABB
|
||||
public override void Clear()
|
||||
{
|
||||
this.PrimaryTriangle = null;
|
||||
this.SecondaryTriangle = null;
|
||||
this.ActivePoint = null;
|
||||
this.ActiveNode = null;
|
||||
this.ActiveConstraint = null;
|
||||
}
|
||||
|
||||
// Token: 0x04000025 RID: 37
|
||||
private DelaunayTriangle _primaryTriangle;
|
||||
|
||||
// Token: 0x04000026 RID: 38
|
||||
private DelaunayTriangle _secondaryTriangle;
|
||||
|
||||
// Token: 0x04000027 RID: 39
|
||||
private TriangulationPoint _activePoint;
|
||||
|
||||
// Token: 0x04000028 RID: 40
|
||||
private AdvancingFrontNode _activeNode;
|
||||
|
||||
// Token: 0x04000029 RID: 41
|
||||
private DTSweepConstraint _activeConstraint;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200000E RID: 14
|
||||
public class DTSweepEdgeEvent
|
||||
{
|
||||
// Token: 0x0400002A RID: 42
|
||||
public DTSweepConstraint ConstrainedEdge;
|
||||
|
||||
// Token: 0x0400002B RID: 43
|
||||
public bool Right;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200000F RID: 15
|
||||
public class DTSweepPointComparator : IComparer<TriangulationPoint>
|
||||
{
|
||||
// Token: 0x0600009D RID: 157 RVA: 0x000048E0 File Offset: 0x00002AE0
|
||||
public int Compare(TriangulationPoint p1, TriangulationPoint p2)
|
||||
{
|
||||
if (p1.Y < p2.Y)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (p1.Y > p2.Y)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (p1.X < p2.X)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (p1.X > p2.X)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000006 RID: 6
|
||||
public class DelaunayTriangle
|
||||
{
|
||||
// Token: 0x17000008 RID: 8
|
||||
// (get) Token: 0x06000026 RID: 38 RVA: 0x000025DD File Offset: 0x000007DD
|
||||
// (set) Token: 0x06000027 RID: 39 RVA: 0x000025E5 File Offset: 0x000007E5
|
||||
public bool IsInterior { get; set; }
|
||||
|
||||
// Token: 0x06000028 RID: 40 RVA: 0x000025EE File Offset: 0x000007EE
|
||||
public DelaunayTriangle(TriangulationPoint p1, TriangulationPoint p2, TriangulationPoint p3)
|
||||
{
|
||||
this.Points[0] = p1;
|
||||
this.Points[1] = p2;
|
||||
this.Points[2] = p3;
|
||||
}
|
||||
|
||||
// Token: 0x06000029 RID: 41 RVA: 0x0000261D File Offset: 0x0000081D
|
||||
public int IndexOf(TriangulationPoint p)
|
||||
{
|
||||
int num = this.Points.IndexOf(p);
|
||||
if (num == -1)
|
||||
{
|
||||
throw new Exception("Calling index with a point that doesn't exist in triangle");
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x0600002A RID: 42 RVA: 0x0000263A File Offset: 0x0000083A
|
||||
public int IndexCWFrom(TriangulationPoint p)
|
||||
{
|
||||
return (this.IndexOf(p) + 2) % 3;
|
||||
}
|
||||
|
||||
// Token: 0x0600002B RID: 43 RVA: 0x00002647 File Offset: 0x00000847
|
||||
public int IndexCCWFrom(TriangulationPoint p)
|
||||
{
|
||||
return (this.IndexOf(p) + 1) % 3;
|
||||
}
|
||||
|
||||
// Token: 0x0600002C RID: 44 RVA: 0x00002654 File Offset: 0x00000854
|
||||
public bool Contains(TriangulationPoint p)
|
||||
{
|
||||
return this.Points.Contains(p);
|
||||
}
|
||||
|
||||
// Token: 0x0600002D RID: 45 RVA: 0x00002664 File Offset: 0x00000864
|
||||
private void MarkNeighbor(TriangulationPoint p1, TriangulationPoint p2, DelaunayTriangle t)
|
||||
{
|
||||
int num = this.EdgeIndex(p1, p2);
|
||||
if (num == -1)
|
||||
{
|
||||
throw new Exception("Error marking neighbors -- t doesn't contain edge p1-p2!");
|
||||
}
|
||||
this.Neighbors[num] = t;
|
||||
}
|
||||
|
||||
// Token: 0x0600002E RID: 46 RVA: 0x00002698 File Offset: 0x00000898
|
||||
public void MarkNeighbor(DelaunayTriangle t)
|
||||
{
|
||||
bool flag = t.Contains(this.Points[0]);
|
||||
bool flag2 = t.Contains(this.Points[1]);
|
||||
bool flag3 = t.Contains(this.Points[2]);
|
||||
if (flag2 && flag3)
|
||||
{
|
||||
this.Neighbors[0] = t;
|
||||
t.MarkNeighbor(this.Points[1], this.Points[2], this);
|
||||
return;
|
||||
}
|
||||
if (flag && flag3)
|
||||
{
|
||||
this.Neighbors[1] = t;
|
||||
t.MarkNeighbor(this.Points[0], this.Points[2], this);
|
||||
return;
|
||||
}
|
||||
if (flag && flag2)
|
||||
{
|
||||
this.Neighbors[2] = t;
|
||||
t.MarkNeighbor(this.Points[0], this.Points[1], this);
|
||||
return;
|
||||
}
|
||||
throw new Exception("Failed to mark neighbor, doesn't share an edge!");
|
||||
}
|
||||
|
||||
// Token: 0x0600002F RID: 47 RVA: 0x0000277E File Offset: 0x0000097E
|
||||
public TriangulationPoint OppositePoint(DelaunayTriangle t, TriangulationPoint p)
|
||||
{
|
||||
return this.PointCWFrom(t.PointCWFrom(p));
|
||||
}
|
||||
|
||||
// Token: 0x06000030 RID: 48 RVA: 0x0000278D File Offset: 0x0000098D
|
||||
public DelaunayTriangle NeighborCWFrom(TriangulationPoint point)
|
||||
{
|
||||
return this.Neighbors[(this.Points.IndexOf(point) + 1) % 3];
|
||||
}
|
||||
|
||||
// Token: 0x06000031 RID: 49 RVA: 0x000027AA File Offset: 0x000009AA
|
||||
public DelaunayTriangle NeighborCCWFrom(TriangulationPoint point)
|
||||
{
|
||||
return this.Neighbors[(this.Points.IndexOf(point) + 2) % 3];
|
||||
}
|
||||
|
||||
// Token: 0x06000032 RID: 50 RVA: 0x000027C7 File Offset: 0x000009C7
|
||||
public DelaunayTriangle NeighborAcrossFrom(TriangulationPoint point)
|
||||
{
|
||||
return this.Neighbors[this.Points.IndexOf(point)];
|
||||
}
|
||||
|
||||
// Token: 0x06000033 RID: 51 RVA: 0x000027E0 File Offset: 0x000009E0
|
||||
public TriangulationPoint PointCCWFrom(TriangulationPoint point)
|
||||
{
|
||||
return this.Points[(this.IndexOf(point) + 1) % 3];
|
||||
}
|
||||
|
||||
// Token: 0x06000034 RID: 52 RVA: 0x000027F8 File Offset: 0x000009F8
|
||||
public TriangulationPoint PointCWFrom(TriangulationPoint point)
|
||||
{
|
||||
return this.Points[(this.IndexOf(point) + 2) % 3];
|
||||
}
|
||||
|
||||
// Token: 0x06000035 RID: 53 RVA: 0x00002810 File Offset: 0x00000A10
|
||||
private void RotateCW()
|
||||
{
|
||||
TriangulationPoint triangulationPoint = this.Points[2];
|
||||
this.Points[2] = this.Points[1];
|
||||
this.Points[1] = this.Points[0];
|
||||
this.Points[0] = triangulationPoint;
|
||||
}
|
||||
|
||||
// Token: 0x06000036 RID: 54 RVA: 0x00002867 File Offset: 0x00000A67
|
||||
public void Legalize(TriangulationPoint oPoint, TriangulationPoint nPoint)
|
||||
{
|
||||
this.RotateCW();
|
||||
this.Points[this.IndexCCWFrom(oPoint)] = nPoint;
|
||||
}
|
||||
|
||||
// Token: 0x06000037 RID: 55 RVA: 0x00002884 File Offset: 0x00000A84
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Concat(new object[]
|
||||
{
|
||||
this.Points[0],
|
||||
",",
|
||||
this.Points[1],
|
||||
",",
|
||||
this.Points[2]
|
||||
});
|
||||
}
|
||||
|
||||
// Token: 0x06000038 RID: 56 RVA: 0x000028DC File Offset: 0x00000ADC
|
||||
public void MarkNeighborEdges()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (this.EdgeIsConstrained[i] && this.Neighbors[i] != null)
|
||||
{
|
||||
this.Neighbors[i].MarkConstrainedEdge(this.Points[(i + 1) % 3], this.Points[(i + 2) % 3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000039 RID: 57 RVA: 0x00002944 File Offset: 0x00000B44
|
||||
public void MarkEdge(DelaunayTriangle triangle)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (this.EdgeIsConstrained[i])
|
||||
{
|
||||
triangle.MarkConstrainedEdge(this.Points[(i + 1) % 3], this.Points[(i + 2) % 3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600003A RID: 58 RVA: 0x00002994 File Offset: 0x00000B94
|
||||
public void MarkEdge(List<DelaunayTriangle> tList)
|
||||
{
|
||||
foreach (DelaunayTriangle delaunayTriangle in tList)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (delaunayTriangle.EdgeIsConstrained[i])
|
||||
{
|
||||
this.MarkConstrainedEdge(delaunayTriangle.Points[(i + 1) % 3], delaunayTriangle.Points[(i + 2) % 3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600003B RID: 59 RVA: 0x00002A1C File Offset: 0x00000C1C
|
||||
public void MarkConstrainedEdge(int index)
|
||||
{
|
||||
this.EdgeIsConstrained[index] = true;
|
||||
}
|
||||
|
||||
// Token: 0x0600003C RID: 60 RVA: 0x00002A2B File Offset: 0x00000C2B
|
||||
public void MarkConstrainedEdge(DTSweepConstraint edge)
|
||||
{
|
||||
this.MarkConstrainedEdge(edge.P, edge.Q);
|
||||
}
|
||||
|
||||
// Token: 0x0600003D RID: 61 RVA: 0x00002A40 File Offset: 0x00000C40
|
||||
public void MarkConstrainedEdge(TriangulationPoint p, TriangulationPoint q)
|
||||
{
|
||||
int num = this.EdgeIndex(p, q);
|
||||
if (num != -1)
|
||||
{
|
||||
this.EdgeIsConstrained[num] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600003E RID: 62 RVA: 0x00002A68 File Offset: 0x00000C68
|
||||
public double Area()
|
||||
{
|
||||
double num = this.Points[0].X - this.Points[1].X;
|
||||
double num2 = this.Points[2].Y - this.Points[1].Y;
|
||||
return Math.Abs(num * num2 * 0.5);
|
||||
}
|
||||
|
||||
// Token: 0x0600003F RID: 63 RVA: 0x00002AD0 File Offset: 0x00000CD0
|
||||
public TriangulationPoint Centroid()
|
||||
{
|
||||
double num = (this.Points[0].X + this.Points[1].X + this.Points[2].X) / 3.0;
|
||||
double num2 = (this.Points[0].Y + this.Points[1].Y + this.Points[2].Y) / 3.0;
|
||||
return new TriangulationPoint(num, num2, -1);
|
||||
}
|
||||
|
||||
// Token: 0x06000040 RID: 64 RVA: 0x00002B64 File Offset: 0x00000D64
|
||||
public int EdgeIndex(TriangulationPoint p1, TriangulationPoint p2)
|
||||
{
|
||||
int num = this.Points.IndexOf(p1);
|
||||
int num2 = this.Points.IndexOf(p2);
|
||||
bool flag = num == 0 || num2 == 0;
|
||||
bool flag2 = num == 1 || num2 == 1;
|
||||
bool flag3 = num == 2 || num2 == 2;
|
||||
if (flag2 && flag3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (flag && flag3)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (flag && flag2)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000041 RID: 65 RVA: 0x00002BC2 File Offset: 0x00000DC2
|
||||
public bool GetConstrainedEdgeCCW(TriangulationPoint p)
|
||||
{
|
||||
return this.EdgeIsConstrained[(this.IndexOf(p) + 2) % 3];
|
||||
}
|
||||
|
||||
// Token: 0x06000042 RID: 66 RVA: 0x00002BDA File Offset: 0x00000DDA
|
||||
public bool GetConstrainedEdgeCW(TriangulationPoint p)
|
||||
{
|
||||
return this.EdgeIsConstrained[(this.IndexOf(p) + 1) % 3];
|
||||
}
|
||||
|
||||
// Token: 0x06000043 RID: 67 RVA: 0x00002BF2 File Offset: 0x00000DF2
|
||||
public bool GetConstrainedEdgeAcross(TriangulationPoint p)
|
||||
{
|
||||
return this.EdgeIsConstrained[this.IndexOf(p)];
|
||||
}
|
||||
|
||||
// Token: 0x06000044 RID: 68 RVA: 0x00002C06 File Offset: 0x00000E06
|
||||
public void SetConstrainedEdgeCCW(TriangulationPoint p, bool ce)
|
||||
{
|
||||
this.EdgeIsConstrained[(this.IndexOf(p) + 2) % 3] = ce;
|
||||
}
|
||||
|
||||
// Token: 0x06000045 RID: 69 RVA: 0x00002C1F File Offset: 0x00000E1F
|
||||
public void SetConstrainedEdgeCW(TriangulationPoint p, bool ce)
|
||||
{
|
||||
this.EdgeIsConstrained[(this.IndexOf(p) + 1) % 3] = ce;
|
||||
}
|
||||
|
||||
// Token: 0x06000046 RID: 70 RVA: 0x00002C38 File Offset: 0x00000E38
|
||||
public void SetConstrainedEdgeAcross(TriangulationPoint p, bool ce)
|
||||
{
|
||||
this.EdgeIsConstrained[this.IndexOf(p)] = ce;
|
||||
}
|
||||
|
||||
// Token: 0x06000047 RID: 71 RVA: 0x00002C4D File Offset: 0x00000E4D
|
||||
public bool GetDelaunayEdgeCCW(TriangulationPoint p)
|
||||
{
|
||||
return this.EdgeIsDelaunay[(this.IndexOf(p) + 2) % 3];
|
||||
}
|
||||
|
||||
// Token: 0x06000048 RID: 72 RVA: 0x00002C65 File Offset: 0x00000E65
|
||||
public bool GetDelaunayEdgeCW(TriangulationPoint p)
|
||||
{
|
||||
return this.EdgeIsDelaunay[(this.IndexOf(p) + 1) % 3];
|
||||
}
|
||||
|
||||
// Token: 0x06000049 RID: 73 RVA: 0x00002C7D File Offset: 0x00000E7D
|
||||
public bool GetDelaunayEdgeAcross(TriangulationPoint p)
|
||||
{
|
||||
return this.EdgeIsDelaunay[this.IndexOf(p)];
|
||||
}
|
||||
|
||||
// Token: 0x0600004A RID: 74 RVA: 0x00002C91 File Offset: 0x00000E91
|
||||
public void SetDelaunayEdgeCCW(TriangulationPoint p, bool ce)
|
||||
{
|
||||
this.EdgeIsDelaunay[(this.IndexOf(p) + 2) % 3] = ce;
|
||||
}
|
||||
|
||||
// Token: 0x0600004B RID: 75 RVA: 0x00002CAA File Offset: 0x00000EAA
|
||||
public void SetDelaunayEdgeCW(TriangulationPoint p, bool ce)
|
||||
{
|
||||
this.EdgeIsDelaunay[(this.IndexOf(p) + 1) % 3] = ce;
|
||||
}
|
||||
|
||||
// Token: 0x0600004C RID: 76 RVA: 0x00002CC3 File Offset: 0x00000EC3
|
||||
public void SetDelaunayEdgeAcross(TriangulationPoint p, bool ce)
|
||||
{
|
||||
this.EdgeIsDelaunay[this.IndexOf(p)] = ce;
|
||||
}
|
||||
|
||||
// Token: 0x0400000A RID: 10
|
||||
public FixedArray3<TriangulationPoint> Points;
|
||||
|
||||
// Token: 0x0400000B RID: 11
|
||||
public FixedArray3<DelaunayTriangle> Neighbors;
|
||||
|
||||
// Token: 0x0400000C RID: 12
|
||||
public FixedBitArray3 EdgeIsConstrained;
|
||||
|
||||
// Token: 0x0400000D RID: 13
|
||||
public FixedBitArray3 EdgeIsDelaunay;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200001E RID: 30
|
||||
public struct FixedArray3<T> : IEnumerable<T>, IEnumerable where T : class
|
||||
{
|
||||
// Token: 0x17000028 RID: 40
|
||||
public T this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
return this._0;
|
||||
case 1:
|
||||
return this._1;
|
||||
case 2:
|
||||
return this._2;
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
this._0 = value;
|
||||
return;
|
||||
case 1:
|
||||
this._1 = value;
|
||||
return;
|
||||
case 2:
|
||||
this._2 = value;
|
||||
return;
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060000E4 RID: 228 RVA: 0x000051C8 File Offset: 0x000033C8
|
||||
public bool Contains(T value)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (this[i] == value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x060000E5 RID: 229 RVA: 0x000051F8 File Offset: 0x000033F8
|
||||
public int IndexOf(T value)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (this[i] == value)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x060000E6 RID: 230 RVA: 0x00005228 File Offset: 0x00003428
|
||||
public void Clear()
|
||||
{
|
||||
this._0 = (this._1 = (this._2 = default(T)));
|
||||
}
|
||||
|
||||
// Token: 0x060000E7 RID: 231 RVA: 0x00005258 File Offset: 0x00003458
|
||||
public void Clear(T value)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (this[i] == value)
|
||||
{
|
||||
this[i] = default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060000E8 RID: 232 RVA: 0x00005295 File Offset: 0x00003495
|
||||
private IEnumerable<T> Enumerate()
|
||||
{
|
||||
int num;
|
||||
for (int i = 0; i < 3; i = num)
|
||||
{
|
||||
yield return this[i];
|
||||
num = i + 1;
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Token: 0x060000E9 RID: 233 RVA: 0x000052AA File Offset: 0x000034AA
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return this.Enumerate().GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x060000EA RID: 234 RVA: 0x000052B7 File Offset: 0x000034B7
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x04000050 RID: 80
|
||||
public T _0;
|
||||
|
||||
// Token: 0x04000051 RID: 81
|
||||
public T _1;
|
||||
|
||||
// Token: 0x04000052 RID: 82
|
||||
public T _2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200001F RID: 31
|
||||
public struct FixedBitArray3 : IEnumerable<bool>, IEnumerable
|
||||
{
|
||||
// Token: 0x17000029 RID: 41
|
||||
public bool this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
return this._0;
|
||||
case 1:
|
||||
return this._1;
|
||||
case 2:
|
||||
return this._2;
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
this._0 = value;
|
||||
return;
|
||||
case 1:
|
||||
this._1 = value;
|
||||
return;
|
||||
case 2:
|
||||
this._2 = value;
|
||||
return;
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060000ED RID: 237 RVA: 0x00005324 File Offset: 0x00003524
|
||||
public bool Contains(bool value)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (this[i] == value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x060000EE RID: 238 RVA: 0x0000534C File Offset: 0x0000354C
|
||||
public int IndexOf(bool value)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (this[i] == value)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x060000EF RID: 239 RVA: 0x00005374 File Offset: 0x00003574
|
||||
public void Clear()
|
||||
{
|
||||
this._0 = (this._1 = (this._2 = false));
|
||||
}
|
||||
|
||||
// Token: 0x060000F0 RID: 240 RVA: 0x0000539C File Offset: 0x0000359C
|
||||
public void Clear(bool value)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (this[i] == value)
|
||||
{
|
||||
this[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060000F1 RID: 241 RVA: 0x000053C7 File Offset: 0x000035C7
|
||||
private IEnumerable<bool> Enumerate()
|
||||
{
|
||||
int num;
|
||||
for (int i = 0; i < 3; i = num)
|
||||
{
|
||||
yield return this[i];
|
||||
num = i + 1;
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
// Token: 0x060000F2 RID: 242 RVA: 0x000053DC File Offset: 0x000035DC
|
||||
public IEnumerator<bool> GetEnumerator()
|
||||
{
|
||||
return this.Enumerate().GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x060000F3 RID: 243 RVA: 0x000053E9 File Offset: 0x000035E9
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x04000053 RID: 83
|
||||
public bool _0;
|
||||
|
||||
// Token: 0x04000054 RID: 84
|
||||
public bool _1;
|
||||
|
||||
// Token: 0x04000055 RID: 85
|
||||
public bool _2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000011 RID: 17
|
||||
public enum Orientation
|
||||
{
|
||||
// Token: 0x04000030 RID: 48
|
||||
CW,
|
||||
// Token: 0x04000031 RID: 49
|
||||
CCW,
|
||||
// Token: 0x04000032 RID: 50
|
||||
Collinear
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000002 RID: 2
|
||||
public static class P2T
|
||||
{
|
||||
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
|
||||
public static void Triangulate(PolygonSet ps)
|
||||
{
|
||||
TriangulationContext triangulationContext = P2T.CreateContext(P2T._defaultAlgorithm);
|
||||
foreach (Polygon polygon in ps.Polygons)
|
||||
{
|
||||
triangulationContext.PrepareTriangulation(polygon);
|
||||
P2T.Triangulate(triangulationContext);
|
||||
triangulationContext.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000002 RID: 2 RVA: 0x000020B4 File Offset: 0x000002B4
|
||||
public static void Triangulate(Polygon p)
|
||||
{
|
||||
P2T.Triangulate(P2T._defaultAlgorithm, p);
|
||||
}
|
||||
|
||||
// Token: 0x06000003 RID: 3 RVA: 0x000020B4 File Offset: 0x000002B4
|
||||
public static void Triangulate(ConstrainedPointSet cps)
|
||||
{
|
||||
P2T.Triangulate(P2T._defaultAlgorithm, cps);
|
||||
}
|
||||
|
||||
// Token: 0x06000004 RID: 4 RVA: 0x000020B4 File Offset: 0x000002B4
|
||||
public static void Triangulate(PointSet ps)
|
||||
{
|
||||
P2T.Triangulate(P2T._defaultAlgorithm, ps);
|
||||
}
|
||||
|
||||
// Token: 0x06000005 RID: 5 RVA: 0x000020C1 File Offset: 0x000002C1
|
||||
public static TriangulationContext CreateContext(TriangulationAlgorithm algorithm)
|
||||
{
|
||||
return new DTSweepContext();
|
||||
}
|
||||
|
||||
// Token: 0x06000006 RID: 6 RVA: 0x000020CA File Offset: 0x000002CA
|
||||
public static void Triangulate(TriangulationAlgorithm algorithm, Triangulatable t)
|
||||
{
|
||||
TriangulationContext triangulationContext = P2T.CreateContext(algorithm);
|
||||
triangulationContext.PrepareTriangulation(t);
|
||||
P2T.Triangulate(triangulationContext);
|
||||
}
|
||||
|
||||
// Token: 0x06000007 RID: 7 RVA: 0x000020E0 File Offset: 0x000002E0
|
||||
public static void Triangulate(TriangulationContext tcx)
|
||||
{
|
||||
TriangulationAlgorithm algorithm = tcx.Algorithm;
|
||||
DTSweep.Triangulate((DTSweepContext)tcx);
|
||||
}
|
||||
|
||||
// Token: 0x06000008 RID: 8 RVA: 0x00002101 File Offset: 0x00000301
|
||||
public static void Warmup()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x04000001 RID: 1
|
||||
private static TriangulationAlgorithm _defaultAlgorithm;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200001C RID: 28
|
||||
public class PointGenerator
|
||||
{
|
||||
// Token: 0x060000DA RID: 218 RVA: 0x00004E50 File Offset: 0x00003050
|
||||
public static List<TriangulationPoint> UniformDistribution(int n, double scale)
|
||||
{
|
||||
List<TriangulationPoint> list = new List<TriangulationPoint>();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
list.Add(new TriangulationPoint(scale * (0.5 - PointGenerator.RNG.NextDouble()), scale * (0.5 - PointGenerator.RNG.NextDouble()), i));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// Token: 0x060000DB RID: 219 RVA: 0x00004EA8 File Offset: 0x000030A8
|
||||
public static List<TriangulationPoint> UniformGrid(int n, double scale)
|
||||
{
|
||||
double num = scale / (double)n;
|
||||
double num2 = 0.5 * scale;
|
||||
List<TriangulationPoint> list = new List<TriangulationPoint>();
|
||||
for (int i = 0; i < n + 1; i++)
|
||||
{
|
||||
double num3 = num2 - (double)i * num;
|
||||
for (int j = 0; j < n + 1; j++)
|
||||
{
|
||||
list.Add(new TriangulationPoint(num3, num2 - (double)j * num, i));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
// Token: 0x0400004D RID: 77
|
||||
private static readonly Random RNG = new Random();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000010 RID: 16
|
||||
public class PointOnEdgeException : NotImplementedException
|
||||
{
|
||||
// Token: 0x0600009F RID: 159 RVA: 0x0000492E File Offset: 0x00002B2E
|
||||
public PointOnEdgeException(string message, TriangulationPoint a, TriangulationPoint b, TriangulationPoint c)
|
||||
: base(message)
|
||||
{
|
||||
this.A = a;
|
||||
this.B = b;
|
||||
this.C = c;
|
||||
}
|
||||
|
||||
// Token: 0x0400002C RID: 44
|
||||
public readonly TriangulationPoint A;
|
||||
|
||||
// Token: 0x0400002D RID: 45
|
||||
public readonly TriangulationPoint B;
|
||||
|
||||
// Token: 0x0400002E RID: 46
|
||||
public readonly TriangulationPoint C;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000013 RID: 19
|
||||
public class PointSet : Triangulatable
|
||||
{
|
||||
// Token: 0x17000017 RID: 23
|
||||
// (get) Token: 0x060000A5 RID: 165 RVA: 0x000049C6 File Offset: 0x00002BC6
|
||||
// (set) Token: 0x060000A6 RID: 166 RVA: 0x000049CE File Offset: 0x00002BCE
|
||||
public IList<TriangulationPoint> Points { get; private set; }
|
||||
|
||||
// Token: 0x17000018 RID: 24
|
||||
// (get) Token: 0x060000A7 RID: 167 RVA: 0x000049D7 File Offset: 0x00002BD7
|
||||
// (set) Token: 0x060000A8 RID: 168 RVA: 0x000049DF File Offset: 0x00002BDF
|
||||
public IList<DelaunayTriangle> Triangles { get; private set; }
|
||||
|
||||
// Token: 0x060000A9 RID: 169 RVA: 0x000049E8 File Offset: 0x00002BE8
|
||||
public PointSet(List<TriangulationPoint> points)
|
||||
{
|
||||
this.Points = new List<TriangulationPoint>(points);
|
||||
}
|
||||
|
||||
// Token: 0x17000019 RID: 25
|
||||
// (get) Token: 0x060000AA RID: 170 RVA: 0x00004807 File Offset: 0x00002A07
|
||||
public virtual TriangulationMode TriangulationMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return TriangulationMode.Unconstrained;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060000AB RID: 171 RVA: 0x000049FC File Offset: 0x00002BFC
|
||||
public void AddTriangle(DelaunayTriangle t)
|
||||
{
|
||||
this.Triangles.Add(t);
|
||||
}
|
||||
|
||||
// Token: 0x060000AC RID: 172 RVA: 0x00004A0C File Offset: 0x00002C0C
|
||||
public void AddTriangles(IEnumerable<DelaunayTriangle> list)
|
||||
{
|
||||
foreach (DelaunayTriangle delaunayTriangle in list)
|
||||
{
|
||||
this.Triangles.Add(delaunayTriangle);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060000AD RID: 173 RVA: 0x00004A5C File Offset: 0x00002C5C
|
||||
public void ClearTriangles()
|
||||
{
|
||||
this.Triangles.Clear();
|
||||
}
|
||||
|
||||
// Token: 0x060000AE RID: 174 RVA: 0x00004A69 File Offset: 0x00002C69
|
||||
public virtual void Prepare(TriangulationContext tcx)
|
||||
{
|
||||
if (this.Triangles == null)
|
||||
{
|
||||
this.Triangles = new List<DelaunayTriangle>(this.Points.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Triangles.Clear();
|
||||
}
|
||||
tcx.Points.AddRange(this.Points);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{99604A24-13D0-4C83-A3AA-9A315339FA50}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Poly2Tri</RootNamespace>
|
||||
<AssemblyName>Poly2Tri</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
</PropertyGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdvancingFront.cs" />
|
||||
<Compile Include="AdvancingFrontNode.cs" />
|
||||
<Compile Include="ConstrainedPointSet.cs" />
|
||||
<Compile Include="DelaunayTriangle.cs" />
|
||||
<Compile Include="DTSweep.cs" />
|
||||
<Compile Include="DTSweepBasin.cs" />
|
||||
<Compile Include="DTSweepConstraint.cs" />
|
||||
<Compile Include="DTSweepContext.cs" />
|
||||
<Compile Include="DTSweepDebugContext.cs" />
|
||||
<Compile Include="DTSweepEdgeEvent.cs" />
|
||||
<Compile Include="DTSweepPointComparator.cs" />
|
||||
<Compile Include="FixedArray3.cs" />
|
||||
<Compile Include="FixedBitArray3.cs" />
|
||||
<Compile Include="Orientation.cs" />
|
||||
<Compile Include="P2T.cs" />
|
||||
<Compile Include="PointGenerator.cs" />
|
||||
<Compile Include="PointOnEdgeException.cs" />
|
||||
<Compile Include="PointSet.cs" />
|
||||
<Compile Include="Polygon.cs" />
|
||||
<Compile Include="PolygonGenerator.cs" />
|
||||
<Compile Include="PolygonPoint.cs" />
|
||||
<Compile Include="PolygonSet.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Triangulatable.cs" />
|
||||
<Compile Include="TriangulationAlgorithm.cs" />
|
||||
<Compile Include="TriangulationConstraint.cs" />
|
||||
<Compile Include="TriangulationContext.cs" />
|
||||
<Compile Include="TriangulationDebugContext.cs" />
|
||||
<Compile Include="TriangulationMode.cs" />
|
||||
<Compile Include="TriangulationPoint.cs" />
|
||||
<Compile Include="TriangulationUtil.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\mscorlib\mscorlib.csproj">
|
||||
<Project>{99604a24-13d0-4c83-a3aa-9a315339fa4c}</Project>
|
||||
<Name>mscorlib</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\System.Core\System.Core.csproj">
|
||||
<Project>{99604a24-13d0-4c83-a3aa-9a315339fa55}</Project>
|
||||
<Name>System.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,239 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000003 RID: 3
|
||||
public class Polygon : Triangulatable
|
||||
{
|
||||
// Token: 0x0600000A RID: 10 RVA: 0x00002104 File Offset: 0x00000304
|
||||
public Polygon(IList<PolygonPoint> points)
|
||||
{
|
||||
if (points.Count < 3)
|
||||
{
|
||||
throw new ArgumentException("List has fewer than 3 points", "points");
|
||||
}
|
||||
if (points[0].Equals(points[points.Count - 1]))
|
||||
{
|
||||
points.RemoveAt(points.Count - 1);
|
||||
}
|
||||
this._points.AddRange(points.Cast<TriangulationPoint>());
|
||||
}
|
||||
|
||||
// Token: 0x0600000B RID: 11 RVA: 0x00002176 File Offset: 0x00000376
|
||||
public Polygon(IEnumerable<PolygonPoint> points)
|
||||
: this((points as IList<PolygonPoint>) ?? points.ToArray<PolygonPoint>())
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600000C RID: 12 RVA: 0x0000218E File Offset: 0x0000038E
|
||||
public Polygon(params PolygonPoint[] points)
|
||||
: this(points)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x17000001 RID: 1
|
||||
// (get) Token: 0x0600000D RID: 13 RVA: 0x00002197 File Offset: 0x00000397
|
||||
public TriangulationMode TriangulationMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return TriangulationMode.Polygon;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600000E RID: 14 RVA: 0x0000219A File Offset: 0x0000039A
|
||||
public void AddSteinerPoint(TriangulationPoint point)
|
||||
{
|
||||
if (this._steinerPoints == null)
|
||||
{
|
||||
this._steinerPoints = new List<TriangulationPoint>();
|
||||
}
|
||||
this._steinerPoints.Add(point);
|
||||
}
|
||||
|
||||
// Token: 0x0600000F RID: 15 RVA: 0x000021BB File Offset: 0x000003BB
|
||||
public void AddSteinerPoints(List<TriangulationPoint> points)
|
||||
{
|
||||
if (this._steinerPoints == null)
|
||||
{
|
||||
this._steinerPoints = new List<TriangulationPoint>();
|
||||
}
|
||||
this._steinerPoints.AddRange(points);
|
||||
}
|
||||
|
||||
// Token: 0x06000010 RID: 16 RVA: 0x000021DC File Offset: 0x000003DC
|
||||
public void ClearSteinerPoints()
|
||||
{
|
||||
if (this._steinerPoints != null)
|
||||
{
|
||||
this._steinerPoints.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000011 RID: 17 RVA: 0x000021F1 File Offset: 0x000003F1
|
||||
public void AddHole(Polygon poly)
|
||||
{
|
||||
if (this._holes == null)
|
||||
{
|
||||
this._holes = new List<Polygon>();
|
||||
}
|
||||
this._holes.Add(poly);
|
||||
}
|
||||
|
||||
// Token: 0x06000012 RID: 18 RVA: 0x00002214 File Offset: 0x00000414
|
||||
public void InsertPointAfter(PolygonPoint point, PolygonPoint newPoint)
|
||||
{
|
||||
int num = this._points.IndexOf(point);
|
||||
if (num == -1)
|
||||
{
|
||||
throw new ArgumentException("Tried to insert a point into a Polygon after a point not belonging to the Polygon", "point");
|
||||
}
|
||||
newPoint.Next = point.Next;
|
||||
newPoint.Previous = point;
|
||||
point.Next.Previous = newPoint;
|
||||
point.Next = newPoint;
|
||||
this._points.Insert(num + 1, newPoint);
|
||||
}
|
||||
|
||||
// Token: 0x06000013 RID: 19 RVA: 0x00002278 File Offset: 0x00000478
|
||||
public void AddPoints(IEnumerable<PolygonPoint> list)
|
||||
{
|
||||
foreach (PolygonPoint polygonPoint in list)
|
||||
{
|
||||
polygonPoint.Previous = this._last;
|
||||
if (this._last != null)
|
||||
{
|
||||
polygonPoint.Next = this._last.Next;
|
||||
this._last.Next = polygonPoint;
|
||||
}
|
||||
this._last = polygonPoint;
|
||||
this._points.Add(polygonPoint);
|
||||
}
|
||||
PolygonPoint polygonPoint2 = (PolygonPoint)this._points[0];
|
||||
this._last.Next = polygonPoint2;
|
||||
polygonPoint2.Previous = this._last;
|
||||
}
|
||||
|
||||
// Token: 0x06000014 RID: 20 RVA: 0x00002328 File Offset: 0x00000528
|
||||
public void AddPoint(PolygonPoint p)
|
||||
{
|
||||
p.Previous = this._last;
|
||||
p.Next = this._last.Next;
|
||||
this._last.Next = p;
|
||||
this._points.Add(p);
|
||||
}
|
||||
|
||||
// Token: 0x06000015 RID: 21 RVA: 0x00002360 File Offset: 0x00000560
|
||||
public void RemovePoint(PolygonPoint p)
|
||||
{
|
||||
PolygonPoint next = p.Next;
|
||||
PolygonPoint previous = p.Previous;
|
||||
previous.Next = next;
|
||||
next.Previous = previous;
|
||||
this._points.Remove(p);
|
||||
}
|
||||
|
||||
// Token: 0x17000002 RID: 2
|
||||
// (get) Token: 0x06000016 RID: 22 RVA: 0x00002396 File Offset: 0x00000596
|
||||
public IList<TriangulationPoint> Points
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._points;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000003 RID: 3
|
||||
// (get) Token: 0x06000017 RID: 23 RVA: 0x0000239E File Offset: 0x0000059E
|
||||
public IList<DelaunayTriangle> Triangles
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._triangles;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000004 RID: 4
|
||||
// (get) Token: 0x06000018 RID: 24 RVA: 0x000023A6 File Offset: 0x000005A6
|
||||
public IList<Polygon> Holes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._holes;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000019 RID: 25 RVA: 0x000023AE File Offset: 0x000005AE
|
||||
public void AddTriangle(DelaunayTriangle t)
|
||||
{
|
||||
this._triangles.Add(t);
|
||||
}
|
||||
|
||||
// Token: 0x0600001A RID: 26 RVA: 0x000023BC File Offset: 0x000005BC
|
||||
public void AddTriangles(IEnumerable<DelaunayTriangle> list)
|
||||
{
|
||||
this._triangles.AddRange(list);
|
||||
}
|
||||
|
||||
// Token: 0x0600001B RID: 27 RVA: 0x000023CA File Offset: 0x000005CA
|
||||
public void ClearTriangles()
|
||||
{
|
||||
if (this._triangles != null)
|
||||
{
|
||||
this._triangles.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600001C RID: 28 RVA: 0x000023E0 File Offset: 0x000005E0
|
||||
public void Prepare(TriangulationContext tcx)
|
||||
{
|
||||
if (this._triangles == null)
|
||||
{
|
||||
this._triangles = new List<DelaunayTriangle>(this._points.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._triangles.Clear();
|
||||
}
|
||||
for (int i = 0; i < this._points.Count - 1; i++)
|
||||
{
|
||||
tcx.NewConstraint(this._points[i], this._points[i + 1]);
|
||||
}
|
||||
tcx.NewConstraint(this._points[0], this._points[this._points.Count - 1]);
|
||||
tcx.Points.AddRange(this._points);
|
||||
if (this._holes != null)
|
||||
{
|
||||
foreach (Polygon polygon in this._holes)
|
||||
{
|
||||
for (int j = 0; j < polygon._points.Count - 1; j++)
|
||||
{
|
||||
tcx.NewConstraint(polygon._points[j], polygon._points[j + 1]);
|
||||
}
|
||||
tcx.NewConstraint(polygon._points[0], polygon._points[polygon._points.Count - 1]);
|
||||
tcx.Points.AddRange(polygon._points);
|
||||
}
|
||||
}
|
||||
if (this._steinerPoints != null)
|
||||
{
|
||||
tcx.Points.AddRange(this._steinerPoints);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000002 RID: 2
|
||||
protected List<TriangulationPoint> _points = new List<TriangulationPoint>();
|
||||
|
||||
// Token: 0x04000003 RID: 3
|
||||
protected List<TriangulationPoint> _steinerPoints;
|
||||
|
||||
// Token: 0x04000004 RID: 4
|
||||
protected List<Polygon> _holes;
|
||||
|
||||
// Token: 0x04000005 RID: 5
|
||||
protected List<DelaunayTriangle> _triangles;
|
||||
|
||||
// Token: 0x04000006 RID: 6
|
||||
protected PolygonPoint _last;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200001D RID: 29
|
||||
public class PolygonGenerator
|
||||
{
|
||||
// Token: 0x060000DE RID: 222 RVA: 0x00004F24 File Offset: 0x00003124
|
||||
public static Polygon RandomCircleSweep(double scale, int vertexCount)
|
||||
{
|
||||
double num = scale / 4.0;
|
||||
PolygonPoint[] array = new PolygonPoint[vertexCount];
|
||||
for (int i = 0; i < vertexCount; i++)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (i % 250 == 0)
|
||||
{
|
||||
num += scale / 2.0 * (0.5 - PolygonGenerator.RNG.NextDouble());
|
||||
}
|
||||
else if (i % 50 == 0)
|
||||
{
|
||||
num += scale / 5.0 * (0.5 - PolygonGenerator.RNG.NextDouble());
|
||||
}
|
||||
else
|
||||
{
|
||||
num += 25.0 * scale / (double)vertexCount * (0.5 - PolygonGenerator.RNG.NextDouble());
|
||||
}
|
||||
num = ((num > scale / 2.0) ? (scale / 2.0) : num);
|
||||
num = ((num < scale / 10.0) ? (scale / 10.0) : num);
|
||||
}
|
||||
while (num < scale / 10.0 || num > scale / 2.0);
|
||||
PolygonPoint polygonPoint = new PolygonPoint(num * Math.Cos(PolygonGenerator.PI_2 * (double)i / (double)vertexCount), num * Math.Sin(PolygonGenerator.PI_2 * (double)i / (double)vertexCount), i);
|
||||
array[i] = polygonPoint;
|
||||
}
|
||||
return new Polygon(array);
|
||||
}
|
||||
|
||||
// Token: 0x060000DF RID: 223 RVA: 0x00005068 File Offset: 0x00003268
|
||||
public static Polygon RandomCircleSweep2(double scale, int vertexCount)
|
||||
{
|
||||
double num = scale / 4.0;
|
||||
PolygonPoint[] array = new PolygonPoint[vertexCount];
|
||||
for (int i = 0; i < vertexCount; i++)
|
||||
{
|
||||
do
|
||||
{
|
||||
num += scale / 5.0 * (0.5 - PolygonGenerator.RNG.NextDouble());
|
||||
num = ((num > scale / 2.0) ? (scale / 2.0) : num);
|
||||
num = ((num < scale / 10.0) ? (scale / 10.0) : num);
|
||||
}
|
||||
while (num < scale / 10.0 || num > scale / 2.0);
|
||||
PolygonPoint polygonPoint = new PolygonPoint(num * Math.Cos(PolygonGenerator.PI_2 * (double)i / (double)vertexCount), num * Math.Sin(PolygonGenerator.PI_2 * (double)i / (double)vertexCount), i);
|
||||
array[i] = polygonPoint;
|
||||
}
|
||||
return new Polygon(array);
|
||||
}
|
||||
|
||||
// Token: 0x0400004E RID: 78
|
||||
private static readonly Random RNG = new Random();
|
||||
|
||||
// Token: 0x0400004F RID: 79
|
||||
private static double PI_2 = 6.283185307179586;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000004 RID: 4
|
||||
public class PolygonPoint : TriangulationPoint
|
||||
{
|
||||
// Token: 0x0600001D RID: 29 RVA: 0x00002568 File Offset: 0x00000768
|
||||
public PolygonPoint(double x, double y, int index = -1)
|
||||
: base(x, y, index)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x17000005 RID: 5
|
||||
// (get) Token: 0x0600001E RID: 30 RVA: 0x00002573 File Offset: 0x00000773
|
||||
// (set) Token: 0x0600001F RID: 31 RVA: 0x0000257B File Offset: 0x0000077B
|
||||
public PolygonPoint Next { get; set; }
|
||||
|
||||
// Token: 0x17000006 RID: 6
|
||||
// (get) Token: 0x06000020 RID: 32 RVA: 0x00002584 File Offset: 0x00000784
|
||||
// (set) Token: 0x06000021 RID: 33 RVA: 0x0000258C File Offset: 0x0000078C
|
||||
public PolygonPoint Previous { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000005 RID: 5
|
||||
public class PolygonSet
|
||||
{
|
||||
// Token: 0x06000022 RID: 34 RVA: 0x00002595 File Offset: 0x00000795
|
||||
public PolygonSet()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000023 RID: 35 RVA: 0x000025A8 File Offset: 0x000007A8
|
||||
public PolygonSet(Polygon poly)
|
||||
{
|
||||
this._polygons.Add(poly);
|
||||
}
|
||||
|
||||
// Token: 0x06000024 RID: 36 RVA: 0x000025C7 File Offset: 0x000007C7
|
||||
public void Add(Polygon p)
|
||||
{
|
||||
this._polygons.Add(p);
|
||||
}
|
||||
|
||||
// Token: 0x17000007 RID: 7
|
||||
// (get) Token: 0x06000025 RID: 37 RVA: 0x000025D5 File Offset: 0x000007D5
|
||||
public IEnumerable<Polygon> Polygons
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._polygons;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000009 RID: 9
|
||||
protected List<Polygon> _polygons = new List<Polygon>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyTitle("Poly2Tri")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Poly2Tri Contributors")]
|
||||
[assembly: AssemblyProduct("Poly2Tri")]
|
||||
[assembly: AssemblyCopyright("Copyright © Poly2Tri Contributors 2009-2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("d1e24f2b-ea85-471a-af97-b431ca71b75c")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000014 RID: 20
|
||||
public interface Triangulatable
|
||||
{
|
||||
// Token: 0x060000AF RID: 175
|
||||
void Prepare(TriangulationContext tcx);
|
||||
|
||||
// Token: 0x1700001A RID: 26
|
||||
// (get) Token: 0x060000B0 RID: 176
|
||||
IList<TriangulationPoint> Points { get; }
|
||||
|
||||
// Token: 0x1700001B RID: 27
|
||||
// (get) Token: 0x060000B1 RID: 177
|
||||
IList<DelaunayTriangle> Triangles { get; }
|
||||
|
||||
// Token: 0x060000B2 RID: 178
|
||||
void AddTriangle(DelaunayTriangle t);
|
||||
|
||||
// Token: 0x060000B3 RID: 179
|
||||
void AddTriangles(IEnumerable<DelaunayTriangle> list);
|
||||
|
||||
// Token: 0x060000B4 RID: 180
|
||||
void ClearTriangles();
|
||||
|
||||
// Token: 0x1700001C RID: 28
|
||||
// (get) Token: 0x060000B5 RID: 181
|
||||
TriangulationMode TriangulationMode { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000015 RID: 21
|
||||
public enum TriangulationAlgorithm
|
||||
{
|
||||
// Token: 0x04000037 RID: 55
|
||||
DTSweep
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000016 RID: 22
|
||||
public class TriangulationConstraint
|
||||
{
|
||||
// Token: 0x04000038 RID: 56
|
||||
public TriangulationPoint P;
|
||||
|
||||
// Token: 0x04000039 RID: 57
|
||||
public TriangulationPoint Q;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000017 RID: 23
|
||||
public abstract class TriangulationContext
|
||||
{
|
||||
// Token: 0x1700001D RID: 29
|
||||
// (get) Token: 0x060000B7 RID: 183 RVA: 0x00004AA7 File Offset: 0x00002CA7
|
||||
// (set) Token: 0x060000B8 RID: 184 RVA: 0x00004AAF File Offset: 0x00002CAF
|
||||
public TriangulationDebugContext DebugContext { get; protected set; }
|
||||
|
||||
// Token: 0x1700001E RID: 30
|
||||
// (get) Token: 0x060000B9 RID: 185 RVA: 0x00004AB8 File Offset: 0x00002CB8
|
||||
// (set) Token: 0x060000BA RID: 186 RVA: 0x00004AC0 File Offset: 0x00002CC0
|
||||
public TriangulationMode TriangulationMode { get; protected set; }
|
||||
|
||||
// Token: 0x1700001F RID: 31
|
||||
// (get) Token: 0x060000BB RID: 187 RVA: 0x00004AC9 File Offset: 0x00002CC9
|
||||
// (set) Token: 0x060000BC RID: 188 RVA: 0x00004AD1 File Offset: 0x00002CD1
|
||||
public Triangulatable Triangulatable { get; private set; }
|
||||
|
||||
// Token: 0x17000020 RID: 32
|
||||
// (get) Token: 0x060000BD RID: 189 RVA: 0x00004ADA File Offset: 0x00002CDA
|
||||
// (set) Token: 0x060000BE RID: 190 RVA: 0x00004AE2 File Offset: 0x00002CE2
|
||||
public int StepCount { get; private set; }
|
||||
|
||||
// Token: 0x060000BF RID: 191 RVA: 0x00004AEC File Offset: 0x00002CEC
|
||||
public void Done()
|
||||
{
|
||||
int stepCount = this.StepCount;
|
||||
this.StepCount = stepCount + 1;
|
||||
}
|
||||
|
||||
// Token: 0x17000021 RID: 33
|
||||
// (get) Token: 0x060000C0 RID: 192
|
||||
public abstract TriangulationAlgorithm Algorithm { get; }
|
||||
|
||||
// Token: 0x060000C1 RID: 193 RVA: 0x00004B09 File Offset: 0x00002D09
|
||||
public virtual void PrepareTriangulation(Triangulatable t)
|
||||
{
|
||||
this.Triangulatable = t;
|
||||
this.TriangulationMode = t.TriangulationMode;
|
||||
t.Prepare(this);
|
||||
}
|
||||
|
||||
// Token: 0x060000C2 RID: 194
|
||||
public abstract TriangulationConstraint NewConstraint(TriangulationPoint a, TriangulationPoint b);
|
||||
|
||||
// Token: 0x060000C3 RID: 195 RVA: 0x00002101 File Offset: 0x00000301
|
||||
public void Update(string message)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060000C4 RID: 196 RVA: 0x00004B25 File Offset: 0x00002D25
|
||||
public virtual void Clear()
|
||||
{
|
||||
this.Points.Clear();
|
||||
if (this.DebugContext != null)
|
||||
{
|
||||
this.DebugContext.Clear();
|
||||
}
|
||||
this.StepCount = 0;
|
||||
}
|
||||
|
||||
// Token: 0x17000022 RID: 34
|
||||
// (get) Token: 0x060000C5 RID: 197 RVA: 0x00004B4C File Offset: 0x00002D4C
|
||||
// (set) Token: 0x060000C6 RID: 198 RVA: 0x00004B54 File Offset: 0x00002D54
|
||||
public virtual bool IsDebugEnabled { get; protected set; }
|
||||
|
||||
// Token: 0x17000023 RID: 35
|
||||
// (get) Token: 0x060000C7 RID: 199 RVA: 0x00004B5D File Offset: 0x00002D5D
|
||||
public DTSweepDebugContext DTDebugContext
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DebugContext as DTSweepDebugContext;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0400003B RID: 59
|
||||
public readonly List<DelaunayTriangle> Triangles = new List<DelaunayTriangle>();
|
||||
|
||||
// Token: 0x0400003C RID: 60
|
||||
public readonly List<TriangulationPoint> Points = new List<TriangulationPoint>(200);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000018 RID: 24
|
||||
public abstract class TriangulationDebugContext
|
||||
{
|
||||
// Token: 0x060000C9 RID: 201 RVA: 0x00004B8D File Offset: 0x00002D8D
|
||||
public TriangulationDebugContext(TriangulationContext tcx)
|
||||
{
|
||||
this._tcx = tcx;
|
||||
}
|
||||
|
||||
// Token: 0x060000CA RID: 202
|
||||
public abstract void Clear();
|
||||
|
||||
// Token: 0x04000041 RID: 65
|
||||
protected TriangulationContext _tcx;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x02000019 RID: 25
|
||||
public enum TriangulationMode
|
||||
{
|
||||
// Token: 0x04000043 RID: 67
|
||||
Unconstrained,
|
||||
// Token: 0x04000044 RID: 68
|
||||
Constrained,
|
||||
// Token: 0x04000045 RID: 69
|
||||
Polygon
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200001A RID: 26
|
||||
public class TriangulationPoint
|
||||
{
|
||||
// Token: 0x17000024 RID: 36
|
||||
// (get) Token: 0x060000CB RID: 203 RVA: 0x00004B9C File Offset: 0x00002D9C
|
||||
// (set) Token: 0x060000CC RID: 204 RVA: 0x00004BA4 File Offset: 0x00002DA4
|
||||
public List<DTSweepConstraint> Edges { get; private set; }
|
||||
|
||||
// Token: 0x060000CD RID: 205 RVA: 0x00004BAD File Offset: 0x00002DAD
|
||||
public TriangulationPoint(double x, double y, int index = -1)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.Index = index;
|
||||
}
|
||||
|
||||
// Token: 0x060000CE RID: 206 RVA: 0x00004BCC File Offset: 0x00002DCC
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Concat(new object[] { "[", this.X, ",", this.Y, "]" });
|
||||
}
|
||||
|
||||
// Token: 0x17000025 RID: 37
|
||||
// (get) Token: 0x060000CF RID: 207 RVA: 0x00004C18 File Offset: 0x00002E18
|
||||
// (set) Token: 0x060000D0 RID: 208 RVA: 0x00004C21 File Offset: 0x00002E21
|
||||
public float Xf
|
||||
{
|
||||
get
|
||||
{
|
||||
return (float)this.X;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.X = (double)value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000026 RID: 38
|
||||
// (get) Token: 0x060000D1 RID: 209 RVA: 0x00004C2B File Offset: 0x00002E2B
|
||||
// (set) Token: 0x060000D2 RID: 210 RVA: 0x00004C34 File Offset: 0x00002E34
|
||||
public float Yf
|
||||
{
|
||||
get
|
||||
{
|
||||
return (float)this.Y;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Y = (double)value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060000D3 RID: 211 RVA: 0x00004C3E File Offset: 0x00002E3E
|
||||
public void AddEdge(DTSweepConstraint e)
|
||||
{
|
||||
if (this.Edges == null)
|
||||
{
|
||||
this.Edges = new List<DTSweepConstraint>();
|
||||
}
|
||||
this.Edges.Add(e);
|
||||
}
|
||||
|
||||
// Token: 0x17000027 RID: 39
|
||||
// (get) Token: 0x060000D4 RID: 212 RVA: 0x00004C5F File Offset: 0x00002E5F
|
||||
public bool HasEdges
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Edges != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000046 RID: 70
|
||||
public const int INSERTED_INDEX = -1;
|
||||
|
||||
// Token: 0x04000047 RID: 71
|
||||
public const int INVALID_INDEX = -2;
|
||||
|
||||
// Token: 0x04000049 RID: 73
|
||||
public double X;
|
||||
|
||||
// Token: 0x0400004A RID: 74
|
||||
public double Y;
|
||||
|
||||
// Token: 0x0400004B RID: 75
|
||||
public int Index;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
|
||||
namespace Poly2Tri
|
||||
{
|
||||
// Token: 0x0200001B RID: 27
|
||||
public class TriangulationUtil
|
||||
{
|
||||
// Token: 0x060000D5 RID: 213 RVA: 0x00004C6C File Offset: 0x00002E6C
|
||||
public static bool SmartIncircle(TriangulationPoint pa, TriangulationPoint pb, TriangulationPoint pc, TriangulationPoint pd)
|
||||
{
|
||||
double x = pd.X;
|
||||
double y = pd.Y;
|
||||
double num = pa.X - x;
|
||||
double num2 = pa.Y - y;
|
||||
double num3 = pb.X - x;
|
||||
double num4 = pb.Y - y;
|
||||
double num5 = num * num4;
|
||||
double num6 = num3 * num2;
|
||||
double num7 = num5 - num6;
|
||||
if (num7 <= 0.0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
double num8 = pc.X - x;
|
||||
double num9 = pc.Y - y;
|
||||
double num10 = num8 * num2;
|
||||
double num11 = num * num9;
|
||||
double num12 = num10 - num11;
|
||||
if (num12 <= 0.0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
double num13 = num3 * num9;
|
||||
double num14 = num8 * num4;
|
||||
double num15 = num * num + num2 * num2;
|
||||
double num16 = num3 * num3 + num4 * num4;
|
||||
double num17 = num8 * num8 + num9 * num9;
|
||||
return num15 * (num13 - num14) + num16 * num12 + num17 * num7 > 0.0;
|
||||
}
|
||||
|
||||
// Token: 0x060000D6 RID: 214 RVA: 0x00004D4C File Offset: 0x00002F4C
|
||||
public static bool InScanArea(TriangulationPoint pa, TriangulationPoint pb, TriangulationPoint pc, TriangulationPoint pd)
|
||||
{
|
||||
double x = pd.X;
|
||||
double y = pd.Y;
|
||||
double num = pa.X - x;
|
||||
double num2 = pa.Y - y;
|
||||
double num3 = pb.X - x;
|
||||
double num4 = pb.Y - y;
|
||||
double num5 = num * num4;
|
||||
double num6 = num3 * num2;
|
||||
if (num5 - num6 <= 0.0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
double num7 = pc.X - x;
|
||||
double num8 = pc.Y - y;
|
||||
double num9 = num7 * num2;
|
||||
double num10 = num * num8;
|
||||
return num9 - num10 > 0.0;
|
||||
}
|
||||
|
||||
// Token: 0x060000D7 RID: 215 RVA: 0x00004DD4 File Offset: 0x00002FD4
|
||||
public static Orientation Orient2d(TriangulationPoint pa, TriangulationPoint pb, TriangulationPoint pc)
|
||||
{
|
||||
double num = (pa.X - pc.X) * (pb.Y - pc.Y);
|
||||
double num2 = (pa.Y - pc.Y) * (pb.X - pc.X);
|
||||
double num3 = num - num2;
|
||||
if (num3 > -TriangulationUtil.EPSILON && num3 < TriangulationUtil.EPSILON)
|
||||
{
|
||||
return Orientation.Collinear;
|
||||
}
|
||||
if (num3 > 0.0)
|
||||
{
|
||||
return Orientation.CCW;
|
||||
}
|
||||
return Orientation.CW;
|
||||
}
|
||||
|
||||
// Token: 0x0400004C RID: 76
|
||||
public static double EPSILON = 1E-12;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user