public int RemainingIndex(UndirectedEdge edge) { Contract.Requires <ArgumentException>(edge.Item1 != edge.Item2, "edge"); int i0 = edge.Item1; int i1 = edge.Item2; int[] indices = { Index1, Index2, Index3 }; int i2 = indices.DefaultIfEmpty(-1).Except(new[] { i0, i1 }).FirstOrDefault(); return(i2); }
public static bool FindSharedEdge(Face face1, Face face2, out UndirectedEdge edge) { Contract.Requires <ArgumentNullException>(face1.Edges != null, "face1"); Contract.Requires <ArgumentNullException>(face2.Edges != null, "face2"); foreach (var e1 in face1.Edges) { foreach (var e2 in face2.Edges) { if (e1 == e2) { edge = e1; return(true); } } } edge = default(UndirectedEdge); return(false); }
public static bool FindOverlappingEdges(Triangle t1, Triangle t2, Face face1, Face face2, out UndirectedEdge edge1, out UndirectedEdge edge2) { Contract.Requires <ArgumentNullException>(face1.Edges != null, "face1"); Contract.Requires <ArgumentNullException>(face2.Edges != null, "face2"); Vector3 tolerance = new Vector3(MathUtil.ZeroTolerance); var segments1 = t1.Segments.ToArray(); var segments2 = t2.Segments.ToArray(); for (int i = 0; i < 3; i++) { Segment s1 = segments1[i]; for (int j = 0; j < 3; j++) { Segment s2 = segments2[j]; Vector3 e1v1 = s1.A; Vector3 e1v2 = s1.B; Vector3 e2v1 = s2.A; Vector3 e2v2 = s2.B; bool test1 = Vector3.NearEqual(e1v1, e2v1, tolerance) || Vector3.NearEqual(e1v1, e2v2, tolerance); bool test2 = Vector3.NearEqual(e1v2, e2v1, tolerance) || Vector3.NearEqual(e1v2, e2v2, tolerance); if (test1 && test2) { var edges1 = face1.Edges.ToArray(); var edges2 = face2.Edges.ToArray(); edge1 = edges1[i]; edge2 = edges2[j]; return(true); } } } edge1 = edge2 = default(UndirectedEdge); return(false); }