Vertex.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // -----------------------------------------------------------------------
  2. // <copyright file="Vertex.cs">
  3. // Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
  4. // </copyright>
  5. // -----------------------------------------------------------------------
  6. namespace UnityEngine.U2D.Animation.TriangleNet
  7. .Topology.DCEL
  8. {
  9. using System.Collections.Generic;
  10. internal class Vertex : Animation.TriangleNet.Geometry.Point
  11. {
  12. internal HalfEdge leaving;
  13. /// <summary>
  14. /// Gets or sets a half-edge leaving the vertex.
  15. /// </summary>
  16. public HalfEdge Leaving
  17. {
  18. get { return leaving; }
  19. set { leaving = value; }
  20. }
  21. /// <summary>
  22. /// Initializes a new instance of the <see cref="Vertex" /> class.
  23. /// </summary>
  24. /// <param name="x">The x coordinate.</param>
  25. /// <param name="y">The y coordinate.</param>
  26. public Vertex(double x, double y)
  27. : base(x, y)
  28. {
  29. }
  30. /// <summary>
  31. /// Initializes a new instance of the <see cref="Vertex" /> class.
  32. /// </summary>
  33. /// <param name="x">The x coordinate.</param>
  34. /// <param name="y">The y coordinate.</param>
  35. /// <param name="leaving">A half-edge leaving this vertex.</param>
  36. public Vertex(double x, double y, HalfEdge leaving)
  37. : base(x, y)
  38. {
  39. this.leaving = leaving;
  40. }
  41. /// <summary>
  42. /// Enumerates all half-edges leaving this vertex.
  43. /// </summary>
  44. /// <returns></returns>
  45. public IEnumerable<HalfEdge> EnumerateEdges()
  46. {
  47. var edge = this.Leaving;
  48. int first = edge.ID;
  49. do
  50. {
  51. yield return edge;
  52. edge = edge.Twin.Next;
  53. }
  54. while (edge.ID != first);
  55. }
  56. public override string ToString()
  57. {
  58. return string.Format("V-ID {0}", base.id);
  59. }
  60. }
  61. }