Exemplo n.º 1
0
        /// <summary>
        /// Merges this halfedge with the Next
        /// </summary>
        public void Merge()
        {
            if (Next == null)
            {
                throw new InvalidOperationException("Next must not be null");
            }
            if (Face == null)
            {
                throw new InvalidOperationException("Face must not be null");
            }
            if (Face != Next.Face)
            {
                throw new InvalidOperationException("Cannot merge two edges bordering different faces");
            }
            if (Twin.Face != null && Twin.Face != Next.Twin.Face)
            {
                throw new InvalidOperationException("Cannot merge two edges with twins bordering different faces");
            }

            HalfEdge oldNext = Next;

            Next = oldNext.Next;
            End  = oldNext.End;

            if (Next.Twin.Next == oldNext.Twin)
            {
                Next.Twin.Next = Twin;
                Next.Twin.End  = End;
            }

            if (Twin.Face != null)
            {
                Twin.Face.Edges.Where(a => a.Next == oldNext.Twin).First().Next = Twin;
            }

            oldNext.Face      = null;
            oldNext.Twin.Face = null;
            oldNext.Next      = null;
            oldNext.Twin.Next = null;

            if (Face.Edge == oldNext)
            {
                Face.Edge = this;
            }
            if (Twin.Face != null && Twin.Face.Edge == oldNext.Twin)
            {
                Twin.Face.Edge = Twin;
            }

            Mesh.Delete(oldNext);
        }
Exemplo n.º 2
0
 public void Delete()
 {
     Mesh.Delete(this);
 }