HalfEdge.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // -----------------------------------------------------------------------
  2. // <copyright file="HalfEdge.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. internal class HalfEdge
  10. {
  11. internal int id;
  12. internal int mark;
  13. internal Vertex origin;
  14. internal Face face;
  15. internal HalfEdge twin;
  16. internal HalfEdge next;
  17. /// <summary>
  18. /// Gets or sets the half-edge id.
  19. /// </summary>
  20. public int ID
  21. {
  22. get { return id; }
  23. set { id = value; }
  24. }
  25. public int Boundary
  26. {
  27. get { return mark; }
  28. set { mark = value; }
  29. }
  30. /// <summary>
  31. /// Gets or sets the origin of the half-edge.
  32. /// </summary>
  33. public Vertex Origin
  34. {
  35. get { return origin; }
  36. set { origin = value; }
  37. }
  38. /// <summary>
  39. /// Gets or sets the face connected to the half-edge.
  40. /// </summary>
  41. public Face Face
  42. {
  43. get { return face; }
  44. set { face = value; }
  45. }
  46. /// <summary>
  47. /// Gets or sets the twin of the half-edge.
  48. /// </summary>
  49. public HalfEdge Twin
  50. {
  51. get { return twin; }
  52. set { twin = value; }
  53. }
  54. /// <summary>
  55. /// Gets or sets the next pointer of the half-edge.
  56. /// </summary>
  57. public HalfEdge Next
  58. {
  59. get { return next; }
  60. set { next = value; }
  61. }
  62. /// <summary>
  63. /// Initializes a new instance of the <see cref="HalfEdge" /> class.
  64. /// </summary>
  65. /// <param name="origin">The origin of this half-edge.</param>
  66. public HalfEdge(Vertex origin)
  67. {
  68. this.origin = origin;
  69. }
  70. /// <summary>
  71. /// Initializes a new instance of the <see cref="HalfEdge" /> class.
  72. /// </summary>
  73. /// <param name="origin">The origin of this half-edge.</param>
  74. /// <param name="face">The face connected to this half-edge.</param>
  75. public HalfEdge(Vertex origin, Face face)
  76. {
  77. this.origin = origin;
  78. this.face = face;
  79. // IMPORTANT: do not remove the (face.edge == null) check!
  80. if (face != null && face.edge == null)
  81. {
  82. face.edge = this;
  83. }
  84. }
  85. public override string ToString()
  86. {
  87. return string.Format("HE-ID {0} (Origin = VID-{1})", id, origin.id);
  88. }
  89. }
  90. }