protected void ConnectEdge(ShapeNode n, ref int index, List <Node> nl) { // Attempts to connect an edge(index) on a ShapeNode(n) against all edges in a list of Nodes(nl) // Subdivides matching edges accordingly if the intersection is less than the entire length of one of the edges. // Note: Subdivision code is fairly basic at the moment. Some edge cases are not covered. if (n.LinkList[index] != null) { return; } Vector2D edge = n.GetEdge(index); Vector2D norm1 = edge.Normalized(); foreach (ShapeNode n2 in nl) { if (n2 != n) { for (int index2 = 0; index2 < n2.points.Count; index2++) { Vector2D edge2 = n2.GetAntiClockwiseEdge(index2); Vector2D norm2 = edge2.Normalized(); if (edge.a == edge2.a && norm1 == norm2) { NodeLink nodeLink = ShapeNode.ConnectEdges(n, index, n2, index2); if (edge.Length() > edge2.Length()) { n.AddPoint(index + 1, edge2.b); index--; } if (edge2.Length() > edge.Length()) { n2.AddPoint(index2 + 1, edge.b); n2.LinkList[index2 + 1] = n2.LinkList[index2]; n2.LinkList[index2] = null; ConnectEdge(n2, ref index2, nl); } return; } } } } }
protected void ConnectEdge(ShapeNode n, ref int index, List<Node> nl) { // Attempts to connect an edge(index) on a ShapeNode(n) against all edges in a list of Nodes(nl) // Subdivides matching edges accordingly if the intersection is less than the entire length of one of the edges. // Note: Subdivision code is fairly basic at the moment. Some edge cases are not covered. if (n.LinkList[index] != null) { return; } Vector2D edge = n.GetEdge(index); Vector2D norm1 = edge.Normalized(); foreach (ShapeNode n2 in nl) { if (n2 != n) { for (int index2 = 0; index2 < n2.points.Count; index2++) { Vector2D edge2 = n2.GetAntiClockwiseEdge(index2); Vector2D norm2 = edge2.Normalized(); if (edge.a == edge2.a && norm1 == norm2) { NodeLink nodeLink = ShapeNode.ConnectEdges(n, index, n2, index2); if (edge.Length() > edge2.Length()) { n.AddPoint(index + 1, edge2.b); index--; } if (edge2.Length() > edge.Length()) { n2.AddPoint(index2 + 1, edge.b); n2.LinkList[index2 + 1] = n2.LinkList[index2]; n2.LinkList[index2] = null; ConnectEdge(n2, ref index2, nl); } return; } } } } }