internal void SetEdge(MeshPoint otherPoint) { var selfEdge = new MeshEdge(); selfEdge.Target = this; var edge = new MeshEdge(); edge.Target = otherPoint; if (otherPoint.Y == Y + 1) { _top = edge; otherPoint._bottom = selfEdge; return; } if (otherPoint.Y == Y - 1) { _bottom = edge; otherPoint._top = selfEdge; return; } if (otherPoint.X == X + 1) { _right = edge; otherPoint._left = selfEdge; return; } if (otherPoint.X == X - 1) { _left = edge; otherPoint._right = selfEdge; return; } throw new NotImplementedException(); }
internal void TryRelaxDiagonal() { var isDiagonal = _top != null && _bottom != null && _left != null && _right != null; if (!isDiagonal) { return; } // there is no other way for a node to have 4 edges, than to be a diagonal // NOTICE: top target has to have exactly one left or right node var isLeftDiagonal = _top.Target._left != null; if (isLeftDiagonal) { _bottom.Target._top.Target = _left.Target; _left.Target._right.Target = _bottom.Target; _top.Target._bottom.Target = _right.Target; _right.Target._left.Target = _top.Target; } else { _bottom.Target._top.Target = _right.Target; _right.Target._left.Target = _bottom.Target; _top.Target._bottom.Target = _left.Target; _left.Target._right.Target = _top.Target; } _top = null; _bottom = null; _left = null; _right = null; Component.Remove(this); Component = null; }