Add files using upload-large-folder tool
Browse files- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Log.cs +84 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Log.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Logging.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Mesh.cs +1768 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Mesh.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/MeshValidator.cs +214 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/MeshValidator.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Meshing.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/NewLocation.cs +0 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/NewLocation.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Properties.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/RobustPredicates.cs +1347 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/RobustPredicates.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Smoothing.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Tools.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Topology.meta +8 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/TriangleLocator.cs +363 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/TriangleLocator.cs.meta +11 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Samples~/AnimationSamples/5 SpriteSwap/Animation/Animators/Rikr.controller +72 -0
- benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Samples~/AnimationSamples/5 SpriteSwap/Animation/Animators/Rikr.controller.meta +8 -0
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Log.cs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -----------------------------------------------------------------------
|
| 2 |
+
// <copyright file="Log.cs" company="">
|
| 3 |
+
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
|
| 4 |
+
// </copyright>
|
| 5 |
+
// -----------------------------------------------------------------------
|
| 6 |
+
|
| 7 |
+
namespace UnityEngine.U2D.Animation.TriangleNet
|
| 8 |
+
{
|
| 9 |
+
using System.Collections.Generic;
|
| 10 |
+
using Animation.TriangleNet.Logging;
|
| 11 |
+
|
| 12 |
+
/// <summary>
|
| 13 |
+
/// A simple logger, which logs messages to a List.
|
| 14 |
+
/// </summary>
|
| 15 |
+
/// <remarks>Using singleton pattern as proposed by Jon Skeet.
|
| 16 |
+
/// http://csharpindepth.com/Articles/General/Singleton.aspx
|
| 17 |
+
/// </remarks>
|
| 18 |
+
internal sealed class Log : ILog<LogItem>
|
| 19 |
+
{
|
| 20 |
+
/// <summary>
|
| 21 |
+
/// Log detailed information.
|
| 22 |
+
/// </summary>
|
| 23 |
+
internal static bool Verbose { get; set; }
|
| 24 |
+
|
| 25 |
+
private List<LogItem> log = new List<LogItem>();
|
| 26 |
+
|
| 27 |
+
private LogLevel level = LogLevel.Info;
|
| 28 |
+
|
| 29 |
+
#region Singleton pattern
|
| 30 |
+
|
| 31 |
+
private static readonly Log instance = new Log();
|
| 32 |
+
|
| 33 |
+
// Explicit static constructor to tell C# compiler
|
| 34 |
+
// not to mark type as beforefieldinit
|
| 35 |
+
static Log() {}
|
| 36 |
+
|
| 37 |
+
private Log() {}
|
| 38 |
+
|
| 39 |
+
internal static ILog<LogItem> Instance
|
| 40 |
+
{
|
| 41 |
+
get
|
| 42 |
+
{
|
| 43 |
+
return instance;
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
#endregion
|
| 48 |
+
|
| 49 |
+
public void Add(LogItem item)
|
| 50 |
+
{
|
| 51 |
+
log.Add(item);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
public void Clear()
|
| 55 |
+
{
|
| 56 |
+
log.Clear();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public void Info(string message)
|
| 60 |
+
{
|
| 61 |
+
log.Add(new LogItem(LogLevel.Info, message));
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public void Warning(string message, string location)
|
| 65 |
+
{
|
| 66 |
+
log.Add(new LogItem(LogLevel.Warning, message, location));
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
public void Error(string message, string location)
|
| 70 |
+
{
|
| 71 |
+
log.Add(new LogItem(LogLevel.Error, message, location));
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
public IList<LogItem> Data
|
| 75 |
+
{
|
| 76 |
+
get { return log; }
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
public LogLevel Level
|
| 80 |
+
{
|
| 81 |
+
get { return level; }
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Log.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 196e2f3da40aa4a94a0a42a5e8fe60b9
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Logging.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 12bf6e7f64391465d8d8ef95ca3a996b
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Mesh.cs
ADDED
|
@@ -0,0 +1,1768 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -----------------------------------------------------------------------
|
| 2 |
+
// <copyright file="Mesh.cs">
|
| 3 |
+
// Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html
|
| 4 |
+
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
|
| 5 |
+
// </copyright>
|
| 6 |
+
// -----------------------------------------------------------------------
|
| 7 |
+
|
| 8 |
+
namespace UnityEngine.U2D.Animation.TriangleNet
|
| 9 |
+
{
|
| 10 |
+
using System;
|
| 11 |
+
using System.Collections.Generic;
|
| 12 |
+
using Animation.TriangleNet.Geometry;
|
| 13 |
+
using Animation.TriangleNet.Logging;
|
| 14 |
+
using Animation.TriangleNet.Meshing;
|
| 15 |
+
using Animation.TriangleNet.Meshing.Data;
|
| 16 |
+
using Animation.TriangleNet.Meshing.Iterators;
|
| 17 |
+
using Animation.TriangleNet.Tools;
|
| 18 |
+
using Animation.TriangleNet.Topology;
|
| 19 |
+
|
| 20 |
+
/// <summary>
|
| 21 |
+
/// Mesh data structure.
|
| 22 |
+
/// </summary>
|
| 23 |
+
internal class Mesh : IMesh
|
| 24 |
+
{
|
| 25 |
+
#region Variables
|
| 26 |
+
|
| 27 |
+
IPredicates predicates;
|
| 28 |
+
|
| 29 |
+
ILog<LogItem> logger;
|
| 30 |
+
|
| 31 |
+
QualityMesher qualityMesher;
|
| 32 |
+
|
| 33 |
+
// Stack that maintains a list of recently flipped triangles.
|
| 34 |
+
Stack<Otri> flipstack;
|
| 35 |
+
|
| 36 |
+
// TODO: Check if custom hashmap implementation could be faster.
|
| 37 |
+
|
| 38 |
+
// Using hashsets for memory management should quite fast.
|
| 39 |
+
internal TrianglePool triangles;
|
| 40 |
+
internal Dictionary<int, SubSegment> subsegs;
|
| 41 |
+
internal Dictionary<int, Vertex> vertices;
|
| 42 |
+
|
| 43 |
+
// Hash seeds (should belong to mesh instance)
|
| 44 |
+
internal int hash_vtx = 0;
|
| 45 |
+
internal int hash_seg = 0;
|
| 46 |
+
internal int hash_tri = 0;
|
| 47 |
+
|
| 48 |
+
internal List<Point> holes;
|
| 49 |
+
internal List<RegionPointer> regions;
|
| 50 |
+
|
| 51 |
+
// TODO: remove mesh_dim, invertices and insegments
|
| 52 |
+
|
| 53 |
+
// Other variables.
|
| 54 |
+
internal Rectangle bounds; // x and y bounds.
|
| 55 |
+
internal int invertices; // Number of input vertices.
|
| 56 |
+
internal int insegments; // Number of input segments.
|
| 57 |
+
internal int undeads; // Number of input vertices that don't appear in the mesh.
|
| 58 |
+
internal int mesh_dim; // Dimension (ought to be 2).
|
| 59 |
+
internal int nextras = 0; // Number of attributes per vertex.
|
| 60 |
+
//internal int eextras; // Number of attributes per triangle.
|
| 61 |
+
internal int hullsize; // Number of edges in convex hull.
|
| 62 |
+
internal int steinerleft; // Number of Steiner points not yet used.
|
| 63 |
+
internal bool checksegments; // Are there segments in the triangulation yet?
|
| 64 |
+
internal bool checkquality; // Has quality triangulation begun yet?
|
| 65 |
+
|
| 66 |
+
// Triangular bounding box vertices.
|
| 67 |
+
internal Vertex infvertex1, infvertex2, infvertex3;
|
| 68 |
+
|
| 69 |
+
internal TriangleLocator locator;
|
| 70 |
+
|
| 71 |
+
// Controls the behavior of the mesh instance.
|
| 72 |
+
internal Behavior behavior;
|
| 73 |
+
|
| 74 |
+
// The current node numbering
|
| 75 |
+
internal NodeNumbering numbering;
|
| 76 |
+
|
| 77 |
+
#endregion
|
| 78 |
+
|
| 79 |
+
#region Public properties
|
| 80 |
+
|
| 81 |
+
/// <summary>
|
| 82 |
+
/// Gets the mesh bounding box.
|
| 83 |
+
/// </summary>
|
| 84 |
+
public Rectangle Bounds
|
| 85 |
+
{
|
| 86 |
+
get { return this.bounds; }
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/// <summary>
|
| 90 |
+
/// Gets the mesh vertices.
|
| 91 |
+
/// </summary>
|
| 92 |
+
public ICollection<Vertex> Vertices
|
| 93 |
+
{
|
| 94 |
+
get { return this.vertices.Values; }
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
/// <summary>
|
| 98 |
+
/// Gets the mesh holes.
|
| 99 |
+
/// </summary>
|
| 100 |
+
public IList<Point> Holes
|
| 101 |
+
{
|
| 102 |
+
get { return this.holes; }
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
/// <summary>
|
| 106 |
+
/// Gets the mesh triangles.
|
| 107 |
+
/// </summary>
|
| 108 |
+
public ICollection<Triangle> Triangles
|
| 109 |
+
{
|
| 110 |
+
get { return this.triangles; }
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/// <summary>
|
| 114 |
+
/// Gets the mesh segments.
|
| 115 |
+
/// </summary>
|
| 116 |
+
public ICollection<SubSegment> Segments
|
| 117 |
+
{
|
| 118 |
+
get { return this.subsegs.Values; }
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/// <summary>
|
| 122 |
+
/// Gets the mesh edges.
|
| 123 |
+
/// </summary>
|
| 124 |
+
public IEnumerable<Edge> Edges
|
| 125 |
+
{
|
| 126 |
+
get
|
| 127 |
+
{
|
| 128 |
+
var e = new EdgeIterator(this);
|
| 129 |
+
while (e.MoveNext())
|
| 130 |
+
{
|
| 131 |
+
yield return e.Current;
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/// <summary>
|
| 137 |
+
/// Gets the number of input vertices.
|
| 138 |
+
/// </summary>
|
| 139 |
+
public int NumberOfInputPoints
|
| 140 |
+
{
|
| 141 |
+
get { return invertices; }
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
/// <summary>
|
| 145 |
+
/// Gets the number of mesh edges.
|
| 146 |
+
/// </summary>
|
| 147 |
+
public int NumberOfEdges
|
| 148 |
+
{
|
| 149 |
+
get { return (3 * triangles.Count + hullsize) / 2; }
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
/// <summary>
|
| 153 |
+
/// Indicates whether the input is a PSLG or a point set.
|
| 154 |
+
/// </summary>
|
| 155 |
+
public bool IsPolygon
|
| 156 |
+
{
|
| 157 |
+
get { return this.insegments > 0; }
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
/// <summary>
|
| 161 |
+
/// Gets the current node numbering.
|
| 162 |
+
/// </summary>
|
| 163 |
+
public NodeNumbering CurrentNumbering
|
| 164 |
+
{
|
| 165 |
+
get { return numbering; }
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
#endregion
|
| 169 |
+
|
| 170 |
+
#region "Outer space" variables
|
| 171 |
+
|
| 172 |
+
internal const int DUMMY = -1;
|
| 173 |
+
|
| 174 |
+
// The triangle that fills "outer space," called 'dummytri', is pointed to
|
| 175 |
+
// by every triangle and subsegment on a boundary (be it outer or inner) of
|
| 176 |
+
// the triangulation. Also, 'dummytri' points to one of the triangles on
|
| 177 |
+
// the convex hull (until the holes and concavities are carved), making it
|
| 178 |
+
// possible to find a starting triangle for point location.
|
| 179 |
+
|
| 180 |
+
// 'dummytri' and 'dummysub' are generally required to fulfill only a few
|
| 181 |
+
// invariants: their vertices must remain NULL and 'dummytri' must always
|
| 182 |
+
// be bonded (at offset zero) to some triangle on the convex hull of the
|
| 183 |
+
// mesh, via a boundary edge. Otherwise, the connections of 'dummytri' and
|
| 184 |
+
// 'dummysub' may change willy-nilly. This makes it possible to avoid
|
| 185 |
+
// writing a good deal of special-case code (in the edge flip, for example)
|
| 186 |
+
// for dealing with the boundary of the mesh, places where no subsegment is
|
| 187 |
+
// present, and so forth. Other entities are frequently bonded to
|
| 188 |
+
// 'dummytri' and 'dummysub' as if they were real mesh entities, with no
|
| 189 |
+
// harm done.
|
| 190 |
+
|
| 191 |
+
internal Triangle dummytri;
|
| 192 |
+
|
| 193 |
+
// Set up 'dummysub', the omnipresent subsegment pointed to by any
|
| 194 |
+
// triangle side or subsegment end that isn't attached to a real
|
| 195 |
+
// subsegment.
|
| 196 |
+
|
| 197 |
+
internal SubSegment dummysub;
|
| 198 |
+
|
| 199 |
+
private void Initialize()
|
| 200 |
+
{
|
| 201 |
+
dummysub = new SubSegment();
|
| 202 |
+
dummysub.hash = DUMMY;
|
| 203 |
+
|
| 204 |
+
// Initialize the two adjoining subsegments to be the omnipresent
|
| 205 |
+
// subsegment. These will eventually be changed by various bonding
|
| 206 |
+
// operations, but their values don't really matter, as long as they
|
| 207 |
+
// can legally be dereferenced.
|
| 208 |
+
dummysub.subsegs[0].seg = dummysub;
|
| 209 |
+
dummysub.subsegs[1].seg = dummysub;
|
| 210 |
+
|
| 211 |
+
// Set up 'dummytri', the 'triangle' that occupies "outer space."
|
| 212 |
+
dummytri = new Triangle();
|
| 213 |
+
dummytri.hash = dummytri.id = DUMMY;
|
| 214 |
+
|
| 215 |
+
// Initialize the three adjoining triangles to be "outer space." These
|
| 216 |
+
// will eventually be changed by various bonding operations, but their
|
| 217 |
+
// values don't really matter, as long as they can legally be
|
| 218 |
+
// dereferenced.
|
| 219 |
+
dummytri.neighbors[0].tri = dummytri;
|
| 220 |
+
dummytri.neighbors[1].tri = dummytri;
|
| 221 |
+
dummytri.neighbors[2].tri = dummytri;
|
| 222 |
+
|
| 223 |
+
// Initialize the three adjoining subsegments of 'dummytri' to be
|
| 224 |
+
// the omnipresent subsegment.
|
| 225 |
+
dummytri.subsegs[0].seg = dummysub;
|
| 226 |
+
dummytri.subsegs[1].seg = dummysub;
|
| 227 |
+
dummytri.subsegs[2].seg = dummysub;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
#endregion
|
| 231 |
+
|
| 232 |
+
/// <summary>
|
| 233 |
+
/// Initializes a new instance of the <see cref="Mesh" /> class.
|
| 234 |
+
/// </summary>
|
| 235 |
+
public Mesh(Configuration config)
|
| 236 |
+
{
|
| 237 |
+
Initialize();
|
| 238 |
+
|
| 239 |
+
logger = Log.Instance;
|
| 240 |
+
|
| 241 |
+
behavior = new Behavior();
|
| 242 |
+
|
| 243 |
+
vertices = new Dictionary<int, Vertex>();
|
| 244 |
+
subsegs = new Dictionary<int, SubSegment>();
|
| 245 |
+
|
| 246 |
+
triangles = config.TrianglePool();
|
| 247 |
+
|
| 248 |
+
flipstack = new Stack<Otri>();
|
| 249 |
+
|
| 250 |
+
holes = new List<Point>();
|
| 251 |
+
regions = new List<RegionPointer>();
|
| 252 |
+
|
| 253 |
+
steinerleft = -1;
|
| 254 |
+
|
| 255 |
+
this.predicates = config.Predicates();
|
| 256 |
+
|
| 257 |
+
this.locator = new TriangleLocator(this, predicates);
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
public void Refine(QualityOptions quality, bool delaunay = false)
|
| 261 |
+
{
|
| 262 |
+
invertices = vertices.Count;
|
| 263 |
+
|
| 264 |
+
if (behavior.Poly)
|
| 265 |
+
{
|
| 266 |
+
insegments = behavior.useSegments ? subsegs.Count : hullsize;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
Reset();
|
| 270 |
+
|
| 271 |
+
if (qualityMesher == null)
|
| 272 |
+
{
|
| 273 |
+
qualityMesher = new QualityMesher(this, new Configuration());
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
// Enforce angle and area constraints.
|
| 277 |
+
qualityMesher.Apply(quality, delaunay);
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
/// <summary>
|
| 281 |
+
/// Renumber vertex and triangle id's.
|
| 282 |
+
/// </summary>
|
| 283 |
+
public void Renumber()
|
| 284 |
+
{
|
| 285 |
+
this.Renumber(NodeNumbering.Linear);
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
/// <summary>
|
| 289 |
+
/// Renumber vertex and triangle id's.
|
| 290 |
+
/// </summary>
|
| 291 |
+
public void Renumber(NodeNumbering num)
|
| 292 |
+
{
|
| 293 |
+
// Don't need to do anything if the nodes are already numbered.
|
| 294 |
+
if (num == this.numbering)
|
| 295 |
+
{
|
| 296 |
+
return;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
int id;
|
| 300 |
+
|
| 301 |
+
if (num == NodeNumbering.Linear)
|
| 302 |
+
{
|
| 303 |
+
id = 0;
|
| 304 |
+
foreach (var node in this.vertices.Values)
|
| 305 |
+
{
|
| 306 |
+
node.id = id++;
|
| 307 |
+
}
|
| 308 |
+
}
|
| 309 |
+
else if (num == NodeNumbering.CuthillMcKee)
|
| 310 |
+
{
|
| 311 |
+
var rcm = new CuthillMcKee();
|
| 312 |
+
var iperm = rcm.Renumber(this);
|
| 313 |
+
|
| 314 |
+
// Permute the node indices.
|
| 315 |
+
foreach (var node in this.vertices.Values)
|
| 316 |
+
{
|
| 317 |
+
node.id = iperm[node.id];
|
| 318 |
+
}
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
// Remember the current numbering.
|
| 322 |
+
numbering = num;
|
| 323 |
+
|
| 324 |
+
// Triangles will always be numbered from 0 to n-1
|
| 325 |
+
id = 0;
|
| 326 |
+
foreach (var item in this.triangles)
|
| 327 |
+
{
|
| 328 |
+
item.id = id++;
|
| 329 |
+
}
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
#region Misc
|
| 333 |
+
|
| 334 |
+
/// <summary>
|
| 335 |
+
/// Set QualityMesher for mesh refinement.
|
| 336 |
+
/// </summary>
|
| 337 |
+
/// <param name="qmesher"></param>
|
| 338 |
+
internal void SetQualityMesher(QualityMesher qmesher)
|
| 339 |
+
{
|
| 340 |
+
qualityMesher = qmesher;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
internal void CopyTo(Mesh target)
|
| 344 |
+
{
|
| 345 |
+
target.vertices = this.vertices;
|
| 346 |
+
target.triangles = this.triangles;
|
| 347 |
+
target.subsegs = this.subsegs;
|
| 348 |
+
|
| 349 |
+
target.holes = this.holes;
|
| 350 |
+
target.regions = this.regions;
|
| 351 |
+
|
| 352 |
+
target.hash_vtx = this.hash_vtx;
|
| 353 |
+
target.hash_seg = this.hash_seg;
|
| 354 |
+
target.hash_tri = this.hash_tri;
|
| 355 |
+
|
| 356 |
+
target.numbering = this.numbering;
|
| 357 |
+
target.hullsize = this.hullsize;
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
/// <summary>
|
| 361 |
+
/// Reset all the mesh data. This method will also wipe
|
| 362 |
+
/// out all mesh data.
|
| 363 |
+
/// </summary>
|
| 364 |
+
private void ResetData()
|
| 365 |
+
{
|
| 366 |
+
vertices.Clear();
|
| 367 |
+
triangles.Restart();
|
| 368 |
+
subsegs.Clear();
|
| 369 |
+
|
| 370 |
+
holes.Clear();
|
| 371 |
+
regions.Clear();
|
| 372 |
+
|
| 373 |
+
this.hash_vtx = 0;
|
| 374 |
+
this.hash_seg = 0;
|
| 375 |
+
this.hash_tri = 0;
|
| 376 |
+
|
| 377 |
+
flipstack.Clear();
|
| 378 |
+
|
| 379 |
+
hullsize = 0;
|
| 380 |
+
|
| 381 |
+
Reset();
|
| 382 |
+
|
| 383 |
+
locator.Reset();
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
/// <summary>
|
| 387 |
+
/// Reset the mesh triangulation state.
|
| 388 |
+
/// </summary>
|
| 389 |
+
private void Reset()
|
| 390 |
+
{
|
| 391 |
+
numbering = NodeNumbering.None;
|
| 392 |
+
|
| 393 |
+
undeads = 0; // No eliminated input vertices yet.
|
| 394 |
+
checksegments = false; // There are no segments in the triangulation yet.
|
| 395 |
+
checkquality = false; // The quality triangulation stage has not begun.
|
| 396 |
+
|
| 397 |
+
Statistic.InCircleCount = 0;
|
| 398 |
+
Statistic.CounterClockwiseCount = 0;
|
| 399 |
+
Statistic.InCircleAdaptCount = 0;
|
| 400 |
+
Statistic.CounterClockwiseAdaptCount = 0;
|
| 401 |
+
Statistic.Orient3dCount = 0;
|
| 402 |
+
Statistic.HyperbolaCount = 0;
|
| 403 |
+
Statistic.CircleTopCount = 0;
|
| 404 |
+
Statistic.CircumcenterCount = 0;
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
/// <summary>
|
| 408 |
+
/// Read the vertices from memory.
|
| 409 |
+
/// </summary>
|
| 410 |
+
/// <param name="data">The input data.</param>
|
| 411 |
+
internal void TransferNodes(IList<Vertex> points)
|
| 412 |
+
{
|
| 413 |
+
this.invertices = points.Count;
|
| 414 |
+
this.mesh_dim = 2;
|
| 415 |
+
this.bounds = new Rectangle();
|
| 416 |
+
|
| 417 |
+
if (this.invertices < 3)
|
| 418 |
+
{
|
| 419 |
+
logger.Error("Input must have at least three input vertices.", "Mesh.TransferNodes()");
|
| 420 |
+
throw new Exception("Input must have at least three input vertices.");
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
var v = points[0];
|
| 424 |
+
|
| 425 |
+
#if USE_ATTRIBS
|
| 426 |
+
// Check attributes.
|
| 427 |
+
this.nextras = v.attributes == null ? 0 : v.attributes.Length;
|
| 428 |
+
#endif
|
| 429 |
+
|
| 430 |
+
// Simple heuristic to check if ids are already set. We assume that if the
|
| 431 |
+
// first two vertex ids are distinct, then all input vertices have pairwise
|
| 432 |
+
// distinct ids.
|
| 433 |
+
bool userId = (v.id != points[1].id);
|
| 434 |
+
|
| 435 |
+
foreach (var p in points)
|
| 436 |
+
{
|
| 437 |
+
if (userId)
|
| 438 |
+
{
|
| 439 |
+
p.hash = p.id;
|
| 440 |
+
|
| 441 |
+
// Make sure the hash counter gets updated.
|
| 442 |
+
hash_vtx = Math.Max(p.hash + 1, hash_vtx);
|
| 443 |
+
}
|
| 444 |
+
else
|
| 445 |
+
{
|
| 446 |
+
p.hash = p.id = hash_vtx++;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
this.vertices.Add(p.hash, p);
|
| 450 |
+
this.bounds.Expand(p);
|
| 451 |
+
}
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
/// <summary>
|
| 455 |
+
/// Construct a mapping from vertices to triangles to improve the speed of
|
| 456 |
+
/// point location for segment insertion.
|
| 457 |
+
/// </summary>
|
| 458 |
+
/// <remarks>
|
| 459 |
+
/// Traverses all the triangles, and provides each corner of each triangle
|
| 460 |
+
/// with a pointer to that triangle. Of course, pointers will be overwritten
|
| 461 |
+
/// by other pointers because (almost) each vertex is a corner of several
|
| 462 |
+
/// triangles, but in the end every vertex will point to some triangle
|
| 463 |
+
/// that contains it.
|
| 464 |
+
/// </remarks>
|
| 465 |
+
internal void MakeVertexMap()
|
| 466 |
+
{
|
| 467 |
+
Otri tri = default(Otri);
|
| 468 |
+
Vertex triorg;
|
| 469 |
+
|
| 470 |
+
foreach (var t in this.triangles)
|
| 471 |
+
{
|
| 472 |
+
tri.tri = t;
|
| 473 |
+
// Check all three vertices of the triangle.
|
| 474 |
+
for (tri.orient = 0; tri.orient < 3; tri.orient++)
|
| 475 |
+
{
|
| 476 |
+
triorg = tri.Org();
|
| 477 |
+
triorg.tri = tri;
|
| 478 |
+
}
|
| 479 |
+
}
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
#endregion
|
| 483 |
+
|
| 484 |
+
#region Factory
|
| 485 |
+
|
| 486 |
+
/// <summary>
|
| 487 |
+
/// Create a new triangle with orientation zero.
|
| 488 |
+
/// </summary>
|
| 489 |
+
/// <param name="newotri">Reference to the new triangle.</param>
|
| 490 |
+
internal void MakeTriangle(ref Otri newotri)
|
| 491 |
+
{
|
| 492 |
+
Triangle tri = triangles.Get();
|
| 493 |
+
|
| 494 |
+
//tri.id = tri.hash;
|
| 495 |
+
|
| 496 |
+
tri.subsegs[0].seg = dummysub;
|
| 497 |
+
tri.subsegs[1].seg = dummysub;
|
| 498 |
+
tri.subsegs[2].seg = dummysub;
|
| 499 |
+
|
| 500 |
+
tri.neighbors[0].tri = dummytri;
|
| 501 |
+
tri.neighbors[1].tri = dummytri;
|
| 502 |
+
tri.neighbors[2].tri = dummytri;
|
| 503 |
+
|
| 504 |
+
newotri.tri = tri;
|
| 505 |
+
newotri.orient = 0;
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
/// <summary>
|
| 509 |
+
/// Create a new subsegment with orientation zero.
|
| 510 |
+
/// </summary>
|
| 511 |
+
/// <param name="newsubseg">Reference to the new subseg.</param>
|
| 512 |
+
internal void MakeSegment(ref Osub newsubseg)
|
| 513 |
+
{
|
| 514 |
+
var seg = new SubSegment();
|
| 515 |
+
|
| 516 |
+
seg.hash = this.hash_seg++;
|
| 517 |
+
|
| 518 |
+
seg.subsegs[0].seg = dummysub;
|
| 519 |
+
seg.subsegs[1].seg = dummysub;
|
| 520 |
+
|
| 521 |
+
seg.triangles[0].tri = dummytri;
|
| 522 |
+
seg.triangles[1].tri = dummytri;
|
| 523 |
+
|
| 524 |
+
newsubseg.seg = seg;
|
| 525 |
+
newsubseg.orient = 0;
|
| 526 |
+
|
| 527 |
+
subsegs.Add(seg.hash, seg);
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
#endregion
|
| 531 |
+
|
| 532 |
+
#region Manipulation
|
| 533 |
+
|
| 534 |
+
/// <summary>
|
| 535 |
+
/// Insert a vertex into a Delaunay triangulation, performing flips as necessary
|
| 536 |
+
/// to maintain the Delaunay property.
|
| 537 |
+
/// </summary>
|
| 538 |
+
/// <param name="newvertex">The point to be inserted.</param>
|
| 539 |
+
/// <param name="searchtri">The triangle to start the search.</param>
|
| 540 |
+
/// <param name="splitseg">Segment to split.</param>
|
| 541 |
+
/// <param name="segmentflaws">Check for creation of encroached subsegments.</param>
|
| 542 |
+
/// <param name="triflaws">Check for creation of bad quality triangles.</param>
|
| 543 |
+
/// <returns>If a duplicate vertex or violated segment does not prevent the
|
| 544 |
+
/// vertex from being inserted, the return value will be ENCROACHINGVERTEX if
|
| 545 |
+
/// the vertex encroaches upon a subsegment (and checking is enabled), or
|
| 546 |
+
/// SUCCESSFULVERTEX otherwise. In either case, 'searchtri' is set to a handle
|
| 547 |
+
/// whose origin is the newly inserted vertex.</returns>
|
| 548 |
+
/// <remarks>
|
| 549 |
+
/// The point 'newvertex' is located. If 'searchtri.triangle' is not NULL,
|
| 550 |
+
/// the search for the containing triangle begins from 'searchtri'. If
|
| 551 |
+
/// 'searchtri.triangle' is NULL, a full point location procedure is called.
|
| 552 |
+
/// If 'insertvertex' is found inside a triangle, the triangle is split into
|
| 553 |
+
/// three; if 'insertvertex' lies on an edge, the edge is split in two,
|
| 554 |
+
/// thereby splitting the two adjacent triangles into four. Edge flips are
|
| 555 |
+
/// used to restore the Delaunay property. If 'insertvertex' lies on an
|
| 556 |
+
/// existing vertex, no action is taken, and the value DUPLICATEVERTEX is
|
| 557 |
+
/// returned. On return, 'searchtri' is set to a handle whose origin is the
|
| 558 |
+
/// existing vertex.
|
| 559 |
+
///
|
| 560 |
+
/// InsertVertex() does not use flip() for reasons of speed; some
|
| 561 |
+
/// information can be reused from edge flip to edge flip, like the
|
| 562 |
+
/// locations of subsegments.
|
| 563 |
+
///
|
| 564 |
+
/// Param 'splitseg': Normally, the parameter 'splitseg' is set to NULL,
|
| 565 |
+
/// implying that no subsegment should be split. In this case, if 'insertvertex'
|
| 566 |
+
/// is found to lie on a segment, no action is taken, and the value VIOLATINGVERTEX
|
| 567 |
+
/// is returned. On return, 'searchtri' is set to a handle whose primary edge is the
|
| 568 |
+
/// violated subsegment.
|
| 569 |
+
/// If the calling routine wishes to split a subsegment by inserting a vertex in it,
|
| 570 |
+
/// the parameter 'splitseg' should be that subsegment. In this case, 'searchtri'
|
| 571 |
+
/// MUST be the triangle handle reached by pivoting from that subsegment; no point
|
| 572 |
+
/// location is done.
|
| 573 |
+
///
|
| 574 |
+
/// Param 'segmentflaws': Flags that indicate whether or not there should
|
| 575 |
+
/// be checks for the creation of encroached subsegments. If a newly inserted
|
| 576 |
+
/// vertex encroaches upon subsegments, these subsegments are added to the list
|
| 577 |
+
/// of subsegments to be split if 'segmentflaws' is set.
|
| 578 |
+
///
|
| 579 |
+
/// Param 'triflaws': Flags that indicate whether or not there should be
|
| 580 |
+
/// checks for the creation of bad quality triangles. If bad triangles are
|
| 581 |
+
/// created, these are added to the queue if 'triflaws' is set.
|
| 582 |
+
/// </remarks>
|
| 583 |
+
internal InsertVertexResult InsertVertex(Vertex newvertex, ref Otri searchtri,
|
| 584 |
+
ref Osub splitseg, bool segmentflaws, bool triflaws)
|
| 585 |
+
{
|
| 586 |
+
Otri horiz = default(Otri);
|
| 587 |
+
Otri top = default(Otri);
|
| 588 |
+
Otri botleft = default(Otri), botright = default(Otri);
|
| 589 |
+
Otri topleft = default(Otri), topright = default(Otri);
|
| 590 |
+
Otri newbotleft = default(Otri), newbotright = default(Otri);
|
| 591 |
+
Otri newtopright = default(Otri);
|
| 592 |
+
Otri botlcasing = default(Otri), botrcasing = default(Otri);
|
| 593 |
+
Otri toplcasing = default(Otri), toprcasing = default(Otri);
|
| 594 |
+
Otri testtri = default(Otri);
|
| 595 |
+
Osub botlsubseg = default(Osub), botrsubseg = default(Osub);
|
| 596 |
+
Osub toplsubseg = default(Osub), toprsubseg = default(Osub);
|
| 597 |
+
Osub brokensubseg = default(Osub);
|
| 598 |
+
Osub checksubseg = default(Osub);
|
| 599 |
+
Osub rightsubseg = default(Osub);
|
| 600 |
+
Osub newsubseg = default(Osub);
|
| 601 |
+
BadSubseg encroached;
|
| 602 |
+
//FlipStacker newflip;
|
| 603 |
+
Vertex first;
|
| 604 |
+
Vertex leftvertex, rightvertex, botvertex, topvertex, farvertex;
|
| 605 |
+
Vertex segmentorg, segmentdest;
|
| 606 |
+
int region;
|
| 607 |
+
double area;
|
| 608 |
+
InsertVertexResult success;
|
| 609 |
+
LocateResult intersect;
|
| 610 |
+
bool doflip;
|
| 611 |
+
bool mirrorflag;
|
| 612 |
+
bool enq;
|
| 613 |
+
|
| 614 |
+
if (splitseg.seg == null)
|
| 615 |
+
{
|
| 616 |
+
// Find the location of the vertex to be inserted. Check if a good
|
| 617 |
+
// starting triangle has already been provided by the caller.
|
| 618 |
+
if (searchtri.tri.id == DUMMY)
|
| 619 |
+
{
|
| 620 |
+
// Find a boundary triangle.
|
| 621 |
+
horiz.tri = dummytri;
|
| 622 |
+
horiz.orient = 0;
|
| 623 |
+
horiz.Sym();
|
| 624 |
+
|
| 625 |
+
// Search for a triangle containing 'newvertex'.
|
| 626 |
+
intersect = locator.Locate(newvertex, ref horiz);
|
| 627 |
+
}
|
| 628 |
+
else
|
| 629 |
+
{
|
| 630 |
+
// Start searching from the triangle provided by the caller.
|
| 631 |
+
searchtri.Copy(ref horiz);
|
| 632 |
+
intersect = locator.PreciseLocate(newvertex, ref horiz, true);
|
| 633 |
+
}
|
| 634 |
+
}
|
| 635 |
+
else
|
| 636 |
+
{
|
| 637 |
+
// The calling routine provides the subsegment in which
|
| 638 |
+
// the vertex is inserted.
|
| 639 |
+
searchtri.Copy(ref horiz);
|
| 640 |
+
intersect = LocateResult.OnEdge;
|
| 641 |
+
}
|
| 642 |
+
|
| 643 |
+
if (intersect == LocateResult.OnVertex)
|
| 644 |
+
{
|
| 645 |
+
// There's already a vertex there. Return in 'searchtri' a triangle
|
| 646 |
+
// whose origin is the existing vertex.
|
| 647 |
+
horiz.Copy(ref searchtri);
|
| 648 |
+
locator.Update(ref horiz);
|
| 649 |
+
return InsertVertexResult.Duplicate;
|
| 650 |
+
}
|
| 651 |
+
if ((intersect == LocateResult.OnEdge) || (intersect == LocateResult.Outside))
|
| 652 |
+
{
|
| 653 |
+
// The vertex falls on an edge or boundary.
|
| 654 |
+
if (checksegments && (splitseg.seg == null))
|
| 655 |
+
{
|
| 656 |
+
// Check whether the vertex falls on a subsegment.
|
| 657 |
+
horiz.Pivot(ref brokensubseg);
|
| 658 |
+
if (brokensubseg.seg.hash != DUMMY)
|
| 659 |
+
{
|
| 660 |
+
// The vertex falls on a subsegment, and hence will not be inserted.
|
| 661 |
+
if (segmentflaws)
|
| 662 |
+
{
|
| 663 |
+
enq = behavior.NoBisect != 2;
|
| 664 |
+
if (enq && (behavior.NoBisect == 1))
|
| 665 |
+
{
|
| 666 |
+
// This subsegment may be split only if it is an
|
| 667 |
+
// internal boundary.
|
| 668 |
+
horiz.Sym(ref testtri);
|
| 669 |
+
enq = testtri.tri.id != DUMMY;
|
| 670 |
+
}
|
| 671 |
+
if (enq)
|
| 672 |
+
{
|
| 673 |
+
// Add the subsegment to the list of encroached subsegments.
|
| 674 |
+
encroached = new BadSubseg();
|
| 675 |
+
encroached.subseg = brokensubseg;
|
| 676 |
+
encroached.org = brokensubseg.Org();
|
| 677 |
+
encroached.dest = brokensubseg.Dest();
|
| 678 |
+
|
| 679 |
+
qualityMesher.AddBadSubseg(encroached);
|
| 680 |
+
}
|
| 681 |
+
}
|
| 682 |
+
// Return a handle whose primary edge contains the vertex,
|
| 683 |
+
// which has not been inserted.
|
| 684 |
+
horiz.Copy(ref searchtri);
|
| 685 |
+
locator.Update(ref horiz);
|
| 686 |
+
return InsertVertexResult.Violating;
|
| 687 |
+
}
|
| 688 |
+
}
|
| 689 |
+
|
| 690 |
+
// Insert the vertex on an edge, dividing one triangle into two (if
|
| 691 |
+
// the edge lies on a boundary) or two triangles into four.
|
| 692 |
+
horiz.Lprev(ref botright);
|
| 693 |
+
botright.Sym(ref botrcasing);
|
| 694 |
+
horiz.Sym(ref topright);
|
| 695 |
+
// Is there a second triangle? (Or does this edge lie on a boundary?)
|
| 696 |
+
mirrorflag = topright.tri.id != DUMMY;
|
| 697 |
+
if (mirrorflag)
|
| 698 |
+
{
|
| 699 |
+
topright.Lnext();
|
| 700 |
+
topright.Sym(ref toprcasing);
|
| 701 |
+
MakeTriangle(ref newtopright);
|
| 702 |
+
}
|
| 703 |
+
else
|
| 704 |
+
{
|
| 705 |
+
// Splitting a boundary edge increases the number of boundary edges.
|
| 706 |
+
hullsize++;
|
| 707 |
+
}
|
| 708 |
+
MakeTriangle(ref newbotright);
|
| 709 |
+
|
| 710 |
+
// Set the vertices of changed and new triangles.
|
| 711 |
+
rightvertex = horiz.Org();
|
| 712 |
+
leftvertex = horiz.Dest();
|
| 713 |
+
botvertex = horiz.Apex();
|
| 714 |
+
newbotright.SetOrg(botvertex);
|
| 715 |
+
newbotright.SetDest(rightvertex);
|
| 716 |
+
newbotright.SetApex(newvertex);
|
| 717 |
+
horiz.SetOrg(newvertex);
|
| 718 |
+
|
| 719 |
+
// Set the region of a new triangle.
|
| 720 |
+
newbotright.tri.label = botright.tri.label;
|
| 721 |
+
|
| 722 |
+
if (behavior.VarArea)
|
| 723 |
+
{
|
| 724 |
+
// Set the area constraint of a new triangle.
|
| 725 |
+
newbotright.tri.area = botright.tri.area;
|
| 726 |
+
}
|
| 727 |
+
|
| 728 |
+
if (mirrorflag)
|
| 729 |
+
{
|
| 730 |
+
topvertex = topright.Dest();
|
| 731 |
+
newtopright.SetOrg(rightvertex);
|
| 732 |
+
newtopright.SetDest(topvertex);
|
| 733 |
+
newtopright.SetApex(newvertex);
|
| 734 |
+
topright.SetOrg(newvertex);
|
| 735 |
+
|
| 736 |
+
// Set the region of another new triangle.
|
| 737 |
+
newtopright.tri.label = topright.tri.label;
|
| 738 |
+
|
| 739 |
+
if (behavior.VarArea)
|
| 740 |
+
{
|
| 741 |
+
// Set the area constraint of another new triangle.
|
| 742 |
+
newtopright.tri.area = topright.tri.area;
|
| 743 |
+
}
|
| 744 |
+
}
|
| 745 |
+
|
| 746 |
+
// There may be subsegments that need to be bonded
|
| 747 |
+
// to the new triangle(s).
|
| 748 |
+
if (checksegments)
|
| 749 |
+
{
|
| 750 |
+
botright.Pivot(ref botrsubseg);
|
| 751 |
+
|
| 752 |
+
if (botrsubseg.seg.hash != DUMMY)
|
| 753 |
+
{
|
| 754 |
+
botright.SegDissolve(dummysub);
|
| 755 |
+
newbotright.SegBond(ref botrsubseg);
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
if (mirrorflag)
|
| 759 |
+
{
|
| 760 |
+
topright.Pivot(ref toprsubseg);
|
| 761 |
+
if (toprsubseg.seg.hash != DUMMY)
|
| 762 |
+
{
|
| 763 |
+
topright.SegDissolve(dummysub);
|
| 764 |
+
newtopright.SegBond(ref toprsubseg);
|
| 765 |
+
}
|
| 766 |
+
}
|
| 767 |
+
}
|
| 768 |
+
|
| 769 |
+
// Bond the new triangle(s) to the surrounding triangles.
|
| 770 |
+
newbotright.Bond(ref botrcasing);
|
| 771 |
+
newbotright.Lprev();
|
| 772 |
+
newbotright.Bond(ref botright);
|
| 773 |
+
newbotright.Lprev();
|
| 774 |
+
|
| 775 |
+
if (mirrorflag)
|
| 776 |
+
{
|
| 777 |
+
newtopright.Bond(ref toprcasing);
|
| 778 |
+
newtopright.Lnext();
|
| 779 |
+
newtopright.Bond(ref topright);
|
| 780 |
+
newtopright.Lnext();
|
| 781 |
+
newtopright.Bond(ref newbotright);
|
| 782 |
+
}
|
| 783 |
+
|
| 784 |
+
if (splitseg.seg != null)
|
| 785 |
+
{
|
| 786 |
+
// Split the subsegment into two.
|
| 787 |
+
splitseg.SetDest(newvertex);
|
| 788 |
+
segmentorg = splitseg.SegOrg();
|
| 789 |
+
segmentdest = splitseg.SegDest();
|
| 790 |
+
splitseg.Sym();
|
| 791 |
+
splitseg.Pivot(ref rightsubseg);
|
| 792 |
+
InsertSubseg(ref newbotright, splitseg.seg.boundary);
|
| 793 |
+
newbotright.Pivot(ref newsubseg);
|
| 794 |
+
newsubseg.SetSegOrg(segmentorg);
|
| 795 |
+
newsubseg.SetSegDest(segmentdest);
|
| 796 |
+
splitseg.Bond(ref newsubseg);
|
| 797 |
+
newsubseg.Sym();
|
| 798 |
+
newsubseg.Bond(ref rightsubseg);
|
| 799 |
+
splitseg.Sym();
|
| 800 |
+
|
| 801 |
+
// Transfer the subsegment's boundary marker to the vertex if required.
|
| 802 |
+
if (newvertex.label == 0)
|
| 803 |
+
{
|
| 804 |
+
newvertex.label = splitseg.seg.boundary;
|
| 805 |
+
}
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
+
if (checkquality)
|
| 809 |
+
{
|
| 810 |
+
flipstack.Clear();
|
| 811 |
+
|
| 812 |
+
flipstack.Push(default(Otri)); // Dummy flip (see UndoVertex)
|
| 813 |
+
flipstack.Push(horiz);
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
// Position 'horiz' on the first edge to check for
|
| 817 |
+
// the Delaunay property.
|
| 818 |
+
horiz.Lnext();
|
| 819 |
+
}
|
| 820 |
+
else
|
| 821 |
+
{
|
| 822 |
+
// Insert the vertex in a triangle, splitting it into three.
|
| 823 |
+
horiz.Lnext(ref botleft);
|
| 824 |
+
horiz.Lprev(ref botright);
|
| 825 |
+
botleft.Sym(ref botlcasing);
|
| 826 |
+
botright.Sym(ref botrcasing);
|
| 827 |
+
MakeTriangle(ref newbotleft);
|
| 828 |
+
MakeTriangle(ref newbotright);
|
| 829 |
+
|
| 830 |
+
// Set the vertices of changed and new triangles.
|
| 831 |
+
rightvertex = horiz.Org();
|
| 832 |
+
leftvertex = horiz.Dest();
|
| 833 |
+
botvertex = horiz.Apex();
|
| 834 |
+
newbotleft.SetOrg(leftvertex);
|
| 835 |
+
newbotleft.SetDest(botvertex);
|
| 836 |
+
newbotleft.SetApex(newvertex);
|
| 837 |
+
newbotright.SetOrg(botvertex);
|
| 838 |
+
newbotright.SetDest(rightvertex);
|
| 839 |
+
newbotright.SetApex(newvertex);
|
| 840 |
+
horiz.SetApex(newvertex);
|
| 841 |
+
|
| 842 |
+
// Set the region of the new triangles.
|
| 843 |
+
newbotleft.tri.label = horiz.tri.label;
|
| 844 |
+
newbotright.tri.label = horiz.tri.label;
|
| 845 |
+
|
| 846 |
+
if (behavior.VarArea)
|
| 847 |
+
{
|
| 848 |
+
// Set the area constraint of the new triangles.
|
| 849 |
+
area = horiz.tri.area;
|
| 850 |
+
newbotleft.tri.area = area;
|
| 851 |
+
newbotright.tri.area = area;
|
| 852 |
+
}
|
| 853 |
+
|
| 854 |
+
// There may be subsegments that need to be bonded
|
| 855 |
+
// to the new triangles.
|
| 856 |
+
if (checksegments)
|
| 857 |
+
{
|
| 858 |
+
botleft.Pivot(ref botlsubseg);
|
| 859 |
+
if (botlsubseg.seg.hash != DUMMY)
|
| 860 |
+
{
|
| 861 |
+
botleft.SegDissolve(dummysub);
|
| 862 |
+
newbotleft.SegBond(ref botlsubseg);
|
| 863 |
+
}
|
| 864 |
+
botright.Pivot(ref botrsubseg);
|
| 865 |
+
if (botrsubseg.seg.hash != DUMMY)
|
| 866 |
+
{
|
| 867 |
+
botright.SegDissolve(dummysub);
|
| 868 |
+
newbotright.SegBond(ref botrsubseg);
|
| 869 |
+
}
|
| 870 |
+
}
|
| 871 |
+
|
| 872 |
+
// Bond the new triangles to the surrounding triangles.
|
| 873 |
+
newbotleft.Bond(ref botlcasing);
|
| 874 |
+
newbotright.Bond(ref botrcasing);
|
| 875 |
+
newbotleft.Lnext();
|
| 876 |
+
newbotright.Lprev();
|
| 877 |
+
newbotleft.Bond(ref newbotright);
|
| 878 |
+
newbotleft.Lnext();
|
| 879 |
+
botleft.Bond(ref newbotleft);
|
| 880 |
+
newbotright.Lprev();
|
| 881 |
+
botright.Bond(ref newbotright);
|
| 882 |
+
|
| 883 |
+
if (checkquality)
|
| 884 |
+
{
|
| 885 |
+
flipstack.Clear();
|
| 886 |
+
flipstack.Push(horiz);
|
| 887 |
+
}
|
| 888 |
+
}
|
| 889 |
+
|
| 890 |
+
// The insertion is successful by default, unless an encroached
|
| 891 |
+
// subsegment is found.
|
| 892 |
+
success = InsertVertexResult.Successful;
|
| 893 |
+
|
| 894 |
+
if (newvertex.tri.tri != null)
|
| 895 |
+
{
|
| 896 |
+
// Store the coordinates of the triangle that contains newvertex.
|
| 897 |
+
newvertex.tri.SetOrg(rightvertex);
|
| 898 |
+
newvertex.tri.SetDest(leftvertex);
|
| 899 |
+
newvertex.tri.SetApex(botvertex);
|
| 900 |
+
}
|
| 901 |
+
|
| 902 |
+
// Circle around the newly inserted vertex, checking each edge opposite it
|
| 903 |
+
// for the Delaunay property. Non-Delaunay edges are flipped. 'horiz' is
|
| 904 |
+
// always the edge being checked. 'first' marks where to stop circling.
|
| 905 |
+
first = horiz.Org();
|
| 906 |
+
rightvertex = first;
|
| 907 |
+
leftvertex = horiz.Dest();
|
| 908 |
+
// Circle until finished.
|
| 909 |
+
while (true)
|
| 910 |
+
{
|
| 911 |
+
// By default, the edge will be flipped.
|
| 912 |
+
doflip = true;
|
| 913 |
+
|
| 914 |
+
if (checksegments)
|
| 915 |
+
{
|
| 916 |
+
// Check for a subsegment, which cannot be flipped.
|
| 917 |
+
horiz.Pivot(ref checksubseg);
|
| 918 |
+
if (checksubseg.seg.hash != DUMMY)
|
| 919 |
+
{
|
| 920 |
+
// The edge is a subsegment and cannot be flipped.
|
| 921 |
+
doflip = false;
|
| 922 |
+
|
| 923 |
+
if (segmentflaws)
|
| 924 |
+
{
|
| 925 |
+
// Does the new vertex encroach upon this subsegment?
|
| 926 |
+
if (qualityMesher.CheckSeg4Encroach(ref checksubseg) > 0)
|
| 927 |
+
{
|
| 928 |
+
success = InsertVertexResult.Encroaching;
|
| 929 |
+
}
|
| 930 |
+
}
|
| 931 |
+
}
|
| 932 |
+
}
|
| 933 |
+
|
| 934 |
+
if (doflip)
|
| 935 |
+
{
|
| 936 |
+
// Check if the edge is a boundary edge.
|
| 937 |
+
horiz.Sym(ref top);
|
| 938 |
+
if (top.tri.id == DUMMY)
|
| 939 |
+
{
|
| 940 |
+
// The edge is a boundary edge and cannot be flipped.
|
| 941 |
+
doflip = false;
|
| 942 |
+
}
|
| 943 |
+
else
|
| 944 |
+
{
|
| 945 |
+
// Find the vertex on the other side of the edge.
|
| 946 |
+
farvertex = top.Apex();
|
| 947 |
+
// In the incremental Delaunay triangulation algorithm, any of
|
| 948 |
+
// 'leftvertex', 'rightvertex', and 'farvertex' could be vertices
|
| 949 |
+
// of the triangular bounding box. These vertices must be
|
| 950 |
+
// treated as if they are infinitely distant, even though their
|
| 951 |
+
// "coordinates" are not.
|
| 952 |
+
if ((leftvertex == infvertex1) || (leftvertex == infvertex2) ||
|
| 953 |
+
(leftvertex == infvertex3))
|
| 954 |
+
{
|
| 955 |
+
// 'leftvertex' is infinitely distant. Check the convexity of
|
| 956 |
+
// the boundary of the triangulation. 'farvertex' might be
|
| 957 |
+
// infinite as well, but trust me, this same condition should
|
| 958 |
+
// be applied.
|
| 959 |
+
doflip = predicates.CounterClockwise(newvertex, rightvertex, farvertex) > 0.0;
|
| 960 |
+
}
|
| 961 |
+
else if ((rightvertex == infvertex1) ||
|
| 962 |
+
(rightvertex == infvertex2) ||
|
| 963 |
+
(rightvertex == infvertex3))
|
| 964 |
+
{
|
| 965 |
+
// 'rightvertex' is infinitely distant. Check the convexity of
|
| 966 |
+
// the boundary of the triangulation. 'farvertex' might be
|
| 967 |
+
// infinite as well, but trust me, this same condition should
|
| 968 |
+
// be applied.
|
| 969 |
+
doflip = predicates.CounterClockwise(farvertex, leftvertex, newvertex) > 0.0;
|
| 970 |
+
}
|
| 971 |
+
else if ((farvertex == infvertex1) ||
|
| 972 |
+
(farvertex == infvertex2) ||
|
| 973 |
+
(farvertex == infvertex3))
|
| 974 |
+
{
|
| 975 |
+
// 'farvertex' is infinitely distant and cannot be inside
|
| 976 |
+
// the circumcircle of the triangle 'horiz'.
|
| 977 |
+
doflip = false;
|
| 978 |
+
}
|
| 979 |
+
else
|
| 980 |
+
{
|
| 981 |
+
// Test whether the edge is locally Delaunay.
|
| 982 |
+
doflip = predicates.InCircle(leftvertex, newvertex, rightvertex, farvertex) > 0.0;
|
| 983 |
+
}
|
| 984 |
+
if (doflip)
|
| 985 |
+
{
|
| 986 |
+
// We made it! Flip the edge 'horiz' by rotating its containing
|
| 987 |
+
// quadrilateral (the two triangles adjacent to 'horiz').
|
| 988 |
+
// Identify the casing of the quadrilateral.
|
| 989 |
+
top.Lprev(ref topleft);
|
| 990 |
+
topleft.Sym(ref toplcasing);
|
| 991 |
+
top.Lnext(ref topright);
|
| 992 |
+
topright.Sym(ref toprcasing);
|
| 993 |
+
horiz.Lnext(ref botleft);
|
| 994 |
+
botleft.Sym(ref botlcasing);
|
| 995 |
+
horiz.Lprev(ref botright);
|
| 996 |
+
botright.Sym(ref botrcasing);
|
| 997 |
+
// Rotate the quadrilateral one-quarter turn counterclockwise.
|
| 998 |
+
topleft.Bond(ref botlcasing);
|
| 999 |
+
botleft.Bond(ref botrcasing);
|
| 1000 |
+
botright.Bond(ref toprcasing);
|
| 1001 |
+
topright.Bond(ref toplcasing);
|
| 1002 |
+
if (checksegments)
|
| 1003 |
+
{
|
| 1004 |
+
// Check for subsegments and rebond them to the quadrilateral.
|
| 1005 |
+
topleft.Pivot(ref toplsubseg);
|
| 1006 |
+
botleft.Pivot(ref botlsubseg);
|
| 1007 |
+
botright.Pivot(ref botrsubseg);
|
| 1008 |
+
topright.Pivot(ref toprsubseg);
|
| 1009 |
+
if (toplsubseg.seg.hash == DUMMY)
|
| 1010 |
+
{
|
| 1011 |
+
topright.SegDissolve(dummysub);
|
| 1012 |
+
}
|
| 1013 |
+
else
|
| 1014 |
+
{
|
| 1015 |
+
topright.SegBond(ref toplsubseg);
|
| 1016 |
+
}
|
| 1017 |
+
if (botlsubseg.seg.hash == DUMMY)
|
| 1018 |
+
{
|
| 1019 |
+
topleft.SegDissolve(dummysub);
|
| 1020 |
+
}
|
| 1021 |
+
else
|
| 1022 |
+
{
|
| 1023 |
+
topleft.SegBond(ref botlsubseg);
|
| 1024 |
+
}
|
| 1025 |
+
if (botrsubseg.seg.hash == DUMMY)
|
| 1026 |
+
{
|
| 1027 |
+
botleft.SegDissolve(dummysub);
|
| 1028 |
+
}
|
| 1029 |
+
else
|
| 1030 |
+
{
|
| 1031 |
+
botleft.SegBond(ref botrsubseg);
|
| 1032 |
+
}
|
| 1033 |
+
if (toprsubseg.seg.hash == DUMMY)
|
| 1034 |
+
{
|
| 1035 |
+
botright.SegDissolve(dummysub);
|
| 1036 |
+
}
|
| 1037 |
+
else
|
| 1038 |
+
{
|
| 1039 |
+
botright.SegBond(ref toprsubseg);
|
| 1040 |
+
}
|
| 1041 |
+
}
|
| 1042 |
+
// New vertex assignments for the rotated quadrilateral.
|
| 1043 |
+
horiz.SetOrg(farvertex);
|
| 1044 |
+
horiz.SetDest(newvertex);
|
| 1045 |
+
horiz.SetApex(rightvertex);
|
| 1046 |
+
top.SetOrg(newvertex);
|
| 1047 |
+
top.SetDest(farvertex);
|
| 1048 |
+
top.SetApex(leftvertex);
|
| 1049 |
+
|
| 1050 |
+
// Assign region.
|
| 1051 |
+
// TODO: check region ok (no Math.Min necessary)
|
| 1052 |
+
region = Math.Min(top.tri.label, horiz.tri.label);
|
| 1053 |
+
top.tri.label = region;
|
| 1054 |
+
horiz.tri.label = region;
|
| 1055 |
+
|
| 1056 |
+
if (behavior.VarArea)
|
| 1057 |
+
{
|
| 1058 |
+
if ((top.tri.area <= 0.0) || (horiz.tri.area <= 0.0))
|
| 1059 |
+
{
|
| 1060 |
+
area = -1.0;
|
| 1061 |
+
}
|
| 1062 |
+
else
|
| 1063 |
+
{
|
| 1064 |
+
// Take the average of the two triangles' area constraints.
|
| 1065 |
+
// This prevents small area constraints from migrating a
|
| 1066 |
+
// long, long way from their original location due to flips.
|
| 1067 |
+
area = 0.5 * (top.tri.area + horiz.tri.area);
|
| 1068 |
+
}
|
| 1069 |
+
|
| 1070 |
+
top.tri.area = area;
|
| 1071 |
+
horiz.tri.area = area;
|
| 1072 |
+
}
|
| 1073 |
+
|
| 1074 |
+
if (checkquality)
|
| 1075 |
+
{
|
| 1076 |
+
flipstack.Push(horiz);
|
| 1077 |
+
}
|
| 1078 |
+
|
| 1079 |
+
// On the next iterations, consider the two edges that were exposed (this
|
| 1080 |
+
// is, are now visible to the newly inserted vertex) by the edge flip.
|
| 1081 |
+
horiz.Lprev();
|
| 1082 |
+
leftvertex = farvertex;
|
| 1083 |
+
}
|
| 1084 |
+
}
|
| 1085 |
+
}
|
| 1086 |
+
if (!doflip)
|
| 1087 |
+
{
|
| 1088 |
+
// The handle 'horiz' is accepted as locally Delaunay.
|
| 1089 |
+
if (triflaws)
|
| 1090 |
+
{
|
| 1091 |
+
// Check the triangle 'horiz' for quality.
|
| 1092 |
+
qualityMesher.TestTriangle(ref horiz);
|
| 1093 |
+
}
|
| 1094 |
+
|
| 1095 |
+
// Look for the next edge around the newly inserted vertex.
|
| 1096 |
+
horiz.Lnext();
|
| 1097 |
+
horiz.Sym(ref testtri);
|
| 1098 |
+
// Check for finishing a complete revolution about the new vertex, or
|
| 1099 |
+
// falling outside of the triangulation. The latter will happen when
|
| 1100 |
+
// a vertex is inserted at a boundary.
|
| 1101 |
+
if ((leftvertex == first) || (testtri.tri.id == DUMMY))
|
| 1102 |
+
{
|
| 1103 |
+
// We're done. Return a triangle whose origin is the new vertex.
|
| 1104 |
+
horiz.Lnext(ref searchtri);
|
| 1105 |
+
|
| 1106 |
+
Otri recenttri = default(Otri);
|
| 1107 |
+
horiz.Lnext(ref recenttri);
|
| 1108 |
+
locator.Update(ref recenttri);
|
| 1109 |
+
|
| 1110 |
+
return success;
|
| 1111 |
+
}
|
| 1112 |
+
// Finish finding the next edge around the newly inserted vertex.
|
| 1113 |
+
testtri.Lnext(ref horiz);
|
| 1114 |
+
rightvertex = leftvertex;
|
| 1115 |
+
leftvertex = horiz.Dest();
|
| 1116 |
+
}
|
| 1117 |
+
}
|
| 1118 |
+
}
|
| 1119 |
+
|
| 1120 |
+
/// <summary>
|
| 1121 |
+
/// Create a new subsegment and inserts it between two triangles. Its
|
| 1122 |
+
/// vertices are properly initialized.
|
| 1123 |
+
/// </summary>
|
| 1124 |
+
/// <param name="tri">The new subsegment is inserted at the edge
|
| 1125 |
+
/// described by this handle.</param>
|
| 1126 |
+
/// <param name="subsegmark">The marker 'subsegmark' is applied to the
|
| 1127 |
+
/// subsegment and, if appropriate, its vertices.</param>
|
| 1128 |
+
internal void InsertSubseg(ref Otri tri, int subsegmark)
|
| 1129 |
+
{
|
| 1130 |
+
Otri oppotri = default(Otri);
|
| 1131 |
+
Osub newsubseg = default(Osub);
|
| 1132 |
+
Vertex triorg, tridest;
|
| 1133 |
+
|
| 1134 |
+
triorg = tri.Org();
|
| 1135 |
+
tridest = tri.Dest();
|
| 1136 |
+
// Mark vertices if possible.
|
| 1137 |
+
if (triorg.label == 0)
|
| 1138 |
+
{
|
| 1139 |
+
triorg.label = subsegmark;
|
| 1140 |
+
}
|
| 1141 |
+
if (tridest.label == 0)
|
| 1142 |
+
{
|
| 1143 |
+
tridest.label = subsegmark;
|
| 1144 |
+
}
|
| 1145 |
+
// Check if there's already a subsegment here.
|
| 1146 |
+
tri.Pivot(ref newsubseg);
|
| 1147 |
+
if (newsubseg.seg.hash == DUMMY)
|
| 1148 |
+
{
|
| 1149 |
+
// Make new subsegment and initialize its vertices.
|
| 1150 |
+
MakeSegment(ref newsubseg);
|
| 1151 |
+
newsubseg.SetOrg(tridest);
|
| 1152 |
+
newsubseg.SetDest(triorg);
|
| 1153 |
+
newsubseg.SetSegOrg(tridest);
|
| 1154 |
+
newsubseg.SetSegDest(triorg);
|
| 1155 |
+
// Bond new subsegment to the two triangles it is sandwiched between.
|
| 1156 |
+
// Note that the facing triangle 'oppotri' might be equal to 'dummytri'
|
| 1157 |
+
// (outer space), but the new subsegment is bonded to it all the same.
|
| 1158 |
+
tri.SegBond(ref newsubseg);
|
| 1159 |
+
tri.Sym(ref oppotri);
|
| 1160 |
+
newsubseg.Sym();
|
| 1161 |
+
oppotri.SegBond(ref newsubseg);
|
| 1162 |
+
newsubseg.seg.boundary = subsegmark;
|
| 1163 |
+
}
|
| 1164 |
+
else if (newsubseg.seg.boundary == 0)
|
| 1165 |
+
{
|
| 1166 |
+
newsubseg.seg.boundary = subsegmark;
|
| 1167 |
+
}
|
| 1168 |
+
}
|
| 1169 |
+
|
| 1170 |
+
/// <summary>
|
| 1171 |
+
/// Transform two triangles to two different triangles by flipping an edge
|
| 1172 |
+
/// counterclockwise within a quadrilateral.
|
| 1173 |
+
/// </summary>
|
| 1174 |
+
/// <param name="flipedge">Handle to the edge that will be flipped.</param>
|
| 1175 |
+
/// <remarks>Imagine the original triangles, abc and bad, oriented so that the
|
| 1176 |
+
/// shared edge ab lies in a horizontal plane, with the vertex b on the left
|
| 1177 |
+
/// and the vertex a on the right. The vertex c lies below the edge, and
|
| 1178 |
+
/// the vertex d lies above the edge. The 'flipedge' handle holds the edge
|
| 1179 |
+
/// ab of triangle abc, and is directed left, from vertex a to vertex b.
|
| 1180 |
+
///
|
| 1181 |
+
/// The triangles abc and bad are deleted and replaced by the triangles cdb
|
| 1182 |
+
/// and dca. The triangles that represent abc and bad are NOT deallocated;
|
| 1183 |
+
/// they are reused for dca and cdb, respectively. Hence, any handles that
|
| 1184 |
+
/// may have held the original triangles are still valid, although not
|
| 1185 |
+
/// directed as they were before.
|
| 1186 |
+
///
|
| 1187 |
+
/// Upon completion of this routine, the 'flipedge' handle holds the edge
|
| 1188 |
+
/// dc of triangle dca, and is directed down, from vertex d to vertex c.
|
| 1189 |
+
/// (Hence, the two triangles have rotated counterclockwise.)
|
| 1190 |
+
///
|
| 1191 |
+
/// WARNING: This transformation is geometrically valid only if the
|
| 1192 |
+
/// quadrilateral adbc is convex. Furthermore, this transformation is
|
| 1193 |
+
/// valid only if there is not a subsegment between the triangles abc and
|
| 1194 |
+
/// bad. This routine does not check either of these preconditions, and
|
| 1195 |
+
/// it is the responsibility of the calling routine to ensure that they are
|
| 1196 |
+
/// met. If they are not, the streets shall be filled with wailing and
|
| 1197 |
+
/// gnashing of teeth.
|
| 1198 |
+
///
|
| 1199 |
+
/// Terminology
|
| 1200 |
+
///
|
| 1201 |
+
/// A "local transformation" replaces a small set of triangles with another
|
| 1202 |
+
/// set of triangles. This may or may not involve inserting or deleting a
|
| 1203 |
+
/// vertex.
|
| 1204 |
+
///
|
| 1205 |
+
/// The term "casing" is used to describe the set of triangles that are
|
| 1206 |
+
/// attached to the triangles being transformed, but are not transformed
|
| 1207 |
+
/// themselves. Think of the casing as a fixed hollow structure inside
|
| 1208 |
+
/// which all the action happens. A "casing" is only defined relative to
|
| 1209 |
+
/// a single transformation; each occurrence of a transformation will
|
| 1210 |
+
/// involve a different casing.
|
| 1211 |
+
/// </remarks>
|
| 1212 |
+
internal void Flip(ref Otri flipedge)
|
| 1213 |
+
{
|
| 1214 |
+
Otri botleft = default(Otri), botright = default(Otri);
|
| 1215 |
+
Otri topleft = default(Otri), topright = default(Otri);
|
| 1216 |
+
Otri top = default(Otri);
|
| 1217 |
+
Otri botlcasing = default(Otri), botrcasing = default(Otri);
|
| 1218 |
+
Otri toplcasing = default(Otri), toprcasing = default(Otri);
|
| 1219 |
+
Osub botlsubseg = default(Osub), botrsubseg = default(Osub);
|
| 1220 |
+
Osub toplsubseg = default(Osub), toprsubseg = default(Osub);
|
| 1221 |
+
Vertex leftvertex, rightvertex, botvertex;
|
| 1222 |
+
Vertex farvertex;
|
| 1223 |
+
|
| 1224 |
+
// Identify the vertices of the quadrilateral.
|
| 1225 |
+
rightvertex = flipedge.Org();
|
| 1226 |
+
leftvertex = flipedge.Dest();
|
| 1227 |
+
botvertex = flipedge.Apex();
|
| 1228 |
+
flipedge.Sym(ref top);
|
| 1229 |
+
|
| 1230 |
+
// SELF CHECK
|
| 1231 |
+
|
| 1232 |
+
//if (top.triangle.id == DUMMY)
|
| 1233 |
+
//{
|
| 1234 |
+
// logger.Error("Attempt to flip on boundary.", "Mesh.Flip()");
|
| 1235 |
+
// flipedge.LnextSelf();
|
| 1236 |
+
// return;
|
| 1237 |
+
//}
|
| 1238 |
+
|
| 1239 |
+
//if (checksegments)
|
| 1240 |
+
//{
|
| 1241 |
+
// flipedge.SegPivot(ref toplsubseg);
|
| 1242 |
+
// if (toplsubseg.ss != Segment.Empty)
|
| 1243 |
+
// {
|
| 1244 |
+
// logger.Error("Attempt to flip a segment.", "Mesh.Flip()");
|
| 1245 |
+
// flipedge.LnextSelf();
|
| 1246 |
+
// return;
|
| 1247 |
+
// }
|
| 1248 |
+
//}
|
| 1249 |
+
|
| 1250 |
+
farvertex = top.Apex();
|
| 1251 |
+
|
| 1252 |
+
// Identify the casing of the quadrilateral.
|
| 1253 |
+
top.Lprev(ref topleft);
|
| 1254 |
+
topleft.Sym(ref toplcasing);
|
| 1255 |
+
top.Lnext(ref topright);
|
| 1256 |
+
topright.Sym(ref toprcasing);
|
| 1257 |
+
flipedge.Lnext(ref botleft);
|
| 1258 |
+
botleft.Sym(ref botlcasing);
|
| 1259 |
+
flipedge.Lprev(ref botright);
|
| 1260 |
+
botright.Sym(ref botrcasing);
|
| 1261 |
+
// Rotate the quadrilateral one-quarter turn counterclockwise.
|
| 1262 |
+
topleft.Bond(ref botlcasing);
|
| 1263 |
+
botleft.Bond(ref botrcasing);
|
| 1264 |
+
botright.Bond(ref toprcasing);
|
| 1265 |
+
topright.Bond(ref toplcasing);
|
| 1266 |
+
|
| 1267 |
+
if (checksegments)
|
| 1268 |
+
{
|
| 1269 |
+
// Check for subsegments and rebond them to the quadrilateral.
|
| 1270 |
+
topleft.Pivot(ref toplsubseg);
|
| 1271 |
+
botleft.Pivot(ref botlsubseg);
|
| 1272 |
+
botright.Pivot(ref botrsubseg);
|
| 1273 |
+
topright.Pivot(ref toprsubseg);
|
| 1274 |
+
|
| 1275 |
+
if (toplsubseg.seg.hash == DUMMY)
|
| 1276 |
+
{
|
| 1277 |
+
topright.SegDissolve(dummysub);
|
| 1278 |
+
}
|
| 1279 |
+
else
|
| 1280 |
+
{
|
| 1281 |
+
topright.SegBond(ref toplsubseg);
|
| 1282 |
+
}
|
| 1283 |
+
|
| 1284 |
+
if (botlsubseg.seg.hash == DUMMY)
|
| 1285 |
+
{
|
| 1286 |
+
topleft.SegDissolve(dummysub);
|
| 1287 |
+
}
|
| 1288 |
+
else
|
| 1289 |
+
{
|
| 1290 |
+
topleft.SegBond(ref botlsubseg);
|
| 1291 |
+
}
|
| 1292 |
+
|
| 1293 |
+
if (botrsubseg.seg.hash == DUMMY)
|
| 1294 |
+
{
|
| 1295 |
+
botleft.SegDissolve(dummysub);
|
| 1296 |
+
}
|
| 1297 |
+
else
|
| 1298 |
+
{
|
| 1299 |
+
botleft.SegBond(ref botrsubseg);
|
| 1300 |
+
}
|
| 1301 |
+
|
| 1302 |
+
if (toprsubseg.seg.hash == DUMMY)
|
| 1303 |
+
{
|
| 1304 |
+
botright.SegDissolve(dummysub);
|
| 1305 |
+
}
|
| 1306 |
+
else
|
| 1307 |
+
{
|
| 1308 |
+
botright.SegBond(ref toprsubseg);
|
| 1309 |
+
}
|
| 1310 |
+
}
|
| 1311 |
+
|
| 1312 |
+
// New vertex assignments for the rotated quadrilateral.
|
| 1313 |
+
flipedge.SetOrg(farvertex);
|
| 1314 |
+
flipedge.SetDest(botvertex);
|
| 1315 |
+
flipedge.SetApex(rightvertex);
|
| 1316 |
+
top.SetOrg(botvertex);
|
| 1317 |
+
top.SetDest(farvertex);
|
| 1318 |
+
top.SetApex(leftvertex);
|
| 1319 |
+
}
|
| 1320 |
+
|
| 1321 |
+
/// <summary>
|
| 1322 |
+
/// Transform two triangles to two different triangles by flipping an edge
|
| 1323 |
+
/// clockwise within a quadrilateral. Reverses the flip() operation so that
|
| 1324 |
+
/// the data structures representing the triangles are back where they were
|
| 1325 |
+
/// before the flip().
|
| 1326 |
+
/// </summary>
|
| 1327 |
+
/// <param name="flipedge"></param>
|
| 1328 |
+
/// <remarks>
|
| 1329 |
+
/// See above Flip() remarks for more information.
|
| 1330 |
+
///
|
| 1331 |
+
/// Upon completion of this routine, the 'flipedge' handle holds the edge
|
| 1332 |
+
/// cd of triangle cdb, and is directed up, from vertex c to vertex d.
|
| 1333 |
+
/// (Hence, the two triangles have rotated clockwise.)
|
| 1334 |
+
/// </remarks>
|
| 1335 |
+
internal void Unflip(ref Otri flipedge)
|
| 1336 |
+
{
|
| 1337 |
+
Otri botleft = default(Otri), botright = default(Otri);
|
| 1338 |
+
Otri topleft = default(Otri), topright = default(Otri);
|
| 1339 |
+
Otri top = default(Otri);
|
| 1340 |
+
Otri botlcasing = default(Otri), botrcasing = default(Otri);
|
| 1341 |
+
Otri toplcasing = default(Otri), toprcasing = default(Otri);
|
| 1342 |
+
Osub botlsubseg = default(Osub), botrsubseg = default(Osub);
|
| 1343 |
+
Osub toplsubseg = default(Osub), toprsubseg = default(Osub);
|
| 1344 |
+
Vertex leftvertex, rightvertex, botvertex;
|
| 1345 |
+
Vertex farvertex;
|
| 1346 |
+
|
| 1347 |
+
// Identify the vertices of the quadrilateral.
|
| 1348 |
+
rightvertex = flipedge.Org();
|
| 1349 |
+
leftvertex = flipedge.Dest();
|
| 1350 |
+
botvertex = flipedge.Apex();
|
| 1351 |
+
flipedge.Sym(ref top);
|
| 1352 |
+
|
| 1353 |
+
farvertex = top.Apex();
|
| 1354 |
+
|
| 1355 |
+
// Identify the casing of the quadrilateral.
|
| 1356 |
+
top.Lprev(ref topleft);
|
| 1357 |
+
topleft.Sym(ref toplcasing);
|
| 1358 |
+
top.Lnext(ref topright);
|
| 1359 |
+
topright.Sym(ref toprcasing);
|
| 1360 |
+
flipedge.Lnext(ref botleft);
|
| 1361 |
+
botleft.Sym(ref botlcasing);
|
| 1362 |
+
flipedge.Lprev(ref botright);
|
| 1363 |
+
botright.Sym(ref botrcasing);
|
| 1364 |
+
// Rotate the quadrilateral one-quarter turn clockwise.
|
| 1365 |
+
topleft.Bond(ref toprcasing);
|
| 1366 |
+
botleft.Bond(ref toplcasing);
|
| 1367 |
+
botright.Bond(ref botlcasing);
|
| 1368 |
+
topright.Bond(ref botrcasing);
|
| 1369 |
+
|
| 1370 |
+
if (checksegments)
|
| 1371 |
+
{
|
| 1372 |
+
// Check for subsegments and rebond them to the quadrilateral.
|
| 1373 |
+
topleft.Pivot(ref toplsubseg);
|
| 1374 |
+
botleft.Pivot(ref botlsubseg);
|
| 1375 |
+
botright.Pivot(ref botrsubseg);
|
| 1376 |
+
topright.Pivot(ref toprsubseg);
|
| 1377 |
+
if (toplsubseg.seg.hash == DUMMY)
|
| 1378 |
+
{
|
| 1379 |
+
botleft.SegDissolve(dummysub);
|
| 1380 |
+
}
|
| 1381 |
+
else
|
| 1382 |
+
{
|
| 1383 |
+
botleft.SegBond(ref toplsubseg);
|
| 1384 |
+
}
|
| 1385 |
+
if (botlsubseg.seg.hash == DUMMY)
|
| 1386 |
+
{
|
| 1387 |
+
botright.SegDissolve(dummysub);
|
| 1388 |
+
}
|
| 1389 |
+
else
|
| 1390 |
+
{
|
| 1391 |
+
botright.SegBond(ref botlsubseg);
|
| 1392 |
+
}
|
| 1393 |
+
if (botrsubseg.seg.hash == DUMMY)
|
| 1394 |
+
{
|
| 1395 |
+
topright.SegDissolve(dummysub);
|
| 1396 |
+
}
|
| 1397 |
+
else
|
| 1398 |
+
{
|
| 1399 |
+
topright.SegBond(ref botrsubseg);
|
| 1400 |
+
}
|
| 1401 |
+
if (toprsubseg.seg.hash == DUMMY)
|
| 1402 |
+
{
|
| 1403 |
+
topleft.SegDissolve(dummysub);
|
| 1404 |
+
}
|
| 1405 |
+
else
|
| 1406 |
+
{
|
| 1407 |
+
topleft.SegBond(ref toprsubseg);
|
| 1408 |
+
}
|
| 1409 |
+
}
|
| 1410 |
+
|
| 1411 |
+
// New vertex assignments for the rotated quadrilateral.
|
| 1412 |
+
flipedge.SetOrg(botvertex);
|
| 1413 |
+
flipedge.SetDest(farvertex);
|
| 1414 |
+
flipedge.SetApex(leftvertex);
|
| 1415 |
+
top.SetOrg(farvertex);
|
| 1416 |
+
top.SetDest(botvertex);
|
| 1417 |
+
top.SetApex(rightvertex);
|
| 1418 |
+
}
|
| 1419 |
+
|
| 1420 |
+
/// <summary>
|
| 1421 |
+
/// Find the Delaunay triangulation of a polygon that has a certain "nice" shape.
|
| 1422 |
+
/// This includes the polygons that result from deletion of a vertex or insertion
|
| 1423 |
+
/// of a segment.
|
| 1424 |
+
/// </summary>
|
| 1425 |
+
/// <param name="firstedge">The primary edge of the first triangle.</param>
|
| 1426 |
+
/// <param name="lastedge">The primary edge of the last triangle.</param>
|
| 1427 |
+
/// <param name="edgecount">The number of sides of the polygon, including its
|
| 1428 |
+
/// base.</param>
|
| 1429 |
+
/// <param name="doflip">A flag, wether to perform the last flip.</param>
|
| 1430 |
+
/// <param name="triflaws">A flag that determines whether the new triangles should
|
| 1431 |
+
/// be tested for quality, and enqueued if they are bad.</param>
|
| 1432 |
+
/// <remarks>
|
| 1433 |
+
// This is a conceptually difficult routine. The starting assumption is
|
| 1434 |
+
// that we have a polygon with n sides. n - 1 of these sides are currently
|
| 1435 |
+
// represented as edges in the mesh. One side, called the "base", need not
|
| 1436 |
+
// be.
|
| 1437 |
+
//
|
| 1438 |
+
// Inside the polygon is a structure I call a "fan", consisting of n - 1
|
| 1439 |
+
// triangles that share a common origin. For each of these triangles, the
|
| 1440 |
+
// edge opposite the origin is one of the sides of the polygon. The
|
| 1441 |
+
// primary edge of each triangle is the edge directed from the origin to
|
| 1442 |
+
// the destination; note that this is not the same edge that is a side of
|
| 1443 |
+
// the polygon. 'firstedge' is the primary edge of the first triangle.
|
| 1444 |
+
// From there, the triangles follow in counterclockwise order about the
|
| 1445 |
+
// polygon, until 'lastedge', the primary edge of the last triangle.
|
| 1446 |
+
// 'firstedge' and 'lastedge' are probably connected to other triangles
|
| 1447 |
+
// beyond the extremes of the fan, but their identity is not important, as
|
| 1448 |
+
// long as the fan remains connected to them.
|
| 1449 |
+
//
|
| 1450 |
+
// Imagine the polygon oriented so that its base is at the bottom. This
|
| 1451 |
+
// puts 'firstedge' on the far right, and 'lastedge' on the far left.
|
| 1452 |
+
// The right vertex of the base is the destination of 'firstedge', and the
|
| 1453 |
+
// left vertex of the base is the apex of 'lastedge'.
|
| 1454 |
+
//
|
| 1455 |
+
// The challenge now is to find the right sequence of edge flips to
|
| 1456 |
+
// transform the fan into a Delaunay triangulation of the polygon. Each
|
| 1457 |
+
// edge flip effectively removes one triangle from the fan, committing it
|
| 1458 |
+
// to the polygon. The resulting polygon has one fewer edge. If 'doflip'
|
| 1459 |
+
// is set, the final flip will be performed, resulting in a fan of one
|
| 1460 |
+
// (useless?) triangle. If 'doflip' is not set, the final flip is not
|
| 1461 |
+
// performed, resulting in a fan of two triangles, and an unfinished
|
| 1462 |
+
// triangular polygon that is not yet filled out with a single triangle.
|
| 1463 |
+
// On completion of the routine, 'lastedge' is the last remaining triangle,
|
| 1464 |
+
// or the leftmost of the last two.
|
| 1465 |
+
//
|
| 1466 |
+
// Although the flips are performed in the order described above, the
|
| 1467 |
+
// decisions about what flips to perform are made in precisely the reverse
|
| 1468 |
+
// order. The recursive triangulatepolygon() procedure makes a decision,
|
| 1469 |
+
// uses up to two recursive calls to triangulate the "subproblems"
|
| 1470 |
+
// (polygons with fewer edges), and then performs an edge flip.
|
| 1471 |
+
//
|
| 1472 |
+
// The "decision" it makes is which vertex of the polygon should be
|
| 1473 |
+
// connected to the base. This decision is made by testing every possible
|
| 1474 |
+
// vertex. Once the best vertex is found, the two edges that connect this
|
| 1475 |
+
// vertex to the base become the bases for two smaller polygons. These
|
| 1476 |
+
// are triangulated recursively. Unfortunately, this approach can take
|
| 1477 |
+
// O(n^2) time not only in the worst case, but in many common cases. It's
|
| 1478 |
+
// rarely a big deal for vertex deletion, where n is rarely larger than
|
| 1479 |
+
// ten, but it could be a big deal for segment insertion, especially if
|
| 1480 |
+
// there's a lot of long segments that each cut many triangles. I ought to
|
| 1481 |
+
// code a faster algorithm some day.
|
| 1482 |
+
/// </remarks>
|
| 1483 |
+
private void TriangulatePolygon(Otri firstedge, Otri lastedge,
|
| 1484 |
+
int edgecount, bool doflip, bool triflaws)
|
| 1485 |
+
{
|
| 1486 |
+
Otri testtri = default(Otri);
|
| 1487 |
+
Otri besttri = default(Otri);
|
| 1488 |
+
Otri tempedge = default(Otri);
|
| 1489 |
+
Vertex leftbasevertex, rightbasevertex;
|
| 1490 |
+
Vertex testvertex;
|
| 1491 |
+
Vertex bestvertex;
|
| 1492 |
+
|
| 1493 |
+
int bestnumber = 1;
|
| 1494 |
+
|
| 1495 |
+
// Identify the base vertices.
|
| 1496 |
+
leftbasevertex = lastedge.Apex();
|
| 1497 |
+
rightbasevertex = firstedge.Dest();
|
| 1498 |
+
|
| 1499 |
+
// Find the best vertex to connect the base to.
|
| 1500 |
+
firstedge.Onext(ref besttri);
|
| 1501 |
+
bestvertex = besttri.Dest();
|
| 1502 |
+
besttri.Copy(ref testtri);
|
| 1503 |
+
|
| 1504 |
+
for (int i = 2; i <= edgecount - 2; i++)
|
| 1505 |
+
{
|
| 1506 |
+
testtri.Onext();
|
| 1507 |
+
testvertex = testtri.Dest();
|
| 1508 |
+
// Is this a better vertex?
|
| 1509 |
+
if (predicates.InCircle(leftbasevertex, rightbasevertex, bestvertex, testvertex) > 0.0)
|
| 1510 |
+
{
|
| 1511 |
+
testtri.Copy(ref besttri);
|
| 1512 |
+
bestvertex = testvertex;
|
| 1513 |
+
bestnumber = i;
|
| 1514 |
+
}
|
| 1515 |
+
}
|
| 1516 |
+
|
| 1517 |
+
if (bestnumber > 1)
|
| 1518 |
+
{
|
| 1519 |
+
// Recursively triangulate the smaller polygon on the right.
|
| 1520 |
+
besttri.Oprev(ref tempedge);
|
| 1521 |
+
TriangulatePolygon(firstedge, tempedge, bestnumber + 1, true, triflaws);
|
| 1522 |
+
}
|
| 1523 |
+
|
| 1524 |
+
if (bestnumber < edgecount - 2)
|
| 1525 |
+
{
|
| 1526 |
+
// Recursively triangulate the smaller polygon on the left.
|
| 1527 |
+
besttri.Sym(ref tempedge);
|
| 1528 |
+
TriangulatePolygon(besttri, lastedge, edgecount - bestnumber, true, triflaws);
|
| 1529 |
+
// Find 'besttri' again; it may have been lost to edge flips.
|
| 1530 |
+
tempedge.Sym(ref besttri);
|
| 1531 |
+
}
|
| 1532 |
+
|
| 1533 |
+
if (doflip)
|
| 1534 |
+
{
|
| 1535 |
+
// Do one final edge flip.
|
| 1536 |
+
Flip(ref besttri);
|
| 1537 |
+
if (triflaws)
|
| 1538 |
+
{
|
| 1539 |
+
// Check the quality of the newly committed triangle.
|
| 1540 |
+
besttri.Sym(ref testtri);
|
| 1541 |
+
qualityMesher.TestTriangle(ref testtri);
|
| 1542 |
+
}
|
| 1543 |
+
}
|
| 1544 |
+
// Return the base triangle.
|
| 1545 |
+
besttri.Copy(ref lastedge);
|
| 1546 |
+
}
|
| 1547 |
+
|
| 1548 |
+
/// <summary>
|
| 1549 |
+
/// Delete a vertex from a Delaunay triangulation, ensuring that the
|
| 1550 |
+
/// triangulation remains Delaunay.
|
| 1551 |
+
/// </summary>
|
| 1552 |
+
/// <param name="deltri"></param>
|
| 1553 |
+
/// <remarks>The origin of 'deltri' is deleted. The union of the triangles
|
| 1554 |
+
/// adjacent to this vertex is a polygon, for which the Delaunay triangulation
|
| 1555 |
+
/// is found. Two triangles are removed from the mesh.
|
| 1556 |
+
///
|
| 1557 |
+
/// Only interior vertices that do not lie on segments or boundaries
|
| 1558 |
+
/// may be deleted.
|
| 1559 |
+
/// </remarks>
|
| 1560 |
+
internal void DeleteVertex(ref Otri deltri)
|
| 1561 |
+
{
|
| 1562 |
+
Otri countingtri = default(Otri);
|
| 1563 |
+
Otri firstedge = default(Otri), lastedge = default(Otri);
|
| 1564 |
+
Otri deltriright = default(Otri);
|
| 1565 |
+
Otri lefttri = default(Otri), righttri = default(Otri);
|
| 1566 |
+
Otri leftcasing = default(Otri), rightcasing = default(Otri);
|
| 1567 |
+
Osub leftsubseg = default(Osub), rightsubseg = default(Osub);
|
| 1568 |
+
Vertex delvertex;
|
| 1569 |
+
Vertex neworg;
|
| 1570 |
+
int edgecount;
|
| 1571 |
+
|
| 1572 |
+
delvertex = deltri.Org();
|
| 1573 |
+
|
| 1574 |
+
VertexDealloc(delvertex);
|
| 1575 |
+
|
| 1576 |
+
// Count the degree of the vertex being deleted.
|
| 1577 |
+
deltri.Onext(ref countingtri);
|
| 1578 |
+
edgecount = 1;
|
| 1579 |
+
while (!deltri.Equals(countingtri))
|
| 1580 |
+
{
|
| 1581 |
+
edgecount++;
|
| 1582 |
+
countingtri.Onext();
|
| 1583 |
+
}
|
| 1584 |
+
|
| 1585 |
+
if (edgecount > 3)
|
| 1586 |
+
{
|
| 1587 |
+
// Triangulate the polygon defined by the union of all triangles
|
| 1588 |
+
// adjacent to the vertex being deleted. Check the quality of
|
| 1589 |
+
// the resulting triangles.
|
| 1590 |
+
deltri.Onext(ref firstedge);
|
| 1591 |
+
deltri.Oprev(ref lastedge);
|
| 1592 |
+
TriangulatePolygon(firstedge, lastedge, edgecount, false, behavior.NoBisect == 0);
|
| 1593 |
+
}
|
| 1594 |
+
// Splice out two triangles.
|
| 1595 |
+
deltri.Lprev(ref deltriright);
|
| 1596 |
+
deltri.Dnext(ref lefttri);
|
| 1597 |
+
lefttri.Sym(ref leftcasing);
|
| 1598 |
+
deltriright.Oprev(ref righttri);
|
| 1599 |
+
righttri.Sym(ref rightcasing);
|
| 1600 |
+
deltri.Bond(ref leftcasing);
|
| 1601 |
+
deltriright.Bond(ref rightcasing);
|
| 1602 |
+
lefttri.Pivot(ref leftsubseg);
|
| 1603 |
+
if (leftsubseg.seg.hash != DUMMY)
|
| 1604 |
+
{
|
| 1605 |
+
deltri.SegBond(ref leftsubseg);
|
| 1606 |
+
}
|
| 1607 |
+
righttri.Pivot(ref rightsubseg);
|
| 1608 |
+
if (rightsubseg.seg.hash != DUMMY)
|
| 1609 |
+
{
|
| 1610 |
+
deltriright.SegBond(ref rightsubseg);
|
| 1611 |
+
}
|
| 1612 |
+
|
| 1613 |
+
// Set the new origin of 'deltri' and check its quality.
|
| 1614 |
+
neworg = lefttri.Org();
|
| 1615 |
+
deltri.SetOrg(neworg);
|
| 1616 |
+
if (behavior.NoBisect == 0)
|
| 1617 |
+
{
|
| 1618 |
+
qualityMesher.TestTriangle(ref deltri);
|
| 1619 |
+
}
|
| 1620 |
+
|
| 1621 |
+
// Delete the two spliced-out triangles.
|
| 1622 |
+
TriangleDealloc(lefttri.tri);
|
| 1623 |
+
TriangleDealloc(righttri.tri);
|
| 1624 |
+
}
|
| 1625 |
+
|
| 1626 |
+
/// <summary>
|
| 1627 |
+
/// Undo the most recent vertex insertion.
|
| 1628 |
+
/// </summary>
|
| 1629 |
+
/// <remarks>
|
| 1630 |
+
/// Walks through the list of transformations (flips and a vertex insertion)
|
| 1631 |
+
/// in the reverse of the order in which they were done, and undoes them.
|
| 1632 |
+
/// The inserted vertex is removed from the triangulation and deallocated.
|
| 1633 |
+
/// Two triangles (possibly just one) are also deallocated.
|
| 1634 |
+
/// </remarks>
|
| 1635 |
+
internal void UndoVertex()
|
| 1636 |
+
{
|
| 1637 |
+
Otri fliptri;
|
| 1638 |
+
|
| 1639 |
+
Otri botleft = default(Otri), botright = default(Otri), topright = default(Otri);
|
| 1640 |
+
Otri botlcasing = default(Otri), botrcasing = default(Otri), toprcasing = default(Otri);
|
| 1641 |
+
Otri gluetri = default(Otri);
|
| 1642 |
+
Osub botlsubseg = default(Osub), botrsubseg = default(Osub), toprsubseg = default(Osub);
|
| 1643 |
+
Vertex botvertex, rightvertex;
|
| 1644 |
+
|
| 1645 |
+
// Walk through the list of transformations (flips and a vertex insertion)
|
| 1646 |
+
// in the reverse of the order in which they were done, and undo them.
|
| 1647 |
+
while (flipstack.Count > 0)
|
| 1648 |
+
{
|
| 1649 |
+
// Find a triangle involved in the last unreversed transformation.
|
| 1650 |
+
fliptri = flipstack.Pop();
|
| 1651 |
+
|
| 1652 |
+
// We are reversing one of three transformations: a trisection of one
|
| 1653 |
+
// triangle into three (by inserting a vertex in the triangle), a
|
| 1654 |
+
// bisection of two triangles into four (by inserting a vertex in an
|
| 1655 |
+
// edge), or an edge flip.
|
| 1656 |
+
if (flipstack.Count == 0)
|
| 1657 |
+
{
|
| 1658 |
+
// Restore a triangle that was split into three triangles,
|
| 1659 |
+
// so it is again one triangle.
|
| 1660 |
+
fliptri.Dprev(ref botleft);
|
| 1661 |
+
botleft.Lnext();
|
| 1662 |
+
fliptri.Onext(ref botright);
|
| 1663 |
+
botright.Lprev();
|
| 1664 |
+
botleft.Sym(ref botlcasing);
|
| 1665 |
+
botright.Sym(ref botrcasing);
|
| 1666 |
+
botvertex = botleft.Dest();
|
| 1667 |
+
|
| 1668 |
+
fliptri.SetApex(botvertex);
|
| 1669 |
+
fliptri.Lnext();
|
| 1670 |
+
fliptri.Bond(ref botlcasing);
|
| 1671 |
+
botleft.Pivot(ref botlsubseg);
|
| 1672 |
+
fliptri.SegBond(ref botlsubseg);
|
| 1673 |
+
fliptri.Lnext();
|
| 1674 |
+
fliptri.Bond(ref botrcasing);
|
| 1675 |
+
botright.Pivot(ref botrsubseg);
|
| 1676 |
+
fliptri.SegBond(ref botrsubseg);
|
| 1677 |
+
|
| 1678 |
+
// Delete the two spliced-out triangles.
|
| 1679 |
+
TriangleDealloc(botleft.tri);
|
| 1680 |
+
TriangleDealloc(botright.tri);
|
| 1681 |
+
}
|
| 1682 |
+
else if (flipstack.Peek().tri == null) // Dummy flip
|
| 1683 |
+
{
|
| 1684 |
+
// Restore two triangles that were split into four triangles,
|
| 1685 |
+
// so they are again two triangles.
|
| 1686 |
+
fliptri.Lprev(ref gluetri);
|
| 1687 |
+
gluetri.Sym(ref botright);
|
| 1688 |
+
botright.Lnext();
|
| 1689 |
+
botright.Sym(ref botrcasing);
|
| 1690 |
+
rightvertex = botright.Dest();
|
| 1691 |
+
|
| 1692 |
+
fliptri.SetOrg(rightvertex);
|
| 1693 |
+
gluetri.Bond(ref botrcasing);
|
| 1694 |
+
botright.Pivot(ref botrsubseg);
|
| 1695 |
+
gluetri.SegBond(ref botrsubseg);
|
| 1696 |
+
|
| 1697 |
+
// Delete the spliced-out triangle.
|
| 1698 |
+
TriangleDealloc(botright.tri);
|
| 1699 |
+
|
| 1700 |
+
fliptri.Sym(ref gluetri);
|
| 1701 |
+
if (gluetri.tri.id != DUMMY)
|
| 1702 |
+
{
|
| 1703 |
+
gluetri.Lnext();
|
| 1704 |
+
gluetri.Dnext(ref topright);
|
| 1705 |
+
topright.Sym(ref toprcasing);
|
| 1706 |
+
|
| 1707 |
+
gluetri.SetOrg(rightvertex);
|
| 1708 |
+
gluetri.Bond(ref toprcasing);
|
| 1709 |
+
topright.Pivot(ref toprsubseg);
|
| 1710 |
+
gluetri.SegBond(ref toprsubseg);
|
| 1711 |
+
|
| 1712 |
+
// Delete the spliced-out triangle.
|
| 1713 |
+
TriangleDealloc(topright.tri);
|
| 1714 |
+
}
|
| 1715 |
+
|
| 1716 |
+
flipstack.Clear();
|
| 1717 |
+
}
|
| 1718 |
+
else
|
| 1719 |
+
{
|
| 1720 |
+
// Undo an edge flip.
|
| 1721 |
+
Unflip(ref fliptri);
|
| 1722 |
+
}
|
| 1723 |
+
}
|
| 1724 |
+
}
|
| 1725 |
+
|
| 1726 |
+
#endregion
|
| 1727 |
+
|
| 1728 |
+
#region Dealloc
|
| 1729 |
+
|
| 1730 |
+
/// <summary>
|
| 1731 |
+
/// Deallocate space for a triangle, marking it dead.
|
| 1732 |
+
/// </summary>
|
| 1733 |
+
/// <param name="dyingtriangle"></param>
|
| 1734 |
+
internal void TriangleDealloc(Triangle dyingtriangle)
|
| 1735 |
+
{
|
| 1736 |
+
// Mark the triangle as dead. This makes it possible to detect dead
|
| 1737 |
+
// triangles when traversing the list of all triangles.
|
| 1738 |
+
Otri.Kill(dyingtriangle);
|
| 1739 |
+
triangles.Release(dyingtriangle);
|
| 1740 |
+
}
|
| 1741 |
+
|
| 1742 |
+
/// <summary>
|
| 1743 |
+
/// Deallocate space for a vertex, marking it dead.
|
| 1744 |
+
/// </summary>
|
| 1745 |
+
/// <param name="dyingvertex"></param>
|
| 1746 |
+
internal void VertexDealloc(Vertex dyingvertex)
|
| 1747 |
+
{
|
| 1748 |
+
// Mark the vertex as dead. This makes it possible to detect dead
|
| 1749 |
+
// vertices when traversing the list of all vertices.
|
| 1750 |
+
dyingvertex.type = VertexType.DeadVertex;
|
| 1751 |
+
vertices.Remove(dyingvertex.hash);
|
| 1752 |
+
}
|
| 1753 |
+
|
| 1754 |
+
/// <summary>
|
| 1755 |
+
/// Deallocate space for a subsegment, marking it dead.
|
| 1756 |
+
/// </summary>
|
| 1757 |
+
/// <param name="dyingsubseg"></param>
|
| 1758 |
+
internal void SubsegDealloc(SubSegment dyingsubseg)
|
| 1759 |
+
{
|
| 1760 |
+
// Mark the subsegment as dead. This makes it possible to detect dead
|
| 1761 |
+
// subsegments when traversing the list of all subsegments.
|
| 1762 |
+
Osub.Kill(dyingsubseg);
|
| 1763 |
+
subsegs.Remove(dyingsubseg.hash);
|
| 1764 |
+
}
|
| 1765 |
+
|
| 1766 |
+
#endregion
|
| 1767 |
+
}
|
| 1768 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Mesh.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: cf5fb0e34d9b14ac88f67bf18b0bc902
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/MeshValidator.cs
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -----------------------------------------------------------------------
|
| 2 |
+
// <copyright file="MeshValidator.cs">
|
| 3 |
+
// Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html
|
| 4 |
+
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
|
| 5 |
+
// </copyright>
|
| 6 |
+
// -----------------------------------------------------------------------
|
| 7 |
+
|
| 8 |
+
namespace UnityEngine.U2D.Animation.TriangleNet
|
| 9 |
+
{
|
| 10 |
+
using System;
|
| 11 |
+
using Animation.TriangleNet.Topology;
|
| 12 |
+
using Animation.TriangleNet.Geometry;
|
| 13 |
+
|
| 14 |
+
internal static class MeshValidator
|
| 15 |
+
{
|
| 16 |
+
private static RobustPredicates predicates = RobustPredicates.Default;
|
| 17 |
+
|
| 18 |
+
/// <summary>
|
| 19 |
+
/// Test the mesh for topological consistency.
|
| 20 |
+
/// </summary>
|
| 21 |
+
internal static bool IsConsistent(Mesh mesh)
|
| 22 |
+
{
|
| 23 |
+
Otri tri = default(Otri);
|
| 24 |
+
Otri oppotri = default(Otri), oppooppotri = default(Otri);
|
| 25 |
+
Vertex org, dest, apex;
|
| 26 |
+
Vertex oppoorg, oppodest;
|
| 27 |
+
|
| 28 |
+
var logger = Log.Instance;
|
| 29 |
+
|
| 30 |
+
// Temporarily turn on exact arithmetic if it's off.
|
| 31 |
+
bool saveexact = Behavior.NoExact;
|
| 32 |
+
Behavior.NoExact = false;
|
| 33 |
+
|
| 34 |
+
int horrors = 0;
|
| 35 |
+
|
| 36 |
+
// Run through the list of triangles, checking each one.
|
| 37 |
+
foreach (var t in mesh.triangles)
|
| 38 |
+
{
|
| 39 |
+
tri.tri = t;
|
| 40 |
+
|
| 41 |
+
// Check all three edges of the triangle.
|
| 42 |
+
for (tri.orient = 0; tri.orient < 3; tri.orient++)
|
| 43 |
+
{
|
| 44 |
+
org = tri.Org();
|
| 45 |
+
dest = tri.Dest();
|
| 46 |
+
if (tri.orient == 0)
|
| 47 |
+
{
|
| 48 |
+
// Only test for inversion once.
|
| 49 |
+
// Test if the triangle is flat or inverted.
|
| 50 |
+
apex = tri.Apex();
|
| 51 |
+
if (predicates.CounterClockwise(org, dest, apex) <= 0.0)
|
| 52 |
+
{
|
| 53 |
+
if (Log.Verbose)
|
| 54 |
+
{
|
| 55 |
+
logger.Warning(String.Format("Triangle is flat or inverted (ID {0}).", t.id),
|
| 56 |
+
"MeshValidator.IsConsistent()");
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
horrors++;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
// Find the neighboring triangle on this edge.
|
| 64 |
+
tri.Sym(ref oppotri);
|
| 65 |
+
if (oppotri.tri.id != Mesh.DUMMY)
|
| 66 |
+
{
|
| 67 |
+
// Check that the triangle's neighbor knows it's a neighbor.
|
| 68 |
+
oppotri.Sym(ref oppooppotri);
|
| 69 |
+
if ((tri.tri != oppooppotri.tri) || (tri.orient != oppooppotri.orient))
|
| 70 |
+
{
|
| 71 |
+
if (tri.tri == oppooppotri.tri && Log.Verbose)
|
| 72 |
+
{
|
| 73 |
+
logger.Warning("Asymmetric triangle-triangle bond: (Right triangle, wrong orientation)",
|
| 74 |
+
"MeshValidator.IsConsistent()");
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
horrors++;
|
| 78 |
+
}
|
| 79 |
+
// Check that both triangles agree on the identities
|
| 80 |
+
// of their shared vertices.
|
| 81 |
+
oppoorg = oppotri.Org();
|
| 82 |
+
oppodest = oppotri.Dest();
|
| 83 |
+
if ((org != oppodest) || (dest != oppoorg))
|
| 84 |
+
{
|
| 85 |
+
if (Log.Verbose)
|
| 86 |
+
{
|
| 87 |
+
logger.Warning("Mismatched edge coordinates between two triangles.",
|
| 88 |
+
"MeshValidator.IsConsistent()");
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
horrors++;
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
// Check for unconnected vertices
|
| 98 |
+
mesh.MakeVertexMap();
|
| 99 |
+
foreach (var v in mesh.vertices.Values)
|
| 100 |
+
{
|
| 101 |
+
if (v.tri.tri == null && Log.Verbose)
|
| 102 |
+
{
|
| 103 |
+
logger.Warning("Vertex (ID " + v.id + ") not connected to mesh (duplicate input vertex?)",
|
| 104 |
+
"MeshValidator.IsConsistent()");
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
// Restore the status of exact arithmetic.
|
| 109 |
+
Behavior.NoExact = saveexact;
|
| 110 |
+
|
| 111 |
+
return (horrors == 0);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
/// <summary>
|
| 115 |
+
/// Check if the mesh is (conforming) Delaunay.
|
| 116 |
+
/// </summary>
|
| 117 |
+
internal static bool IsDelaunay(Mesh mesh)
|
| 118 |
+
{
|
| 119 |
+
return IsDelaunay(mesh, false);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/// <summary>
|
| 123 |
+
/// Check if that the mesh is (constrained) Delaunay.
|
| 124 |
+
/// </summary>
|
| 125 |
+
internal static bool IsConstrainedDelaunay(Mesh mesh)
|
| 126 |
+
{
|
| 127 |
+
return IsDelaunay(mesh, true);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/// <summary>
|
| 131 |
+
/// Ensure that the mesh is (constrained) Delaunay.
|
| 132 |
+
/// </summary>
|
| 133 |
+
private static bool IsDelaunay(Mesh mesh, bool constrained)
|
| 134 |
+
{
|
| 135 |
+
Otri loop = default(Otri);
|
| 136 |
+
Otri oppotri = default(Otri);
|
| 137 |
+
Osub opposubseg = default(Osub);
|
| 138 |
+
Vertex org, dest, apex;
|
| 139 |
+
Vertex oppoapex;
|
| 140 |
+
|
| 141 |
+
bool shouldbedelaunay;
|
| 142 |
+
|
| 143 |
+
var logger = Log.Instance;
|
| 144 |
+
|
| 145 |
+
// Temporarily turn on exact arithmetic if it's off.
|
| 146 |
+
bool saveexact = Behavior.NoExact;
|
| 147 |
+
Behavior.NoExact = false;
|
| 148 |
+
|
| 149 |
+
int horrors = 0;
|
| 150 |
+
|
| 151 |
+
var inf1 = mesh.infvertex1;
|
| 152 |
+
var inf2 = mesh.infvertex2;
|
| 153 |
+
var inf3 = mesh.infvertex3;
|
| 154 |
+
|
| 155 |
+
// Run through the list of triangles, checking each one.
|
| 156 |
+
foreach (var tri in mesh.triangles)
|
| 157 |
+
{
|
| 158 |
+
loop.tri = tri;
|
| 159 |
+
|
| 160 |
+
// Check all three edges of the triangle.
|
| 161 |
+
for (loop.orient = 0; loop.orient < 3; loop.orient++)
|
| 162 |
+
{
|
| 163 |
+
org = loop.Org();
|
| 164 |
+
dest = loop.Dest();
|
| 165 |
+
apex = loop.Apex();
|
| 166 |
+
|
| 167 |
+
loop.Sym(ref oppotri);
|
| 168 |
+
oppoapex = oppotri.Apex();
|
| 169 |
+
|
| 170 |
+
// Only test that the edge is locally Delaunay if there is an
|
| 171 |
+
// adjoining triangle whose pointer is larger (to ensure that
|
| 172 |
+
// each pair isn't tested twice).
|
| 173 |
+
shouldbedelaunay = (loop.tri.id < oppotri.tri.id) &&
|
| 174 |
+
!Otri.IsDead(oppotri.tri) && (oppotri.tri.id != Mesh.DUMMY) &&
|
| 175 |
+
(org != inf1) && (org != inf2) && (org != inf3) &&
|
| 176 |
+
(dest != inf1) && (dest != inf2) && (dest != inf3) &&
|
| 177 |
+
(apex != inf1) && (apex != inf2) && (apex != inf3) &&
|
| 178 |
+
(oppoapex != inf1) && (oppoapex != inf2) && (oppoapex != inf3);
|
| 179 |
+
|
| 180 |
+
if (constrained && mesh.checksegments && shouldbedelaunay)
|
| 181 |
+
{
|
| 182 |
+
// If a subsegment separates the triangles, then the edge is
|
| 183 |
+
// constrained, so no local Delaunay test should be done.
|
| 184 |
+
loop.Pivot(ref opposubseg);
|
| 185 |
+
|
| 186 |
+
if (opposubseg.seg.hash != Mesh.DUMMY)
|
| 187 |
+
{
|
| 188 |
+
shouldbedelaunay = false;
|
| 189 |
+
}
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
if (shouldbedelaunay)
|
| 193 |
+
{
|
| 194 |
+
if (predicates.NonRegular(org, dest, apex, oppoapex) > 0.0)
|
| 195 |
+
{
|
| 196 |
+
if (Log.Verbose)
|
| 197 |
+
{
|
| 198 |
+
logger.Warning(String.Format("Non-regular pair of triangles found (IDs {0}/{1}).",
|
| 199 |
+
loop.tri.id, oppotri.tri.id), "MeshValidator.IsDelaunay()");
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
horrors++;
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
// Restore the status of exact arithmetic.
|
| 209 |
+
Behavior.NoExact = saveexact;
|
| 210 |
+
|
| 211 |
+
return (horrors == 0);
|
| 212 |
+
}
|
| 213 |
+
}
|
| 214 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/MeshValidator.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 8688318786c2246dbae9df88b4e94a46
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Meshing.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 2e613ffc4de344b0cb197af2ee53feb5
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/NewLocation.cs
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/NewLocation.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 19387af761aa944a6bda921093ae6d70
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Properties.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 943a851f7cd974d46b9e88ddd1a92567
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/RobustPredicates.cs
ADDED
|
@@ -0,0 +1,1347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -----------------------------------------------------------------------
|
| 2 |
+
// <copyright file="RobustPredicates.cs">
|
| 3 |
+
// Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html
|
| 4 |
+
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
|
| 5 |
+
// </copyright>
|
| 6 |
+
// -----------------------------------------------------------------------
|
| 7 |
+
|
| 8 |
+
namespace UnityEngine.U2D.Animation.TriangleNet
|
| 9 |
+
{
|
| 10 |
+
using System;
|
| 11 |
+
using Animation.TriangleNet.Geometry;
|
| 12 |
+
using Animation.TriangleNet.Tools;
|
| 13 |
+
|
| 14 |
+
/// <summary>
|
| 15 |
+
/// Adaptive exact arithmetic geometric predicates.
|
| 16 |
+
/// </summary>
|
| 17 |
+
/// <remarks>
|
| 18 |
+
/// The adaptive exact arithmetic geometric predicates implemented herein are described in
|
| 19 |
+
/// detail in the paper "Adaptive Precision Floating-Point Arithmetic and Fast Robust
|
| 20 |
+
/// Geometric Predicates." by Jonathan Richard Shewchuk, see
|
| 21 |
+
/// http://www.cs.cmu.edu/~quake/robust.html
|
| 22 |
+
///
|
| 23 |
+
/// The macros of the original C code were automatically expanded using the Visual Studio
|
| 24 |
+
/// command prompt with the command "CL /P /C EXACT.C", see
|
| 25 |
+
/// http://msdn.microsoft.com/en-us/library/8z9z0bx6.aspx
|
| 26 |
+
/// </remarks>
|
| 27 |
+
internal class RobustPredicates : IPredicates
|
| 28 |
+
{
|
| 29 |
+
#region Default predicates instance (Singleton)
|
| 30 |
+
|
| 31 |
+
private static readonly object creationLock = new object();
|
| 32 |
+
private static RobustPredicates _default;
|
| 33 |
+
|
| 34 |
+
/// <summary>
|
| 35 |
+
/// Gets the default configuration instance.
|
| 36 |
+
/// </summary>
|
| 37 |
+
internal static RobustPredicates Default
|
| 38 |
+
{
|
| 39 |
+
get
|
| 40 |
+
{
|
| 41 |
+
if (_default == null)
|
| 42 |
+
{
|
| 43 |
+
lock (creationLock)
|
| 44 |
+
{
|
| 45 |
+
if (_default == null)
|
| 46 |
+
{
|
| 47 |
+
_default = new RobustPredicates();
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
return _default;
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
#endregion
|
| 57 |
+
|
| 58 |
+
#region Static initialization
|
| 59 |
+
|
| 60 |
+
private static double epsilon, splitter, resulterrbound;
|
| 61 |
+
private static double ccwerrboundA, ccwerrboundB, ccwerrboundC;
|
| 62 |
+
private static double iccerrboundA, iccerrboundB, iccerrboundC;
|
| 63 |
+
//private static double o3derrboundA, o3derrboundB, o3derrboundC;
|
| 64 |
+
|
| 65 |
+
/// <summary>
|
| 66 |
+
/// Initialize the variables used for exact arithmetic.
|
| 67 |
+
/// </summary>
|
| 68 |
+
/// <remarks>
|
| 69 |
+
/// 'epsilon' is the largest power of two such that 1.0 + epsilon = 1.0 in
|
| 70 |
+
/// floating-point arithmetic. 'epsilon' bounds the relative roundoff
|
| 71 |
+
/// error. It is used for floating-point error analysis.
|
| 72 |
+
///
|
| 73 |
+
/// 'splitter' is used to split floating-point numbers into two half-
|
| 74 |
+
/// length significands for exact multiplication.
|
| 75 |
+
///
|
| 76 |
+
/// I imagine that a highly optimizing compiler might be too smart for its
|
| 77 |
+
/// own good, and somehow cause this routine to fail, if it pretends that
|
| 78 |
+
/// floating-point arithmetic is too much like double arithmetic.
|
| 79 |
+
///
|
| 80 |
+
/// Don't change this routine unless you fully understand it.
|
| 81 |
+
/// </remarks>
|
| 82 |
+
static RobustPredicates()
|
| 83 |
+
{
|
| 84 |
+
double half;
|
| 85 |
+
double check, lastcheck;
|
| 86 |
+
bool every_other;
|
| 87 |
+
|
| 88 |
+
every_other = true;
|
| 89 |
+
half = 0.5;
|
| 90 |
+
epsilon = 1.0;
|
| 91 |
+
splitter = 1.0;
|
| 92 |
+
check = 1.0;
|
| 93 |
+
// Repeatedly divide 'epsilon' by two until it is too small to add to
|
| 94 |
+
// one without causing roundoff. (Also check if the sum is equal to
|
| 95 |
+
// the previous sum, for machines that round up instead of using exact
|
| 96 |
+
// rounding. Not that these routines will work on such machines.)
|
| 97 |
+
do
|
| 98 |
+
{
|
| 99 |
+
lastcheck = check;
|
| 100 |
+
epsilon *= half;
|
| 101 |
+
if (every_other)
|
| 102 |
+
{
|
| 103 |
+
splitter *= 2.0;
|
| 104 |
+
}
|
| 105 |
+
every_other = !every_other;
|
| 106 |
+
check = 1.0 + epsilon;
|
| 107 |
+
}
|
| 108 |
+
while ((check != 1.0) && (check != lastcheck));
|
| 109 |
+
splitter += 1.0;
|
| 110 |
+
// Error bounds for orientation and incircle tests.
|
| 111 |
+
resulterrbound = (3.0 + 8.0 * epsilon) * epsilon;
|
| 112 |
+
ccwerrboundA = (3.0 + 16.0 * epsilon) * epsilon;
|
| 113 |
+
ccwerrboundB = (2.0 + 12.0 * epsilon) * epsilon;
|
| 114 |
+
ccwerrboundC = (9.0 + 64.0 * epsilon) * epsilon * epsilon;
|
| 115 |
+
iccerrboundA = (10.0 + 96.0 * epsilon) * epsilon;
|
| 116 |
+
iccerrboundB = (4.0 + 48.0 * epsilon) * epsilon;
|
| 117 |
+
iccerrboundC = (44.0 + 576.0 * epsilon) * epsilon * epsilon;
|
| 118 |
+
//o3derrboundA = (7.0 + 56.0 * epsilon) * epsilon;
|
| 119 |
+
//o3derrboundB = (3.0 + 28.0 * epsilon) * epsilon;
|
| 120 |
+
//o3derrboundC = (26.0 + 288.0 * epsilon) * epsilon * epsilon;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
#endregion
|
| 124 |
+
|
| 125 |
+
public RobustPredicates()
|
| 126 |
+
{
|
| 127 |
+
AllocateWorkspace();
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/// <summary>
|
| 131 |
+
/// Check, if the three points appear in counterclockwise order. The result is
|
| 132 |
+
/// also a rough approximation of twice the signed area of the triangle defined
|
| 133 |
+
/// by the three points.
|
| 134 |
+
/// </summary>
|
| 135 |
+
/// <param name="pa">Point a.</param>
|
| 136 |
+
/// <param name="pb">Point b.</param>
|
| 137 |
+
/// <param name="pc">Point c.</param>
|
| 138 |
+
/// <returns>Return a positive value if the points pa, pb, and pc occur in
|
| 139 |
+
/// counterclockwise order; a negative value if they occur in clockwise order;
|
| 140 |
+
/// and zero if they are collinear.</returns>
|
| 141 |
+
public double CounterClockwise(Point pa, Point pb, Point pc)
|
| 142 |
+
{
|
| 143 |
+
double detleft, detright, det;
|
| 144 |
+
double detsum, errbound;
|
| 145 |
+
|
| 146 |
+
Statistic.CounterClockwiseCount++;
|
| 147 |
+
|
| 148 |
+
detleft = (pa.x - pc.x) * (pb.y - pc.y);
|
| 149 |
+
detright = (pa.y - pc.y) * (pb.x - pc.x);
|
| 150 |
+
det = detleft - detright;
|
| 151 |
+
|
| 152 |
+
if (Behavior.NoExact)
|
| 153 |
+
{
|
| 154 |
+
return det;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
if (detleft > 0.0)
|
| 158 |
+
{
|
| 159 |
+
if (detright <= 0.0)
|
| 160 |
+
{
|
| 161 |
+
return det;
|
| 162 |
+
}
|
| 163 |
+
else
|
| 164 |
+
{
|
| 165 |
+
detsum = detleft + detright;
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
else if (detleft < 0.0)
|
| 169 |
+
{
|
| 170 |
+
if (detright >= 0.0)
|
| 171 |
+
{
|
| 172 |
+
return det;
|
| 173 |
+
}
|
| 174 |
+
else
|
| 175 |
+
{
|
| 176 |
+
detsum = -detleft - detright;
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
else
|
| 180 |
+
{
|
| 181 |
+
return det;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
errbound = ccwerrboundA * detsum;
|
| 185 |
+
if ((det >= errbound) || (-det >= errbound))
|
| 186 |
+
{
|
| 187 |
+
return det;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
Statistic.CounterClockwiseAdaptCount++;
|
| 191 |
+
return CounterClockwiseAdapt(pa, pb, pc, detsum);
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
/// <summary>
|
| 195 |
+
/// Check if the point pd lies inside the circle passing through pa, pb, and pc. The
|
| 196 |
+
/// points pa, pb, and pc must be in counterclockwise order, or the sign of the result
|
| 197 |
+
/// will be reversed.
|
| 198 |
+
/// </summary>
|
| 199 |
+
/// <param name="pa">Point a.</param>
|
| 200 |
+
/// <param name="pb">Point b.</param>
|
| 201 |
+
/// <param name="pc">Point c.</param>
|
| 202 |
+
/// <param name="pd">Point d.</param>
|
| 203 |
+
/// <returns>Return a positive value if the point pd lies inside the circle passing through
|
| 204 |
+
/// pa, pb, and pc; a negative value if it lies outside; and zero if the four points
|
| 205 |
+
/// are cocircular.</returns>
|
| 206 |
+
public double InCircle(Point pa, Point pb, Point pc, Point pd)
|
| 207 |
+
{
|
| 208 |
+
double adx, bdx, cdx, ady, bdy, cdy;
|
| 209 |
+
double bdxcdy, cdxbdy, cdxady, adxcdy, adxbdy, bdxady;
|
| 210 |
+
double alift, blift, clift;
|
| 211 |
+
double det;
|
| 212 |
+
double permanent, errbound;
|
| 213 |
+
|
| 214 |
+
Statistic.InCircleCount++;
|
| 215 |
+
|
| 216 |
+
adx = pa.x - pd.x;
|
| 217 |
+
bdx = pb.x - pd.x;
|
| 218 |
+
cdx = pc.x - pd.x;
|
| 219 |
+
ady = pa.y - pd.y;
|
| 220 |
+
bdy = pb.y - pd.y;
|
| 221 |
+
cdy = pc.y - pd.y;
|
| 222 |
+
|
| 223 |
+
bdxcdy = bdx * cdy;
|
| 224 |
+
cdxbdy = cdx * bdy;
|
| 225 |
+
alift = adx * adx + ady * ady;
|
| 226 |
+
|
| 227 |
+
cdxady = cdx * ady;
|
| 228 |
+
adxcdy = adx * cdy;
|
| 229 |
+
blift = bdx * bdx + bdy * bdy;
|
| 230 |
+
|
| 231 |
+
adxbdy = adx * bdy;
|
| 232 |
+
bdxady = bdx * ady;
|
| 233 |
+
clift = cdx * cdx + cdy * cdy;
|
| 234 |
+
|
| 235 |
+
det = alift * (bdxcdy - cdxbdy)
|
| 236 |
+
+ blift * (cdxady - adxcdy)
|
| 237 |
+
+ clift * (adxbdy - bdxady);
|
| 238 |
+
|
| 239 |
+
if (Behavior.NoExact)
|
| 240 |
+
{
|
| 241 |
+
return det;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
permanent = (Math.Abs(bdxcdy) + Math.Abs(cdxbdy)) * alift
|
| 245 |
+
+ (Math.Abs(cdxady) + Math.Abs(adxcdy)) * blift
|
| 246 |
+
+ (Math.Abs(adxbdy) + Math.Abs(bdxady)) * clift;
|
| 247 |
+
errbound = iccerrboundA * permanent;
|
| 248 |
+
if ((det > errbound) || (-det > errbound))
|
| 249 |
+
{
|
| 250 |
+
return det;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
Statistic.InCircleAdaptCount++;
|
| 254 |
+
return InCircleAdapt(pa, pb, pc, pd, permanent);
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
/// <summary>
|
| 258 |
+
/// Return a positive value if the point pd is incompatible with the circle
|
| 259 |
+
/// or plane passing through pa, pb, and pc (meaning that pd is inside the
|
| 260 |
+
/// circle or below the plane); a negative value if it is compatible; and
|
| 261 |
+
/// zero if the four points are cocircular/coplanar. The points pa, pb, and
|
| 262 |
+
/// pc must be in counterclockwise order, or the sign of the result will be
|
| 263 |
+
/// reversed.
|
| 264 |
+
/// </summary>
|
| 265 |
+
/// <param name="pa">Point a.</param>
|
| 266 |
+
/// <param name="pb">Point b.</param>
|
| 267 |
+
/// <param name="pc">Point c.</param>
|
| 268 |
+
/// <param name="pd">Point d.</param>
|
| 269 |
+
/// <returns>Return a positive value if the point pd lies inside the circle passing through
|
| 270 |
+
/// pa, pb, and pc; a negative value if it lies outside; and zero if the four points
|
| 271 |
+
/// are cocircular.</returns>
|
| 272 |
+
public double NonRegular(Point pa, Point pb, Point pc, Point pd)
|
| 273 |
+
{
|
| 274 |
+
return InCircle(pa, pb, pc, pd);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/// <summary>
|
| 278 |
+
/// Find the circumcenter of a triangle.
|
| 279 |
+
/// </summary>
|
| 280 |
+
/// <param name="org">Triangle point.</param>
|
| 281 |
+
/// <param name="dest">Triangle point.</param>
|
| 282 |
+
/// <param name="apex">Triangle point.</param>
|
| 283 |
+
/// <param name="xi">Relative coordinate of new location.</param>
|
| 284 |
+
/// <param name="eta">Relative coordinate of new location.</param>
|
| 285 |
+
/// <param name="offconstant">Off-center constant.</param>
|
| 286 |
+
/// <returns>Coordinates of the circumcenter (or off-center)</returns>
|
| 287 |
+
public Point FindCircumcenter(Point org, Point dest, Point apex,
|
| 288 |
+
ref double xi, ref double eta, double offconstant)
|
| 289 |
+
{
|
| 290 |
+
double xdo, ydo, xao, yao;
|
| 291 |
+
double dodist, aodist, dadist;
|
| 292 |
+
double denominator;
|
| 293 |
+
double dx, dy, dxoff, dyoff;
|
| 294 |
+
|
| 295 |
+
Statistic.CircumcenterCount++;
|
| 296 |
+
|
| 297 |
+
// Compute the circumcenter of the triangle.
|
| 298 |
+
xdo = dest.x - org.x;
|
| 299 |
+
ydo = dest.y - org.y;
|
| 300 |
+
xao = apex.x - org.x;
|
| 301 |
+
yao = apex.y - org.y;
|
| 302 |
+
dodist = xdo * xdo + ydo * ydo;
|
| 303 |
+
aodist = xao * xao + yao * yao;
|
| 304 |
+
dadist = (dest.x - apex.x) * (dest.x - apex.x) +
|
| 305 |
+
(dest.y - apex.y) * (dest.y - apex.y);
|
| 306 |
+
|
| 307 |
+
if (Behavior.NoExact)
|
| 308 |
+
{
|
| 309 |
+
denominator = 0.5 / (xdo * yao - xao * ydo);
|
| 310 |
+
}
|
| 311 |
+
else
|
| 312 |
+
{
|
| 313 |
+
// Use the counterclockwise() routine to ensure a positive (and
|
| 314 |
+
// reasonably accurate) result, avoiding any possibility of
|
| 315 |
+
// division by zero.
|
| 316 |
+
denominator = 0.5 / CounterClockwise(dest, apex, org);
|
| 317 |
+
// Don't count the above as an orientation test.
|
| 318 |
+
Statistic.CounterClockwiseCount--;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
dx = (yao * dodist - ydo * aodist) * denominator;
|
| 322 |
+
dy = (xdo * aodist - xao * dodist) * denominator;
|
| 323 |
+
|
| 324 |
+
// Find the (squared) length of the triangle's shortest edge. This
|
| 325 |
+
// serves as a conservative estimate of the insertion radius of the
|
| 326 |
+
// circumcenter's parent. The estimate is used to ensure that
|
| 327 |
+
// the algorithm terminates even if very small angles appear in
|
| 328 |
+
// the input PSLG.
|
| 329 |
+
if ((dodist < aodist) && (dodist < dadist))
|
| 330 |
+
{
|
| 331 |
+
if (offconstant > 0.0)
|
| 332 |
+
{
|
| 333 |
+
// Find the position of the off-center, as described by Alper Ungor.
|
| 334 |
+
dxoff = 0.5 * xdo - offconstant * ydo;
|
| 335 |
+
dyoff = 0.5 * ydo + offconstant * xdo;
|
| 336 |
+
// If the off-center is closer to the origin than the
|
| 337 |
+
// circumcenter, use the off-center instead.
|
| 338 |
+
if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy)
|
| 339 |
+
{
|
| 340 |
+
dx = dxoff;
|
| 341 |
+
dy = dyoff;
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
}
|
| 345 |
+
else if (aodist < dadist)
|
| 346 |
+
{
|
| 347 |
+
if (offconstant > 0.0)
|
| 348 |
+
{
|
| 349 |
+
dxoff = 0.5 * xao + offconstant * yao;
|
| 350 |
+
dyoff = 0.5 * yao - offconstant * xao;
|
| 351 |
+
// If the off-center is closer to the origin than the
|
| 352 |
+
// circumcenter, use the off-center instead.
|
| 353 |
+
if (dxoff * dxoff + dyoff * dyoff < dx * dx + dy * dy)
|
| 354 |
+
{
|
| 355 |
+
dx = dxoff;
|
| 356 |
+
dy = dyoff;
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
else
|
| 361 |
+
{
|
| 362 |
+
if (offconstant > 0.0)
|
| 363 |
+
{
|
| 364 |
+
dxoff = 0.5 * (apex.x - dest.x) - offconstant * (apex.y - dest.y);
|
| 365 |
+
dyoff = 0.5 * (apex.y - dest.y) + offconstant * (apex.x - dest.x);
|
| 366 |
+
// If the off-center is closer to the destination than the
|
| 367 |
+
// circumcenter, use the off-center instead.
|
| 368 |
+
if (dxoff * dxoff + dyoff * dyoff <
|
| 369 |
+
(dx - xdo) * (dx - xdo) + (dy - ydo) * (dy - ydo))
|
| 370 |
+
{
|
| 371 |
+
dx = xdo + dxoff;
|
| 372 |
+
dy = ydo + dyoff;
|
| 373 |
+
}
|
| 374 |
+
}
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
// To interpolate vertex attributes for the new vertex inserted at
|
| 378 |
+
// the circumcenter, define a coordinate system with a xi-axis,
|
| 379 |
+
// directed from the triangle's origin to its destination, and
|
| 380 |
+
// an eta-axis, directed from its origin to its apex.
|
| 381 |
+
// Calculate the xi and eta coordinates of the circumcenter.
|
| 382 |
+
xi = (yao * dx - xao * dy) * (2.0 * denominator);
|
| 383 |
+
eta = (xdo * dy - ydo * dx) * (2.0 * denominator);
|
| 384 |
+
|
| 385 |
+
return new Point(org.x + dx, org.y + dy);
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
/// <summary>
|
| 389 |
+
/// Find the circumcenter of a triangle.
|
| 390 |
+
/// </summary>
|
| 391 |
+
/// <param name="org">Triangle point.</param>
|
| 392 |
+
/// <param name="dest">Triangle point.</param>
|
| 393 |
+
/// <param name="apex">Triangle point.</param>
|
| 394 |
+
/// <param name="xi">Relative coordinate of new location.</param>
|
| 395 |
+
/// <param name="eta">Relative coordinate of new location.</param>
|
| 396 |
+
/// <returns>Coordinates of the circumcenter</returns>
|
| 397 |
+
/// <remarks>
|
| 398 |
+
/// The result is returned both in terms of x-y coordinates and xi-eta
|
| 399 |
+
/// (barycentric) coordinates. The xi-eta coordinate system is defined in
|
| 400 |
+
/// terms of the triangle: the origin of the triangle is the origin of the
|
| 401 |
+
/// coordinate system; the destination of the triangle is one unit along the
|
| 402 |
+
/// xi axis; and the apex of the triangle is one unit along the eta axis.
|
| 403 |
+
/// This procedure also returns the square of the length of the triangle's
|
| 404 |
+
/// shortest edge.
|
| 405 |
+
/// </remarks>
|
| 406 |
+
public Point FindCircumcenter(Point org, Point dest, Point apex,
|
| 407 |
+
ref double xi, ref double eta)
|
| 408 |
+
{
|
| 409 |
+
double xdo, ydo, xao, yao;
|
| 410 |
+
double dodist, aodist;
|
| 411 |
+
double denominator;
|
| 412 |
+
double dx, dy;
|
| 413 |
+
|
| 414 |
+
Statistic.CircumcenterCount++;
|
| 415 |
+
|
| 416 |
+
// Compute the circumcenter of the triangle.
|
| 417 |
+
xdo = dest.x - org.x;
|
| 418 |
+
ydo = dest.y - org.y;
|
| 419 |
+
xao = apex.x - org.x;
|
| 420 |
+
yao = apex.y - org.y;
|
| 421 |
+
dodist = xdo * xdo + ydo * ydo;
|
| 422 |
+
aodist = xao * xao + yao * yao;
|
| 423 |
+
|
| 424 |
+
if (Behavior.NoExact)
|
| 425 |
+
{
|
| 426 |
+
denominator = 0.5 / (xdo * yao - xao * ydo);
|
| 427 |
+
}
|
| 428 |
+
else
|
| 429 |
+
{
|
| 430 |
+
// Use the counterclockwise() routine to ensure a positive (and
|
| 431 |
+
// reasonably accurate) result, avoiding any possibility of
|
| 432 |
+
// division by zero.
|
| 433 |
+
denominator = 0.5 / CounterClockwise(dest, apex, org);
|
| 434 |
+
// Don't count the above as an orientation test.
|
| 435 |
+
Statistic.CounterClockwiseCount--;
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
dx = (yao * dodist - ydo * aodist) * denominator;
|
| 439 |
+
dy = (xdo * aodist - xao * dodist) * denominator;
|
| 440 |
+
|
| 441 |
+
// To interpolate vertex attributes for the new vertex inserted at
|
| 442 |
+
// the circumcenter, define a coordinate system with a xi-axis,
|
| 443 |
+
// directed from the triangle's origin to its destination, and
|
| 444 |
+
// an eta-axis, directed from its origin to its apex.
|
| 445 |
+
// Calculate the xi and eta coordinates of the circumcenter.
|
| 446 |
+
xi = (yao * dx - xao * dy) * (2.0 * denominator);
|
| 447 |
+
eta = (xdo * dy - ydo * dx) * (2.0 * denominator);
|
| 448 |
+
|
| 449 |
+
return new Point(org.x + dx, org.y + dy);
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
#region Exact arithmetics
|
| 453 |
+
|
| 454 |
+
/// <summary>
|
| 455 |
+
/// Sum two expansions, eliminating zero components from the output expansion.
|
| 456 |
+
/// </summary>
|
| 457 |
+
/// <param name="elen"></param>
|
| 458 |
+
/// <param name="e"></param>
|
| 459 |
+
/// <param name="flen"></param>
|
| 460 |
+
/// <param name="f"></param>
|
| 461 |
+
/// <param name="h"></param>
|
| 462 |
+
/// <returns></returns>
|
| 463 |
+
/// <remarks>
|
| 464 |
+
/// Sets h = e + f. See the Robust Predicates paper for details.
|
| 465 |
+
///
|
| 466 |
+
/// If round-to-even is used (as with IEEE 754), maintains the strongly nonoverlapping
|
| 467 |
+
/// property. (That is, if e is strongly nonoverlapping, h will be also.) Does NOT
|
| 468 |
+
/// maintain the nonoverlapping or nonadjacent properties.
|
| 469 |
+
/// </remarks>
|
| 470 |
+
private int FastExpansionSumZeroElim(int elen, double[] e, int flen, double[] f, double[] h)
|
| 471 |
+
{
|
| 472 |
+
double Q;
|
| 473 |
+
double Qnew;
|
| 474 |
+
double hh;
|
| 475 |
+
double bvirt;
|
| 476 |
+
double avirt, bround, around;
|
| 477 |
+
int eindex, findex, hindex;
|
| 478 |
+
double enow, fnow;
|
| 479 |
+
|
| 480 |
+
enow = e[0];
|
| 481 |
+
fnow = f[0];
|
| 482 |
+
eindex = findex = 0;
|
| 483 |
+
if ((fnow > enow) == (fnow > -enow))
|
| 484 |
+
{
|
| 485 |
+
Q = enow;
|
| 486 |
+
enow = e[++eindex];
|
| 487 |
+
}
|
| 488 |
+
else
|
| 489 |
+
{
|
| 490 |
+
Q = fnow;
|
| 491 |
+
fnow = f[++findex];
|
| 492 |
+
}
|
| 493 |
+
hindex = 0;
|
| 494 |
+
if ((eindex < elen) && (findex < flen))
|
| 495 |
+
{
|
| 496 |
+
if ((fnow > enow) == (fnow > -enow))
|
| 497 |
+
{
|
| 498 |
+
Qnew = (double)(enow + Q); bvirt = Qnew - enow; hh = Q - bvirt;
|
| 499 |
+
enow = e[++eindex];
|
| 500 |
+
}
|
| 501 |
+
else
|
| 502 |
+
{
|
| 503 |
+
Qnew = (double)(fnow + Q); bvirt = Qnew - fnow; hh = Q - bvirt;
|
| 504 |
+
fnow = f[++findex];
|
| 505 |
+
}
|
| 506 |
+
Q = Qnew;
|
| 507 |
+
if (hh != 0.0)
|
| 508 |
+
{
|
| 509 |
+
h[hindex++] = hh;
|
| 510 |
+
}
|
| 511 |
+
while ((eindex < elen) && (findex < flen))
|
| 512 |
+
{
|
| 513 |
+
if ((fnow > enow) == (fnow > -enow))
|
| 514 |
+
{
|
| 515 |
+
Qnew = (double)(Q + enow);
|
| 516 |
+
bvirt = (double)(Qnew - Q);
|
| 517 |
+
avirt = Qnew - bvirt;
|
| 518 |
+
bround = enow - bvirt;
|
| 519 |
+
around = Q - avirt;
|
| 520 |
+
hh = around + bround;
|
| 521 |
+
|
| 522 |
+
enow = e[++eindex];
|
| 523 |
+
}
|
| 524 |
+
else
|
| 525 |
+
{
|
| 526 |
+
Qnew = (double)(Q + fnow);
|
| 527 |
+
bvirt = (double)(Qnew - Q);
|
| 528 |
+
avirt = Qnew - bvirt;
|
| 529 |
+
bround = fnow - bvirt;
|
| 530 |
+
around = Q - avirt;
|
| 531 |
+
hh = around + bround;
|
| 532 |
+
|
| 533 |
+
fnow = f[++findex];
|
| 534 |
+
}
|
| 535 |
+
Q = Qnew;
|
| 536 |
+
if (hh != 0.0)
|
| 537 |
+
{
|
| 538 |
+
h[hindex++] = hh;
|
| 539 |
+
}
|
| 540 |
+
}
|
| 541 |
+
}
|
| 542 |
+
while (eindex < elen)
|
| 543 |
+
{
|
| 544 |
+
Qnew = (double)(Q + enow);
|
| 545 |
+
bvirt = (double)(Qnew - Q);
|
| 546 |
+
avirt = Qnew - bvirt;
|
| 547 |
+
bround = enow - bvirt;
|
| 548 |
+
around = Q - avirt;
|
| 549 |
+
hh = around + bround;
|
| 550 |
+
|
| 551 |
+
enow = e[++eindex];
|
| 552 |
+
Q = Qnew;
|
| 553 |
+
if (hh != 0.0)
|
| 554 |
+
{
|
| 555 |
+
h[hindex++] = hh;
|
| 556 |
+
}
|
| 557 |
+
}
|
| 558 |
+
while (findex < flen)
|
| 559 |
+
{
|
| 560 |
+
Qnew = (double)(Q + fnow);
|
| 561 |
+
bvirt = (double)(Qnew - Q);
|
| 562 |
+
avirt = Qnew - bvirt;
|
| 563 |
+
bround = fnow - bvirt;
|
| 564 |
+
around = Q - avirt;
|
| 565 |
+
hh = around + bround;
|
| 566 |
+
|
| 567 |
+
fnow = f[++findex];
|
| 568 |
+
Q = Qnew;
|
| 569 |
+
if (hh != 0.0)
|
| 570 |
+
{
|
| 571 |
+
h[hindex++] = hh;
|
| 572 |
+
}
|
| 573 |
+
}
|
| 574 |
+
if ((Q != 0.0) || (hindex == 0))
|
| 575 |
+
{
|
| 576 |
+
h[hindex++] = Q;
|
| 577 |
+
}
|
| 578 |
+
return hindex;
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
/// <summary>
|
| 582 |
+
/// Multiply an expansion by a scalar, eliminating zero components from the output expansion.
|
| 583 |
+
/// </summary>
|
| 584 |
+
/// <param name="elen"></param>
|
| 585 |
+
/// <param name="e"></param>
|
| 586 |
+
/// <param name="b"></param>
|
| 587 |
+
/// <param name="h"></param>
|
| 588 |
+
/// <returns></returns>
|
| 589 |
+
/// <remarks>
|
| 590 |
+
/// Sets h = be. See my Robust Predicates paper for details.
|
| 591 |
+
///
|
| 592 |
+
/// Maintains the nonoverlapping property. If round-to-even is used (as with IEEE 754),
|
| 593 |
+
/// maintains the strongly nonoverlapping and nonadjacent properties as well. (That is,
|
| 594 |
+
/// if e has one of these properties, so will h.)
|
| 595 |
+
/// </remarks>
|
| 596 |
+
private int ScaleExpansionZeroElim(int elen, double[] e, double b, double[] h)
|
| 597 |
+
{
|
| 598 |
+
double Q, sum;
|
| 599 |
+
double hh;
|
| 600 |
+
double product1;
|
| 601 |
+
double product0;
|
| 602 |
+
int eindex, hindex;
|
| 603 |
+
double enow;
|
| 604 |
+
double bvirt;
|
| 605 |
+
double avirt, bround, around;
|
| 606 |
+
double c;
|
| 607 |
+
double abig;
|
| 608 |
+
double ahi, alo, bhi, blo;
|
| 609 |
+
double err1, err2, err3;
|
| 610 |
+
|
| 611 |
+
c = (double)(splitter * b); abig = (double)(c - b); bhi = c - abig; blo = b - bhi;
|
| 612 |
+
Q = (double)(e[0] * b); c = (double)(splitter * e[0]); abig = (double)(c - e[0]); ahi = c - abig; alo = e[0] - ahi; err1 = Q - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); hh = (alo * blo) - err3;
|
| 613 |
+
hindex = 0;
|
| 614 |
+
if (hh != 0)
|
| 615 |
+
{
|
| 616 |
+
h[hindex++] = hh;
|
| 617 |
+
}
|
| 618 |
+
for (eindex = 1; eindex < elen; eindex++)
|
| 619 |
+
{
|
| 620 |
+
enow = e[eindex];
|
| 621 |
+
product1 = (double)(enow * b); c = (double)(splitter * enow); abig = (double)(c - enow); ahi = c - abig; alo = enow - ahi; err1 = product1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); product0 = (alo * blo) - err3;
|
| 622 |
+
sum = (double)(Q + product0); bvirt = (double)(sum - Q); avirt = sum - bvirt; bround = product0 - bvirt; around = Q - avirt; hh = around + bround;
|
| 623 |
+
if (hh != 0)
|
| 624 |
+
{
|
| 625 |
+
h[hindex++] = hh;
|
| 626 |
+
}
|
| 627 |
+
Q = (double)(product1 + sum); bvirt = Q - product1; hh = sum - bvirt;
|
| 628 |
+
if (hh != 0)
|
| 629 |
+
{
|
| 630 |
+
h[hindex++] = hh;
|
| 631 |
+
}
|
| 632 |
+
}
|
| 633 |
+
if ((Q != 0.0) || (hindex == 0))
|
| 634 |
+
{
|
| 635 |
+
h[hindex++] = Q;
|
| 636 |
+
}
|
| 637 |
+
return hindex;
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
/// <summary>
|
| 641 |
+
/// Produce a one-word estimate of an expansion's value.
|
| 642 |
+
/// </summary>
|
| 643 |
+
/// <param name="elen"></param>
|
| 644 |
+
/// <param name="e"></param>
|
| 645 |
+
/// <returns></returns>
|
| 646 |
+
private double Estimate(int elen, double[] e)
|
| 647 |
+
{
|
| 648 |
+
double Q;
|
| 649 |
+
int eindex;
|
| 650 |
+
|
| 651 |
+
Q = e[0];
|
| 652 |
+
for (eindex = 1; eindex < elen; eindex++)
|
| 653 |
+
{
|
| 654 |
+
Q += e[eindex];
|
| 655 |
+
}
|
| 656 |
+
return Q;
|
| 657 |
+
}
|
| 658 |
+
|
| 659 |
+
/// <summary>
|
| 660 |
+
/// Return a positive value if the points pa, pb, and pc occur in counterclockwise
|
| 661 |
+
/// order; a negative value if they occur in clockwise order; and zero if they are
|
| 662 |
+
/// collinear. The result is also a rough approximation of twice the signed area of
|
| 663 |
+
/// the triangle defined by the three points.
|
| 664 |
+
/// </summary>
|
| 665 |
+
/// <param name="pa"></param>
|
| 666 |
+
/// <param name="pb"></param>
|
| 667 |
+
/// <param name="pc"></param>
|
| 668 |
+
/// <param name="detsum"></param>
|
| 669 |
+
/// <returns></returns>
|
| 670 |
+
/// <remarks>
|
| 671 |
+
/// Uses exact arithmetic if necessary to ensure a correct answer. The result returned
|
| 672 |
+
/// is the determinant of a matrix. This determinant is computed adaptively, in the
|
| 673 |
+
/// sense that exact arithmetic is used only to the degree it is needed to ensure that
|
| 674 |
+
/// the returned value has the correct sign. Hence, this function is usually quite fast,
|
| 675 |
+
/// but will run more slowly when the input points are collinear or nearly so.
|
| 676 |
+
/// </remarks>
|
| 677 |
+
private double CounterClockwiseAdapt(Point pa, Point pb, Point pc, double detsum)
|
| 678 |
+
{
|
| 679 |
+
double acx, acy, bcx, bcy;
|
| 680 |
+
double acxtail, acytail, bcxtail, bcytail;
|
| 681 |
+
double detleft, detright;
|
| 682 |
+
double detlefttail, detrighttail;
|
| 683 |
+
double det, errbound;
|
| 684 |
+
// Edited to work around index out of range exceptions (changed array length from 4 to 5).
|
| 685 |
+
// See unsafe indexing in FastExpansionSumZeroElim.
|
| 686 |
+
double[] B = new double[5], u = new double[5];
|
| 687 |
+
double[] C1 = new double[8], C2 = new double[12], D = new double[16];
|
| 688 |
+
double B3;
|
| 689 |
+
int C1length, C2length, Dlength;
|
| 690 |
+
|
| 691 |
+
double u3;
|
| 692 |
+
double s1, t1;
|
| 693 |
+
double s0, t0;
|
| 694 |
+
|
| 695 |
+
double bvirt;
|
| 696 |
+
double avirt, bround, around;
|
| 697 |
+
double c;
|
| 698 |
+
double abig;
|
| 699 |
+
double ahi, alo, bhi, blo;
|
| 700 |
+
double err1, err2, err3;
|
| 701 |
+
double _i, _j;
|
| 702 |
+
double _0;
|
| 703 |
+
|
| 704 |
+
acx = (double)(pa.x - pc.x);
|
| 705 |
+
bcx = (double)(pb.x - pc.x);
|
| 706 |
+
acy = (double)(pa.y - pc.y);
|
| 707 |
+
bcy = (double)(pb.y - pc.y);
|
| 708 |
+
|
| 709 |
+
detleft = (double)(acx * bcy); c = (double)(splitter * acx); abig = (double)(c - acx); ahi = c - abig; alo = acx - ahi; c = (double)(splitter * bcy); abig = (double)(c - bcy); bhi = c - abig; blo = bcy - bhi; err1 = detleft - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); detlefttail = (alo * blo) - err3;
|
| 710 |
+
detright = (double)(acy * bcx); c = (double)(splitter * acy); abig = (double)(c - acy); ahi = c - abig; alo = acy - ahi; c = (double)(splitter * bcx); abig = (double)(c - bcx); bhi = c - abig; blo = bcx - bhi; err1 = detright - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); detrighttail = (alo * blo) - err3;
|
| 711 |
+
|
| 712 |
+
_i = (double)(detlefttail - detrighttail); bvirt = (double)(detlefttail - _i); avirt = _i + bvirt; bround = bvirt - detrighttail; around = detlefttail - avirt; B[0] = around + bround; _j = (double)(detleft + _i); bvirt = (double)(_j - detleft); avirt = _j - bvirt; bround = _i - bvirt; around = detleft - avirt; _0 = around + bround; _i = (double)(_0 - detright); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - detright; around = _0 - avirt; B[1] = around + bround; B3 = (double)(_j + _i); bvirt = (double)(B3 - _j); avirt = B3 - bvirt; bround = _i - bvirt; around = _j - avirt; B[2] = around + bround;
|
| 713 |
+
|
| 714 |
+
B[3] = B3;
|
| 715 |
+
|
| 716 |
+
det = Estimate(4, B);
|
| 717 |
+
errbound = ccwerrboundB * detsum;
|
| 718 |
+
if ((det >= errbound) || (-det >= errbound))
|
| 719 |
+
{
|
| 720 |
+
return det;
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
bvirt = (double)(pa.x - acx); avirt = acx + bvirt; bround = bvirt - pc.x; around = pa.x - avirt; acxtail = around + bround;
|
| 724 |
+
bvirt = (double)(pb.x - bcx); avirt = bcx + bvirt; bround = bvirt - pc.x; around = pb.x - avirt; bcxtail = around + bround;
|
| 725 |
+
bvirt = (double)(pa.y - acy); avirt = acy + bvirt; bround = bvirt - pc.y; around = pa.y - avirt; acytail = around + bround;
|
| 726 |
+
bvirt = (double)(pb.y - bcy); avirt = bcy + bvirt; bround = bvirt - pc.y; around = pb.y - avirt; bcytail = around + bround;
|
| 727 |
+
|
| 728 |
+
if ((acxtail == 0.0) && (acytail == 0.0)
|
| 729 |
+
&& (bcxtail == 0.0) && (bcytail == 0.0))
|
| 730 |
+
{
|
| 731 |
+
return det;
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
errbound = ccwerrboundC * detsum + resulterrbound * ((det) >= 0.0 ? (det) : -(det));
|
| 735 |
+
det += (acx * bcytail + bcy * acxtail)
|
| 736 |
+
- (acy * bcxtail + bcx * acytail);
|
| 737 |
+
if ((det >= errbound) || (-det >= errbound))
|
| 738 |
+
{
|
| 739 |
+
return det;
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
s1 = (double)(acxtail * bcy); c = (double)(splitter * acxtail); abig = (double)(c - acxtail); ahi = c - abig; alo = acxtail - ahi; c = (double)(splitter * bcy); abig = (double)(c - bcy); bhi = c - abig; blo = bcy - bhi; err1 = s1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); s0 = (alo * blo) - err3;
|
| 743 |
+
t1 = (double)(acytail * bcx); c = (double)(splitter * acytail); abig = (double)(c - acytail); ahi = c - abig; alo = acytail - ahi; c = (double)(splitter * bcx); abig = (double)(c - bcx); bhi = c - abig; blo = bcx - bhi; err1 = t1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); t0 = (alo * blo) - err3;
|
| 744 |
+
_i = (double)(s0 - t0); bvirt = (double)(s0 - _i); avirt = _i + bvirt; bround = bvirt - t0; around = s0 - avirt; u[0] = around + bround; _j = (double)(s1 + _i); bvirt = (double)(_j - s1); avirt = _j - bvirt; bround = _i - bvirt; around = s1 - avirt; _0 = around + bround; _i = (double)(_0 - t1); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - t1; around = _0 - avirt; u[1] = around + bround; u3 = (double)(_j + _i); bvirt = (double)(u3 - _j); avirt = u3 - bvirt; bround = _i - bvirt; around = _j - avirt; u[2] = around + bround;
|
| 745 |
+
u[3] = u3;
|
| 746 |
+
C1length = FastExpansionSumZeroElim(4, B, 4, u, C1);
|
| 747 |
+
|
| 748 |
+
s1 = (double)(acx * bcytail); c = (double)(splitter * acx); abig = (double)(c - acx); ahi = c - abig; alo = acx - ahi; c = (double)(splitter * bcytail); abig = (double)(c - bcytail); bhi = c - abig; blo = bcytail - bhi; err1 = s1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); s0 = (alo * blo) - err3;
|
| 749 |
+
t1 = (double)(acy * bcxtail); c = (double)(splitter * acy); abig = (double)(c - acy); ahi = c - abig; alo = acy - ahi; c = (double)(splitter * bcxtail); abig = (double)(c - bcxtail); bhi = c - abig; blo = bcxtail - bhi; err1 = t1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); t0 = (alo * blo) - err3;
|
| 750 |
+
_i = (double)(s0 - t0); bvirt = (double)(s0 - _i); avirt = _i + bvirt; bround = bvirt - t0; around = s0 - avirt; u[0] = around + bround; _j = (double)(s1 + _i); bvirt = (double)(_j - s1); avirt = _j - bvirt; bround = _i - bvirt; around = s1 - avirt; _0 = around + bround; _i = (double)(_0 - t1); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - t1; around = _0 - avirt; u[1] = around + bround; u3 = (double)(_j + _i); bvirt = (double)(u3 - _j); avirt = u3 - bvirt; bround = _i - bvirt; around = _j - avirt; u[2] = around + bround;
|
| 751 |
+
u[3] = u3;
|
| 752 |
+
C2length = FastExpansionSumZeroElim(C1length, C1, 4, u, C2);
|
| 753 |
+
|
| 754 |
+
s1 = (double)(acxtail * bcytail); c = (double)(splitter * acxtail); abig = (double)(c - acxtail); ahi = c - abig; alo = acxtail - ahi; c = (double)(splitter * bcytail); abig = (double)(c - bcytail); bhi = c - abig; blo = bcytail - bhi; err1 = s1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); s0 = (alo * blo) - err3;
|
| 755 |
+
t1 = (double)(acytail * bcxtail); c = (double)(splitter * acytail); abig = (double)(c - acytail); ahi = c - abig; alo = acytail - ahi; c = (double)(splitter * bcxtail); abig = (double)(c - bcxtail); bhi = c - abig; blo = bcxtail - bhi; err1 = t1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); t0 = (alo * blo) - err3;
|
| 756 |
+
_i = (double)(s0 - t0); bvirt = (double)(s0 - _i); avirt = _i + bvirt; bround = bvirt - t0; around = s0 - avirt; u[0] = around + bround; _j = (double)(s1 + _i); bvirt = (double)(_j - s1); avirt = _j - bvirt; bround = _i - bvirt; around = s1 - avirt; _0 = around + bround; _i = (double)(_0 - t1); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - t1; around = _0 - avirt; u[1] = around + bround; u3 = (double)(_j + _i); bvirt = (double)(u3 - _j); avirt = u3 - bvirt; bround = _i - bvirt; around = _j - avirt; u[2] = around + bround;
|
| 757 |
+
u[3] = u3;
|
| 758 |
+
Dlength = FastExpansionSumZeroElim(C2length, C2, 4, u, D);
|
| 759 |
+
|
| 760 |
+
return (D[Dlength - 1]);
|
| 761 |
+
}
|
| 762 |
+
|
| 763 |
+
/// <summary>
|
| 764 |
+
/// Return a positive value if the point pd lies inside the circle passing through
|
| 765 |
+
/// pa, pb, and pc; a negative value if it lies outside; and zero if the four points
|
| 766 |
+
/// are cocircular. The points pa, pb, and pc must be in counterclockwise order, or
|
| 767 |
+
/// the sign of the result will be reversed.
|
| 768 |
+
/// </summary>
|
| 769 |
+
/// <param name="pa"></param>
|
| 770 |
+
/// <param name="pb"></param>
|
| 771 |
+
/// <param name="pc"></param>
|
| 772 |
+
/// <param name="pd"></param>
|
| 773 |
+
/// <param name="permanent"></param>
|
| 774 |
+
/// <returns></returns>
|
| 775 |
+
/// <remarks>
|
| 776 |
+
/// Uses exact arithmetic if necessary to ensure a correct answer. The result returned
|
| 777 |
+
/// is the determinant of a matrix. This determinant is computed adaptively, in the
|
| 778 |
+
/// sense that exact arithmetic is used only to the degree it is needed to ensure that
|
| 779 |
+
/// the returned value has the correct sign. Hence, this function is usually quite fast,
|
| 780 |
+
/// but will run more slowly when the input points are cocircular or nearly so.
|
| 781 |
+
/// </remarks>
|
| 782 |
+
private double InCircleAdapt(Point pa, Point pb, Point pc, Point pd, double permanent)
|
| 783 |
+
{
|
| 784 |
+
double adx, bdx, cdx, ady, bdy, cdy;
|
| 785 |
+
double det, errbound;
|
| 786 |
+
|
| 787 |
+
double bdxcdy1, cdxbdy1, cdxady1, adxcdy1, adxbdy1, bdxady1;
|
| 788 |
+
double bdxcdy0, cdxbdy0, cdxady0, adxcdy0, adxbdy0, bdxady0;
|
| 789 |
+
double[] bc = new double[4], ca = new double[4], ab = new double[4];
|
| 790 |
+
double bc3, ca3, ab3;
|
| 791 |
+
int axbclen, axxbclen, aybclen, ayybclen, alen;
|
| 792 |
+
int bxcalen, bxxcalen, bycalen, byycalen, blen;
|
| 793 |
+
int cxablen, cxxablen, cyablen, cyyablen, clen;
|
| 794 |
+
int ablen;
|
| 795 |
+
double[] finnow, finother, finswap;
|
| 796 |
+
int finlength;
|
| 797 |
+
|
| 798 |
+
double adxtail, bdxtail, cdxtail, adytail, bdytail, cdytail;
|
| 799 |
+
double adxadx1, adyady1, bdxbdx1, bdybdy1, cdxcdx1, cdycdy1;
|
| 800 |
+
double adxadx0, adyady0, bdxbdx0, bdybdy0, cdxcdx0, cdycdy0;
|
| 801 |
+
double[] aa = new double[4], bb = new double[4], cc = new double[4];
|
| 802 |
+
double aa3, bb3, cc3;
|
| 803 |
+
double ti1, tj1;
|
| 804 |
+
double ti0, tj0;
|
| 805 |
+
// Edited to work around index out of range exceptions (changed array length from 4 to 5).
|
| 806 |
+
// See unsafe indexing in FastExpansionSumZeroElim.
|
| 807 |
+
double[] u = new double[5], v = new double[5];
|
| 808 |
+
double u3, v3;
|
| 809 |
+
int temp8len, temp16alen, temp16blen, temp16clen;
|
| 810 |
+
int temp32alen, temp32blen, temp48len, temp64len;
|
| 811 |
+
double[] axtbb = new double[8], axtcc = new double[8], aytbb = new double[8], aytcc = new double[8];
|
| 812 |
+
int axtbblen, axtcclen, aytbblen, aytcclen;
|
| 813 |
+
double[] bxtaa = new double[8], bxtcc = new double[8], bytaa = new double[8], bytcc = new double[8];
|
| 814 |
+
int bxtaalen, bxtcclen, bytaalen, bytcclen;
|
| 815 |
+
double[] cxtaa = new double[8], cxtbb = new double[8], cytaa = new double[8], cytbb = new double[8];
|
| 816 |
+
int cxtaalen, cxtbblen, cytaalen, cytbblen;
|
| 817 |
+
double[] axtbc = new double[8], aytbc = new double[8], bxtca = new double[8], bytca = new double[8], cxtab = new double[8], cytab = new double[8];
|
| 818 |
+
int axtbclen = 0, aytbclen = 0, bxtcalen = 0, bytcalen = 0, cxtablen = 0, cytablen = 0;
|
| 819 |
+
double[] axtbct = new double[16], aytbct = new double[16], bxtcat = new double[16], bytcat = new double[16], cxtabt = new double[16], cytabt = new double[16];
|
| 820 |
+
int axtbctlen, aytbctlen, bxtcatlen, bytcatlen, cxtabtlen, cytabtlen;
|
| 821 |
+
double[] axtbctt = new double[8], aytbctt = new double[8], bxtcatt = new double[8];
|
| 822 |
+
double[] bytcatt = new double[8], cxtabtt = new double[8], cytabtt = new double[8];
|
| 823 |
+
int axtbcttlen, aytbcttlen, bxtcattlen, bytcattlen, cxtabttlen, cytabttlen;
|
| 824 |
+
double[] abt = new double[8], bct = new double[8], cat = new double[8];
|
| 825 |
+
int abtlen, bctlen, catlen;
|
| 826 |
+
double[] abtt = new double[4], bctt = new double[4], catt = new double[4];
|
| 827 |
+
int abttlen, bcttlen, cattlen;
|
| 828 |
+
double abtt3, bctt3, catt3;
|
| 829 |
+
double negate;
|
| 830 |
+
|
| 831 |
+
double bvirt;
|
| 832 |
+
double avirt, bround, around;
|
| 833 |
+
double c;
|
| 834 |
+
double abig;
|
| 835 |
+
double ahi, alo, bhi, blo;
|
| 836 |
+
double err1, err2, err3;
|
| 837 |
+
double _i, _j;
|
| 838 |
+
double _0;
|
| 839 |
+
|
| 840 |
+
adx = (double)(pa.x - pd.x);
|
| 841 |
+
bdx = (double)(pb.x - pd.x);
|
| 842 |
+
cdx = (double)(pc.x - pd.x);
|
| 843 |
+
ady = (double)(pa.y - pd.y);
|
| 844 |
+
bdy = (double)(pb.y - pd.y);
|
| 845 |
+
cdy = (double)(pc.y - pd.y);
|
| 846 |
+
|
| 847 |
+
adx = (double)(pa.x - pd.x);
|
| 848 |
+
bdx = (double)(pb.x - pd.x);
|
| 849 |
+
cdx = (double)(pc.x - pd.x);
|
| 850 |
+
ady = (double)(pa.y - pd.y);
|
| 851 |
+
bdy = (double)(pb.y - pd.y);
|
| 852 |
+
cdy = (double)(pc.y - pd.y);
|
| 853 |
+
|
| 854 |
+
bdxcdy1 = (double)(bdx * cdy); c = (double)(splitter * bdx); abig = (double)(c - bdx); ahi = c - abig; alo = bdx - ahi; c = (double)(splitter * cdy); abig = (double)(c - cdy); bhi = c - abig; blo = cdy - bhi; err1 = bdxcdy1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); bdxcdy0 = (alo * blo) - err3;
|
| 855 |
+
cdxbdy1 = (double)(cdx * bdy); c = (double)(splitter * cdx); abig = (double)(c - cdx); ahi = c - abig; alo = cdx - ahi; c = (double)(splitter * bdy); abig = (double)(c - bdy); bhi = c - abig; blo = bdy - bhi; err1 = cdxbdy1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); cdxbdy0 = (alo * blo) - err3;
|
| 856 |
+
_i = (double)(bdxcdy0 - cdxbdy0); bvirt = (double)(bdxcdy0 - _i); avirt = _i + bvirt; bround = bvirt - cdxbdy0; around = bdxcdy0 - avirt; bc[0] = around + bround; _j = (double)(bdxcdy1 + _i); bvirt = (double)(_j - bdxcdy1); avirt = _j - bvirt; bround = _i - bvirt; around = bdxcdy1 - avirt; _0 = around + bround; _i = (double)(_0 - cdxbdy1); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - cdxbdy1; around = _0 - avirt; bc[1] = around + bround; bc3 = (double)(_j + _i); bvirt = (double)(bc3 - _j); avirt = bc3 - bvirt; bround = _i - bvirt; around = _j - avirt; bc[2] = around + bround;
|
| 857 |
+
bc[3] = bc3;
|
| 858 |
+
axbclen = ScaleExpansionZeroElim(4, bc, adx, axbc);
|
| 859 |
+
axxbclen = ScaleExpansionZeroElim(axbclen, axbc, adx, axxbc);
|
| 860 |
+
aybclen = ScaleExpansionZeroElim(4, bc, ady, aybc);
|
| 861 |
+
ayybclen = ScaleExpansionZeroElim(aybclen, aybc, ady, ayybc);
|
| 862 |
+
alen = FastExpansionSumZeroElim(axxbclen, axxbc, ayybclen, ayybc, adet);
|
| 863 |
+
|
| 864 |
+
cdxady1 = (double)(cdx * ady); c = (double)(splitter * cdx); abig = (double)(c - cdx); ahi = c - abig; alo = cdx - ahi; c = (double)(splitter * ady); abig = (double)(c - ady); bhi = c - abig; blo = ady - bhi; err1 = cdxady1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); cdxady0 = (alo * blo) - err3;
|
| 865 |
+
adxcdy1 = (double)(adx * cdy); c = (double)(splitter * adx); abig = (double)(c - adx); ahi = c - abig; alo = adx - ahi; c = (double)(splitter * cdy); abig = (double)(c - cdy); bhi = c - abig; blo = cdy - bhi; err1 = adxcdy1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); adxcdy0 = (alo * blo) - err3;
|
| 866 |
+
_i = (double)(cdxady0 - adxcdy0); bvirt = (double)(cdxady0 - _i); avirt = _i + bvirt; bround = bvirt - adxcdy0; around = cdxady0 - avirt; ca[0] = around + bround; _j = (double)(cdxady1 + _i); bvirt = (double)(_j - cdxady1); avirt = _j - bvirt; bround = _i - bvirt; around = cdxady1 - avirt; _0 = around + bround; _i = (double)(_0 - adxcdy1); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - adxcdy1; around = _0 - avirt; ca[1] = around + bround; ca3 = (double)(_j + _i); bvirt = (double)(ca3 - _j); avirt = ca3 - bvirt; bround = _i - bvirt; around = _j - avirt; ca[2] = around + bround;
|
| 867 |
+
ca[3] = ca3;
|
| 868 |
+
bxcalen = ScaleExpansionZeroElim(4, ca, bdx, bxca);
|
| 869 |
+
bxxcalen = ScaleExpansionZeroElim(bxcalen, bxca, bdx, bxxca);
|
| 870 |
+
bycalen = ScaleExpansionZeroElim(4, ca, bdy, byca);
|
| 871 |
+
byycalen = ScaleExpansionZeroElim(bycalen, byca, bdy, byyca);
|
| 872 |
+
blen = FastExpansionSumZeroElim(bxxcalen, bxxca, byycalen, byyca, bdet);
|
| 873 |
+
|
| 874 |
+
adxbdy1 = (double)(adx * bdy); c = (double)(splitter * adx); abig = (double)(c - adx); ahi = c - abig; alo = adx - ahi; c = (double)(splitter * bdy); abig = (double)(c - bdy); bhi = c - abig; blo = bdy - bhi; err1 = adxbdy1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); adxbdy0 = (alo * blo) - err3;
|
| 875 |
+
bdxady1 = (double)(bdx * ady); c = (double)(splitter * bdx); abig = (double)(c - bdx); ahi = c - abig; alo = bdx - ahi; c = (double)(splitter * ady); abig = (double)(c - ady); bhi = c - abig; blo = ady - bhi; err1 = bdxady1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); bdxady0 = (alo * blo) - err3;
|
| 876 |
+
_i = (double)(adxbdy0 - bdxady0); bvirt = (double)(adxbdy0 - _i); avirt = _i + bvirt; bround = bvirt - bdxady0; around = adxbdy0 - avirt; ab[0] = around + bround; _j = (double)(adxbdy1 + _i); bvirt = (double)(_j - adxbdy1); avirt = _j - bvirt; bround = _i - bvirt; around = adxbdy1 - avirt; _0 = around + bround; _i = (double)(_0 - bdxady1); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - bdxady1; around = _0 - avirt; ab[1] = around + bround; ab3 = (double)(_j + _i); bvirt = (double)(ab3 - _j); avirt = ab3 - bvirt; bround = _i - bvirt; around = _j - avirt; ab[2] = around + bround;
|
| 877 |
+
ab[3] = ab3;
|
| 878 |
+
cxablen = ScaleExpansionZeroElim(4, ab, cdx, cxab);
|
| 879 |
+
cxxablen = ScaleExpansionZeroElim(cxablen, cxab, cdx, cxxab);
|
| 880 |
+
cyablen = ScaleExpansionZeroElim(4, ab, cdy, cyab);
|
| 881 |
+
cyyablen = ScaleExpansionZeroElim(cyablen, cyab, cdy, cyyab);
|
| 882 |
+
clen = FastExpansionSumZeroElim(cxxablen, cxxab, cyyablen, cyyab, cdet);
|
| 883 |
+
|
| 884 |
+
ablen = FastExpansionSumZeroElim(alen, adet, blen, bdet, abdet);
|
| 885 |
+
finlength = FastExpansionSumZeroElim(ablen, abdet, clen, cdet, fin1);
|
| 886 |
+
|
| 887 |
+
det = Estimate(finlength, fin1);
|
| 888 |
+
errbound = iccerrboundB * permanent;
|
| 889 |
+
if ((det >= errbound) || (-det >= errbound))
|
| 890 |
+
{
|
| 891 |
+
return det;
|
| 892 |
+
}
|
| 893 |
+
|
| 894 |
+
bvirt = (double)(pa.x - adx); avirt = adx + bvirt; bround = bvirt - pd.x; around = pa.x - avirt; adxtail = around + bround;
|
| 895 |
+
bvirt = (double)(pa.y - ady); avirt = ady + bvirt; bround = bvirt - pd.y; around = pa.y - avirt; adytail = around + bround;
|
| 896 |
+
bvirt = (double)(pb.x - bdx); avirt = bdx + bvirt; bround = bvirt - pd.x; around = pb.x - avirt; bdxtail = around + bround;
|
| 897 |
+
bvirt = (double)(pb.y - bdy); avirt = bdy + bvirt; bround = bvirt - pd.y; around = pb.y - avirt; bdytail = around + bround;
|
| 898 |
+
bvirt = (double)(pc.x - cdx); avirt = cdx + bvirt; bround = bvirt - pd.x; around = pc.x - avirt; cdxtail = around + bround;
|
| 899 |
+
bvirt = (double)(pc.y - cdy); avirt = cdy + bvirt; bround = bvirt - pd.y; around = pc.y - avirt; cdytail = around + bround;
|
| 900 |
+
if ((adxtail == 0.0) && (bdxtail == 0.0) && (cdxtail == 0.0)
|
| 901 |
+
&& (adytail == 0.0) && (bdytail == 0.0) && (cdytail == 0.0))
|
| 902 |
+
{
|
| 903 |
+
return det;
|
| 904 |
+
}
|
| 905 |
+
|
| 906 |
+
errbound = iccerrboundC * permanent + resulterrbound * ((det) >= 0.0 ? (det) : -(det));
|
| 907 |
+
det += ((adx * adx + ady * ady) * ((bdx * cdytail + cdy * bdxtail) - (bdy * cdxtail + cdx * bdytail))
|
| 908 |
+
+ 2.0 * (adx * adxtail + ady * adytail) * (bdx * cdy - bdy * cdx))
|
| 909 |
+
+ ((bdx * bdx + bdy * bdy) * ((cdx * adytail + ady * cdxtail) - (cdy * adxtail + adx * cdytail))
|
| 910 |
+
+ 2.0 * (bdx * bdxtail + bdy * bdytail) * (cdx * ady - cdy * adx))
|
| 911 |
+
+ ((cdx * cdx + cdy * cdy) * ((adx * bdytail + bdy * adxtail) - (ady * bdxtail + bdx * adytail))
|
| 912 |
+
+ 2.0 * (cdx * cdxtail + cdy * cdytail) * (adx * bdy - ady * bdx));
|
| 913 |
+
if ((det >= errbound) || (-det >= errbound))
|
| 914 |
+
{
|
| 915 |
+
return det;
|
| 916 |
+
}
|
| 917 |
+
|
| 918 |
+
finnow = fin1;
|
| 919 |
+
finother = fin2;
|
| 920 |
+
|
| 921 |
+
if ((bdxtail != 0.0) || (bdytail != 0.0) || (cdxtail != 0.0) || (cdytail != 0.0))
|
| 922 |
+
{
|
| 923 |
+
adxadx1 = (double)(adx * adx); c = (double)(splitter * adx); abig = (double)(c - adx); ahi = c - abig; alo = adx - ahi; err1 = adxadx1 - (ahi * ahi); err3 = err1 - ((ahi + ahi) * alo); adxadx0 = (alo * alo) - err3;
|
| 924 |
+
adyady1 = (double)(ady * ady); c = (double)(splitter * ady); abig = (double)(c - ady); ahi = c - abig; alo = ady - ahi; err1 = adyady1 - (ahi * ahi); err3 = err1 - ((ahi + ahi) * alo); adyady0 = (alo * alo) - err3;
|
| 925 |
+
_i = (double)(adxadx0 + adyady0); bvirt = (double)(_i - adxadx0); avirt = _i - bvirt; bround = adyady0 - bvirt; around = adxadx0 - avirt; aa[0] = around + bround; _j = (double)(adxadx1 + _i); bvirt = (double)(_j - adxadx1); avirt = _j - bvirt; bround = _i - bvirt; around = adxadx1 - avirt; _0 = around + bround; _i = (double)(_0 + adyady1); bvirt = (double)(_i - _0); avirt = _i - bvirt; bround = adyady1 - bvirt; around = _0 - avirt; aa[1] = around + bround; aa3 = (double)(_j + _i); bvirt = (double)(aa3 - _j); avirt = aa3 - bvirt; bround = _i - bvirt; around = _j - avirt; aa[2] = around + bround;
|
| 926 |
+
aa[3] = aa3;
|
| 927 |
+
}
|
| 928 |
+
if ((cdxtail != 0.0) || (cdytail != 0.0) || (adxtail != 0.0) || (adytail != 0.0))
|
| 929 |
+
{
|
| 930 |
+
bdxbdx1 = (double)(bdx * bdx); c = (double)(splitter * bdx); abig = (double)(c - bdx); ahi = c - abig; alo = bdx - ahi; err1 = bdxbdx1 - (ahi * ahi); err3 = err1 - ((ahi + ahi) * alo); bdxbdx0 = (alo * alo) - err3;
|
| 931 |
+
bdybdy1 = (double)(bdy * bdy); c = (double)(splitter * bdy); abig = (double)(c - bdy); ahi = c - abig; alo = bdy - ahi; err1 = bdybdy1 - (ahi * ahi); err3 = err1 - ((ahi + ahi) * alo); bdybdy0 = (alo * alo) - err3;
|
| 932 |
+
_i = (double)(bdxbdx0 + bdybdy0); bvirt = (double)(_i - bdxbdx0); avirt = _i - bvirt; bround = bdybdy0 - bvirt; around = bdxbdx0 - avirt; bb[0] = around + bround; _j = (double)(bdxbdx1 + _i); bvirt = (double)(_j - bdxbdx1); avirt = _j - bvirt; bround = _i - bvirt; around = bdxbdx1 - avirt; _0 = around + bround; _i = (double)(_0 + bdybdy1); bvirt = (double)(_i - _0); avirt = _i - bvirt; bround = bdybdy1 - bvirt; around = _0 - avirt; bb[1] = around + bround; bb3 = (double)(_j + _i); bvirt = (double)(bb3 - _j); avirt = bb3 - bvirt; bround = _i - bvirt; around = _j - avirt; bb[2] = around + bround;
|
| 933 |
+
bb[3] = bb3;
|
| 934 |
+
}
|
| 935 |
+
if ((adxtail != 0.0) || (adytail != 0.0) || (bdxtail != 0.0) || (bdytail != 0.0))
|
| 936 |
+
{
|
| 937 |
+
cdxcdx1 = (double)(cdx * cdx); c = (double)(splitter * cdx); abig = (double)(c - cdx); ahi = c - abig; alo = cdx - ahi; err1 = cdxcdx1 - (ahi * ahi); err3 = err1 - ((ahi + ahi) * alo); cdxcdx0 = (alo * alo) - err3;
|
| 938 |
+
cdycdy1 = (double)(cdy * cdy); c = (double)(splitter * cdy); abig = (double)(c - cdy); ahi = c - abig; alo = cdy - ahi; err1 = cdycdy1 - (ahi * ahi); err3 = err1 - ((ahi + ahi) * alo); cdycdy0 = (alo * alo) - err3;
|
| 939 |
+
_i = (double)(cdxcdx0 + cdycdy0); bvirt = (double)(_i - cdxcdx0); avirt = _i - bvirt; bround = cdycdy0 - bvirt; around = cdxcdx0 - avirt; cc[0] = around + bround; _j = (double)(cdxcdx1 + _i); bvirt = (double)(_j - cdxcdx1); avirt = _j - bvirt; bround = _i - bvirt; around = cdxcdx1 - avirt; _0 = around + bround; _i = (double)(_0 + cdycdy1); bvirt = (double)(_i - _0); avirt = _i - bvirt; bround = cdycdy1 - bvirt; around = _0 - avirt; cc[1] = around + bround; cc3 = (double)(_j + _i); bvirt = (double)(cc3 - _j); avirt = cc3 - bvirt; bround = _i - bvirt; around = _j - avirt; cc[2] = around + bround;
|
| 940 |
+
cc[3] = cc3;
|
| 941 |
+
}
|
| 942 |
+
|
| 943 |
+
if (adxtail != 0.0)
|
| 944 |
+
{
|
| 945 |
+
axtbclen = ScaleExpansionZeroElim(4, bc, adxtail, axtbc);
|
| 946 |
+
temp16alen = ScaleExpansionZeroElim(axtbclen, axtbc, 2.0 * adx, temp16a);
|
| 947 |
+
|
| 948 |
+
axtcclen = ScaleExpansionZeroElim(4, cc, adxtail, axtcc);
|
| 949 |
+
temp16blen = ScaleExpansionZeroElim(axtcclen, axtcc, bdy, temp16b);
|
| 950 |
+
|
| 951 |
+
axtbblen = ScaleExpansionZeroElim(4, bb, adxtail, axtbb);
|
| 952 |
+
temp16clen = ScaleExpansionZeroElim(axtbblen, axtbb, -cdy, temp16c);
|
| 953 |
+
|
| 954 |
+
temp32alen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
| 955 |
+
temp48len = FastExpansionSumZeroElim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
| 956 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 957 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 958 |
+
}
|
| 959 |
+
if (adytail != 0.0)
|
| 960 |
+
{
|
| 961 |
+
aytbclen = ScaleExpansionZeroElim(4, bc, adytail, aytbc);
|
| 962 |
+
temp16alen = ScaleExpansionZeroElim(aytbclen, aytbc, 2.0 * ady, temp16a);
|
| 963 |
+
|
| 964 |
+
aytbblen = ScaleExpansionZeroElim(4, bb, adytail, aytbb);
|
| 965 |
+
temp16blen = ScaleExpansionZeroElim(aytbblen, aytbb, cdx, temp16b);
|
| 966 |
+
|
| 967 |
+
aytcclen = ScaleExpansionZeroElim(4, cc, adytail, aytcc);
|
| 968 |
+
temp16clen = ScaleExpansionZeroElim(aytcclen, aytcc, -bdx, temp16c);
|
| 969 |
+
|
| 970 |
+
temp32alen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
| 971 |
+
temp48len = FastExpansionSumZeroElim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
| 972 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 973 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 974 |
+
}
|
| 975 |
+
if (bdxtail != 0.0)
|
| 976 |
+
{
|
| 977 |
+
bxtcalen = ScaleExpansionZeroElim(4, ca, bdxtail, bxtca);
|
| 978 |
+
temp16alen = ScaleExpansionZeroElim(bxtcalen, bxtca, 2.0 * bdx, temp16a);
|
| 979 |
+
|
| 980 |
+
bxtaalen = ScaleExpansionZeroElim(4, aa, bdxtail, bxtaa);
|
| 981 |
+
temp16blen = ScaleExpansionZeroElim(bxtaalen, bxtaa, cdy, temp16b);
|
| 982 |
+
|
| 983 |
+
bxtcclen = ScaleExpansionZeroElim(4, cc, bdxtail, bxtcc);
|
| 984 |
+
temp16clen = ScaleExpansionZeroElim(bxtcclen, bxtcc, -ady, temp16c);
|
| 985 |
+
|
| 986 |
+
temp32alen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
| 987 |
+
temp48len = FastExpansionSumZeroElim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
| 988 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 989 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 990 |
+
}
|
| 991 |
+
if (bdytail != 0.0)
|
| 992 |
+
{
|
| 993 |
+
bytcalen = ScaleExpansionZeroElim(4, ca, bdytail, bytca);
|
| 994 |
+
temp16alen = ScaleExpansionZeroElim(bytcalen, bytca, 2.0 * bdy, temp16a);
|
| 995 |
+
|
| 996 |
+
bytcclen = ScaleExpansionZeroElim(4, cc, bdytail, bytcc);
|
| 997 |
+
temp16blen = ScaleExpansionZeroElim(bytcclen, bytcc, adx, temp16b);
|
| 998 |
+
|
| 999 |
+
bytaalen = ScaleExpansionZeroElim(4, aa, bdytail, bytaa);
|
| 1000 |
+
temp16clen = ScaleExpansionZeroElim(bytaalen, bytaa, -cdx, temp16c);
|
| 1001 |
+
|
| 1002 |
+
temp32alen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
| 1003 |
+
temp48len = FastExpansionSumZeroElim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
| 1004 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 1005 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1006 |
+
}
|
| 1007 |
+
if (cdxtail != 0.0)
|
| 1008 |
+
{
|
| 1009 |
+
cxtablen = ScaleExpansionZeroElim(4, ab, cdxtail, cxtab);
|
| 1010 |
+
temp16alen = ScaleExpansionZeroElim(cxtablen, cxtab, 2.0 * cdx, temp16a);
|
| 1011 |
+
|
| 1012 |
+
cxtbblen = ScaleExpansionZeroElim(4, bb, cdxtail, cxtbb);
|
| 1013 |
+
temp16blen = ScaleExpansionZeroElim(cxtbblen, cxtbb, ady, temp16b);
|
| 1014 |
+
|
| 1015 |
+
cxtaalen = ScaleExpansionZeroElim(4, aa, cdxtail, cxtaa);
|
| 1016 |
+
temp16clen = ScaleExpansionZeroElim(cxtaalen, cxtaa, -bdy, temp16c);
|
| 1017 |
+
|
| 1018 |
+
temp32alen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
| 1019 |
+
temp48len = FastExpansionSumZeroElim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
| 1020 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 1021 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1022 |
+
}
|
| 1023 |
+
if (cdytail != 0.0)
|
| 1024 |
+
{
|
| 1025 |
+
cytablen = ScaleExpansionZeroElim(4, ab, cdytail, cytab);
|
| 1026 |
+
temp16alen = ScaleExpansionZeroElim(cytablen, cytab, 2.0 * cdy, temp16a);
|
| 1027 |
+
|
| 1028 |
+
cytaalen = ScaleExpansionZeroElim(4, aa, cdytail, cytaa);
|
| 1029 |
+
temp16blen = ScaleExpansionZeroElim(cytaalen, cytaa, bdx, temp16b);
|
| 1030 |
+
|
| 1031 |
+
cytbblen = ScaleExpansionZeroElim(4, bb, cdytail, cytbb);
|
| 1032 |
+
temp16clen = ScaleExpansionZeroElim(cytbblen, cytbb, -adx, temp16c);
|
| 1033 |
+
|
| 1034 |
+
temp32alen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32a);
|
| 1035 |
+
temp48len = FastExpansionSumZeroElim(temp16clen, temp16c, temp32alen, temp32a, temp48);
|
| 1036 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 1037 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1038 |
+
}
|
| 1039 |
+
|
| 1040 |
+
if ((adxtail != 0.0) || (adytail != 0.0))
|
| 1041 |
+
{
|
| 1042 |
+
if ((bdxtail != 0.0) || (bdytail != 0.0)
|
| 1043 |
+
|| (cdxtail != 0.0) || (cdytail != 0.0))
|
| 1044 |
+
{
|
| 1045 |
+
ti1 = (double)(bdxtail * cdy); c = (double)(splitter * bdxtail); abig = (double)(c - bdxtail); ahi = c - abig; alo = bdxtail - ahi; c = (double)(splitter * cdy); abig = (double)(c - cdy); bhi = c - abig; blo = cdy - bhi; err1 = ti1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); ti0 = (alo * blo) - err3;
|
| 1046 |
+
tj1 = (double)(bdx * cdytail); c = (double)(splitter * bdx); abig = (double)(c - bdx); ahi = c - abig; alo = bdx - ahi; c = (double)(splitter * cdytail); abig = (double)(c - cdytail); bhi = c - abig; blo = cdytail - bhi; err1 = tj1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); tj0 = (alo * blo) - err3;
|
| 1047 |
+
_i = (double)(ti0 + tj0); bvirt = (double)(_i - ti0); avirt = _i - bvirt; bround = tj0 - bvirt; around = ti0 - avirt; u[0] = around + bround; _j = (double)(ti1 + _i); bvirt = (double)(_j - ti1); avirt = _j - bvirt; bround = _i - bvirt; around = ti1 - avirt; _0 = around + bround; _i = (double)(_0 + tj1); bvirt = (double)(_i - _0); avirt = _i - bvirt; bround = tj1 - bvirt; around = _0 - avirt; u[1] = around + bround; u3 = (double)(_j + _i); bvirt = (double)(u3 - _j); avirt = u3 - bvirt; bround = _i - bvirt; around = _j - avirt; u[2] = around + bround;
|
| 1048 |
+
u[3] = u3;
|
| 1049 |
+
negate = -bdy;
|
| 1050 |
+
ti1 = (double)(cdxtail * negate); c = (double)(splitter * cdxtail); abig = (double)(c - cdxtail); ahi = c - abig; alo = cdxtail - ahi; c = (double)(splitter * negate); abig = (double)(c - negate); bhi = c - abig; blo = negate - bhi; err1 = ti1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); ti0 = (alo * blo) - err3;
|
| 1051 |
+
negate = -bdytail;
|
| 1052 |
+
tj1 = (double)(cdx * negate); c = (double)(splitter * cdx); abig = (double)(c - cdx); ahi = c - abig; alo = cdx - ahi; c = (double)(splitter * negate); abig = (double)(c - negate); bhi = c - abig; blo = negate - bhi; err1 = tj1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); tj0 = (alo * blo) - err3;
|
| 1053 |
+
_i = (double)(ti0 + tj0); bvirt = (double)(_i - ti0); avirt = _i - bvirt; bround = tj0 - bvirt; around = ti0 - avirt; v[0] = around + bround; _j = (double)(ti1 + _i); bvirt = (double)(_j - ti1); avirt = _j - bvirt; bround = _i - bvirt; around = ti1 - avirt; _0 = around + bround; _i = (double)(_0 + tj1); bvirt = (double)(_i - _0); avirt = _i - bvirt; bround = tj1 - bvirt; around = _0 - avirt; v[1] = around + bround; v3 = (double)(_j + _i); bvirt = (double)(v3 - _j); avirt = v3 - bvirt; bround = _i - bvirt; around = _j - avirt; v[2] = around + bround;
|
| 1054 |
+
v[3] = v3;
|
| 1055 |
+
bctlen = FastExpansionSumZeroElim(4, u, 4, v, bct);
|
| 1056 |
+
|
| 1057 |
+
ti1 = (double)(bdxtail * cdytail); c = (double)(splitter * bdxtail); abig = (double)(c - bdxtail); ahi = c - abig; alo = bdxtail - ahi; c = (double)(splitter * cdytail); abig = (double)(c - cdytail); bhi = c - abig; blo = cdytail - bhi; err1 = ti1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); ti0 = (alo * blo) - err3;
|
| 1058 |
+
tj1 = (double)(cdxtail * bdytail); c = (double)(splitter * cdxtail); abig = (double)(c - cdxtail); ahi = c - abig; alo = cdxtail - ahi; c = (double)(splitter * bdytail); abig = (double)(c - bdytail); bhi = c - abig; blo = bdytail - bhi; err1 = tj1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); tj0 = (alo * blo) - err3;
|
| 1059 |
+
_i = (double)(ti0 - tj0); bvirt = (double)(ti0 - _i); avirt = _i + bvirt; bround = bvirt - tj0; around = ti0 - avirt; bctt[0] = around + bround; _j = (double)(ti1 + _i); bvirt = (double)(_j - ti1); avirt = _j - bvirt; bround = _i - bvirt; around = ti1 - avirt; _0 = around + bround; _i = (double)(_0 - tj1); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - tj1; around = _0 - avirt; bctt[1] = around + bround; bctt3 = (double)(_j + _i); bvirt = (double)(bctt3 - _j); avirt = bctt3 - bvirt; bround = _i - bvirt; around = _j - avirt; bctt[2] = around + bround;
|
| 1060 |
+
bctt[3] = bctt3;
|
| 1061 |
+
bcttlen = 4;
|
| 1062 |
+
}
|
| 1063 |
+
else
|
| 1064 |
+
{
|
| 1065 |
+
bct[0] = 0.0;
|
| 1066 |
+
bctlen = 1;
|
| 1067 |
+
bctt[0] = 0.0;
|
| 1068 |
+
bcttlen = 1;
|
| 1069 |
+
}
|
| 1070 |
+
|
| 1071 |
+
if (adxtail != 0.0)
|
| 1072 |
+
{
|
| 1073 |
+
temp16alen = ScaleExpansionZeroElim(axtbclen, axtbc, adxtail, temp16a);
|
| 1074 |
+
axtbctlen = ScaleExpansionZeroElim(bctlen, bct, adxtail, axtbct);
|
| 1075 |
+
temp32alen = ScaleExpansionZeroElim(axtbctlen, axtbct, 2.0 * adx, temp32a);
|
| 1076 |
+
temp48len = FastExpansionSumZeroElim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
| 1077 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 1078 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1079 |
+
if (bdytail != 0.0)
|
| 1080 |
+
{
|
| 1081 |
+
temp8len = ScaleExpansionZeroElim(4, cc, adxtail, temp8);
|
| 1082 |
+
temp16alen = ScaleExpansionZeroElim(temp8len, temp8, bdytail, temp16a);
|
| 1083 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp16alen, temp16a, finother);
|
| 1084 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1085 |
+
}
|
| 1086 |
+
if (cdytail != 0.0)
|
| 1087 |
+
{
|
| 1088 |
+
temp8len = ScaleExpansionZeroElim(4, bb, -adxtail, temp8);
|
| 1089 |
+
temp16alen = ScaleExpansionZeroElim(temp8len, temp8, cdytail, temp16a);
|
| 1090 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp16alen, temp16a, finother);
|
| 1091 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1092 |
+
}
|
| 1093 |
+
|
| 1094 |
+
temp32alen = ScaleExpansionZeroElim(axtbctlen, axtbct, adxtail, temp32a);
|
| 1095 |
+
axtbcttlen = ScaleExpansionZeroElim(bcttlen, bctt, adxtail, axtbctt);
|
| 1096 |
+
temp16alen = ScaleExpansionZeroElim(axtbcttlen, axtbctt, 2.0 * adx, temp16a);
|
| 1097 |
+
temp16blen = ScaleExpansionZeroElim(axtbcttlen, axtbctt, adxtail, temp16b);
|
| 1098 |
+
temp32blen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
| 1099 |
+
temp64len = FastExpansionSumZeroElim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
| 1100 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp64len, temp64, finother);
|
| 1101 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1102 |
+
}
|
| 1103 |
+
if (adytail != 0.0)
|
| 1104 |
+
{
|
| 1105 |
+
temp16alen = ScaleExpansionZeroElim(aytbclen, aytbc, adytail, temp16a);
|
| 1106 |
+
aytbctlen = ScaleExpansionZeroElim(bctlen, bct, adytail, aytbct);
|
| 1107 |
+
temp32alen = ScaleExpansionZeroElim(aytbctlen, aytbct, 2.0 * ady, temp32a);
|
| 1108 |
+
temp48len = FastExpansionSumZeroElim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
| 1109 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 1110 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1111 |
+
|
| 1112 |
+
|
| 1113 |
+
temp32alen = ScaleExpansionZeroElim(aytbctlen, aytbct, adytail, temp32a);
|
| 1114 |
+
aytbcttlen = ScaleExpansionZeroElim(bcttlen, bctt, adytail, aytbctt);
|
| 1115 |
+
temp16alen = ScaleExpansionZeroElim(aytbcttlen, aytbctt, 2.0 * ady, temp16a);
|
| 1116 |
+
temp16blen = ScaleExpansionZeroElim(aytbcttlen, aytbctt, adytail, temp16b);
|
| 1117 |
+
temp32blen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
| 1118 |
+
temp64len = FastExpansionSumZeroElim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
| 1119 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp64len, temp64, finother);
|
| 1120 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1121 |
+
}
|
| 1122 |
+
}
|
| 1123 |
+
if ((bdxtail != 0.0) || (bdytail != 0.0))
|
| 1124 |
+
{
|
| 1125 |
+
if ((cdxtail != 0.0) || (cdytail != 0.0)
|
| 1126 |
+
|| (adxtail != 0.0) || (adytail != 0.0))
|
| 1127 |
+
{
|
| 1128 |
+
ti1 = (double)(cdxtail * ady); c = (double)(splitter * cdxtail); abig = (double)(c - cdxtail); ahi = c - abig; alo = cdxtail - ahi; c = (double)(splitter * ady); abig = (double)(c - ady); bhi = c - abig; blo = ady - bhi; err1 = ti1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); ti0 = (alo * blo) - err3;
|
| 1129 |
+
tj1 = (double)(cdx * adytail); c = (double)(splitter * cdx); abig = (double)(c - cdx); ahi = c - abig; alo = cdx - ahi; c = (double)(splitter * adytail); abig = (double)(c - adytail); bhi = c - abig; blo = adytail - bhi; err1 = tj1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); tj0 = (alo * blo) - err3;
|
| 1130 |
+
_i = (double)(ti0 + tj0); bvirt = (double)(_i - ti0); avirt = _i - bvirt; bround = tj0 - bvirt; around = ti0 - avirt; u[0] = around + bround; _j = (double)(ti1 + _i); bvirt = (double)(_j - ti1); avirt = _j - bvirt; bround = _i - bvirt; around = ti1 - avirt; _0 = around + bround; _i = (double)(_0 + tj1); bvirt = (double)(_i - _0); avirt = _i - bvirt; bround = tj1 - bvirt; around = _0 - avirt; u[1] = around + bround; u3 = (double)(_j + _i); bvirt = (double)(u3 - _j); avirt = u3 - bvirt; bround = _i - bvirt; around = _j - avirt; u[2] = around + bround;
|
| 1131 |
+
u[3] = u3;
|
| 1132 |
+
negate = -cdy;
|
| 1133 |
+
ti1 = (double)(adxtail * negate); c = (double)(splitter * adxtail); abig = (double)(c - adxtail); ahi = c - abig; alo = adxtail - ahi; c = (double)(splitter * negate); abig = (double)(c - negate); bhi = c - abig; blo = negate - bhi; err1 = ti1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); ti0 = (alo * blo) - err3;
|
| 1134 |
+
negate = -cdytail;
|
| 1135 |
+
tj1 = (double)(adx * negate); c = (double)(splitter * adx); abig = (double)(c - adx); ahi = c - abig; alo = adx - ahi; c = (double)(splitter * negate); abig = (double)(c - negate); bhi = c - abig; blo = negate - bhi; err1 = tj1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); tj0 = (alo * blo) - err3;
|
| 1136 |
+
_i = (double)(ti0 + tj0); bvirt = (double)(_i - ti0); avirt = _i - bvirt; bround = tj0 - bvirt; around = ti0 - avirt; v[0] = around + bround; _j = (double)(ti1 + _i); bvirt = (double)(_j - ti1); avirt = _j - bvirt; bround = _i - bvirt; around = ti1 - avirt; _0 = around + bround; _i = (double)(_0 + tj1); bvirt = (double)(_i - _0); avirt = _i - bvirt; bround = tj1 - bvirt; around = _0 - avirt; v[1] = around + bround; v3 = (double)(_j + _i); bvirt = (double)(v3 - _j); avirt = v3 - bvirt; bround = _i - bvirt; around = _j - avirt; v[2] = around + bround;
|
| 1137 |
+
v[3] = v3;
|
| 1138 |
+
catlen = FastExpansionSumZeroElim(4, u, 4, v, cat);
|
| 1139 |
+
|
| 1140 |
+
ti1 = (double)(cdxtail * adytail); c = (double)(splitter * cdxtail); abig = (double)(c - cdxtail); ahi = c - abig; alo = cdxtail - ahi; c = (double)(splitter * adytail); abig = (double)(c - adytail); bhi = c - abig; blo = adytail - bhi; err1 = ti1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); ti0 = (alo * blo) - err3;
|
| 1141 |
+
tj1 = (double)(adxtail * cdytail); c = (double)(splitter * adxtail); abig = (double)(c - adxtail); ahi = c - abig; alo = adxtail - ahi; c = (double)(splitter * cdytail); abig = (double)(c - cdytail); bhi = c - abig; blo = cdytail - bhi; err1 = tj1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); tj0 = (alo * blo) - err3;
|
| 1142 |
+
_i = (double)(ti0 - tj0); bvirt = (double)(ti0 - _i); avirt = _i + bvirt; bround = bvirt - tj0; around = ti0 - avirt; catt[0] = around + bround; _j = (double)(ti1 + _i); bvirt = (double)(_j - ti1); avirt = _j - bvirt; bround = _i - bvirt; around = ti1 - avirt; _0 = around + bround; _i = (double)(_0 - tj1); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - tj1; around = _0 - avirt; catt[1] = around + bround; catt3 = (double)(_j + _i); bvirt = (double)(catt3 - _j); avirt = catt3 - bvirt; bround = _i - bvirt; around = _j - avirt; catt[2] = around + bround;
|
| 1143 |
+
catt[3] = catt3;
|
| 1144 |
+
cattlen = 4;
|
| 1145 |
+
}
|
| 1146 |
+
else
|
| 1147 |
+
{
|
| 1148 |
+
cat[0] = 0.0;
|
| 1149 |
+
catlen = 1;
|
| 1150 |
+
catt[0] = 0.0;
|
| 1151 |
+
cattlen = 1;
|
| 1152 |
+
}
|
| 1153 |
+
|
| 1154 |
+
if (bdxtail != 0.0)
|
| 1155 |
+
{
|
| 1156 |
+
temp16alen = ScaleExpansionZeroElim(bxtcalen, bxtca, bdxtail, temp16a);
|
| 1157 |
+
bxtcatlen = ScaleExpansionZeroElim(catlen, cat, bdxtail, bxtcat);
|
| 1158 |
+
temp32alen = ScaleExpansionZeroElim(bxtcatlen, bxtcat, 2.0 * bdx, temp32a);
|
| 1159 |
+
temp48len = FastExpansionSumZeroElim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
| 1160 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 1161 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1162 |
+
if (cdytail != 0.0)
|
| 1163 |
+
{
|
| 1164 |
+
temp8len = ScaleExpansionZeroElim(4, aa, bdxtail, temp8);
|
| 1165 |
+
temp16alen = ScaleExpansionZeroElim(temp8len, temp8, cdytail, temp16a);
|
| 1166 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp16alen, temp16a, finother);
|
| 1167 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1168 |
+
}
|
| 1169 |
+
if (adytail != 0.0)
|
| 1170 |
+
{
|
| 1171 |
+
temp8len = ScaleExpansionZeroElim(4, cc, -bdxtail, temp8);
|
| 1172 |
+
temp16alen = ScaleExpansionZeroElim(temp8len, temp8, adytail, temp16a);
|
| 1173 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp16alen, temp16a, finother);
|
| 1174 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1175 |
+
}
|
| 1176 |
+
|
| 1177 |
+
temp32alen = ScaleExpansionZeroElim(bxtcatlen, bxtcat, bdxtail, temp32a);
|
| 1178 |
+
bxtcattlen = ScaleExpansionZeroElim(cattlen, catt, bdxtail, bxtcatt);
|
| 1179 |
+
temp16alen = ScaleExpansionZeroElim(bxtcattlen, bxtcatt, 2.0 * bdx, temp16a);
|
| 1180 |
+
temp16blen = ScaleExpansionZeroElim(bxtcattlen, bxtcatt, bdxtail, temp16b);
|
| 1181 |
+
temp32blen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
| 1182 |
+
temp64len = FastExpansionSumZeroElim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
| 1183 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp64len, temp64, finother);
|
| 1184 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1185 |
+
}
|
| 1186 |
+
if (bdytail != 0.0)
|
| 1187 |
+
{
|
| 1188 |
+
temp16alen = ScaleExpansionZeroElim(bytcalen, bytca, bdytail, temp16a);
|
| 1189 |
+
bytcatlen = ScaleExpansionZeroElim(catlen, cat, bdytail, bytcat);
|
| 1190 |
+
temp32alen = ScaleExpansionZeroElim(bytcatlen, bytcat, 2.0 * bdy, temp32a);
|
| 1191 |
+
temp48len = FastExpansionSumZeroElim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
| 1192 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 1193 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1194 |
+
|
| 1195 |
+
temp32alen = ScaleExpansionZeroElim(bytcatlen, bytcat, bdytail, temp32a);
|
| 1196 |
+
bytcattlen = ScaleExpansionZeroElim(cattlen, catt, bdytail, bytcatt);
|
| 1197 |
+
temp16alen = ScaleExpansionZeroElim(bytcattlen, bytcatt, 2.0 * bdy, temp16a);
|
| 1198 |
+
temp16blen = ScaleExpansionZeroElim(bytcattlen, bytcatt, bdytail, temp16b);
|
| 1199 |
+
temp32blen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
| 1200 |
+
temp64len = FastExpansionSumZeroElim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
| 1201 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp64len, temp64, finother);
|
| 1202 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1203 |
+
}
|
| 1204 |
+
}
|
| 1205 |
+
if ((cdxtail != 0.0) || (cdytail != 0.0))
|
| 1206 |
+
{
|
| 1207 |
+
if ((adxtail != 0.0) || (adytail != 0.0)
|
| 1208 |
+
|| (bdxtail != 0.0) || (bdytail != 0.0))
|
| 1209 |
+
{
|
| 1210 |
+
ti1 = (double)(adxtail * bdy); c = (double)(splitter * adxtail); abig = (double)(c - adxtail); ahi = c - abig; alo = adxtail - ahi; c = (double)(splitter * bdy); abig = (double)(c - bdy); bhi = c - abig; blo = bdy - bhi; err1 = ti1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); ti0 = (alo * blo) - err3;
|
| 1211 |
+
tj1 = (double)(adx * bdytail); c = (double)(splitter * adx); abig = (double)(c - adx); ahi = c - abig; alo = adx - ahi; c = (double)(splitter * bdytail); abig = (double)(c - bdytail); bhi = c - abig; blo = bdytail - bhi; err1 = tj1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); tj0 = (alo * blo) - err3;
|
| 1212 |
+
_i = (double)(ti0 + tj0); bvirt = (double)(_i - ti0); avirt = _i - bvirt; bround = tj0 - bvirt; around = ti0 - avirt; u[0] = around + bround; _j = (double)(ti1 + _i); bvirt = (double)(_j - ti1); avirt = _j - bvirt; bround = _i - bvirt; around = ti1 - avirt; _0 = around + bround; _i = (double)(_0 + tj1); bvirt = (double)(_i - _0); avirt = _i - bvirt; bround = tj1 - bvirt; around = _0 - avirt; u[1] = around + bround; u3 = (double)(_j + _i); bvirt = (double)(u3 - _j); avirt = u3 - bvirt; bround = _i - bvirt; around = _j - avirt; u[2] = around + bround;
|
| 1213 |
+
u[3] = u3;
|
| 1214 |
+
negate = -ady;
|
| 1215 |
+
ti1 = (double)(bdxtail * negate); c = (double)(splitter * bdxtail); abig = (double)(c - bdxtail); ahi = c - abig; alo = bdxtail - ahi; c = (double)(splitter * negate); abig = (double)(c - negate); bhi = c - abig; blo = negate - bhi; err1 = ti1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); ti0 = (alo * blo) - err3;
|
| 1216 |
+
negate = -adytail;
|
| 1217 |
+
tj1 = (double)(bdx * negate); c = (double)(splitter * bdx); abig = (double)(c - bdx); ahi = c - abig; alo = bdx - ahi; c = (double)(splitter * negate); abig = (double)(c - negate); bhi = c - abig; blo = negate - bhi; err1 = tj1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); tj0 = (alo * blo) - err3;
|
| 1218 |
+
_i = (double)(ti0 + tj0); bvirt = (double)(_i - ti0); avirt = _i - bvirt; bround = tj0 - bvirt; around = ti0 - avirt; v[0] = around + bround; _j = (double)(ti1 + _i); bvirt = (double)(_j - ti1); avirt = _j - bvirt; bround = _i - bvirt; around = ti1 - avirt; _0 = around + bround; _i = (double)(_0 + tj1); bvirt = (double)(_i - _0); avirt = _i - bvirt; bround = tj1 - bvirt; around = _0 - avirt; v[1] = around + bround; v3 = (double)(_j + _i); bvirt = (double)(v3 - _j); avirt = v3 - bvirt; bround = _i - bvirt; around = _j - avirt; v[2] = around + bround;
|
| 1219 |
+
v[3] = v3;
|
| 1220 |
+
abtlen = FastExpansionSumZeroElim(4, u, 4, v, abt);
|
| 1221 |
+
|
| 1222 |
+
ti1 = (double)(adxtail * bdytail); c = (double)(splitter * adxtail); abig = (double)(c - adxtail); ahi = c - abig; alo = adxtail - ahi; c = (double)(splitter * bdytail); abig = (double)(c - bdytail); bhi = c - abig; blo = bdytail - bhi; err1 = ti1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); ti0 = (alo * blo) - err3;
|
| 1223 |
+
tj1 = (double)(bdxtail * adytail); c = (double)(splitter * bdxtail); abig = (double)(c - bdxtail); ahi = c - abig; alo = bdxtail - ahi; c = (double)(splitter * adytail); abig = (double)(c - adytail); bhi = c - abig; blo = adytail - bhi; err1 = tj1 - (ahi * bhi); err2 = err1 - (alo * bhi); err3 = err2 - (ahi * blo); tj0 = (alo * blo) - err3;
|
| 1224 |
+
_i = (double)(ti0 - tj0); bvirt = (double)(ti0 - _i); avirt = _i + bvirt; bround = bvirt - tj0; around = ti0 - avirt; abtt[0] = around + bround; _j = (double)(ti1 + _i); bvirt = (double)(_j - ti1); avirt = _j - bvirt; bround = _i - bvirt; around = ti1 - avirt; _0 = around + bround; _i = (double)(_0 - tj1); bvirt = (double)(_0 - _i); avirt = _i + bvirt; bround = bvirt - tj1; around = _0 - avirt; abtt[1] = around + bround; abtt3 = (double)(_j + _i); bvirt = (double)(abtt3 - _j); avirt = abtt3 - bvirt; bround = _i - bvirt; around = _j - avirt; abtt[2] = around + bround;
|
| 1225 |
+
abtt[3] = abtt3;
|
| 1226 |
+
abttlen = 4;
|
| 1227 |
+
}
|
| 1228 |
+
else
|
| 1229 |
+
{
|
| 1230 |
+
abt[0] = 0.0;
|
| 1231 |
+
abtlen = 1;
|
| 1232 |
+
abtt[0] = 0.0;
|
| 1233 |
+
abttlen = 1;
|
| 1234 |
+
}
|
| 1235 |
+
|
| 1236 |
+
if (cdxtail != 0.0)
|
| 1237 |
+
{
|
| 1238 |
+
temp16alen = ScaleExpansionZeroElim(cxtablen, cxtab, cdxtail, temp16a);
|
| 1239 |
+
cxtabtlen = ScaleExpansionZeroElim(abtlen, abt, cdxtail, cxtabt);
|
| 1240 |
+
temp32alen = ScaleExpansionZeroElim(cxtabtlen, cxtabt, 2.0 * cdx, temp32a);
|
| 1241 |
+
temp48len = FastExpansionSumZeroElim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
| 1242 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 1243 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1244 |
+
if (adytail != 0.0)
|
| 1245 |
+
{
|
| 1246 |
+
temp8len = ScaleExpansionZeroElim(4, bb, cdxtail, temp8);
|
| 1247 |
+
temp16alen = ScaleExpansionZeroElim(temp8len, temp8, adytail, temp16a);
|
| 1248 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp16alen, temp16a, finother);
|
| 1249 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1250 |
+
}
|
| 1251 |
+
if (bdytail != 0.0)
|
| 1252 |
+
{
|
| 1253 |
+
temp8len = ScaleExpansionZeroElim(4, aa, -cdxtail, temp8);
|
| 1254 |
+
temp16alen = ScaleExpansionZeroElim(temp8len, temp8, bdytail, temp16a);
|
| 1255 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp16alen, temp16a, finother);
|
| 1256 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1257 |
+
}
|
| 1258 |
+
|
| 1259 |
+
temp32alen = ScaleExpansionZeroElim(cxtabtlen, cxtabt, cdxtail, temp32a);
|
| 1260 |
+
cxtabttlen = ScaleExpansionZeroElim(abttlen, abtt, cdxtail, cxtabtt);
|
| 1261 |
+
temp16alen = ScaleExpansionZeroElim(cxtabttlen, cxtabtt, 2.0 * cdx, temp16a);
|
| 1262 |
+
temp16blen = ScaleExpansionZeroElim(cxtabttlen, cxtabtt, cdxtail, temp16b);
|
| 1263 |
+
temp32blen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
| 1264 |
+
temp64len = FastExpansionSumZeroElim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
| 1265 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp64len, temp64, finother);
|
| 1266 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1267 |
+
}
|
| 1268 |
+
if (cdytail != 0.0)
|
| 1269 |
+
{
|
| 1270 |
+
temp16alen = ScaleExpansionZeroElim(cytablen, cytab, cdytail, temp16a);
|
| 1271 |
+
cytabtlen = ScaleExpansionZeroElim(abtlen, abt, cdytail, cytabt);
|
| 1272 |
+
temp32alen = ScaleExpansionZeroElim(cytabtlen, cytabt, 2.0 * cdy, temp32a);
|
| 1273 |
+
temp48len = FastExpansionSumZeroElim(temp16alen, temp16a, temp32alen, temp32a, temp48);
|
| 1274 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp48len, temp48, finother);
|
| 1275 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1276 |
+
|
| 1277 |
+
|
| 1278 |
+
temp32alen = ScaleExpansionZeroElim(cytabtlen, cytabt, cdytail, temp32a);
|
| 1279 |
+
cytabttlen = ScaleExpansionZeroElim(abttlen, abtt, cdytail, cytabtt);
|
| 1280 |
+
temp16alen = ScaleExpansionZeroElim(cytabttlen, cytabtt, 2.0 * cdy, temp16a);
|
| 1281 |
+
temp16blen = ScaleExpansionZeroElim(cytabttlen, cytabtt, cdytail, temp16b);
|
| 1282 |
+
temp32blen = FastExpansionSumZeroElim(temp16alen, temp16a, temp16blen, temp16b, temp32b);
|
| 1283 |
+
temp64len = FastExpansionSumZeroElim(temp32alen, temp32a, temp32blen, temp32b, temp64);
|
| 1284 |
+
finlength = FastExpansionSumZeroElim(finlength, finnow, temp64len, temp64, finother);
|
| 1285 |
+
finswap = finnow; finnow = finother; finother = finswap;
|
| 1286 |
+
}
|
| 1287 |
+
}
|
| 1288 |
+
|
| 1289 |
+
return finnow[finlength - 1];
|
| 1290 |
+
}
|
| 1291 |
+
|
| 1292 |
+
#region Workspace
|
| 1293 |
+
|
| 1294 |
+
// InCircleAdapt workspace:
|
| 1295 |
+
double[] fin1, fin2, abdet;
|
| 1296 |
+
|
| 1297 |
+
double[] axbc, axxbc, aybc, ayybc, adet;
|
| 1298 |
+
double[] bxca, bxxca, byca, byyca, bdet;
|
| 1299 |
+
double[] cxab, cxxab, cyab, cyyab, cdet;
|
| 1300 |
+
|
| 1301 |
+
double[] temp8, temp16a, temp16b, temp16c;
|
| 1302 |
+
double[] temp32a, temp32b, temp48, temp64;
|
| 1303 |
+
|
| 1304 |
+
private void AllocateWorkspace()
|
| 1305 |
+
{
|
| 1306 |
+
fin1 = new double[1152];
|
| 1307 |
+
fin2 = new double[1152];
|
| 1308 |
+
abdet = new double[64];
|
| 1309 |
+
|
| 1310 |
+
axbc = new double[8];
|
| 1311 |
+
axxbc = new double[16];
|
| 1312 |
+
aybc = new double[8];
|
| 1313 |
+
ayybc = new double[16];
|
| 1314 |
+
adet = new double[32];
|
| 1315 |
+
|
| 1316 |
+
bxca = new double[8];
|
| 1317 |
+
bxxca = new double[16];
|
| 1318 |
+
byca = new double[8];
|
| 1319 |
+
byyca = new double[16];
|
| 1320 |
+
bdet = new double[32];
|
| 1321 |
+
|
| 1322 |
+
cxab = new double[8];
|
| 1323 |
+
cxxab = new double[16];
|
| 1324 |
+
cyab = new double[8];
|
| 1325 |
+
cyyab = new double[16];
|
| 1326 |
+
cdet = new double[32];
|
| 1327 |
+
|
| 1328 |
+
temp8 = new double[8];
|
| 1329 |
+
temp16a = new double[16];
|
| 1330 |
+
temp16b = new double[16];
|
| 1331 |
+
temp16c = new double[16];
|
| 1332 |
+
|
| 1333 |
+
temp32a = new double[32];
|
| 1334 |
+
temp32b = new double[32];
|
| 1335 |
+
temp48 = new double[48];
|
| 1336 |
+
temp64 = new double[64];
|
| 1337 |
+
}
|
| 1338 |
+
|
| 1339 |
+
private void ClearWorkspace()
|
| 1340 |
+
{
|
| 1341 |
+
}
|
| 1342 |
+
|
| 1343 |
+
#endregion
|
| 1344 |
+
|
| 1345 |
+
#endregion
|
| 1346 |
+
}
|
| 1347 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/RobustPredicates.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: a913e1ffc26254097a25b9656988d897
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Smoothing.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 0f49becd1eebe4b09ad7fa4c59ab4aee
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Tools.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: e487941dcff804523858078cb673697b
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/Topology.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 775f09564537d41e79692de55677a215
|
| 3 |
+
folderAsset: yes
|
| 4 |
+
DefaultImporter:
|
| 5 |
+
externalObjects: {}
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/TriangleLocator.cs
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -----------------------------------------------------------------------
|
| 2 |
+
// <copyright file="TriangleLocator.cs" company="">
|
| 3 |
+
// Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html
|
| 4 |
+
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
|
| 5 |
+
// </copyright>
|
| 6 |
+
// -----------------------------------------------------------------------
|
| 7 |
+
|
| 8 |
+
namespace UnityEngine.U2D.Animation.TriangleNet
|
| 9 |
+
{
|
| 10 |
+
using Animation.TriangleNet.Geometry;
|
| 11 |
+
using Animation.TriangleNet.Topology;
|
| 12 |
+
|
| 13 |
+
/// <summary>
|
| 14 |
+
/// Locate triangles in a mesh.
|
| 15 |
+
/// </summary>
|
| 16 |
+
/// <remarks>
|
| 17 |
+
/// WARNING: This routine is designed for convex triangulations, and will
|
| 18 |
+
/// not generally work after the holes and concavities have been carved.
|
| 19 |
+
///
|
| 20 |
+
/// Based on a paper by Ernst P. Mucke, Isaac Saias, and Binhai Zhu, "Fast
|
| 21 |
+
/// Randomized Point Location Without Preprocessing in Two- and Three-Dimensional
|
| 22 |
+
/// Delaunay Triangulations," Proceedings of the Twelfth Annual Symposium on
|
| 23 |
+
/// Computational Geometry, ACM, May 1996.
|
| 24 |
+
/// </remarks>
|
| 25 |
+
internal class TriangleLocator
|
| 26 |
+
{
|
| 27 |
+
TriangleSampler sampler;
|
| 28 |
+
Mesh mesh;
|
| 29 |
+
|
| 30 |
+
IPredicates predicates;
|
| 31 |
+
|
| 32 |
+
// Pointer to a recently visited triangle. Improves point location if
|
| 33 |
+
// proximate vertices are inserted sequentially.
|
| 34 |
+
internal Otri recenttri;
|
| 35 |
+
|
| 36 |
+
public TriangleLocator(Mesh mesh)
|
| 37 |
+
: this(mesh, RobustPredicates.Default)
|
| 38 |
+
{
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
public TriangleLocator(Mesh mesh, IPredicates predicates)
|
| 42 |
+
{
|
| 43 |
+
this.mesh = mesh;
|
| 44 |
+
this.predicates = predicates;
|
| 45 |
+
|
| 46 |
+
sampler = new TriangleSampler(mesh);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/// <summary>
|
| 50 |
+
/// Suggest the given triangle as a starting triangle for point location.
|
| 51 |
+
/// </summary>
|
| 52 |
+
/// <param name="otri"></param>
|
| 53 |
+
public void Update(ref Otri otri)
|
| 54 |
+
{
|
| 55 |
+
otri.Copy(ref recenttri);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
public void Reset()
|
| 59 |
+
{
|
| 60 |
+
sampler.Reset();
|
| 61 |
+
recenttri.tri = null; // No triangle has been visited yet.
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/// <summary>
|
| 65 |
+
/// Find a triangle or edge containing a given point.
|
| 66 |
+
/// </summary>
|
| 67 |
+
/// <param name="searchpoint">The point to locate.</param>
|
| 68 |
+
/// <param name="searchtri">The triangle to start the search at.</param>
|
| 69 |
+
/// <param name="stopatsubsegment"> If 'stopatsubsegment' is set, the search
|
| 70 |
+
/// will stop if it tries to walk through a subsegment, and will return OUTSIDE.</param>
|
| 71 |
+
/// <returns>Location information.</returns>
|
| 72 |
+
/// <remarks>
|
| 73 |
+
/// Begins its search from 'searchtri'. It is important that 'searchtri'
|
| 74 |
+
/// be a handle with the property that 'searchpoint' is strictly to the left
|
| 75 |
+
/// of the edge denoted by 'searchtri', or is collinear with that edge and
|
| 76 |
+
/// does not intersect that edge. (In particular, 'searchpoint' should not
|
| 77 |
+
/// be the origin or destination of that edge.)
|
| 78 |
+
///
|
| 79 |
+
/// These conditions are imposed because preciselocate() is normally used in
|
| 80 |
+
/// one of two situations:
|
| 81 |
+
///
|
| 82 |
+
/// (1) To try to find the location to insert a new point. Normally, we
|
| 83 |
+
/// know an edge that the point is strictly to the left of. In the
|
| 84 |
+
/// incremental Delaunay algorithm, that edge is a bounding box edge.
|
| 85 |
+
/// In Ruppert's Delaunay refinement algorithm for quality meshing,
|
| 86 |
+
/// that edge is the shortest edge of the triangle whose circumcenter
|
| 87 |
+
/// is being inserted.
|
| 88 |
+
///
|
| 89 |
+
/// (2) To try to find an existing point. In this case, any edge on the
|
| 90 |
+
/// convex hull is a good starting edge. You must screen out the
|
| 91 |
+
/// possibility that the vertex sought is an endpoint of the starting
|
| 92 |
+
/// edge before you call preciselocate().
|
| 93 |
+
///
|
| 94 |
+
/// On completion, 'searchtri' is a triangle that contains 'searchpoint'.
|
| 95 |
+
///
|
| 96 |
+
/// This implementation differs from that given by Guibas and Stolfi. It
|
| 97 |
+
/// walks from triangle to triangle, crossing an edge only if 'searchpoint'
|
| 98 |
+
/// is on the other side of the line containing that edge. After entering
|
| 99 |
+
/// a triangle, there are two edges by which one can leave that triangle.
|
| 100 |
+
/// If both edges are valid ('searchpoint' is on the other side of both
|
| 101 |
+
/// edges), one of the two is chosen by drawing a line perpendicular to
|
| 102 |
+
/// the label edge (whose endpoints are 'forg' and 'fdest') passing through
|
| 103 |
+
/// 'fapex'. Depending on which side of this perpendicular 'searchpoint'
|
| 104 |
+
/// falls on, an exit edge is chosen.
|
| 105 |
+
///
|
| 106 |
+
/// This implementation is empirically faster than the Guibas and Stolfi
|
| 107 |
+
/// point location routine (which I originally used), which tends to spiral
|
| 108 |
+
/// in toward its target.
|
| 109 |
+
///
|
| 110 |
+
/// Returns ONVERTEX if the point lies on an existing vertex. 'searchtri'
|
| 111 |
+
/// is a handle whose origin is the existing vertex.
|
| 112 |
+
///
|
| 113 |
+
/// Returns ONEDGE if the point lies on a mesh edge. 'searchtri' is a
|
| 114 |
+
/// handle whose primary edge is the edge on which the point lies.
|
| 115 |
+
///
|
| 116 |
+
/// Returns INTRIANGLE if the point lies strictly within a triangle.
|
| 117 |
+
/// 'searchtri' is a handle on the triangle that contains the point.
|
| 118 |
+
///
|
| 119 |
+
/// Returns OUTSIDE if the point lies outside the mesh. 'searchtri' is a
|
| 120 |
+
/// handle whose primary edge the point is to the right of. This might
|
| 121 |
+
/// occur when the circumcenter of a triangle falls just slightly outside
|
| 122 |
+
/// the mesh due to floating-point roundoff error. It also occurs when
|
| 123 |
+
/// seeking a hole or region point that a foolish user has placed outside
|
| 124 |
+
/// the mesh.
|
| 125 |
+
///
|
| 126 |
+
/// WARNING: This routine is designed for convex triangulations, and will
|
| 127 |
+
/// not generally work after the holes and concavities have been carved.
|
| 128 |
+
/// However, it can still be used to find the circumcenter of a triangle, as
|
| 129 |
+
/// long as the search is begun from the triangle in question.</remarks>
|
| 130 |
+
public LocateResult PreciseLocate(Point searchpoint, ref Otri searchtri,
|
| 131 |
+
bool stopatsubsegment)
|
| 132 |
+
{
|
| 133 |
+
Otri backtracktri = default(Otri);
|
| 134 |
+
Osub checkedge = default(Osub);
|
| 135 |
+
Vertex forg, fdest, fapex;
|
| 136 |
+
double orgorient, destorient;
|
| 137 |
+
bool moveleft;
|
| 138 |
+
|
| 139 |
+
// Where are we?
|
| 140 |
+
forg = searchtri.Org();
|
| 141 |
+
fdest = searchtri.Dest();
|
| 142 |
+
fapex = searchtri.Apex();
|
| 143 |
+
while (true)
|
| 144 |
+
{
|
| 145 |
+
// Check whether the apex is the point we seek.
|
| 146 |
+
if ((fapex.x == searchpoint.x) && (fapex.y == searchpoint.y))
|
| 147 |
+
{
|
| 148 |
+
searchtri.Lprev();
|
| 149 |
+
return LocateResult.OnVertex;
|
| 150 |
+
}
|
| 151 |
+
// Does the point lie on the other side of the line defined by the
|
| 152 |
+
// triangle edge opposite the triangle's destination?
|
| 153 |
+
destorient = predicates.CounterClockwise(forg, fapex, searchpoint);
|
| 154 |
+
// Does the point lie on the other side of the line defined by the
|
| 155 |
+
// triangle edge opposite the triangle's origin?
|
| 156 |
+
orgorient = predicates.CounterClockwise(fapex, fdest, searchpoint);
|
| 157 |
+
if (destorient > 0.0)
|
| 158 |
+
{
|
| 159 |
+
if (orgorient > 0.0)
|
| 160 |
+
{
|
| 161 |
+
// Move left if the inner product of (fapex - searchpoint) and
|
| 162 |
+
// (fdest - forg) is positive. This is equivalent to drawing
|
| 163 |
+
// a line perpendicular to the line (forg, fdest) and passing
|
| 164 |
+
// through 'fapex', and determining which side of this line
|
| 165 |
+
// 'searchpoint' falls on.
|
| 166 |
+
moveleft = (fapex.x - searchpoint.x) * (fdest.x - forg.x) +
|
| 167 |
+
(fapex.y - searchpoint.y) * (fdest.y - forg.y) > 0.0;
|
| 168 |
+
}
|
| 169 |
+
else
|
| 170 |
+
{
|
| 171 |
+
moveleft = true;
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
else
|
| 175 |
+
{
|
| 176 |
+
if (orgorient > 0.0)
|
| 177 |
+
{
|
| 178 |
+
moveleft = false;
|
| 179 |
+
}
|
| 180 |
+
else
|
| 181 |
+
{
|
| 182 |
+
// The point we seek must be on the boundary of or inside this
|
| 183 |
+
// triangle.
|
| 184 |
+
if (destorient == 0.0)
|
| 185 |
+
{
|
| 186 |
+
searchtri.Lprev();
|
| 187 |
+
return LocateResult.OnEdge;
|
| 188 |
+
}
|
| 189 |
+
if (orgorient == 0.0)
|
| 190 |
+
{
|
| 191 |
+
searchtri.Lnext();
|
| 192 |
+
return LocateResult.OnEdge;
|
| 193 |
+
}
|
| 194 |
+
return LocateResult.InTriangle;
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
// Move to another triangle. Leave a trace 'backtracktri' in case
|
| 199 |
+
// floating-point roundoff or some such bogey causes us to walk
|
| 200 |
+
// off a boundary of the triangulation.
|
| 201 |
+
if (moveleft)
|
| 202 |
+
{
|
| 203 |
+
searchtri.Lprev(ref backtracktri);
|
| 204 |
+
fdest = fapex;
|
| 205 |
+
}
|
| 206 |
+
else
|
| 207 |
+
{
|
| 208 |
+
searchtri.Lnext(ref backtracktri);
|
| 209 |
+
forg = fapex;
|
| 210 |
+
}
|
| 211 |
+
backtracktri.Sym(ref searchtri);
|
| 212 |
+
|
| 213 |
+
if (mesh.checksegments && stopatsubsegment)
|
| 214 |
+
{
|
| 215 |
+
// Check for walking through a subsegment.
|
| 216 |
+
backtracktri.Pivot(ref checkedge);
|
| 217 |
+
if (checkedge.seg.hash != Mesh.DUMMY)
|
| 218 |
+
{
|
| 219 |
+
// Go back to the last triangle.
|
| 220 |
+
backtracktri.Copy(ref searchtri);
|
| 221 |
+
return LocateResult.Outside;
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
// Check for walking right out of the triangulation.
|
| 225 |
+
if (searchtri.tri.id == Mesh.DUMMY)
|
| 226 |
+
{
|
| 227 |
+
// Go back to the last triangle.
|
| 228 |
+
backtracktri.Copy(ref searchtri);
|
| 229 |
+
return LocateResult.Outside;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
fapex = searchtri.Apex();
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
/// <summary>
|
| 237 |
+
/// Find a triangle or edge containing a given point.
|
| 238 |
+
/// </summary>
|
| 239 |
+
/// <param name="searchpoint">The point to locate.</param>
|
| 240 |
+
/// <param name="searchtri">The triangle to start the search at.</param>
|
| 241 |
+
/// <returns>Location information.</returns>
|
| 242 |
+
/// <remarks>
|
| 243 |
+
/// Searching begins from one of: the input 'searchtri', a recently
|
| 244 |
+
/// encountered triangle 'recenttri', or from a triangle chosen from a
|
| 245 |
+
/// random sample. The choice is made by determining which triangle's
|
| 246 |
+
/// origin is closest to the point we are searching for. Normally,
|
| 247 |
+
/// 'searchtri' should be a handle on the convex hull of the triangulation.
|
| 248 |
+
///
|
| 249 |
+
/// Details on the random sampling method can be found in the Mucke, Saias,
|
| 250 |
+
/// and Zhu paper cited in the header of this code.
|
| 251 |
+
///
|
| 252 |
+
/// On completion, 'searchtri' is a triangle that contains 'searchpoint'.
|
| 253 |
+
///
|
| 254 |
+
/// Returns ONVERTEX if the point lies on an existing vertex. 'searchtri'
|
| 255 |
+
/// is a handle whose origin is the existing vertex.
|
| 256 |
+
///
|
| 257 |
+
/// Returns ONEDGE if the point lies on a mesh edge. 'searchtri' is a
|
| 258 |
+
/// handle whose primary edge is the edge on which the point lies.
|
| 259 |
+
///
|
| 260 |
+
/// Returns INTRIANGLE if the point lies strictly within a triangle.
|
| 261 |
+
/// 'searchtri' is a handle on the triangle that contains the point.
|
| 262 |
+
///
|
| 263 |
+
/// Returns OUTSIDE if the point lies outside the mesh. 'searchtri' is a
|
| 264 |
+
/// handle whose primary edge the point is to the right of. This might
|
| 265 |
+
/// occur when the circumcenter of a triangle falls just slightly outside
|
| 266 |
+
/// the mesh due to floating-point roundoff error. It also occurs when
|
| 267 |
+
/// seeking a hole or region point that a foolish user has placed outside
|
| 268 |
+
/// the mesh.
|
| 269 |
+
///
|
| 270 |
+
/// WARNING: This routine is designed for convex triangulations, and will
|
| 271 |
+
/// not generally work after the holes and concavities have been carved.
|
| 272 |
+
/// </remarks>
|
| 273 |
+
public LocateResult Locate(Point searchpoint, ref Otri searchtri)
|
| 274 |
+
{
|
| 275 |
+
Otri sampletri = default(Otri);
|
| 276 |
+
Vertex torg, tdest;
|
| 277 |
+
double searchdist, dist;
|
| 278 |
+
double ahead;
|
| 279 |
+
|
| 280 |
+
// Record the distance from the suggested starting triangle to the
|
| 281 |
+
// point we seek.
|
| 282 |
+
torg = searchtri.Org();
|
| 283 |
+
searchdist = (searchpoint.x - torg.x) * (searchpoint.x - torg.x) +
|
| 284 |
+
(searchpoint.y - torg.y) * (searchpoint.y - torg.y);
|
| 285 |
+
|
| 286 |
+
// If a recently encountered triangle has been recorded and has not been
|
| 287 |
+
// deallocated, test it as a good starting point.
|
| 288 |
+
if (recenttri.tri != null)
|
| 289 |
+
{
|
| 290 |
+
if (!Otri.IsDead(recenttri.tri))
|
| 291 |
+
{
|
| 292 |
+
torg = recenttri.Org();
|
| 293 |
+
if ((torg.x == searchpoint.x) && (torg.y == searchpoint.y))
|
| 294 |
+
{
|
| 295 |
+
recenttri.Copy(ref searchtri);
|
| 296 |
+
return LocateResult.OnVertex;
|
| 297 |
+
}
|
| 298 |
+
dist = (searchpoint.x - torg.x) * (searchpoint.x - torg.x) +
|
| 299 |
+
(searchpoint.y - torg.y) * (searchpoint.y - torg.y);
|
| 300 |
+
if (dist < searchdist)
|
| 301 |
+
{
|
| 302 |
+
recenttri.Copy(ref searchtri);
|
| 303 |
+
searchdist = dist;
|
| 304 |
+
}
|
| 305 |
+
}
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
// TODO: Improve sampling.
|
| 309 |
+
sampler.Update();
|
| 310 |
+
|
| 311 |
+
foreach (var t in sampler)
|
| 312 |
+
{
|
| 313 |
+
sampletri.tri = t;
|
| 314 |
+
if (!Otri.IsDead(sampletri.tri))
|
| 315 |
+
{
|
| 316 |
+
torg = sampletri.Org();
|
| 317 |
+
dist = (searchpoint.x - torg.x) * (searchpoint.x - torg.x) +
|
| 318 |
+
(searchpoint.y - torg.y) * (searchpoint.y - torg.y);
|
| 319 |
+
if (dist < searchdist)
|
| 320 |
+
{
|
| 321 |
+
sampletri.Copy(ref searchtri);
|
| 322 |
+
searchdist = dist;
|
| 323 |
+
}
|
| 324 |
+
}
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
// Where are we?
|
| 328 |
+
torg = searchtri.Org();
|
| 329 |
+
tdest = searchtri.Dest();
|
| 330 |
+
|
| 331 |
+
// Check the starting triangle's vertices.
|
| 332 |
+
if ((torg.x == searchpoint.x) && (torg.y == searchpoint.y))
|
| 333 |
+
{
|
| 334 |
+
return LocateResult.OnVertex;
|
| 335 |
+
}
|
| 336 |
+
if ((tdest.x == searchpoint.x) && (tdest.y == searchpoint.y))
|
| 337 |
+
{
|
| 338 |
+
searchtri.Lnext();
|
| 339 |
+
return LocateResult.OnVertex;
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
// Orient 'searchtri' to fit the preconditions of calling preciselocate().
|
| 343 |
+
ahead = predicates.CounterClockwise(torg, tdest, searchpoint);
|
| 344 |
+
if (ahead < 0.0)
|
| 345 |
+
{
|
| 346 |
+
// Turn around so that 'searchpoint' is to the left of the
|
| 347 |
+
// edge specified by 'searchtri'.
|
| 348 |
+
searchtri.Sym();
|
| 349 |
+
}
|
| 350 |
+
else if (ahead == 0.0)
|
| 351 |
+
{
|
| 352 |
+
// Check if 'searchpoint' is between 'torg' and 'tdest'.
|
| 353 |
+
if (((torg.x < searchpoint.x) == (searchpoint.x < tdest.x)) &&
|
| 354 |
+
((torg.y < searchpoint.y) == (searchpoint.y < tdest.y)))
|
| 355 |
+
{
|
| 356 |
+
return LocateResult.OnEdge;
|
| 357 |
+
}
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
return PreciseLocate(searchpoint, ref searchtri, false);
|
| 361 |
+
}
|
| 362 |
+
}
|
| 363 |
+
}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Runtime/Triangle/TriangleLocator.cs.meta
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: a6f597013f4dd4897a204c7116d61766
|
| 3 |
+
MonoImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
serializedVersion: 2
|
| 6 |
+
defaultReferences: []
|
| 7 |
+
executionOrder: 0
|
| 8 |
+
icon: {instanceID: 0}
|
| 9 |
+
userData:
|
| 10 |
+
assetBundleName:
|
| 11 |
+
assetBundleVariant:
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Samples~/AnimationSamples/5 SpriteSwap/Animation/Animators/Rikr.controller
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%YAML 1.1
|
| 2 |
+
%TAG !u! tag:unity3d.com,2011:
|
| 3 |
+
--- !u!91 &9100000
|
| 4 |
+
AnimatorController:
|
| 5 |
+
m_ObjectHideFlags: 0
|
| 6 |
+
m_CorrespondingSourceObject: {fileID: 0}
|
| 7 |
+
m_PrefabInstance: {fileID: 0}
|
| 8 |
+
m_PrefabAsset: {fileID: 0}
|
| 9 |
+
m_Name: Rikr
|
| 10 |
+
serializedVersion: 5
|
| 11 |
+
m_AnimatorParameters: []
|
| 12 |
+
m_AnimatorLayers:
|
| 13 |
+
- serializedVersion: 5
|
| 14 |
+
m_Name: Base Layer
|
| 15 |
+
m_StateMachine: {fileID: 1107221854909101526}
|
| 16 |
+
m_Mask: {fileID: 0}
|
| 17 |
+
m_Motions: []
|
| 18 |
+
m_Behaviours: []
|
| 19 |
+
m_BlendingMode: 0
|
| 20 |
+
m_SyncedLayerIndex: -1
|
| 21 |
+
m_DefaultWeight: 0
|
| 22 |
+
m_IKPass: 0
|
| 23 |
+
m_SyncedLayerAffectsTiming: 0
|
| 24 |
+
m_Controller: {fileID: 9100000}
|
| 25 |
+
--- !u!1102 &1102824689331069682
|
| 26 |
+
AnimatorState:
|
| 27 |
+
serializedVersion: 5
|
| 28 |
+
m_ObjectHideFlags: 1
|
| 29 |
+
m_CorrespondingSourceObject: {fileID: 0}
|
| 30 |
+
m_PrefabInstance: {fileID: 0}
|
| 31 |
+
m_PrefabAsset: {fileID: 0}
|
| 32 |
+
m_Name: New Animation
|
| 33 |
+
m_Speed: 1
|
| 34 |
+
m_CycleOffset: 0
|
| 35 |
+
m_Transitions: []
|
| 36 |
+
m_StateMachineBehaviours: []
|
| 37 |
+
m_Position: {x: 50, y: 50, z: 0}
|
| 38 |
+
m_IKOnFeet: 0
|
| 39 |
+
m_WriteDefaultValues: 1
|
| 40 |
+
m_Mirror: 0
|
| 41 |
+
m_SpeedParameterActive: 0
|
| 42 |
+
m_MirrorParameterActive: 0
|
| 43 |
+
m_CycleOffsetParameterActive: 0
|
| 44 |
+
m_TimeParameterActive: 0
|
| 45 |
+
m_Motion: {fileID: 7400000, guid: 9b2cd1aa90c02a7428b34dc5060cbecb, type: 2}
|
| 46 |
+
m_Tag:
|
| 47 |
+
m_SpeedParameter:
|
| 48 |
+
m_MirrorParameter:
|
| 49 |
+
m_CycleOffsetParameter:
|
| 50 |
+
m_TimeParameter:
|
| 51 |
+
--- !u!1107 &1107221854909101526
|
| 52 |
+
AnimatorStateMachine:
|
| 53 |
+
serializedVersion: 5
|
| 54 |
+
m_ObjectHideFlags: 1
|
| 55 |
+
m_CorrespondingSourceObject: {fileID: 0}
|
| 56 |
+
m_PrefabInstance: {fileID: 0}
|
| 57 |
+
m_PrefabAsset: {fileID: 0}
|
| 58 |
+
m_Name: Base Layer
|
| 59 |
+
m_ChildStates:
|
| 60 |
+
- serializedVersion: 1
|
| 61 |
+
m_State: {fileID: 1102824689331069682}
|
| 62 |
+
m_Position: {x: 200, y: 0, z: 0}
|
| 63 |
+
m_ChildStateMachines: []
|
| 64 |
+
m_AnyStateTransitions: []
|
| 65 |
+
m_EntryTransitions: []
|
| 66 |
+
m_StateMachineTransitions: {}
|
| 67 |
+
m_StateMachineBehaviours: []
|
| 68 |
+
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
| 69 |
+
m_EntryPosition: {x: 50, y: 120, z: 0}
|
| 70 |
+
m_ExitPosition: {x: 800, y: 120, z: 0}
|
| 71 |
+
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
| 72 |
+
m_DefaultState: {fileID: 1102824689331069682}
|
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.2d.animation@5.0.4/Samples~/AnimationSamples/5 SpriteSwap/Animation/Animators/Rikr.controller.meta
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 698995a1f48c8a34d873540aa75279f8
|
| 3 |
+
NativeFormatImporter:
|
| 4 |
+
externalObjects: {}
|
| 5 |
+
mainObjectFileID: 9100000
|
| 6 |
+
userData:
|
| 7 |
+
assetBundleName:
|
| 8 |
+
assetBundleVariant:
|