// -----------------------------------------------------------------------
//
// Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
//
// -----------------------------------------------------------------------
namespace UnityEngine.U2D.Animation.TriangleNet
.Geometry
{
using System;
using Animation.TriangleNet.Topology;
///
/// The vertex data structure.
///
internal class Vertex : Point
{
// Hash for dictionary. Will be set by mesh instance.
internal int hash;
#if USE_ATTRIBS
internal double[] attributes;
#endif
internal VertexType type;
internal Otri tri;
///
/// Initializes a new instance of the class.
///
public Vertex()
: this(0, 0, 0)
{
}
///
/// Initializes a new instance of the class.
///
/// The x coordinate of the vertex.
/// The y coordinate of the vertex.
public Vertex(double x, double y)
: this(x, y, 0)
{
}
///
/// Initializes a new instance of the class.
///
/// The x coordinate of the vertex.
/// The y coordinate of the vertex.
/// The boundary mark.
public Vertex(double x, double y, int mark)
: base(x, y, mark)
{
this.type = VertexType.InputVertex;
}
#if USE_ATTRIBS
///
/// Initializes a new instance of the class.
///
/// The x coordinate of the vertex.
/// The y coordinate of the vertex.
/// The boundary mark.
/// The number of point attributes.
public Vertex(double x, double y, int mark, int attribs)
: this(x, y, mark)
{
if (attribs > 0)
{
this.attributes = new double[attribs];
}
}
#endif
#region Public properties
#if USE_ATTRIBS
///
/// Gets the vertex attributes (may be null).
///
public double[] Attributes
{
get { return this.attributes; }
}
#endif
///
/// Gets the vertex type.
///
public VertexType Type
{
get { return this.type; }
}
///
/// Gets the specified coordinate of the vertex.
///
/// Coordinate index.
/// X coordinate, if index is 0, Y coordinate, if index is 1.
public double this[int i]
{
get
{
if (i == 0)
{
return x;
}
if (i == 1)
{
return y;
}
throw new ArgumentOutOfRangeException("Index must be 0 or 1.");
}
}
#endregion
public override int GetHashCode()
{
return this.hash;
}
}
}