// -----------------------------------------------------------------------
//
// 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 TriangleNet.Data
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TriangleNet.Geometry;
///
/// The vertex data structure.
///
public class Vertex : Point
{
// Hash for dictionary. Will be set by mesh instance.
internal int hash;
// The ID is only used for mesh output.
internal int id;
internal VertexType type;
internal Otri tri;
///
/// Initializes a new instance of the class.
///
public Vertex()
: this(0, 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, 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)
: this(x, y, mark, 0)
{
}
///
/// 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)
: base(x, y, mark)
{
this.type = VertexType.InputVertex;
if (attribs > 0)
{
this.attributes = new double[attribs];
}
}
#region Public properties
///
/// Gets the vertex id.
///
public int ID
{
get { return this.id; }
}
///
/// 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;
}
}
}