// -----------------------------------------------------------------------
//
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
//
// -----------------------------------------------------------------------
namespace UnityEngine.U2D.Animation.TriangleNet
.Topology.DCEL
{
using System.Collections.Generic;
using Animation.TriangleNet.Geometry;
///
/// A face of DCEL mesh.
///
internal class Face
{
#region Static initialization of "Outer Space" face
internal static readonly Face Empty;
static Face()
{
Empty = new Face(null);
Empty.id = -1;
}
#endregion
internal int id;
internal int mark = 0;
internal Point generator;
internal HalfEdge edge;
internal bool bounded;
///
/// Gets or sets the face id.
///
public int ID
{
get { return id; }
set { id = value; }
}
///
/// Gets or sets a half-edge connected to the face.
///
public HalfEdge Edge
{
get { return edge; }
set { edge = value; }
}
///
/// Gets or sets a value, indicating if the face is bounded (for Voronoi diagram).
///
public bool Bounded
{
get { return bounded; }
set { bounded = value; }
}
///
/// Initializes a new instance of the class.
///
/// The generator of this face (for Voronoi diagram)
public Face(Point generator)
: this(generator, null)
{
}
///
/// Initializes a new instance of the class.
///
/// The generator of this face (for Voronoi diagram)
/// The half-edge connected to this face.
public Face(Point generator, HalfEdge edge)
{
this.generator = generator;
this.edge = edge;
this.bounded = true;
if (generator != null)
{
this.id = generator.ID;
}
}
///
/// Enumerates all half-edges of the face boundary.
///
///
public IEnumerable EnumerateEdges()
{
var edge = this.Edge;
int first = edge.ID;
do
{
yield return edge;
edge = edge.Next;
}
while (edge.ID != first);
}
public override string ToString()
{
return string.Format("F-ID {0}", id);
}
}
}